author | llornkcor <llornkcor> | 2004-08-06 19:03:36 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-08-06 19:03:36 (UTC) |
commit | 5e10278e748608766245ff9f59a54d1ae8ff6f7e (patch) (unidiff) | |
tree | ca01e05ff77f7b80209deba47c93be48d20d8df2 | |
parent | 75675815cb051e14bf8ad50c4069338bfa83eed1 (diff) | |
download | opie-5e10278e748608766245ff9f59a54d1ae8ff6f7e.zip opie-5e10278e748608766245ff9f59a54d1ae8ff6f7e.tar.gz opie-5e10278e748608766245ff9f59a54d1ae8ff6f7e.tar.bz2 |
no warnings
-rw-r--r-- | noncore/multimedia/opierec/device.cpp | 192 |
1 files changed, 96 insertions, 96 deletions
diff --git a/noncore/multimedia/opierec/device.cpp b/noncore/multimedia/opierec/device.cpp index db2d63f..683f0a5 100644 --- a/noncore/multimedia/opierec/device.cpp +++ b/noncore/multimedia/opierec/device.cpp | |||
@@ -3,9 +3,6 @@ | |||
3 | #include "device.h" | 3 | #include "device.h" |
4 | 4 | ||
5 | /* OPIE */ | ||
6 | #include <opie2/odebug.h> | ||
7 | #include <qpe/config.h> | 5 | #include <qpe/config.h> |
8 | #include <qpe/qcopenvelope_qws.h> | 6 | #include <qpe/qcopenvelope_qws.h> |
9 | using namespace Opie::Core; | ||
10 | 7 | ||
11 | /* STD */ | 8 | /* STD */ |
@@ -33,8 +30,8 @@ Device::Device( QObject * parent, const char * dsp, const char * mixr, bool reco | |||
33 | 30 | ||
34 | if( !record){ //playing | 31 | if( !record){ //playing |
35 | odebug << "setting up DSP for playing" << oendl; | 32 | qDebug( "setting up DSP for playing" ); |
36 | flags = O_WRONLY; | 33 | flags = O_WRONLY; |
37 | } else { //recording | 34 | } else { //recording |
38 | odebug << "setting up DSP for recording" << oendl; | 35 | qDebug( "setting up DSP for recording" ); |
39 | flags = O_RDWR; | 36 | flags = O_RDWR; |
40 | // flags = O_RDONLY; | 37 | // flags = O_RDONLY; |
@@ -53,4 +50,87 @@ bool Device::openDsp() { | |||
53 | } | 50 | } |
54 | 51 | ||
52 | int Device::openDevice( int flags) { | ||
53 | /* pid_t pid; | ||
54 | int status; | ||
55 | int pipefd[2]; | ||
56 | char message[20]; | ||
57 | if (pipe(pipefd) == -1){ | ||
58 | perror ("Error creating pipe"); | ||
59 | exit(1); | ||
60 | } | ||
61 | switch (pid = fork()) { | ||
62 | case -1: | ||
63 | perror("The fork failed!"); | ||
64 | break; | ||
65 | case 0: { | ||
66 | */ | ||
67 | qDebug( "Opening %s",dspstr); | ||
68 | if (( sd = ::open( dspstr, flags)) == -1) { | ||
69 | perror("open(\"/dev/dsp\")"); | ||
70 | QString errorMsg="Could not open audio device\n /dev/dsp\n" | ||
71 | +(QString)strerror(errno); | ||
72 | qDebug( "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg ); | ||
73 | return -1; | ||
74 | } | ||
75 | |||
76 | qDebug( "Opening mixer" ); | ||
77 | int mixerHandle=0; | ||
78 | if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) { | ||
79 | perror("open(\"/dev/mixer\")"); | ||
80 | QString errorMsg="Could not open audio device\n /dev/dsp\n" | ||
81 | +(QString)strerror(errno); | ||
82 | qDebug( "XXXXXXXXXXXXXXXXXXXXXX "+errorMsg ); | ||
83 | } | ||
84 | |||
85 | if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){ | ||
86 | perror("ioctl RESET"); | ||
87 | } | ||
88 | // sprintf(message, "%d", sd); | ||
89 | |||
90 | /* QFile f1("/pid"); | ||
91 | f1.open(IO_WriteOnly ); | ||
92 | f1.writeBlock(message, strlen(message)); | ||
93 | f1.close(); | ||
94 | */ | ||
95 | /* close(pipefd[0]); | ||
96 | write(pipefd[1], message, sizeof(message)); | ||
97 | close(pipefd[1]); | ||
98 | // qDebug( "" + soundDevice->sd ); | ||
99 | _exit(0); | ||
100 | } | ||
101 | default: | ||
102 | // pid greater than zero is parent getting the child's pid | ||
103 | printf("Child's pid is %d\n",pid); | ||
104 | QString s; | ||
105 | close(pipefd[1]); | ||
106 | read(pipefd[0], message, sizeof(message)); | ||
107 | s = message; | ||
108 | close(pipefd[0]); | ||
109 | |||
110 | // while(wait(NULL)!=pid) | ||
111 | // ; | ||
112 | printf("child %ld terminated normally, return status is zero\n", (long) pid); | ||
113 | */ | ||
114 | // filePara.sd=(long) pid; | ||
115 | /* QFile f2("/pid"); | ||
116 | f2.open(IO_ReadOnly); | ||
117 | QTextStream t(&f2); | ||
118 | // for(int f=0; f < t.atEnd() ;f++) { | ||
119 | s = t.readLine(); | ||
120 | // } | ||
121 | */ | ||
122 | // bool ok; | ||
123 | // sd = s.toInt(&ok, 10); | ||
124 | // qDebug( "<<<<<<<<<<<<<>>>>>>>>>>>>"+s ); | ||
125 | |||
126 | // f2.close(); | ||
127 | // } | ||
128 | ::close(mixerHandle ); | ||
129 | // qDebug( "open device " + dspstr ); | ||
130 | // qDebug( "success! " + sd ); | ||
131 | return sd; | ||
132 | } | ||
133 | |||
134 | |||
55 | int Device::getOutVolume( ) { | 135 | int Device::getOutVolume( ) { |
56 | unsigned int volume; | 136 | unsigned int volume; |
@@ -97,5 +177,5 @@ void Device::changedOutVolume(int vol) { | |||
97 | cfg.writeEntry("VolumePercent", QString::number( vol )); | 177 | cfg.writeEntry("VolumePercent", QString::number( vol )); |
98 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; | 178 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << false; |
99 | owarn << "changing output vol " << vol << "" << oendl; | 179 | qDebug("changing output vol %d" ,vol ); |
100 | } | 180 | } |
101 | ::close(fd); | 181 | ::close(fd); |
@@ -112,5 +192,5 @@ void Device::changedInVolume(int vol ) { | |||
112 | cfg.writeEntry("Mic", QString::number(vol )); | 192 | cfg.writeEntry("Mic", QString::number(vol )); |
113 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << false; | 193 | QCopEnvelope( "QPE/System", "micChange(bool)" ) << false; |
114 | owarn << "changing input volume " << vol << "" << oendl; | 194 | qDebug("changing input volume %d",vol); |
115 | } | 195 | } |
116 | ::close(fd); | 196 | ::close(fd); |
@@ -135,86 +215,4 @@ bool Device::selectMicInput() { | |||
135 | } | 215 | } |
136 | 216 | ||
137 | int Device::openDevice( int flags) { | ||
138 | /* pid_t pid; | ||
139 | int status; | ||
140 | int pipefd[2]; | ||
141 | char message[20]; | ||
142 | if (pipe(pipefd) == -1){ | ||
143 | perror ("Error creating pipe"); | ||
144 | exit(1); | ||
145 | } | ||
146 | switch (pid = fork()) { | ||
147 | case -1: | ||
148 | perror("The fork failed!"); | ||
149 | break; | ||
150 | case 0: { | ||
151 | */ | ||
152 | odebug << "Opening " << dspstr << "" << oendl; | ||
153 | if (( sd = ::open( dspstr, flags)) == -1) { | ||
154 | perror("open(\"/dev/dsp\")"); | ||
155 | QString errorMsg="Could not open audio device\n /dev/dsp\n" | ||
156 | +(QString)strerror(errno); | ||
157 | odebug << "XXXXXXXXXXXXXXXXXXXXXXX "+errorMsg << oendl; | ||
158 | return -1; | ||
159 | } | ||
160 | |||
161 | odebug << "Opening mixer" << oendl; | ||
162 | int mixerHandle=0; | ||
163 | if (( mixerHandle = open("/dev/mixer",O_RDWR))<0) { | ||
164 | perror("open(\"/dev/mixer\")"); | ||
165 | QString errorMsg="Could not open audio device\n /dev/dsp\n" | ||
166 | +(QString)strerror(errno); | ||
167 | odebug << "XXXXXXXXXXXXXXXXXXXXXX "+errorMsg << oendl; | ||
168 | } | ||
169 | |||
170 | if(ioctl(sd,SNDCTL_DSP_RESET,0)<0){ | ||
171 | perror("ioctl RESET"); | ||
172 | } | ||
173 | // sprintf(message, "%d", sd); | ||
174 | |||
175 | /* QFile f1("/pid"); | ||
176 | f1.open(IO_WriteOnly ); | ||
177 | f1.writeBlock(message, strlen(message)); | ||
178 | f1.close(); | ||
179 | */ | ||
180 | /* close(pipefd[0]); | ||
181 | write(pipefd[1], message, sizeof(message)); | ||
182 | close(pipefd[1]); | ||
183 | // odebug << "" << soundDevice->sd << "" << oendl; | ||
184 | _exit(0); | ||
185 | } | ||
186 | default: | ||
187 | // pid greater than zero is parent getting the child's pid | ||
188 | printf("Child's pid is %d\n",pid); | ||
189 | QString s; | ||
190 | close(pipefd[1]); | ||
191 | read(pipefd[0], message, sizeof(message)); | ||
192 | s = message; | ||
193 | close(pipefd[0]); | ||
194 | |||
195 | // while(wait(NULL)!=pid) | ||
196 | // ; | ||
197 | printf("child %ld terminated normally, return status is zero\n", (long) pid); | ||
198 | */ | ||
199 | // filePara.sd=(long) pid; | ||
200 | /* QFile f2("/pid"); | ||
201 | f2.open(IO_ReadOnly); | ||
202 | QTextStream t(&f2); | ||
203 | // for(int f=0; f < t.atEnd() ;f++) { | ||
204 | s = t.readLine(); | ||
205 | // } | ||
206 | */ | ||
207 | // bool ok; | ||
208 | // sd = s.toInt(&ok, 10); | ||
209 | // odebug << "<<<<<<<<<<<<<>>>>>>>>>>>>"+s << oendl; | ||
210 | |||
211 | // f2.close(); | ||
212 | // } | ||
213 | ::close(mixerHandle ); | ||
214 | // odebug << "open device " << dspstr << "" << oendl; | ||
215 | // odebug << "success! " << sd << "" << oendl; | ||
216 | return sd; | ||
217 | } | ||
218 | |||
219 | bool Device::closeDevice( bool) { | 217 | bool Device::closeDevice( bool) { |
220 | // if(b) {//close now | 218 | // if(b) {//close now |
@@ -231,10 +229,10 @@ bool Device::closeDevice( bool) { | |||
231 | // sdfd=0; | 229 | // sdfd=0; |
232 | // sd=0; | 230 | // sd=0; |
233 | // odebug << "closed dsp" << oendl; | 231 | // qDebug( "closed dsp" ); |
234 | return true; | 232 | return true; |
235 | } | 233 | } |
236 | 234 | ||
237 | bool Device::setDeviceFormat( int form) { | 235 | bool Device::setDeviceFormat( int form) { |
238 | odebug << "set device res " << form << " " << sd << "" << oendl; | 236 | qDebug( "set device res %d: %d ",form, sd ); |
239 | if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format | 237 | if (ioctl( sd, SNDCTL_DSP_SETFMT, &form)==-1) { //set format |
240 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 238 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
@@ -246,5 +244,5 @@ bool Device::setDeviceFormat( int form) { | |||
246 | 244 | ||
247 | bool Device::setDeviceChannels( int ch) { | 245 | bool Device::setDeviceChannels( int ch) { |
248 | odebug << "set channels " << ch << " " << sd << "" << oendl; | 246 | qDebug( "set channels %d: %d",ch ,sd); |
249 | if (ioctl( sd, SNDCTL_DSP_CHANNELS, &ch)==-1) { | 247 | if (ioctl( sd, SNDCTL_DSP_CHANNELS, &ch)==-1) { |
250 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 248 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
@@ -256,5 +254,5 @@ bool Device::setDeviceChannels( int ch) { | |||
256 | 254 | ||
257 | bool Device::setDeviceRate( int rate) { | 255 | bool Device::setDeviceRate( int rate) { |
258 | odebug << "set rate " << rate << " " << sd << "" << oendl; | 256 | qDebug( "set rate %d: %d",rate,sd); |
259 | if (ioctl( sd, SNDCTL_DSP_SPEED, &rate) == -1) { | 257 | if (ioctl( sd, SNDCTL_DSP_SPEED, &rate) == -1) { |
260 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 258 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
@@ -319,7 +317,7 @@ int Device::getDeviceFragSize() { | |||
319 | 317 | ||
320 | if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) { | 318 | if (ioctl( sd, SNDCTL_DSP_GETBLKSIZE, &frag_size) == -1) { |
321 | odebug << "no fragsize" << oendl; | 319 | qDebug( "no fragsize" ); |
322 | } else { | 320 | } else { |
323 | odebug << "driver says frag size is " << frag_size << "" << oendl; | 321 | qDebug( "driver says frag size is %d",frag_size); |
324 | } | 322 | } |
325 | return frag_size; | 323 | return frag_size; |
@@ -345,4 +343,5 @@ bool Device::reset() { | |||
345 | 343 | ||
346 | int Device::devRead(int soundDescriptor, short *buf, int size) { | 344 | int Device::devRead(int soundDescriptor, short *buf, int size) { |
345 | Q_UNUSED(soundDescriptor); | ||
347 | int number = 0; | 346 | int number = 0; |
348 | number = ::read( sd /*soundDescriptor*/, (char *)buf, size); | 347 | number = ::read( sd /*soundDescriptor*/, (char *)buf, size); |
@@ -351,5 +350,6 @@ int Device::devRead(int soundDescriptor, short *buf, int size) { | |||
351 | 350 | ||
352 | int Device::devWrite(int soundDescriptor, short * buf, int size) { | 351 | int Device::devWrite(int soundDescriptor, short * buf, int size) { |
353 | int bytesWritten = 0; | 352 | Q_UNUSED(soundDescriptor); |
353 | int bytesWritten = 0; | ||
354 | bytesWritten = ::write( sd /*soundDescriptor*/, buf, size); | 354 | bytesWritten = ::write( sd /*soundDescriptor*/, buf, size); |
355 | return bytesWritten; | 355 | return bytesWritten; |