diff options
Diffstat (limited to 'src/gui/embedded/qsoundqss_qws.cpp')
-rw-r--r-- | src/gui/embedded/qsoundqss_qws.cpp | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/src/gui/embedded/qsoundqss_qws.cpp b/src/gui/embedded/qsoundqss_qws.cpp index 6250764..b859be5 100644 --- a/src/gui/embedded/qsoundqss_qws.cpp +++ b/src/gui/embedded/qsoundqss_qws.cpp @@ -53,6 +53,7 @@ #include <qtimer.h> #include <qpointer.h> #include <qendian.h> +#include <private/qcore_unix_p.h> // overrides QT_OPEN #include <unistd.h> #include <stdlib.h> @@ -66,10 +67,12 @@ #include <qdebug.h> -QT_BEGIN_NAMESPACE +#include <qvfbhdr.h> extern int errno; +QT_BEGIN_NAMESPACE + #define QT_QWS_SOUND_16BIT 1 // or 0, or undefined for always 0 #define QT_QWS_SOUND_STEREO 1 // or 0, or undefined for always 0 @@ -78,7 +81,6 @@ extern int errno; static int sound_speed = 44100; #ifndef QT_NO_QWS_SOUNDSERVER extern int qws_display_id; -#define SOUND_PIPE "/tmp/.qt_soundserver-%1" #endif static char *zeroMem = 0; @@ -707,7 +709,7 @@ protected: #ifndef QT_NO_QWS_SOUNDSERVER QWSSoundServerSocket::QWSSoundServerSocket(QObject *parent) : - QWSServerSocket(QString::fromLatin1(SOUND_PIPE).arg(qws_display_id), parent) + QWSServerSocket(QT_VFB_SOUND_PIPE(qws_display_id), parent) { connect(this, SIGNAL(newConnection()), this, SLOT(newConnection())); } @@ -715,7 +717,7 @@ QWSSoundServerSocket::QWSSoundServerSocket(QObject *parent) : #ifdef QT3_SUPPORT QWSSoundServerSocket::QWSSoundServerSocket(QObject *parent, const char *name) : - QWSServerSocket(QString::fromLatin1(SOUND_PIPE).arg(qws_display_id), parent) + QWSServerSocket(QT_VFB_SOUND_PIPE(qws_display_id), parent) { if (name) setObjectName(QString::fromAscii(name)); @@ -1036,24 +1038,28 @@ void QWSSoundServerPrivate::stopFile(int wid, int sid) void QWSSoundServerPrivate::stopAll(int wid) { QWSSoundServerProvider *bucket; - QList<QWSSoundServerProvider*>::Iterator it = active.begin(); - while (it != active.end()) { - bucket = *it; - if (bucket->groupId() == wid) { - it = active.erase(it); - delete bucket; - } else { - ++it; + if (!active.isEmpty()) { + QList<QWSSoundServerProvider*>::Iterator it = active.begin(); + while (it != active.end()) { + bucket = *it; + if (bucket->groupId() == wid) { + it = active.erase(it); + delete bucket; + } else { + ++it; + } } } - it = inactive.begin(); - while (it != inactive.end()) { - bucket = *it; - if (bucket->groupId() == wid) { - it = inactive.erase(it); - delete bucket; - } else { - ++it; + if (!inactive.isEmpty()) { + QList<QWSSoundServerProvider*>::Iterator it = inactive.begin(); + while (it != inactive.end()) { + bucket = *it; + if (bucket->groupId() == wid) { + it = inactive.erase(it); + delete bucket; + } else { + ++it; + } } } } @@ -1137,7 +1143,7 @@ void QWSSoundServerPrivate::sendCompletedSignals() int QWSSoundServerPrivate::openFile(int wid, int sid, const QString& filename) { stopFile(wid, sid); // close and re-open. - int f = ::open(QFile::encodeName(filename), O_RDONLY|O_NONBLOCK); + int f = QT_OPEN(QFile::encodeName(filename), O_RDONLY|O_NONBLOCK); if (f == -1) { // XXX check ferror, check reason. qDebug("Failed opening \"%s\"",filename.toLatin1().data()); @@ -1157,7 +1163,7 @@ bool QWSSoundServerPrivate::openDevice() { if (fd < 0) { if( silent ) { - fd = ::open( "/dev/null", O_WRONLY ); + fd = QT_OPEN( "/dev/null", O_WRONLY ); // Emulate write to audio device int delay = 1000*(sound_buffer_size>>(sound_stereo+sound_16bit))/sound_speed/2; timerId = startTimer(delay); @@ -1168,7 +1174,7 @@ bool QWSSoundServerPrivate::openDevice() // Don't block open right away. // bool openOkay = false; - if ((fd = ::open("/dev/dsp", O_WRONLY|O_NONBLOCK)) != -1) { + if ((fd = QT_OPEN("/dev/dsp", O_WRONLY|O_NONBLOCK)) != -1) { int flags = fcntl(fd, F_GETFL); flags &= ~O_NONBLOCK; openOkay = (fcntl(fd, F_SETFL, flags) == 0); @@ -1222,7 +1228,7 @@ bool QWSSoundServerPrivate::openDevice() // // Check system volume // - int mixerHandle = ::open( "/dev/mixer", O_RDWR|O_NONBLOCK ); + int mixerHandle = QT_OPEN( "/dev/mixer", O_RDWR|O_NONBLOCK ); if ( mixerHandle >= 0 ) { int volume; ioctl( mixerHandle, MIXER_READ(0), &volume ); @@ -1390,7 +1396,7 @@ void QWSSoundServer::translateSoundCompleted( int, int sid ) QWSSoundClient::QWSSoundClient(QObject* parent) : QWSSocket(parent) { - connectToLocalFile(QString::fromLatin1(SOUND_PIPE).arg(qws_display_id)); + connectToLocalFile(QT_VFB_SOUND_PIPE(qws_display_id)); QObject::connect(this,SIGNAL(readyRead()), this,SLOT(tryReadCommand())); if( state() == QWS_SOCK_BASE::ConnectedState ) QTimer::singleShot(1, this, SIGNAL(connected())); @@ -1404,7 +1410,7 @@ QWSSoundClient::~QWSSoundClient( ) void QWSSoundClient::reconnect() { - connectToLocalFile(QString::fromLatin1(SOUND_PIPE).arg(qws_display_id)); + connectToLocalFile(QT_VFB_SOUND_PIPE(qws_display_id)); if( state() == QWS_SOCK_BASE::ConnectedState ) emit connected(); else emit error( QTcpSocket::ConnectionRefusedError ); } |