Diffstat (limited to 'core/multimedia/opieplayer/audiodevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/audiodevice.cpp | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp index 6a38fc9..d296d27 100644 --- a/core/multimedia/opieplayer/audiodevice.cpp +++ b/core/multimedia/opieplayer/audiodevice.cpp @@ -21,38 +21,39 @@ #include <stdlib.h> #include <stdio.h> #include <qpe/qpeapplication.h> #include <qpe/config.h> +#include <qpe/custom.h> #include <qmessagebox.h> #include "audiodevice.h" #include <errno.h> -#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) -#include "qpe/qcopenvelope_qws.h" +#if !defined(QT_NO_COP) +#include <qpe/qcopenvelope_qws.h> #endif #if defined(Q_WS_X11) || defined(Q_WS_QWS) #include <fcntl.h> #include <sys/ioctl.h> #include <sys/soundcard.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <unistd.h> #endif -# if defined(QT_QWS_IPAQ) -static const int sound_fragment_shift = 14; -# else +#ifdef OPIE_SOUND_FRAGMENT_SHIFT +static const int sound_fragment_shift = OPIE_SOUND_FRAGMENT_SHIFT; +#else static const int sound_fragment_shift = 16; -# endif +#endif static const int sound_fragment_bytes = (1<<sound_fragment_shift); //#endif class AudioDevicePrivate { public: @@ -142,24 +143,24 @@ void AudioDevice::setVolume( unsigned int leftVolume, unsigned int rightVolume, Config cfg("qpe"); // qtopia is "Sound" cfg.setGroup("Volume"); // qtopia is "Settings" cfg.writeEntry("VolumePercent",(int)rV); //qtopia is Volume # endif //#endif -// qDebug( "setting volume to: 0x%x", volume ); +// qDebug( "setting volume to: 0x%x", volume ); #if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) // Send notification that the volume has changed - QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; + QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << muted; #endif } AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { // qDebug("creating new audio device"); -// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; +// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; d = new AudioDevicePrivate; d->frequency = f; d->channels = chs; d->bytesPerSample = bps; // qDebug("%d",bps); int format=0; @@ -169,13 +170,13 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { // qDebug("AD- freq %d, channels %d, b/sample %d, bitrate %d",f,chs,bps,format); connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); int fragments = 0x10000 * 8 + sound_fragment_shift; int capabilities = 0; - + #ifdef KEEP_DEVICE_OPEN if ( AudioDevicePrivate::dspFd == 0 ) { #endif #ifdef QT_QWS_DEVFS if ( ( d->handle = ::open( "/dev/sound/dsp", O_WRONLY ) ) < 0 ) { #else @@ -184,13 +185,13 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { perror("open(\"/dev/dsp\")"); QString errorMsg=tr("Somethin's wrong with\nyour sound device.\nopen(\"/dev/dsp\")\n")+(QString)strerror(errno)+tr("\n\nClosing player now."); QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort")); exit(-1); //harsh? } -#ifdef KEEP_DEVICE_OPEN +#ifdef KEEP_DEVICE_OPEN AudioDevicePrivate::dspFd = d->handle; } else { d->handle = AudioDevicePrivate::dspFd; } #endif @@ -206,40 +207,40 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) { // qDebug("channels %d",d->channels); if ( ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels ) == -1 ) { d->channels = ( d->channels == 1 ) ? 2 : d->channels; if(ioctl( d->handle, SNDCTL_DSP_CHANNELS, &d->channels )==-1) perror("ioctl(\"SNDCTL_DSP_CHANNELS\")"); } -// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; +// QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; d->bufferSize = sound_fragment_bytes; d->unwrittenBuffer = new char[d->bufferSize]; d->unwritten = 0; d->can_GETOSPACE = TRUE; // until we find otherwise - + //if ( chs != d->channels ) qDebug( "Wanted %d, got %d channels", chs, d->channels ); //if ( f != d->frequency ) qDebug( "wanted %dHz, got %dHz", f, d->frequency ); //if ( capabilities & DSP_CAP_BATCH ) qDebug( "Sound card has local buffer" ); //if ( capabilities & DSP_CAP_REALTIME )qDebug( "Sound card has realtime sync" ); //if ( capabilities & DSP_CAP_TRIGGER ) qDebug( "Sound card has precise trigger" ); //if ( capabilities & DSP_CAP_MMAP ) qDebug( "Sound card can mmap" ); - + } - + AudioDevice::~AudioDevice() { // qDebug("destryo audiodevice"); // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << TRUE; - -# ifndef KEEP_DEVICE_OPEN + +# ifndef KEEP_DEVICE_OPEN close( d->handle ); // Now it should be safe to shut the handle # endif delete d->unwrittenBuffer; delete d; // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << FALSE; - + } void AudioDevice::volumeChanged( bool muted ) { AudioDevicePrivate::muted = muted; |