summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/audiodevice.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/audiodevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/audiodevice.cpp50
1 files changed, 27 insertions, 23 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index 355062b..9b64e07 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -20,21 +20,25 @@
20// L.J.Potter added better error code Fri 02-15-2002 14:37:47 20// L.J.Potter added better error code Fri 02-15-2002 14:37:47
21 21
22 22
23#include <stdlib.h>
24#include <stdio.h>
25#include <qpe/qpeapplication.h>
26#include <qpe/config.h>
27#include <qmessagebox.h>
28
29#include "audiodevice.h" 23#include "audiodevice.h"
30 24
31 25/* OPIE */
32#include <errno.h> 26#include <qpe/qpeapplication.h>
27#include <qpe/config.h>
28#include <opie2/odebug.h>
33 29
34#if !defined(QT_NO_COP) 30#if !defined(QT_NO_COP)
35#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
36#endif 32#endif
37 33
34/* QT */
35#include <qmessagebox.h>
36
37/* STD */
38#include <stdlib.h>
39#include <stdio.h>
40#include <errno.h>
41
38#if defined(Q_WS_X11) || defined(Q_WS_QWS) 42#if defined(Q_WS_X11) || defined(Q_WS_QWS)
39#include <fcntl.h> 43#include <fcntl.h>
40#include <sys/ioctl.h> 44#include <sys/ioctl.h>
@@ -145,7 +149,7 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume,
145# endif 149# endif
146 150
147//#endif 151//#endif
148// qDebug( "setting volume to: 0x%x", volume ); 152// odebug << "setting volume to: 0x" << volume << "" << oendl;
149#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 153#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
150 // Send notification that the volume has changed 154 // Send notification that the volume has changed
151 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; 155 QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted;
@@ -155,18 +159,18 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume,
155 159
156 160
157AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { 161AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
158 // qDebug("creating new audio device"); 162 // odebug << "creating new audio device" << oendl;
159// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; 163// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
160 d = new AudioDevicePrivate; 164 d = new AudioDevicePrivate;
161 d->frequency = f; 165 d->frequency = f;
162 d->channels = chs; 166 d->channels = chs;
163 d->bytesPerSample = bps; 167 d->bytesPerSample = bps;
164 // qDebug("%d",bps); 168 // odebug << "" << bps << "" << oendl;
165 int format=0; 169 int format=0;
166 if( bps == 8) format = AFMT_U8; 170 if( bps == 8) format = AFMT_U8;
167 else if( bps <= 0) format = AFMT_S16_LE; 171 else if( bps <= 0) format = AFMT_S16_LE;
168 else format = AFMT_S16_LE; 172 else format = AFMT_S16_LE;
169 // qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); 173 // odebug << "AD- freq " << f << ", channels " << chs << ", b/sample " << bps << ", bitrate " << format << "" << oendl;
170 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); 174 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
171 175
172 int fragments = 0x10000 * 8 + sound_fragment_shift; 176 int fragments = 0x10000 * 8 + sound_fragment_shift;
@@ -200,10 +204,10 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
200 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); 204 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")");
201 if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1) 205 if(ioctl( d->handle, SNDCTL_DSP_SETFMT, & format )==-1)
202 perror("ioctl(\"SNDCTL_DSP_SETFMT\")"); 206 perror("ioctl(\"SNDCTL_DSP_SETFMT\")");
203 // qDebug("freq %d", d->frequency); 207 // odebug << "freq " << d->frequency << "" << oendl;
204 if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1) 208 if(ioctl( d->handle, SNDCTL_DSP_SPEED, &d->frequency )==-1)
205 perror("ioctl(\"SNDCTL_DSP_SPEED\")"); 209 perror("ioctl(\"SNDCTL_DSP_SPEED\")");
206 // qDebug("channels %d",d->channels); 210 // odebug << "channels " << d->channels << "" << oendl;
207 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { 211 if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) {
208 d->channels = ( d->channels == 1 ) ? 2 : d->channels; 212 d->channels = ( d->channels == 1 ) ? 2 : d->channels;
209 if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) 213 if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1)
@@ -216,18 +220,18 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
216 d->unwritten = 0; 220 d->unwritten = 0;
217 d->can_GETOSPACE = TRUE; // until we find otherwise 221 d->can_GETOSPACE = TRUE; // until we find otherwise
218 222
219 //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); 223 //if ( chs != d->channels ) odebug << "Wanted " << chs << ", got " << d->channels << " channels" << oendl;
220 //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); 224 //if ( f != d->frequency ) odebug << "wanted " << f << "Hz, got " << d->frequency << "Hz" << oendl;
221 //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); 225 //if ( capabilities & DSP_CAP_BATCH ) odebug << "Sound card has local buffer" << oendl;
222 //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); 226 //if ( capabilities & DSP_CAP_REALTIME )odebug << "Sound card has realtime sync" << oendl;
223 //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); 227 //if ( capabilities & DSP_CAP_TRIGGER ) odebug << "Sound card has precise trigger" << oendl;
224 //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); 228 //if ( capabilities & DSP_CAP_MMAP ) odebug << "Sound card can mmap" << oendl;
225 229
226} 230}
227 231
228 232
229AudioDevice::~AudioDevice() { 233AudioDevice::~AudioDevice() {
230 // qDebug("destryo audiodevice"); 234 // odebug << "destryo audiodevice" << oendl;
231// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; 235// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE;
232 236
233# ifndef KEEP_DEVICE_OPEN 237# ifndef KEEP_DEVICE_OPEN
@@ -251,7 +255,7 @@ void AudioDevice::write( char *buffer, unsigned int length )
251 int t = ::write( d->handle, buffer, length ); 255 int t = ::write( d->handle, buffer, length );
252 if ( t<0 ) t = 0; 256 if ( t<0 ) t = 0;
253 if ( t != (int)length) { 257 if ( t != (int)length) {
254 // qDebug("Ahhh!! memcpys 1"); 258 // odebug << "Ahhh!! memcpys 1" << oendl;
255 memcpy(d->unwrittenBuffer,buffer+t,length-t); 259 memcpy(d->unwrittenBuffer,buffer+t,length-t);
256 d->unwritten = length-t; 260 d->unwritten = length-t;
257 } 261 }
@@ -314,7 +318,7 @@ unsigned int AudioDevice::canWrite() const
314int AudioDevice::bytesWritten() { 318int AudioDevice::bytesWritten() {
315 int buffered = 0; 319 int buffered = 0;
316 if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) { 320 if ( ioctl( d->handle, SNDCTL_DSP_GETODELAY, &buffered ) ) {
317 // qDebug( "failed to get audio device position" ); 321 // odebug << "failed to get audio device position" << oendl;
318 return -1; 322 return -1;
319 } 323 }
320 return buffered; 324 return buffered;