-rw-r--r-- | core/multimedia/opieplayer/audiodevice.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index abbe5c8..020f6be 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp | |||
@@ -180,33 +180,33 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, | |||
180 | cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume | 180 | cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume |
181 | # endif | 181 | # endif |
182 | 182 | ||
183 | //#endif | 183 | //#endif |
184 | // qDebug( "setting volume to: 0x%x", volume ); | 184 | // qDebug( "setting volume to: 0x%x", volume ); |
185 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) | 185 | #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) |
186 | // Send notification that the volume has changed | 186 | // Send notification that the volume has changed |
187 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; | 187 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; |
188 | #endif | 188 | #endif |
189 | } | 189 | } |
190 | 190 | ||
191 | 191 | ||
192 | 192 | ||
193 | 193 | ||
194 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { | 194 | AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { |
195 | qDebug("creating new audio device"); | 195 | qDebug("creating new audio device"); |
196 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; | 196 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; |
197 | d = new AudioDevicePrivate; | 197 | d = new AudioDevicePrivate; |
198 | d->frequency = f; | 198 | d->frequency = f; |
199 | d->channels = chs; | 199 | d->channels = chs; |
200 | d->bytesPerSample = bps; | 200 | d->bytesPerSample = bps; |
201 | qDebug("%d",bps); | 201 | qDebug("%d",bps); |
202 | int format=0; | 202 | int format=0; |
203 | if( bps == 8) format = AFMT_U8; | 203 | if( bps == 8) format = AFMT_U8; |
204 | else if( bps <= 0) format = AFMT_S16_LE; | 204 | else if( bps <= 0) format = AFMT_S16_LE; |
205 | else format = AFMT_S16_LE; | 205 | else format = AFMT_S16_LE; |
206 | qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); | 206 | qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); |
207 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); | 207 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); |
208 | 208 | ||
209 | int fragments = 0x10000 * 8 + sound_fragment_shift; | 209 | int fragments = 0x10000 * 8 + sound_fragment_shift; |
210 | int capabilities = 0; | 210 | int capabilities = 0; |
211 | 211 | ||
212 | 212 | ||
@@ -232,63 +232,63 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { | |||
232 | 232 | ||
233 | if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) | 233 | if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) |
234 | perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); | 234 | perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); |
235 | if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) | 235 | if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) |
236 | perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); | 236 | perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); |
237 | if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) | 237 | if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) |
238 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); | 238 | perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); |
239 | qDebug("freq %d", d->frequency); | 239 | qDebug("freq %d", d->frequency); |
240 | if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) | 240 | if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) |
241 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); | 241 | perror("ioctl(\"SNDCTL_DSP_SPEED\")"); |
242 | qDebug("channels %d",d->channels); | 242 | qDebug("channels %d",d->channels); |
243 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { | 243 | if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { |
244 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; | 244 | d->channels = ( d->channels == 1 ) ? 2 : d->channels; |
245 | if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) | 245 | if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) |
246 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); | 246 | perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); |
247 | } | 247 | } |
248 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; | 248 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; |
249 | 249 | ||
250 | d->bufferSize = sound_fragment_bytes; | 250 | d->bufferSize = sound_fragment_bytes; |
251 | d->unwrittenBuffer = new char[d->bufferSize]; | 251 | d->unwrittenBuffer = new char[d->bufferSize]; |
252 | d->unwritten = 0; | 252 | d->unwritten = 0; |
253 | d->can_GETOSPACE = TRUE; // until we find otherwise | 253 | d->can_GETOSPACE = TRUE; // until we find otherwise |
254 | 254 | ||
255 | //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); | 255 | //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); |
256 | //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); | 256 | //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); |
257 | //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); | 257 | //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); |
258 | //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); | 258 | //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); |
259 | //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); | 259 | //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); |
260 | //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); | 260 | //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); |
261 | 261 | ||
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | AudioDevice::~AudioDevice() { | 265 | AudioDevice::~AudioDevice() { |
266 | qDebug("destryo audiodevice"); | 266 | qDebug("destryo audiodevice"); |
267 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; | 267 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; |
268 | 268 | ||
269 | // #ifdef Q_OS_WIN32 | 269 | // #ifdef Q_OS_WIN32 |
270 | // waveOutClose( (HWAVEOUT)d->handle ); | 270 | // waveOutClose( (HWAVEOUT)d->handle ); |
271 | // #else | 271 | // #else |
272 | # ifndef KEEP_DEVICE_OPEN | 272 | # ifndef KEEP_DEVICE_OPEN |
273 | close( d->handle ); // Now it should be safe to shut the handle | 273 | close( d->handle ); // Now it should be safe to shut the handle |
274 | # endif | 274 | # endif |
275 | delete d->unwrittenBuffer; | 275 | delete d->unwrittenBuffer; |
276 | delete d; | 276 | delete d; |
277 | //#endif | 277 | //#endif |
278 | // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; | 278 | QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; |
279 | 279 | ||
280 | } | 280 | } |
281 | 281 | ||
282 | 282 | ||
283 | void AudioDevice::volumeChanged( bool muted ) | 283 | void AudioDevice::volumeChanged( bool muted ) |
284 | { | 284 | { |
285 | AudioDevicePrivate::muted = muted; | 285 | AudioDevicePrivate::muted = muted; |
286 | } | 286 | } |
287 | 287 | ||
288 | 288 | ||
289 | void AudioDevice::write( char *buffer, unsigned int length ) | 289 | void AudioDevice::write( char *buffer, unsigned int length ) |
290 | { | 290 | { |
291 | // #ifdef Q_OS_WIN32 | 291 | // #ifdef Q_OS_WIN32 |
292 | // // returns immediately and (to be implemented) emits completedIO() when finished writing | 292 | // // returns immediately and (to be implemented) emits completedIO() when finished writing |
293 | // WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) ); | 293 | // WAVEHDR *lpWaveHdr = (WAVEHDR *)malloc( sizeof(WAVEHDR) ); |
294 | // // maybe the buffer should be copied so that this fool proof, but its a performance hit | 294 | // // maybe the buffer should be copied so that this fool proof, but its a performance hit |