author | llornkcor <llornkcor> | 2003-05-26 03:13:01 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-05-26 03:13:01 (UTC) |
commit | 830bab619ea396c018ccd29b20ce81cb47e113e1 (patch) (unidiff) | |
tree | 41acd0f61f309992e5cd8faa4995cafff099fea1 | |
parent | eaa924af86511fd43fc9eac5438e73972f82158b (diff) | |
download | opie-830bab619ea396c018ccd29b20ce81cb47e113e1.zip opie-830bab619ea396c018ccd29b20ce81cb47e113e1.tar.gz opie-830bab619ea396c018ccd29b20ce81cb47e113e1.tar.bz2 |
remove extra includes
-rw-r--r-- | noncore/multimedia/opierec/device.cpp | 6 | ||||
-rw-r--r-- | noncore/multimedia/opierec/helpwindow.cpp | 23 | ||||
-rw-r--r-- | noncore/multimedia/opierec/opierec.control | 2 | ||||
-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 16 | ||||
-rw-r--r-- | noncore/multimedia/opierec/wavFile.cpp | 2 |
5 files changed, 1 insertions, 48 deletions
diff --git a/noncore/multimedia/opierec/device.cpp b/noncore/multimedia/opierec/device.cpp index c2029b7..f9a80c5 100644 --- a/noncore/multimedia/opierec/device.cpp +++ b/noncore/multimedia/opierec/device.cpp | |||
@@ -1,206 +1,200 @@ | |||
1 | // device.cpp | 1 | // device.cpp |
2 | 2 | ||
3 | #include "device.h" | 3 | #include "device.h" |
4 | #include "qtrec.h" | ||
5 | 4 | ||
6 | #include <qpe/qpeapplication.h> | ||
7 | #include <qpe/config.h> | 5 | #include <qpe/config.h> |
8 | #include <qpe/qcopenvelope_qws.h> | 6 | #include <qpe/qcopenvelope_qws.h> |
9 | 7 | ||
10 | #include <qslider.h> | ||
11 | #include <qmessagebox.h> | ||
12 | 8 | ||
13 | #include <qfile.h> | ||
14 | #include <qtextstream.h> | ||
15 | #include <fcntl.h> | 9 | #include <fcntl.h> |
16 | #include <stdio.h> | 10 | #include <stdio.h> |
17 | #include <stdlib.h> | 11 | #include <stdlib.h> |
18 | #include <sys/ioctl.h> | 12 | #include <sys/ioctl.h> |
19 | #include <sys/soundcard.h> | 13 | #include <sys/soundcard.h> |
20 | #include <unistd.h> | 14 | #include <unistd.h> |
21 | #include<sys/wait.h> | 15 | #include<sys/wait.h> |
22 | // #include <sys/stat.h> | 16 | // #include <sys/stat.h> |
23 | // #include <sys/time.h> | 17 | // #include <sys/time.h> |
24 | // #include <sys/types.h> | 18 | // #include <sys/types.h> |
25 | #include <unistd.h> | 19 | #include <unistd.h> |
26 | #include <errno.h> | 20 | #include <errno.h> |
27 | 21 | ||
28 | //extern QtRec *qperec; | 22 | //extern QtRec *qperec; |
29 | 23 | ||
30 | Device::Device( QObject * parent, const char * dsp, const char * mixr, bool record ) | 24 | Device::Device( QObject * parent, const char * dsp, const char * mixr, bool record ) |
31 | : QObject( parent) | 25 | : QObject( parent) |
32 | { | 26 | { |
33 | dspstr = (char *)dsp; | 27 | dspstr = (char *)dsp; |
34 | mixstr = (char *)mixr; | 28 | mixstr = (char *)mixr; |
35 | 29 | ||
36 | devForm=-1; | 30 | devForm=-1; |
37 | devCh=-1; | 31 | devCh=-1; |
38 | devRate=-1; | 32 | devRate=-1; |
39 | 33 | ||
40 | if( !record){ //playing | 34 | if( !record){ //playing |
41 | qDebug("setting up DSP for playing"); | 35 | qDebug("setting up DSP for playing"); |
42 | flags = O_WRONLY; | 36 | flags = O_WRONLY; |
43 | } else { //recording | 37 | } else { //recording |
44 | qDebug("setting up DSP for recording"); | 38 | qDebug("setting up DSP for recording"); |
45 | flags = O_RDWR; | 39 | flags = O_RDWR; |
46 | // flags = O_RDONLY; | 40 | // flags = O_RDONLY; |
47 | selectMicInput(); | 41 | selectMicInput(); |
48 | } | 42 | } |
49 | } | 43 | } |
50 | 44 | ||
51 | bool Device::openDsp() { | 45 | bool Device::openDsp() { |
52 | if( openDevice( flags) == -1) { | 46 | if( openDevice( flags) == -1) { |
53 | perror("<<<<<<<<<<<<<<ioctl(\"Open device\")"); | 47 | perror("<<<<<<<<<<<<<<ioctl(\"Open device\")"); |
54 | return false; | 48 | return false; |
55 | } | 49 | } |
56 | return true; | 50 | return true; |
57 | } | 51 | } |
58 | 52 | ||
59 | int Device::getOutVolume( ) { | 53 | int Device::getOutVolume( ) { |
60 | unsigned int volume; | 54 | unsigned int volume; |
61 | int mixerHandle = open( mixstr, O_RDWR ); | 55 | int mixerHandle = open( mixstr, O_RDWR ); |
62 | if ( mixerHandle >= 0 ) { | 56 | if ( mixerHandle >= 0 ) { |
63 | if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_VOLUME), &volume )==-1) | 57 | if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_VOLUME), &volume )==-1) |
64 | perror("<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")"); | 58 | perror("<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")"); |
65 | ::close( mixerHandle ); | 59 | ::close( mixerHandle ); |
66 | } else | 60 | } else |
67 | perror("open(\"/dev/mixer\")"); | 61 | perror("open(\"/dev/mixer\")"); |
68 | printf("<<<<<<<<<<<<<<<<<<<<output volume %d\n",volume); | 62 | printf("<<<<<<<<<<<<<<<<<<<<output volume %d\n",volume); |
69 | 63 | ||
70 | Config cfg("qpe"); | 64 | Config cfg("qpe"); |
71 | cfg.setGroup("Volume"); | 65 | cfg.setGroup("Volume"); |
72 | 66 | ||
73 | return cfg.readNumEntry("VolumePercent"); | 67 | return cfg.readNumEntry("VolumePercent"); |
74 | } | 68 | } |
75 | 69 | ||
76 | int Device::getInVolume() { | 70 | int Device::getInVolume() { |
77 | unsigned int volume=0; | 71 | unsigned int volume=0; |
78 | int mixerHandle = ::open( mixstr, O_RDWR ); | 72 | int mixerHandle = ::open( mixstr, O_RDWR ); |
79 | if ( mixerHandle >= 0 ) { | 73 | if ( mixerHandle >= 0 ) { |
80 | if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_MIC), &volume )==-1) | 74 | if(ioctl( mixerHandle, MIXER_READ(SOUND_MIXER_MIC), &volume )==-1) |
81 | perror("<<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")"); | 75 | perror("<<<<<<<<<<<<<<<ioctl(\"MIXER_READ\")"); |
82 | ::close( mixerHandle ); | 76 | ::close( mixerHandle ); |
83 | } else | 77 | } else |
84 | perror("open(\"/dev/mixer\")"); | 78 | perror("open(\"/dev/mixer\")"); |
85 | printf("<<<<<<<<<<<<<<input volume %d\n", volume ); | 79 | printf("<<<<<<<<<<<<<<input volume %d\n", volume ); |
86 | Config cfg("qpe"); | 80 | Config cfg("qpe"); |
87 | cfg.setGroup("Volume"); | 81 | cfg.setGroup("Volume"); |
88 | 82 | ||
89 | return cfg.readNumEntry("Mic"); | 83 | return cfg.readNumEntry("Mic"); |
90 | } | 84 | } |
91 | 85 | ||
92 | void Device::changedOutVolume(int vol) { | 86 | void Device::changedOutVolume(int vol) { |
93 | int level = (vol << 8) + vol; | 87 | int level = (vol << 8) + vol; |
94 | int fd = 0; | 88 | int fd = 0; |
95 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { | 89 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { |
96 | if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &level) == -1) | 90 | if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_VOLUME), &level) == -1) |
97 | perror("ioctl(\"MIXER_IN_WRITE\")"); | 91 | perror("ioctl(\"MIXER_IN_WRITE\")"); |
98 | 92 | ||
99 | Config cfg("qpe"); | 93 | Config cfg("qpe"); |
100 | cfg.setGroup("Volume"); | 94 | cfg.setGroup("Volume"); |
101 | cfg.writeEntry("VolumePercent", QString::number( vol )); | 95 | cfg.writeEntry("VolumePercent", QString::number( vol )); |
102 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; | 96 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; |
103 | } | 97 | } |
104 | ::close(fd); | 98 | ::close(fd); |
105 | } | 99 | } |
106 | 100 | ||
107 | void Device::changedInVolume(int vol ) { | 101 | void Device::changedInVolume(int vol ) { |
108 | int level = (vol << 8) + vol; | 102 | int level = (vol << 8) + vol; |
109 | int fd = 0; | 103 | int fd = 0; |
110 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { | 104 | if ((fd = open("/dev/mixer", O_RDWR))>=0) { |
111 | if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &level) == -1) | 105 | if(ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &level) == -1) |
112 | perror("ioctl(\"MIXER_IN_WRITE\")"); | 106 | perror("ioctl(\"MIXER_IN_WRITE\")"); |
113 | Config cfg("qpe"); | 107 | Config cfg("qpe"); |
114 | cfg.setGroup("Volume"); | 108 | cfg.setGroup("Volume"); |
115 | cfg.writeEntry("Mic", QString::number(vol )); | 109 | cfg.writeEntry("Mic", QString::number(vol )); |
116 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << false; | 110 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << false; |
117 | } | 111 | } |
118 | ::close(fd); | 112 | ::close(fd); |
119 | } | 113 | } |
120 | 114 | ||
121 | bool Device::selectMicInput() { | 115 | bool Device::selectMicInput() { |
122 | /* | 116 | /* |
123 | int md=0; | 117 | int md=0; |
124 | int info=MIXER_WRITE(SOUND_MIXER_MIC); | 118 | int info=MIXER_WRITE(SOUND_MIXER_MIC); |
125 | md = ::open( "/dev/mixer", O_RDWR ); | 119 | md = ::open( "/dev/mixer", O_RDWR ); |
126 | if ( md == -1) | 120 | if ( md == -1) |
127 | perror("open(\"/dev/mixer\")"); | 121 | perror("open(\"/dev/mixer\")"); |
128 | else { | 122 | else { |
129 | if( ioctl( md, SOUND_MIXER_WRITE_RECSRC, &info) == -1) | 123 | if( ioctl( md, SOUND_MIXER_WRITE_RECSRC, &info) == -1) |
130 | perror("ioctl(\"SOUND_MIXER_WRITE_RECSRC\")"); | 124 | perror("ioctl(\"SOUND_MIXER_WRITE_RECSRC\")"); |
131 | ::close(md); | 125 | ::close(md); |
132 | return false; | 126 | return false; |
133 | } | 127 | } |
134 | ::close(md); | 128 | ::close(md); |
135 | */ | 129 | */ |
136 | return true; | 130 | return true; |
137 | } | 131 | } |
138 | 132 | ||
139 | int Device::openDevice( int flags) { | 133 | int Device::openDevice( int flags) { |
140 | /* pid_t pid; | 134 | /* pid_t pid; |
141 | int status; | 135 | int status; |
142 | int pipefd[2]; | 136 | int pipefd[2]; |
143 | char message[20]; | 137 | char message[20]; |
144 | if (pipe(pipefd) == -1){ | 138 | if (pipe(pipefd) == -1){ |
145 | perror ("Error creating pipe"); | 139 | perror ("Error creating pipe"); |
146 | exit(1); | 140 | exit(1); |
147 | } | 141 | } |
148 | switch (pid = fork()) { | 142 | switch (pid = fork()) { |
149 | case -1: | 143 | case -1: |
150 | perror("The fork failed!"); | 144 | perror("The fork failed!"); |
151 | break; | 145 | break; |
152 | case 0: { | 146 | case 0: { |
153 | */ | 147 | */ |
154 | if (( sd = ::open( dspstr, flags)) == -1) { | 148 | if (( sd = ::open( dspstr, flags)) == -1) { |
155 | perror("open(\"/dev/dsp\")"); | 149 | perror("open(\"/dev/dsp\")"); |
156 | QString errorMsg="Could not open audio device\n /dev/dsp\n" | 150 | QString errorMsg="Could not open audio device\n /dev/dsp\n" |
157 | +(QString)strerror(errno); | 151 | +(QString)strerror(errno); |
158 | qDebug(errorMsg); | 152 | qDebug(errorMsg); |
159 | return -1; | 153 | return -1; |
160 | } | 154 | } |
161 | 155 | ||
162 | int mixerHandle=0; | 156 | int mixerHandle=0; |
163 | /* Set the input dsp device and its input gain the weird Zaurus way */ | 157 | /* Set the input dsp device and its input gain the weird Zaurus way */ |
164 | if (( mixerHandle = open("/dev/mixer1",O_RDWR))<0) { | 158 | if (( mixerHandle = open("/dev/mixer1",O_RDWR))<0) { |
165 | perror("open(\"/dev/mixer1\")"); | 159 | perror("open(\"/dev/mixer1\")"); |
166 | } | 160 | } |
167 | 161 | ||
168 | if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){ | 162 | if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){ |
169 | perror("ioctl RESET"); | 163 | perror("ioctl RESET"); |
170 | } | 164 | } |
171 | // sprintf(message, "%d", sd); | 165 | // sprintf(message, "%d", sd); |
172 | 166 | ||
173 | /* QFile f1("/pid"); | 167 | /* QFile f1("/pid"); |
174 | f1.open(IO_WriteOnly ); | 168 | f1.open(IO_WriteOnly ); |
175 | f1.writeBlock(message, strlen(message)); | 169 | f1.writeBlock(message, strlen(message)); |
176 | f1.close(); | 170 | f1.close(); |
177 | */ | 171 | */ |
178 | /* close(pipefd[0]); | 172 | /* close(pipefd[0]); |
179 | write(pipefd[1], message, sizeof(message)); | 173 | write(pipefd[1], message, sizeof(message)); |
180 | close(pipefd[1]); | 174 | close(pipefd[1]); |
181 | // qDebug("%d",soundDevice->sd ); | 175 | // qDebug("%d",soundDevice->sd ); |
182 | _exit(0); | 176 | _exit(0); |
183 | } | 177 | } |
184 | default: | 178 | default: |
185 | // pid greater than zero is parent getting the child's pid | 179 | // pid greater than zero is parent getting the child's pid |
186 | printf("Child's pid is %d\n",pid); | 180 | printf("Child's pid is %d\n",pid); |
187 | QString s; | 181 | QString s; |
188 | close(pipefd[1]); | 182 | close(pipefd[1]); |
189 | read(pipefd[0], message, sizeof(message)); | 183 | read(pipefd[0], message, sizeof(message)); |
190 | s = message; | 184 | s = message; |
191 | close(pipefd[0]); | 185 | close(pipefd[0]); |
192 | 186 | ||
193 | // while(wait(NULL)!=pid) | 187 | // while(wait(NULL)!=pid) |
194 | // ; | 188 | // ; |
195 | printf("child %ld terminated normally, return status is zero\n", (long) pid); | 189 | printf("child %ld terminated normally, return status is zero\n", (long) pid); |
196 | */ | 190 | */ |
197 | // filePara.sd=(long) pid; | 191 | // filePara.sd=(long) pid; |
198 | /* QFile f2("/pid"); | 192 | /* QFile f2("/pid"); |
199 | f2.open(IO_ReadOnly); | 193 | f2.open(IO_ReadOnly); |
200 | QTextStream t(&f2); | 194 | QTextStream t(&f2); |
201 | // for(int f=0; f < t.atEnd() ;f++) { | 195 | // for(int f=0; f < t.atEnd() ;f++) { |
202 | s = t.readLine(); | 196 | s = t.readLine(); |
203 | // } | 197 | // } |
204 | */ | 198 | */ |
205 | // bool ok; | 199 | // bool ok; |
206 | // sd = s.toInt(&ok, 10); | 200 | // sd = s.toInt(&ok, 10); |
diff --git a/noncore/multimedia/opierec/helpwindow.cpp b/noncore/multimedia/opierec/helpwindow.cpp index 0c4ac78..1ab6510 100644 --- a/noncore/multimedia/opierec/helpwindow.cpp +++ b/noncore/multimedia/opierec/helpwindow.cpp | |||
@@ -1,219 +1,196 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
5 | ** | 5 | ** |
6 | ** This file is part of an example program for Qt. This example | 6 | ** This file is part of an example program for Qt. This example |
7 | ** program may be used, distributed and modified without limitation. | 7 | ** program may be used, distributed and modified without limitation. |
8 | ** | 8 | ** |
9 | *****************************************************************************/ | 9 | *****************************************************************************/ |
10 | 10 | ||
11 | #include "helpwindow.h" | 11 | #include "helpwindow.h" |
12 | #include <qstatusbar.h> | ||
13 | #include <qstringlist.h> | ||
14 | #include <qlayout.h> | 12 | #include <qlayout.h> |
15 | 13 | ||
16 | #include <qpe/qpemenubar.h> | ||
17 | #include <qpe/qpetoolbar.h> | 14 | #include <qpe/qpetoolbar.h> |
18 | #include <qpe/resource.h> | 15 | #include <qpe/resource.h> |
19 | 16 | ||
20 | #include <qaction.h> | 17 | #include <qaction.h> |
21 | #include <qpixmap.h> | ||
22 | #include <qpopupmenu.h> | ||
23 | #include <qmenubar.h> | 18 | #include <qmenubar.h> |
24 | #include <qtoolbutton.h> | ||
25 | #include <qiconset.h> | ||
26 | #include <qfile.h> | ||
27 | #include <qtextstream.h> | ||
28 | #include <qstylesheet.h> | ||
29 | #include <qmessagebox.h> | ||
30 | #include <qfiledialog.h> | ||
31 | #include <qapplication.h> | ||
32 | #include <qcombobox.h> | ||
33 | #include <qevent.h> | ||
34 | #include <qlineedit.h> | ||
35 | #include <qobjectlist.h> | ||
36 | #include <qfileinfo.h> | ||
37 | #include <qfile.h> | ||
38 | #include <qdatastream.h> | ||
39 | #include <qprinter.h> | ||
40 | #include <qsimplerichtext.h> | ||
41 | #include <qpaintdevicemetrics.h> | ||
42 | 19 | ||
43 | #include <ctype.h> | 20 | #include <ctype.h> |
44 | 21 | ||
45 | HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name ) | 22 | HelpWindow::HelpWindow( const QString& home_, const QString& _path, QWidget* parent, const char *name ) |
46 | : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() | 23 | : QMainWindow( parent, name, WDestructiveClose ), pathCombo( 0 ), selectedURL() |
47 | { | 24 | { |
48 | QGridLayout *layout = new QGridLayout( this ); | 25 | QGridLayout *layout = new QGridLayout( this ); |
49 | layout->setSpacing( 2); | 26 | layout->setSpacing( 2); |
50 | layout->setMargin( 2); | 27 | layout->setMargin( 2); |
51 | qDebug(_path); | 28 | qDebug(_path); |
52 | browser = new QTextBrowser( this ); | 29 | browser = new QTextBrowser( this ); |
53 | QStringList Strlist; | 30 | QStringList Strlist; |
54 | Strlist.append( home_); | 31 | Strlist.append( home_); |
55 | browser->mimeSourceFactory()->setFilePath( Strlist ); | 32 | browser->mimeSourceFactory()->setFilePath( Strlist ); |
56 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); | 33 | browser->setFrameStyle( QFrame::Panel | QFrame::Sunken ); |
57 | 34 | ||
58 | connect( browser, SIGNAL( textChanged() ), this, SLOT( textChanged() ) ); | 35 | connect( browser, SIGNAL( textChanged() ), this, SLOT( textChanged() ) ); |
59 | 36 | ||
60 | if ( !home_.isEmpty() ) | 37 | if ( !home_.isEmpty() ) |
61 | browser->setSource( home_ ); | 38 | browser->setSource( home_ ); |
62 | QPEToolBar *toolbar = new QPEToolBar( this ); | 39 | QPEToolBar *toolbar = new QPEToolBar( this ); |
63 | 40 | ||
64 | QAction *a = new QAction( tr( "Backward" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); | 41 | QAction *a = new QAction( tr( "Backward" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); |
65 | connect( a, SIGNAL( activated() ), browser, SLOT( backward() ) ); | 42 | connect( a, SIGNAL( activated() ), browser, SLOT( backward() ) ); |
66 | a->addTo( toolbar ); | 43 | a->addTo( toolbar ); |
67 | 44 | ||
68 | a = new QAction( tr( "Forward" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); | 45 | a = new QAction( tr( "Forward" ), Resource::loadPixmap( "forward" ), QString::null, 0, this, 0 ); |
69 | connect( a, SIGNAL( activated() ), browser, SLOT( forward() ) ); | 46 | connect( a, SIGNAL( activated() ), browser, SLOT( forward() ) ); |
70 | a->addTo( toolbar ); | 47 | a->addTo( toolbar ); |
71 | 48 | ||
72 | 49 | ||
73 | layout->addMultiCellWidget( toolbar, 0, 0, 0, 0); | 50 | layout->addMultiCellWidget( toolbar, 0, 0, 0, 0); |
74 | 51 | ||
75 | layout->addMultiCellWidget( browser, 1, 2, 0, 2); | 52 | layout->addMultiCellWidget( browser, 1, 2, 0, 2); |
76 | 53 | ||
77 | browser->setFocus(); | 54 | browser->setFocus(); |
78 | } | 55 | } |
79 | 56 | ||
80 | 57 | ||
81 | void HelpWindow::setBackwardAvailable( bool b) | 58 | void HelpWindow::setBackwardAvailable( bool b) |
82 | { | 59 | { |
83 | menuBar()->setItemEnabled( backwardId, b); | 60 | menuBar()->setItemEnabled( backwardId, b); |
84 | } | 61 | } |
85 | 62 | ||
86 | void HelpWindow::setForwardAvailable( bool b) | 63 | void HelpWindow::setForwardAvailable( bool b) |
87 | { | 64 | { |
88 | menuBar()->setItemEnabled( forwardId, b); | 65 | menuBar()->setItemEnabled( forwardId, b); |
89 | } | 66 | } |
90 | 67 | ||
91 | 68 | ||
92 | void HelpWindow::textChanged() | 69 | void HelpWindow::textChanged() |
93 | { | 70 | { |
94 | if ( browser->documentTitle().isNull() ) { | 71 | if ( browser->documentTitle().isNull() ) { |
95 | setCaption( "QpeRec - Helpviewer - " + browser->context() ); | 72 | setCaption( "QpeRec - Helpviewer - " + browser->context() ); |
96 | selectedURL = browser->context(); | 73 | selectedURL = browser->context(); |
97 | } | 74 | } |
98 | else { | 75 | else { |
99 | setCaption( "QpeRec - Helpviewer - " + browser->documentTitle() ) ; | 76 | setCaption( "QpeRec - Helpviewer - " + browser->documentTitle() ) ; |
100 | selectedURL = browser->documentTitle(); | 77 | selectedURL = browser->documentTitle(); |
101 | } | 78 | } |
102 | 79 | ||
103 | // if ( !selectedURL.isEmpty() && pathCombo ) { | 80 | // if ( !selectedURL.isEmpty() && pathCombo ) { |
104 | // bool exists = FALSE; | 81 | // bool exists = FALSE; |
105 | // int i; | 82 | // int i; |
106 | // for ( i = 0; i < pathCombo->count(); ++i ) { | 83 | // for ( i = 0; i < pathCombo->count(); ++i ) { |
107 | // if ( pathCombo->text( i ) == selectedURL ) { | 84 | // if ( pathCombo->text( i ) == selectedURL ) { |
108 | // exists = TRUE; | 85 | // exists = TRUE; |
109 | // break; | 86 | // break; |
110 | // } | 87 | // } |
111 | // } | 88 | // } |
112 | // if ( !exists ) { | 89 | // if ( !exists ) { |
113 | // pathCombo->insertItem( selectedURL, 0 ); | 90 | // pathCombo->insertItem( selectedURL, 0 ); |
114 | // pathCombo->setCurrentItem( 0 ); | 91 | // pathCombo->setCurrentItem( 0 ); |
115 | // mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; | 92 | // mHistory[ hist->insertItem( selectedURL ) ] = selectedURL; |
116 | // } else | 93 | // } else |
117 | // pathCombo->setCurrentItem( i ); | 94 | // pathCombo->setCurrentItem( i ); |
118 | // selectedURL = QString::null; | 95 | // selectedURL = QString::null; |
119 | // } | 96 | // } |
120 | } | 97 | } |
121 | 98 | ||
122 | HelpWindow::~HelpWindow() | 99 | HelpWindow::~HelpWindow() |
123 | { | 100 | { |
124 | history.clear(); | 101 | history.clear(); |
125 | QMap<int, QString>::Iterator it = mHistory.begin(); | 102 | QMap<int, QString>::Iterator it = mHistory.begin(); |
126 | for ( ; it != mHistory.end(); ++it ) | 103 | for ( ; it != mHistory.end(); ++it ) |
127 | history.append( *it ); | 104 | history.append( *it ); |
128 | 105 | ||
129 | QFile f( QDir::currentDirPath() + "/.history" ); | 106 | QFile f( QDir::currentDirPath() + "/.history" ); |
130 | f.open( IO_WriteOnly ); | 107 | f.open( IO_WriteOnly ); |
131 | QDataStream s( &f ); | 108 | QDataStream s( &f ); |
132 | s << history; | 109 | s << history; |
133 | f.close(); | 110 | f.close(); |
134 | 111 | ||
135 | bookmarks.clear(); | 112 | bookmarks.clear(); |
136 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); | 113 | QMap<int, QString>::Iterator it2 = mBookmarks.begin(); |
137 | for ( ; it2 != mBookmarks.end(); ++it2 ) | 114 | for ( ; it2 != mBookmarks.end(); ++it2 ) |
138 | bookmarks.append( *it2 ); | 115 | bookmarks.append( *it2 ); |
139 | 116 | ||
140 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); | 117 | QFile f2( QDir::currentDirPath() + "/.bookmarks" ); |
141 | f2.open( IO_WriteOnly ); | 118 | f2.open( IO_WriteOnly ); |
142 | QDataStream s2( &f2 ); | 119 | QDataStream s2( &f2 ); |
143 | s2 << bookmarks; | 120 | s2 << bookmarks; |
144 | f2.close(); | 121 | f2.close(); |
145 | } | 122 | } |
146 | 123 | ||
147 | void HelpWindow::openFile() | 124 | void HelpWindow::openFile() |
148 | { | 125 | { |
149 | #ifndef QT_NO_FILEDIALOG | 126 | #ifndef QT_NO_FILEDIALOG |
150 | #endif | 127 | #endif |
151 | } | 128 | } |
152 | 129 | ||
153 | void HelpWindow::newWindow() | 130 | void HelpWindow::newWindow() |
154 | { | 131 | { |
155 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); | 132 | ( new HelpWindow(browser->source(), "qbrowser") )->show(); |
156 | } | 133 | } |
157 | 134 | ||
158 | void HelpWindow::print() | 135 | void HelpWindow::print() |
159 | { | 136 | { |
160 | #ifndef QT_NO_PRINTER | 137 | #ifndef QT_NO_PRINTER |
161 | #endif | 138 | #endif |
162 | } | 139 | } |
163 | 140 | ||
164 | void HelpWindow::pathSelected( const QString &_path ) | 141 | void HelpWindow::pathSelected( const QString &_path ) |
165 | { | 142 | { |
166 | browser->setSource( _path ); | 143 | browser->setSource( _path ); |
167 | QMap<int, QString>::Iterator it = mHistory.begin(); | 144 | QMap<int, QString>::Iterator it = mHistory.begin(); |
168 | bool exists = FALSE; | 145 | bool exists = FALSE; |
169 | for ( ; it != mHistory.end(); ++it ) { | 146 | for ( ; it != mHistory.end(); ++it ) { |
170 | if ( *it == _path ) { | 147 | if ( *it == _path ) { |
171 | exists = TRUE; | 148 | exists = TRUE; |
172 | break; | 149 | break; |
173 | } | 150 | } |
174 | } | 151 | } |
175 | if ( !exists ) | 152 | if ( !exists ) |
176 | mHistory[ hist->insertItem( _path ) ] = _path; | 153 | mHistory[ hist->insertItem( _path ) ] = _path; |
177 | } | 154 | } |
178 | 155 | ||
179 | void HelpWindow::readHistory() | 156 | void HelpWindow::readHistory() |
180 | { | 157 | { |
181 | if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { | 158 | if ( QFile::exists( QDir::currentDirPath() + "/.history" ) ) { |
182 | QFile f( QDir::currentDirPath() + "/.history" ); | 159 | QFile f( QDir::currentDirPath() + "/.history" ); |
183 | f.open( IO_ReadOnly ); | 160 | f.open( IO_ReadOnly ); |
184 | QDataStream s( &f ); | 161 | QDataStream s( &f ); |
185 | s >> history; | 162 | s >> history; |
186 | f.close(); | 163 | f.close(); |
187 | while ( history.count() > 20 ) | 164 | while ( history.count() > 20 ) |
188 | history.remove( history.begin() ); | 165 | history.remove( history.begin() ); |
189 | } | 166 | } |
190 | } | 167 | } |
191 | 168 | ||
192 | void HelpWindow::readBookmarks() | 169 | void HelpWindow::readBookmarks() |
193 | { | 170 | { |
194 | if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { | 171 | if ( QFile::exists( QDir::currentDirPath() + "/.bookmarks" ) ) { |
195 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); | 172 | QFile f( QDir::currentDirPath() + "/.bookmarks" ); |
196 | f.open( IO_ReadOnly ); | 173 | f.open( IO_ReadOnly ); |
197 | QDataStream s( &f ); | 174 | QDataStream s( &f ); |
198 | s >> bookmarks; | 175 | s >> bookmarks; |
199 | f.close(); | 176 | f.close(); |
200 | } | 177 | } |
201 | } | 178 | } |
202 | 179 | ||
203 | void HelpWindow::histChosen( int i ) | 180 | void HelpWindow::histChosen( int i ) |
204 | { | 181 | { |
205 | if ( mHistory.contains( i ) ) | 182 | if ( mHistory.contains( i ) ) |
206 | browser->setSource( mHistory[ i ] ); | 183 | browser->setSource( mHistory[ i ] ); |
207 | } | 184 | } |
208 | 185 | ||
209 | void HelpWindow::bookmChosen( int i ) | 186 | void HelpWindow::bookmChosen( int i ) |
210 | { | 187 | { |
211 | if ( mBookmarks.contains( i ) ) | 188 | if ( mBookmarks.contains( i ) ) |
212 | browser->setSource( mBookmarks[ i ] ); | 189 | browser->setSource( mBookmarks[ i ] ); |
213 | } | 190 | } |
214 | 191 | ||
215 | void HelpWindow::addBookmark() | 192 | void HelpWindow::addBookmark() |
216 | { | 193 | { |
217 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); | 194 | mBookmarks[ bookm->insertItem( caption() ) ] = caption(); |
218 | } | 195 | } |
219 | 196 | ||
diff --git a/noncore/multimedia/opierec/opierec.control b/noncore/multimedia/opierec/opierec.control index e8396ae..455691f 100644 --- a/noncore/multimedia/opierec/opierec.control +++ b/noncore/multimedia/opierec/opierec.control | |||
@@ -1,10 +1,10 @@ | |||
1 | Package: opierec | 1 | Package: opie-rec |
2 | Files: bin/opierec pics/opierec apps/Applications/opierec.desktop | 2 | Files: bin/opierec pics/opierec apps/Applications/opierec.desktop |
3 | Priority: optional | 3 | Priority: optional |
4 | Section: multimedia/applications | 4 | Section: multimedia/applications |
5 | Maintainer: L.J. Potter <ljp@llornkcor.com> | 5 | Maintainer: L.J. Potter <ljp@llornkcor.com> |
6 | Architecture: arm | 6 | Architecture: arm |
7 | Version: 1.5-2 | 7 | Version: 1.5-2 |
8 | Depends: opie ($QPE_VERSION) | 8 | Depends: opie ($QPE_VERSION) |
9 | Description: audio sampling recorder | 9 | Description: audio sampling recorder |
10 | A simple audio recording/playing application. | 10 | A simple audio recording/playing application. |
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp index 28f6546..0307d99 100644 --- a/noncore/multimedia/opierec/qtrec.cpp +++ b/noncore/multimedia/opierec/qtrec.cpp | |||
@@ -1,251 +1,235 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | // qtrec.cpp | 2 | // qtrec.cpp |
3 | Created: Thu Jan 17 11:19:58 2002 | 3 | Created: Thu Jan 17 11:19:58 2002 |
4 | copyright 2002 by L.J. Potter <ljp@llornkcor.com> | 4 | copyright 2002 by L.J. Potter <ljp@llornkcor.com> |
5 | ****************************************************************************/ | 5 | ****************************************************************************/ |
6 | 6 | ||
7 | #define DEV_VERSION | 7 | #define DEV_VERSION |
8 | 8 | ||
9 | #include "pixmaps.h" | 9 | #include "pixmaps.h" |
10 | #include "qtrec.h" | 10 | #include "qtrec.h" |
11 | #include "helpwindow.h" | ||
12 | #include "device.h" | ||
13 | #include "wavFile.h" | ||
14 | 11 | ||
15 | #include <pthread.h> | 12 | #include <pthread.h> |
16 | 13 | ||
17 | extern "C" { | 14 | extern "C" { |
18 | #include "adpcm.h" | 15 | #include "adpcm.h" |
19 | } | 16 | } |
20 | 17 | ||
21 | #include <sys/soundcard.h> | 18 | #include <sys/soundcard.h> |
22 | 19 | ||
23 | // #if defined (QTOPIA_INTERNAL_FSLP) | 20 | // #if defined (QTOPIA_INTERNAL_FSLP) |
24 | // #include <qpe/lnkproperties.h> | 21 | // #include <qpe/lnkproperties.h> |
25 | // #endif | 22 | // #endif |
26 | 23 | ||
27 | #include <qpe/applnk.h> | ||
28 | #include <qpe/config.h> | 24 | #include <qpe/config.h> |
29 | #include <qpe/ir.h> | ||
30 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
31 | #include <qpe/qpeapplication.h> | 26 | #include <qpe/qpeapplication.h> |
32 | #include <qpe/resource.h> | 27 | #include <qpe/resource.h> |
33 | #include <qpe/storage.h> | 28 | #include <qpe/storage.h> |
34 | 29 | ||
35 | #include <qlineedit.h> | ||
36 | #include <qbuttongroup.h> | ||
37 | #include <qcheckbox.h> | 30 | #include <qcheckbox.h> |
38 | #include <qcombobox.h> | 31 | #include <qcombobox.h> |
39 | #include <qcursor.h> | ||
40 | //#include <qdatetime.h> | 32 | //#include <qdatetime.h> |
41 | #include <qdir.h> | 33 | #include <qdir.h> |
42 | #include <qfile.h> | ||
43 | #include <qtextstream.h> | ||
44 | #include <qgroupbox.h> | 34 | #include <qgroupbox.h> |
45 | #include <qiconview.h> | ||
46 | #include <qimage.h> | ||
47 | #include <qlabel.h> | 35 | #include <qlabel.h> |
48 | #include <qlayout.h> | 36 | #include <qlayout.h> |
49 | #include <qlineedit.h> | ||
50 | #include <qlistview.h> | 37 | #include <qlistview.h> |
51 | #include <qmessagebox.h> | 38 | #include <qmessagebox.h> |
52 | #include <qpixmap.h> | ||
53 | #include <qpopupmenu.h> | 39 | #include <qpopupmenu.h> |
54 | #include <qpushbutton.h> | 40 | #include <qpushbutton.h> |
55 | #include <qregexp.h> | ||
56 | #include <qslider.h> | 41 | #include <qslider.h> |
57 | #include <qtabwidget.h> | 42 | #include <qtabwidget.h> |
58 | #include <qtimer.h> | 43 | #include <qtimer.h> |
59 | #include <qvariant.h> | ||
60 | 44 | ||
61 | #include <errno.h> | 45 | #include <errno.h> |
62 | #include <fcntl.h> | 46 | #include <fcntl.h> |
63 | #include <math.h> | 47 | #include <math.h> |
64 | #include <mntent.h> | 48 | #include <mntent.h> |
65 | #include <stdio.h> | 49 | #include <stdio.h> |
66 | #include <stdlib.h> | 50 | #include <stdlib.h> |
67 | #include <sys/ioctl.h> | 51 | #include <sys/ioctl.h> |
68 | #include <sys/soundcard.h> | 52 | #include <sys/soundcard.h> |
69 | #include <sys/stat.h> | 53 | #include <sys/stat.h> |
70 | #include <sys/time.h> | 54 | #include <sys/time.h> |
71 | #include <sys/types.h> | 55 | #include <sys/types.h> |
72 | #include <sys/vfs.h> | 56 | #include <sys/vfs.h> |
73 | #include <unistd.h> | 57 | #include <unistd.h> |
74 | #include<sys/wait.h> | 58 | #include<sys/wait.h> |
75 | #include <sys/signal.h> | 59 | #include <sys/signal.h> |
76 | 60 | ||
77 | //#define ZAURUS 0 | 61 | //#define ZAURUS 0 |
78 | struct adpcm_state encoder_state; | 62 | struct adpcm_state encoder_state; |
79 | struct adpcm_state decoder_state; | 63 | struct adpcm_state decoder_state; |
80 | 64 | ||
81 | long findPeak(long input ); | 65 | long findPeak(long input ); |
82 | //char deviceRates[]; | 66 | //char deviceRates[]; |
83 | 67 | ||
84 | typedef struct { | 68 | typedef struct { |
85 | int sampleRate; | 69 | int sampleRate; |
86 | /* int fragSize; */ | 70 | /* int fragSize; */ |
87 | /* int blockSize; */ | 71 | /* int blockSize; */ |
88 | int resolution; //bitrate | 72 | int resolution; //bitrate |
89 | int channels; //number of channels | 73 | int channels; //number of channels |
90 | int fd; //file descriptor | 74 | int fd; //file descriptor |
91 | int sd; //sound device descriptor | 75 | int sd; //sound device descriptor |
92 | int numberSamples; //total number of samples | 76 | int numberSamples; //total number of samples |
93 | int SecondsToRecord; // number of seconds that should be recorded | 77 | int SecondsToRecord; // number of seconds that should be recorded |
94 | float numberOfRecordedSeconds; //total number of samples recorded | 78 | float numberOfRecordedSeconds; //total number of samples recorded |
95 | int samplesToRecord; //number of samples to be recorded | 79 | int samplesToRecord; //number of samples to be recorded |
96 | int inVol; //input volume | 80 | int inVol; //input volume |
97 | int outVol; //output volume | 81 | int outVol; //output volume |
98 | int format; //wavfile format PCM.. ADPCM | 82 | int format; //wavfile format PCM.. ADPCM |
99 | const char *fileName; //name of fiel to be played/recorded | 83 | const char *fileName; //name of fiel to be played/recorded |
100 | } fileParameters; | 84 | } fileParameters; |
101 | 85 | ||
102 | fileParameters filePara; | 86 | fileParameters filePara; |
103 | 87 | ||
104 | bool monitoring, recording; | 88 | bool monitoring, recording; |
105 | bool stopped; | 89 | bool stopped; |
106 | QLabel *timeLabel; | 90 | QLabel *timeLabel; |
107 | QSlider *timeSlider; | 91 | QSlider *timeSlider; |
108 | int sd; | 92 | int sd; |
109 | 93 | ||
110 | #if defined(QT_QWS_EBX) | 94 | #if defined(QT_QWS_EBX) |
111 | #define DSPSTROUT "/dev/dsp" | 95 | #define DSPSTROUT "/dev/dsp" |
112 | #define DSPSTRIN "/dev/dsp1" | 96 | #define DSPSTRIN "/dev/dsp1" |
113 | #define DSPSTRMIXEROUT "/dev/mixer" | 97 | #define DSPSTRMIXEROUT "/dev/mixer" |
114 | #define DSPSTRMIXERIN "/dev/mixer1" | 98 | #define DSPSTRMIXERIN "/dev/mixer1" |
115 | #else | 99 | #else |
116 | #define DSPSTROUT "/dev/dsp" | 100 | #define DSPSTROUT "/dev/dsp" |
117 | #define DSPSTRIN "/dev/dsp" | 101 | #define DSPSTRIN "/dev/dsp" |
118 | #define DSPSTRMIXERIN "/dev/mixer" | 102 | #define DSPSTRMIXERIN "/dev/mixer" |
119 | #define DSPSTRMIXEROUT "/dev/mixer" | 103 | #define DSPSTRMIXEROUT "/dev/mixer" |
120 | #endif | 104 | #endif |
121 | 105 | ||
122 | // threaded recording | 106 | // threaded recording |
123 | void quickRec() { | 107 | void quickRec() { |
124 | //void QtRec::quickRec() { | 108 | //void QtRec::quickRec() { |
125 | 109 | ||
126 | qDebug("%d", | 110 | qDebug("%d", |
127 | filePara.numberSamples/filePara.sampleRate * filePara.channels); | 111 | filePara.numberSamples/filePara.sampleRate * filePara.channels); |
128 | qDebug("samples %d, rate %d, channels %d", | 112 | qDebug("samples %d, rate %d, channels %d", |
129 | filePara.numberSamples, filePara.sampleRate, filePara.channels); | 113 | filePara.numberSamples, filePara.sampleRate, filePara.channels); |
130 | 114 | ||
131 | int total = 0; // Total number of bytes read in so far. | 115 | int total = 0; // Total number of bytes read in so far. |
132 | int bytesWritten, number; | 116 | int bytesWritten, number; |
133 | 117 | ||
134 | count_info info; | 118 | count_info info; |
135 | 119 | ||
136 | bytesWritten=0; | 120 | bytesWritten=0; |
137 | number=0; | 121 | number=0; |
138 | QString num, timeString; | 122 | QString num, timeString; |
139 | int level=0; | 123 | int level=0; |
140 | int threshold=0; | 124 | int threshold=0; |
141 | // if(limit != 0) | 125 | // if(limit != 0) |
142 | // t->start( ( limit +.3) , true); | 126 | // t->start( ( limit +.3) , true); |
143 | 127 | ||
144 | recording = true; | 128 | recording = true; |
145 | //rate=filePara.sampleRate; | 129 | //rate=filePara.sampleRate; |
146 | int bits = filePara.resolution; | 130 | int bits = filePara.resolution; |
147 | qDebug("bits %d", bits); | 131 | qDebug("bits %d", bits); |
148 | // if( filePara.format==WAVE_FORMAT_DVI_ADPCM) | 132 | // if( filePara.format==WAVE_FORMAT_DVI_ADPCM) |
149 | // else | 133 | // else |
150 | audio_buf_info inInfo; | 134 | audio_buf_info inInfo; |
151 | ioctl( filePara.fd, SNDCTL_DSP_GETISPACE, &inInfo); | 135 | ioctl( filePara.fd, SNDCTL_DSP_GETISPACE, &inInfo); |
152 | qDebug("ispace is frags %d, total %d", inInfo.fragments, inInfo.fragstotal); | 136 | qDebug("ispace is frags %d, total %d", inInfo.fragments, inInfo.fragstotal); |
153 | 137 | ||
154 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) | 138 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) |
155 | qDebug("AFMT_S16_LE size %d", filePara.SecondsToRecord); | 139 | qDebug("AFMT_S16_LE size %d", filePara.SecondsToRecord); |
156 | qDebug("samples to record %d", filePara.samplesToRecord); | 140 | qDebug("samples to record %d", filePara.samplesToRecord); |
157 | qDebug("%d", filePara.sd); | 141 | qDebug("%d", filePara.sd); |
158 | level=7; | 142 | level=7; |
159 | threshold=0; | 143 | threshold=0; |
160 | timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 144 | timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
161 | timeLabel->setText( timeString+ " seconds"); | 145 | timeLabel->setText( timeString+ " seconds"); |
162 | 146 | ||
163 | if( filePara.format==WAVE_FORMAT_DVI_ADPCM) { | 147 | if( filePara.format==WAVE_FORMAT_DVI_ADPCM) { |
164 | qDebug("start recording WAVE_FORMAT_DVI_ADPCM"); | 148 | qDebug("start recording WAVE_FORMAT_DVI_ADPCM"); |
165 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> | 149 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> |
166 | char abuf[BUFSIZE/2]; | 150 | char abuf[BUFSIZE/2]; |
167 | short sbuf[BUFSIZE]; | 151 | short sbuf[BUFSIZE]; |
168 | short sbuf2[BUFSIZE]; | 152 | short sbuf2[BUFSIZE]; |
169 | memset( abuf,0,BUFSIZE/2); | 153 | memset( abuf,0,BUFSIZE/2); |
170 | memset( sbuf,0,BUFSIZE); | 154 | memset( sbuf,0,BUFSIZE); |
171 | memset( sbuf2,0,BUFSIZE); | 155 | memset( sbuf2,0,BUFSIZE); |
172 | 156 | ||
173 | for(;;) { | 157 | for(;;) { |
174 | if (stopped) { | 158 | if (stopped) { |
175 | qDebug("quickRec:: stopped"); | 159 | qDebug("quickRec:: stopped"); |
176 | break; // stop if playing was set to false | 160 | break; // stop if playing was set to false |
177 | // return; | 161 | // return; |
178 | } | 162 | } |
179 | 163 | ||
180 | number=::read( filePara.sd, sbuf, BUFSIZE); | 164 | number=::read( filePara.sd, sbuf, BUFSIZE); |
181 | 165 | ||
182 | if(number <= 0) { | 166 | if(number <= 0) { |
183 | perror("recording error "); | 167 | perror("recording error "); |
184 | qDebug( "%s %d", filePara.fileName, number); | 168 | qDebug( "%s %d", filePara.fileName, number); |
185 | // errorStop(); | 169 | // errorStop(); |
186 | recording=stopped=false; | 170 | recording=stopped=false; |
187 | // QMessageBox::message("Note", | 171 | // QMessageBox::message("Note", |
188 | // "Error recording to file\n%s", | 172 | // "Error recording to file\n%s", |
189 | // filePara.fileName); | 173 | // filePara.fileName); |
190 | return; | 174 | return; |
191 | } | 175 | } |
192 | //if(stereo == 2) { | 176 | //if(stereo == 2) { |
193 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); | 177 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); |
194 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); | 178 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); |
195 | 179 | ||
196 | bytesWritten = ::write( filePara.fd , abuf, number/4); | 180 | bytesWritten = ::write( filePara.fd , abuf, number/4); |
197 | 181 | ||
198 | long peak; | 182 | long peak; |
199 | for (int i = 0; i < number; i++) | 183 | for (int i = 0; i < number; i++) |
200 | { //since Z is mono do normally | 184 | { //since Z is mono do normally |
201 | peak = findPeak((long)sbuf[i]); | 185 | peak = findPeak((long)sbuf[i]); |
202 | printf("peak %ld\r",peak); | 186 | printf("peak %ld\r",peak); |
203 | fflush(stdout); | 187 | fflush(stdout); |
204 | } | 188 | } |
205 | 189 | ||
206 | 190 | ||
207 | //------------->>>> out to file | 191 | //------------->>>> out to file |
208 | // if(filePara.channels==1) | 192 | // if(filePara.channels==1) |
209 | // total += bytesWritten/2; //mono | 193 | // total += bytesWritten/2; //mono |
210 | // else | 194 | // else |
211 | total += bytesWritten; | 195 | total += bytesWritten; |
212 | filePara.numberSamples = total; | 196 | filePara.numberSamples = total; |
213 | // if( total >= filePara.samplesToRecord) | 197 | // if( total >= filePara.samplesToRecord) |
214 | // timeSlider->setValue(0); | 198 | // timeSlider->setValue(0); |
215 | // else if( filePara.SecondsToRecord !=0) | 199 | // else if( filePara.SecondsToRecord !=0) |
216 | timeSlider->setValue( total); | 200 | timeSlider->setValue( total); |
217 | 201 | ||
218 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2; | 202 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2; |
219 | 203 | ||
220 | // printf("Writing number %d, bytes %d,total %d, sample rate %d, secs %.2f \n", | 204 | // printf("Writing number %d, bytes %d,total %d, sample rate %d, secs %.2f \n", |
221 | // number, | 205 | // number, |
222 | // bytesWritten , | 206 | // bytesWritten , |
223 | // total, | 207 | // total, |
224 | // filePara.sampleRate, | 208 | // filePara.sampleRate, |
225 | // filePara.numberOfRecordedSeconds); | 209 | // filePara.numberOfRecordedSeconds); |
226 | // fflush(stdout); | 210 | // fflush(stdout); |
227 | ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info); | 211 | ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info); |
228 | // qDebug("%d, %d", info.bytes, (info.bytes / filePara.sampleRate) / 2); | 212 | // qDebug("%d, %d", info.bytes, (info.bytes / filePara.sampleRate) / 2); |
229 | 213 | ||
230 | timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 214 | timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
231 | timeLabel->setText( timeString + " seconds"); | 215 | timeLabel->setText( timeString + " seconds"); |
232 | 216 | ||
233 | qApp->processEvents(); | 217 | qApp->processEvents(); |
234 | if( total >= filePara.samplesToRecord) | 218 | if( total >= filePara.samplesToRecord) |
235 | break; | 219 | break; |
236 | } | 220 | } |
237 | } else { | 221 | } else { |
238 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> | 222 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> |
239 | qDebug("start recording WAVE_FORMAT_PCM"); | 223 | qDebug("start recording WAVE_FORMAT_PCM"); |
240 | short inbuffer[BUFSIZE], outbuffer[BUFSIZE]; | 224 | short inbuffer[BUFSIZE], outbuffer[BUFSIZE]; |
241 | memset( inbuffer,0,BUFSIZE); | 225 | memset( inbuffer,0,BUFSIZE); |
242 | memset( outbuffer,0,BUFSIZE); | 226 | memset( outbuffer,0,BUFSIZE); |
243 | for(;;) { | 227 | for(;;) { |
244 | if (stopped) { | 228 | if (stopped) { |
245 | qDebug("quickRec:: stopped"); | 229 | qDebug("quickRec:: stopped"); |
246 | break; // stop if playing was set to false | 230 | break; // stop if playing was set to false |
247 | return; | 231 | return; |
248 | } | 232 | } |
249 | 233 | ||
250 | number=::read( filePara.sd, inbuffer, BUFSIZE); | 234 | number=::read( filePara.sd, inbuffer, BUFSIZE); |
251 | 235 | ||
diff --git a/noncore/multimedia/opierec/wavFile.cpp b/noncore/multimedia/opierec/wavFile.cpp index 0bb5736..7bfffb6 100644 --- a/noncore/multimedia/opierec/wavFile.cpp +++ b/noncore/multimedia/opierec/wavFile.cpp | |||
@@ -1,198 +1,196 @@ | |||
1 | //wavFile.cpp | 1 | //wavFile.cpp |
2 | #include "wavFile.h" | 2 | #include "wavFile.h" |
3 | #include "qtrec.h" | 3 | #include "qtrec.h" |
4 | 4 | ||
5 | #include <qdatetime.h> | ||
6 | #include <qstring.h> | ||
7 | #include <qmessagebox.h> | 5 | #include <qmessagebox.h> |
8 | #include <qdir.h> | 6 | #include <qdir.h> |
9 | 7 | ||
10 | #include <qpe/timestring.h> | 8 | #include <qpe/timestring.h> |
11 | #include <qpe/config.h> | 9 | #include <qpe/config.h> |
12 | 10 | ||
13 | #include <errno.h> | 11 | #include <errno.h> |
14 | 12 | ||
15 | #include <sys/time.h> | 13 | #include <sys/time.h> |
16 | #include <sys/types.h> | 14 | #include <sys/types.h> |
17 | #include <sys/vfs.h> | 15 | #include <sys/vfs.h> |
18 | 16 | ||
19 | #include <fcntl.h> | 17 | #include <fcntl.h> |
20 | #include <math.h> | 18 | #include <math.h> |
21 | #include <mntent.h> | 19 | #include <mntent.h> |
22 | #include <stdio.h> | 20 | #include <stdio.h> |
23 | #include <stdlib.h> | 21 | #include <stdlib.h> |
24 | #include <unistd.h> | 22 | #include <unistd.h> |
25 | 23 | ||
26 | WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int sampleRate, | 24 | WavFile::WavFile( QObject * parent,const QString &fileName, bool makeNwFile, int sampleRate, |
27 | int channels, int resolution, int format ) | 25 | int channels, int resolution, int format ) |
28 | : QObject( parent) | 26 | : QObject( parent) |
29 | { | 27 | { |
30 | qDebug("new wave file"); | 28 | qDebug("new wave file"); |
31 | bool b = makeNwFile; | 29 | bool b = makeNwFile; |
32 | wavSampleRate=sampleRate; | 30 | wavSampleRate=sampleRate; |
33 | wavFormat=format; | 31 | wavFormat=format; |
34 | wavChannels=channels; | 32 | wavChannels=channels; |
35 | wavResolution=resolution; | 33 | wavResolution=resolution; |
36 | useTmpFile=false; | 34 | useTmpFile=false; |
37 | if( b) { | 35 | if( b) { |
38 | newFile(); | 36 | newFile(); |
39 | } else { | 37 | } else { |
40 | openFile(fileName); | 38 | openFile(fileName); |
41 | } | 39 | } |
42 | } | 40 | } |
43 | 41 | ||
44 | bool WavFile::newFile() { | 42 | bool WavFile::newFile() { |
45 | 43 | ||
46 | qDebug("Set up new file"); | 44 | qDebug("Set up new file"); |
47 | Config cfg("OpieRec"); | 45 | Config cfg("OpieRec"); |
48 | cfg.setGroup("Settings"); | 46 | cfg.setGroup("Settings"); |
49 | 47 | ||
50 | currentFileName=cfg.readEntry("directory",QDir::homeDirPath()); | 48 | currentFileName=cfg.readEntry("directory",QDir::homeDirPath()); |
51 | QString date; | 49 | QString date; |
52 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); | 50 | date = TimeString::dateString( QDateTime::currentDateTime(),false,true); |
53 | date.replace(QRegExp("'"),""); | 51 | date.replace(QRegExp("'"),""); |
54 | date.replace(QRegExp(" "),"_"); | 52 | date.replace(QRegExp(" "),"_"); |
55 | date.replace(QRegExp(":"),"."); | 53 | date.replace(QRegExp(":"),"."); |
56 | date.replace(QRegExp(","),""); | 54 | date.replace(QRegExp(","),""); |
57 | 55 | ||
58 | QString currentFile=date; | 56 | QString currentFile=date; |
59 | if(currentFileName.right(1).find("/",0,true) == -1) | 57 | if(currentFileName.right(1).find("/",0,true) == -1) |
60 | currentFileName += "/" + date; | 58 | currentFileName += "/" + date; |
61 | else | 59 | else |
62 | currentFileName += date; | 60 | currentFileName += date; |
63 | currentFileName+=".wav"; | 61 | currentFileName+=".wav"; |
64 | 62 | ||
65 | qDebug("set up file for recording: "+currentFileName); | 63 | qDebug("set up file for recording: "+currentFileName); |
66 | char *pointer; | 64 | char *pointer; |
67 | 65 | ||
68 | if( currentFileName.find("/mnt",0,true) == -1 | 66 | if( currentFileName.find("/mnt",0,true) == -1 |
69 | && currentFileName.find("/tmp",0,true) == -1 ) { | 67 | && currentFileName.find("/tmp",0,true) == -1 ) { |
70 | // if destination file is most likely in flash (assuming jffs2) | 68 | // if destination file is most likely in flash (assuming jffs2) |
71 | // we have to write to a different filesystem first | 69 | // we have to write to a different filesystem first |
72 | 70 | ||
73 | useTmpFile = true; | 71 | useTmpFile = true; |
74 | pointer=tmpnam(NULL); | 72 | pointer=tmpnam(NULL); |
75 | qDebug("Opening tmp file %s",pointer); | 73 | qDebug("Opening tmp file %s",pointer); |
76 | track.setName( pointer); | 74 | track.setName( pointer); |
77 | 75 | ||
78 | } else { //just use regular file.. no moving | 76 | } else { //just use regular file.. no moving |
79 | 77 | ||
80 | useTmpFile = false; | 78 | useTmpFile = false; |
81 | track.setName( currentFileName); | 79 | track.setName( currentFileName); |
82 | } | 80 | } |
83 | if(!track.open( IO_ReadWrite | IO_Truncate)) { | 81 | if(!track.open( IO_ReadWrite | IO_Truncate)) { |
84 | QString errorMsg=(QString)strerror(errno); | 82 | QString errorMsg=(QString)strerror(errno); |
85 | qDebug(errorMsg); | 83 | qDebug(errorMsg); |
86 | QMessageBox::message("Note", "Error opening file.\n" +errorMsg); | 84 | QMessageBox::message("Note", "Error opening file.\n" +errorMsg); |
87 | 85 | ||
88 | return false; | 86 | return false; |
89 | } else { | 87 | } else { |
90 | setWavHeader( track.handle() , &hdr); | 88 | setWavHeader( track.handle() , &hdr); |
91 | } | 89 | } |
92 | return true; | 90 | return true; |
93 | } | 91 | } |
94 | 92 | ||
95 | WavFile::~WavFile() { | 93 | WavFile::~WavFile() { |
96 | 94 | ||
97 | closeFile(); | 95 | closeFile(); |
98 | } | 96 | } |
99 | 97 | ||
100 | void WavFile::closeFile() { | 98 | void WavFile::closeFile() { |
101 | if(track.isOpen()) | 99 | if(track.isOpen()) |
102 | track.close(); | 100 | track.close(); |
103 | } | 101 | } |
104 | 102 | ||
105 | int WavFile::openFile(const QString ¤tFileName) { | 103 | int WavFile::openFile(const QString ¤tFileName) { |
106 | qDebug("open play file "+currentFileName); | 104 | qDebug("open play file "+currentFileName); |
107 | closeFile(); | 105 | closeFile(); |
108 | 106 | ||
109 | track.setName(currentFileName); | 107 | track.setName(currentFileName); |
110 | 108 | ||
111 | if(!track.open(IO_ReadOnly)) { | 109 | if(!track.open(IO_ReadOnly)) { |
112 | QString errorMsg=(QString)strerror(errno); | 110 | QString errorMsg=(QString)strerror(errno); |
113 | qDebug("<<<<<<<<<<< "+errorMsg+currentFileName); | 111 | qDebug("<<<<<<<<<<< "+errorMsg+currentFileName); |
114 | QMessageBox::message("Note", "Error opening file.\n" +errorMsg); | 112 | QMessageBox::message("Note", "Error opening file.\n" +errorMsg); |
115 | return -1; | 113 | return -1; |
116 | } else { | 114 | } else { |
117 | parseWavHeader( track.handle()); | 115 | parseWavHeader( track.handle()); |
118 | } | 116 | } |
119 | return track.handle(); | 117 | return track.handle(); |
120 | } | 118 | } |
121 | 119 | ||
122 | bool WavFile::setWavHeader(int fd, wavhdr *hdr) { | 120 | bool WavFile::setWavHeader(int fd, wavhdr *hdr) { |
123 | 121 | ||
124 | strncpy((*hdr).riffID, "RIFF", 4); // RIFF | 122 | strncpy((*hdr).riffID, "RIFF", 4); // RIFF |
125 | strncpy((*hdr).wavID, "WAVE", 4); //WAVE | 123 | strncpy((*hdr).wavID, "WAVE", 4); //WAVE |
126 | strncpy((*hdr).fmtID, "fmt ", 4); // fmt | 124 | strncpy((*hdr).fmtID, "fmt ", 4); // fmt |
127 | (*hdr).fmtLen = 16; // format length = 16 | 125 | (*hdr).fmtLen = 16; // format length = 16 |
128 | 126 | ||
129 | if( wavFormat == WAVE_FORMAT_PCM) { | 127 | if( wavFormat == WAVE_FORMAT_PCM) { |
130 | (*hdr).fmtTag = 1; // PCM | 128 | (*hdr).fmtTag = 1; // PCM |
131 | qDebug("set header WAVE_FORMAT_PCM"); | 129 | qDebug("set header WAVE_FORMAT_PCM"); |
132 | } | 130 | } |
133 | else { | 131 | else { |
134 | (*hdr).fmtTag = WAVE_FORMAT_DVI_ADPCM; //intel ADPCM | 132 | (*hdr).fmtTag = WAVE_FORMAT_DVI_ADPCM; //intel ADPCM |
135 | qDebug("set header WAVE_FORMAT_DVI_ADPCM"); | 133 | qDebug("set header WAVE_FORMAT_DVI_ADPCM"); |
136 | } | 134 | } |
137 | 135 | ||
138 | // (*hdr).nChannels = 1;//filePara.channels;// ? 2 : 1*/; // channels | 136 | // (*hdr).nChannels = 1;//filePara.channels;// ? 2 : 1*/; // channels |
139 | (*hdr).nChannels = wavChannels;// ? 2 : 1*/; // channels | 137 | (*hdr).nChannels = wavChannels;// ? 2 : 1*/; // channels |
140 | 138 | ||
141 | (*hdr).sampleRate = wavSampleRate; //samples per second | 139 | (*hdr).sampleRate = wavSampleRate; //samples per second |
142 | (*hdr).avgBytesPerSec = (wavSampleRate)*( wavChannels*(wavResolution/8)); // bytes per second | 140 | (*hdr).avgBytesPerSec = (wavSampleRate)*( wavChannels*(wavResolution/8)); // bytes per second |
143 | (*hdr).nBlockAlign = wavChannels*( wavResolution/8); //block align | 141 | (*hdr).nBlockAlign = wavChannels*( wavResolution/8); //block align |
144 | (*hdr).bitsPerSample = wavResolution; //bits per sample 8, or 16 | 142 | (*hdr).bitsPerSample = wavResolution; //bits per sample 8, or 16 |
145 | 143 | ||
146 | strncpy((*hdr).dataID, "data", 4); | 144 | strncpy((*hdr).dataID, "data", 4); |
147 | 145 | ||
148 | write( fd,hdr, sizeof(*hdr)); | 146 | write( fd,hdr, sizeof(*hdr)); |
149 | qDebug("writing header: bitrate%d, samplerate %d, channels %d", | 147 | qDebug("writing header: bitrate%d, samplerate %d, channels %d", |
150 | wavResolution, wavSampleRate, wavChannels); | 148 | wavResolution, wavSampleRate, wavChannels); |
151 | return true; | 149 | return true; |
152 | } | 150 | } |
153 | 151 | ||
154 | bool WavFile::adjustHeaders(int fd, int total) { | 152 | bool WavFile::adjustHeaders(int fd, int total) { |
155 | lseek(fd, 4, SEEK_SET); | 153 | lseek(fd, 4, SEEK_SET); |
156 | int i = total + 36; | 154 | int i = total + 36; |
157 | write( fd, &i, sizeof(i)); | 155 | write( fd, &i, sizeof(i)); |
158 | lseek( fd, 40, SEEK_SET); | 156 | lseek( fd, 40, SEEK_SET); |
159 | write( fd, &total, sizeof(total)); | 157 | write( fd, &total, sizeof(total)); |
160 | qDebug("adjusting header %d", total); | 158 | qDebug("adjusting header %d", total); |
161 | return true; | 159 | return true; |
162 | } | 160 | } |
163 | 161 | ||
164 | int WavFile::parseWavHeader(int fd) { | 162 | int WavFile::parseWavHeader(int fd) { |
165 | qDebug("Parsing wav header"); | 163 | qDebug("Parsing wav header"); |
166 | char string[4]; | 164 | char string[4]; |
167 | int found; | 165 | int found; |
168 | short fmt; | 166 | short fmt; |
169 | unsigned short ch, bitrate; | 167 | unsigned short ch, bitrate; |
170 | unsigned long samplerrate, longdata; | 168 | unsigned long samplerrate, longdata; |
171 | 169 | ||
172 | if (read(fd, string, 4) < 4) { | 170 | if (read(fd, string, 4) < 4) { |
173 | qDebug(" Could not read from sound file.\n"); | 171 | qDebug(" Could not read from sound file.\n"); |
174 | return -1; | 172 | return -1; |
175 | } | 173 | } |
176 | if (strncmp(string, "RIFF", 4)) { | 174 | if (strncmp(string, "RIFF", 4)) { |
177 | qDebug(" not a valid WAV file.\n"); | 175 | qDebug(" not a valid WAV file.\n"); |
178 | return -1; | 176 | return -1; |
179 | } | 177 | } |
180 | lseek(fd, 4, SEEK_CUR); | 178 | lseek(fd, 4, SEEK_CUR); |
181 | if (read(fd, string, 4) < 4) { | 179 | if (read(fd, string, 4) < 4) { |
182 | qDebug("Could not read from sound file.\n"); | 180 | qDebug("Could not read from sound file.\n"); |
183 | return -1; | 181 | return -1; |
184 | } | 182 | } |
185 | if (strncmp(string, "WAVE", 4)) { | 183 | if (strncmp(string, "WAVE", 4)) { |
186 | qDebug("not a valid WAV file.\n"); | 184 | qDebug("not a valid WAV file.\n"); |
187 | return -1; | 185 | return -1; |
188 | } | 186 | } |
189 | found = 0; | 187 | found = 0; |
190 | 188 | ||
191 | while (!found) { | 189 | while (!found) { |
192 | if (read(fd, string, 4) < 4) { | 190 | if (read(fd, string, 4) < 4) { |
193 | qDebug("Could not read from sound file.\n"); | 191 | qDebug("Could not read from sound file.\n"); |
194 | return -1; | 192 | return -1; |
195 | } | 193 | } |
196 | if (strncmp(string, "fmt ", 4)) { | 194 | if (strncmp(string, "fmt ", 4)) { |
197 | if (read(fd, &longdata, 4) < 4) { | 195 | if (read(fd, &longdata, 4) < 4) { |
198 | qDebug("Could not read from sound file.\n"); | 196 | qDebug("Could not read from sound file.\n"); |