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.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/core/multimedia/opieplayer/audiodevice.cpp b/core/multimedia/opieplayer/audiodevice.cpp
index faadd72..8f04d0d 100644
--- a/core/multimedia/opieplayer/audiodevice.cpp
+++ b/core/multimedia/opieplayer/audiodevice.cpp
@@ -15,26 +15,31 @@
15 ** 15 **
16 ** Contact info@trolltech.com if any conditions of this licensing are 16 ** Contact info@trolltech.com if any conditions of this licensing are
17 ** not clear to you. 17 ** not clear to you.
18 ** 18 **
19 **********************************************************************/ 19 **********************************************************************/
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> 23#include <stdlib.h>
24#include <stdio.h> 24#include <stdio.h>
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/config.h> 26#include <qpe/config.h>
27#include <qmessagebox.h>
28
27#include "audiodevice.h" 29#include "audiodevice.h"
28 30
31
32#include <errno.h>
33
29#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP) 34#if ( defined Q_WS_QWS || defined(_WS_QWS_) ) && !defined(QT_NO_COP)
30#include "qpe/qcopenvelope_qws.h" 35#include "qpe/qcopenvelope_qws.h"
31#endif 36#endif
32 37
33// #ifdef Q_WS_WIN 38// #ifdef Q_WS_WIN
34// #include <windows.h> 39// #include <windows.h>
35// #include <mmsystem.h> 40// #include <mmsystem.h>
36// #include <mmreg.h> 41// #include <mmreg.h>
37// #endif 42// #endif
38#if defined(Q_WS_X11) || defined(Q_WS_QWS) 43#if defined(Q_WS_X11) || defined(Q_WS_QWS)
39#include <fcntl.h> 44#include <fcntl.h>
40#include <sys/ioctl.h> 45#include <sys/ioctl.h>
@@ -200,26 +205,32 @@ AudioDevice::AudioDevice( unsigned int f, unsigned int chs, unsigned int bps ) {
200 else format = AFMT_S16_LE; 205 else format = AFMT_S16_LE;
201 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);
202 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) ); 207 connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( volumeChanged(bool) ) );
203 208
204 int fragments = 0x10000 * 8 + sound_fragment_shift; 209 int fragments = 0x10000 * 8 + sound_fragment_shift;
205 int capabilities = 0; 210 int capabilities = 0;
206 211
207 212
208#ifdef KEEP_DEVICE_OPEN 213#ifdef KEEP_DEVICE_OPEN
209 if ( AudioDevicePrivate::dspFd == 0 ) { 214 if ( AudioDevicePrivate::dspFd == 0 ) {
210#endif 215#endif
211 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) { 216 if ( ( d->handle = ::open( "/dev/dsp", O_WRONLY ) ) < 0 ) {
212 perror("open(\"/dev/dsp\") sending to /dev/null instead"); 217
213 d->handle = ::open( "/dev/null", O_WRONLY ); 218// perror("open(\"/dev/dsp\") sending to /dev/null instead");
219 perror("open(\"/dev/dsp\")");
220 QString errorMsg=tr("Somethin's wrong with\nyour sound device.\nopen(\"/dev/dsp\")\n")+(QString)strerror(errno)+tr("\n\nClosing player now.");
221 QMessageBox::critical(0, "Vmemo", errorMsg, tr("Abort"));
222 exit(-1); //harsh?
223// d->handle = ::open( "/dev/null", O_WRONLY );
224 // WTF?!?!
214 } 225 }
215#ifdef KEEP_DEVICE_OPEN 226#ifdef KEEP_DEVICE_OPEN
216 AudioDevicePrivate::dspFd = d->handle; 227 AudioDevicePrivate::dspFd = d->handle;
217 } else { 228 } else {
218 d->handle = AudioDevicePrivate::dspFd; 229 d->handle = AudioDevicePrivate::dspFd;
219 } 230 }
220#endif 231#endif
221 232
222 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1) 233 if(ioctl( d->handle, SNDCTL_DSP_GETCAPS, &capabilities )==-1)
223 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")"); 234 perror("ioctl(\"SNDCTL_DSP_GETCAPS\")");
224 if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1) 235 if(ioctl( d->handle, SNDCTL_DSP_SETFRAGMENT, &fragments )==-1)
225 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")"); 236 perror("ioctl(\"SNDCTL_DSP_SETFRAGMENT\")");