Qt 4.8
Classes | Public Slots | Signals | Public Functions | Protected Functions | Private Functions | Properties | List of all members
QWSSoundServerPrivate Class Reference
Inheritance diagram for QWSSoundServerPrivate:
QObject

Classes

struct  CompletedInfo
 
struct  PresetVolume
 

Public Slots

void checkPresetVolumes (int wid, int sid, QWSSoundServerProvider *p)
 
void feedDevice (int fd)
 
void pauseFile (int wid, int sid)
 
void playFile (int wid, int sid, const QString &filename)
 
void playFile (int wid, int sid, const QString &filename, int v, int flags)
 
void playPriorityOnly (bool p)
 
void playRawFile (int wid, int sid, const QString &filename, int freq, int channels, int bitspersample, int flags)
 
void resumeFile (int wid, int sid)
 
void sendCompletedSignals ()
 
void setMute (int wid, int sid, bool m)
 
void setSilent (bool enabled)
 
void setVolume (int wid, int sid, int lv, int rv)
 
void stopAll (int wid)
 
void stopFile (int wid, int sid)
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Signals

void deviceError (int, int, int)
 
void deviceReady (int, int)
 
void soundFileCompleted (int, int)
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

 QWSSoundServerPrivate (QObject *parent=0, const char *name=0)
 
 ~QWSSoundServerPrivate ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Protected Functions

void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 

Private Functions

void closeDevice ()
 
bool openDevice ()
 
int openFile (int wid, int sid, const QString &filename)
 

Properties

QList< QWSSoundServerProvider * > active
 
bool can_GETOSPACE
 
QList< CompletedInfocompleted
 
char * cursor
 
short data [sound_buffer_size *2]
 
int fd
 
QList< QWSSoundServerProvider * > inactive
 
QWSSoundServerSocket * server
 
bool silent
 
int timerId
 
int unwritten
 
QList< PresetVolumevolumes
 

Additional Inherited Members

- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 770 of file qsoundqss_qws.cpp.

Constructors and Destructors

◆ QWSSoundServerPrivate()

QWSSoundServerPrivate::QWSSoundServerPrivate ( QObject parent = 0,
const char *  name = 0 
)
inline

Definition at line 774 of file qsoundqss_qws.cpp.

774  :
775  QObject(parent)
776  {
777  timerId = 0;
778  if (name)
780 #ifndef QT_NO_QWS_SOUNDSERVER
781  server = new QWSSoundServerSocket(this);
782 
783  connect(server, SIGNAL(playFile(int,int,QString)),
784  this, SLOT(playFile(int,int,QString)));
785  connect(server, SIGNAL(playFile(int,int,QString,int,int)),
786  this, SLOT(playFile(int,int,QString,int,int)));
787  connect(server, SIGNAL(playRawFile(int,int,QString,int,int,int,int)),
788  this, SLOT(playRawFile(int,int,QString,int,int,int,int)));
789 
790  connect(server, SIGNAL(pauseFile(int,int)),
791  this, SLOT(pauseFile(int,int)));
792  connect(server, SIGNAL(stopFile(int,int)),
793  this, SLOT(stopFile(int,int)));
794  connect(server, SIGNAL(stopAll(int)),
795  this, SLOT(stopAll(int)));
797  this, SLOT(playPriorityOnly(bool)));
798  connect(server, SIGNAL(resumeFile(int,int)),
799  this, SLOT(resumeFile(int,int)));
800 
801  connect( server, SIGNAL(setSilent(bool)),
802  this, SLOT(setSilent(bool)));
803 
804  connect(server, SIGNAL(setMute(int,int,bool)),
805  this, SLOT(setMute(int,int,bool)));
806  connect(server, SIGNAL(setVolume(int,int,int,int)),
807  this, SLOT(setVolume(int,int,int,int)));
808 
809  connect(this, SIGNAL(soundFileCompleted(int,int)),
810  server, SIGNAL(soundFileCompleted(int,int)));
811  connect(this, SIGNAL(deviceReady(int,int)),
812  server, SIGNAL(deviceReady(int,int)));
813  connect(this, SIGNAL(deviceError(int,int,int)),
814  server, SIGNAL(deviceError(int,int,int)));
815 
816 #endif
817  silent = false;
818  fd = -1;
819  unwritten = 0;
820  can_GETOSPACE = true;
821  }
void deviceReady(int, int)
static QString fromAscii(const char *, int size=-1)
Returns a QString initialized with the first size characters from the string str. ...
Definition: qstring.cpp:4276
void playFile(int wid, int sid, const QString &filename)
#define SLOT(a)
Definition: qobjectdefs.h:226
void resumeFile(int wid, int sid)
void soundFileCompleted(int, int)
The QString class provides a Unicode character string.
Definition: qstring.h:83
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
void setVolume(int wid, int sid, int lv, int rv)
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void deviceError(int, int, int)
void setSilent(bool enabled)
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void playPriorityOnly(bool p)
void pauseFile(int wid, int sid)
const char * name
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753
QWSSoundServerSocket * server
void stopFile(int wid, int sid)
void setMute(int wid, int sid, bool m)
void playRawFile(int wid, int sid, const QString &filename, int freq, int channels, int bitspersample, int flags)

◆ ~QWSSoundServerPrivate()

QWSSoundServerPrivate::~QWSSoundServerPrivate ( )
inline

Definition at line 823 of file qsoundqss_qws.cpp.

824  {
827  }
QList< QWSSoundServerProvider * > inactive
QList< QWSSoundServerProvider * > active
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

Functions

◆ checkPresetVolumes

void QWSSoundServerPrivate::checkPresetVolumes ( int  wid,
int  sid,
QWSSoundServerProvider p 
)
slot

Definition at line 973 of file qsoundqss_qws.cpp.

974 {
976  while (it != volumes.end()) {
977  PresetVolume v = *it;
978  if (v.wid == wid && v.sid == sid) {
979  p->setVolume(v.left, v.right);
980  p->setMute(v.mute);
981  it = volumes.erase(it);
982  return;
983  } else {
984  ++it;
985  }
986  }
987 }
#define it(className, varName)
void setVolume(int lv, int rv)
QList< PresetVolume > volumes
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
Definition: qlist.h:181

◆ closeDevice()

void QWSSoundServerPrivate::closeDevice ( )
inlineprivate

Definition at line 856 of file qsoundqss_qws.cpp.

857  {
858  if (fd >= 0) {
859  ::close(fd);
860  fd = -1;
861  }
862  }

◆ deviceError

void QWSSoundServerPrivate::deviceError ( int  ,
int  ,
int   
)
signal

◆ deviceReady

void QWSSoundServerPrivate::deviceReady ( int  ,
int   
)
signal

◆ feedDevice

void QWSSoundServerPrivate::feedDevice ( int  fd)
slot

Definition at line 1246 of file qsoundqss_qws.cpp.

1247 {
1248  if ( !unwritten && active.size() == 0 ) {
1249  closeDevice();
1251  return;
1252  } else {
1254  }
1255 
1256  QWSSoundServerProvider* bucket;
1257 
1258  // find out how much audio is possible
1259  int available = sound_buffer_size;
1261  for (int i = 0; i < active.size(); ++i) {
1262  bucket = active.at(i);
1263  int ready = bucket->readySamples(available);
1264  if (ready > 0) {
1265  available = qMin(available, ready);
1266  running.append(bucket);
1267  }
1268  }
1269 
1270  audio_buf_info info;
1271  if (can_GETOSPACE && ioctl(fd,SNDCTL_DSP_GETOSPACE,&info)) {
1272  can_GETOSPACE = false;
1273  fcntl(fd, F_SETFL, O_NONBLOCK);
1274  }
1275  if (!can_GETOSPACE)
1276  info.fragments = 4; // #### configurable?
1277  if (info.fragments > 0) {
1278  if (!unwritten) {
1279  int left[sound_buffer_size];
1280  memset(left,0,available*sizeof(int));
1281  int right[sound_buffer_size];
1282  if ( sound_stereo )
1283  memset(right,0,available*sizeof(int));
1284 
1285  if (running.size() > 0) {
1286  // should do volume mod here in regards to each bucket to avoid flattened/bad peaks.
1287  for (int i = 0; i < running.size(); ++i ) {
1288  bucket = running.at(i);
1289  int unused = bucket->add(left,right,available);
1290  if (unused > 0) {
1291  // this error is quite serious, as
1292  // it will really screw up mixing.
1293  qDebug("provider lied about samples ready");
1294  }
1295  }
1296  if ( sound_16bit ) {
1297  short *d = (short*)data;
1298  for (int i=0; i<available; i++) {
1299  *d++ = (short)qMax(qMin(left[i],32767),-32768);
1300  if ( sound_stereo )
1301  *d++ = (short)qMax(qMin(right[i],32767),-32768);
1302  }
1303  } else {
1304  signed char *d = (signed char *)data;
1305  for (int i=0; i<available; i++) {
1306  *d++ = (signed char)qMax(qMin(left[i]/256,127),-128)+128;
1307  if ( sound_stereo )
1308  *d++ = (signed char)qMax(qMin(right[i]/256,127),-128)+128;
1309  }
1310  }
1311  unwritten = available*(sound_16bit+1)*(sound_stereo+1);
1312  cursor = (char*)data;
1313  }
1314  }
1315  // sound open, but nothing written. Should clear the buffer.
1316 
1317  int w;
1318  if (unwritten) {
1319  w = ::write(fd,cursor,unwritten);
1320 
1321  if (w < 0) {
1322  if (can_GETOSPACE)
1323  return;
1324  w = 0;
1325  }
1326 
1327  cursor += w;
1328  unwritten -= w;
1329  } else {
1330  // write some zeros to clear the buffer?
1331  if (!zeroMem)
1332  zeroMem = (char *)calloc(sound_buffer_size, sizeof(char));
1333  w = ::write(fd, zeroMem, sound_buffer_size);
1334  if (w < 0)
1335  w = 0;
1336  }
1337  }
1338 
1340  while (it != active.end()) {
1341  bucket = *it;
1342  if (bucket->finished()) {
1343  completed.append(CompletedInfo(bucket->groupId(), bucket->soundId()));
1344  it = active.erase(it);
1345  delete bucket;
1346  } else {
1347  ++it;
1348  }
1349  }
1350 }
double d
Definition: qnumeric_p.h:62
short data[sound_buffer_size *2]
static int sound_stereo
static mach_timebase_info_data_t info
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
#define it(className, varName)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
static char * zeroMem
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
Q_CORE_EXPORT void qDebug(const char *,...)
virtual bool finished() const =0
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
int add(int *mixl, int *mixr, int count)
#define calloc(a, b)
virtual int readySamples(int)=0
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
Definition: qlist.h:181
int fcntl(int, int,...)
iterator erase(iterator pos)
Removes the item associated with the iterator pos from the list, and returns an iterator to the next ...
Definition: qlist.h:464
QList< QWSSoundServerProvider * > active
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QList< CompletedInfo > completed
static bool sound_16bit
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
static const int sound_buffer_size
The QList class is a template class that provides lists.
Definition: qdatastream.h:62

◆ openDevice()

bool QWSSoundServerPrivate::openDevice ( )
private

Definition at line 1162 of file qsoundqss_qws.cpp.

1163 {
1164  if (fd < 0) {
1165  if( silent ) {
1166  fd = QT_OPEN( "/dev/null", O_WRONLY );
1167  // Emulate write to audio device
1168  int delay = 1000*(sound_buffer_size>>(sound_stereo+sound_16bit))/sound_speed/2;
1169  timerId = startTimer(delay);
1170 
1171  return true;
1172  }
1173  //
1174  // Don't block open right away.
1175  //
1176  bool openOkay = false;
1177  if ((fd = QT_OPEN("/dev/dsp", O_WRONLY|O_NONBLOCK)) != -1) {
1178  int flags = fcntl(fd, F_GETFL);
1179  flags &= ~O_NONBLOCK;
1180  openOkay = (fcntl(fd, F_SETFL, flags) == 0);
1181  }
1182  if (!openOkay) {
1183  qDebug("Failed opening audio device");
1184  return false;
1185  }
1186 
1187  // Setup soundcard at 16 bit mono
1188  int v;
1189  //v=0x00010000+sound_fragment_size;
1190  // um the media player did this instead.
1191  v=0x10000 * 4 + sound_fragment_size;
1192  if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &v))
1193  qWarning("Could not set fragments to %08x",v);
1194 #ifdef QT_QWS_SOUND_16BIT
1195  //
1196  // Use native endian
1197  // Since we have manipulated the data volume the data
1198  // is now in native format, even though its stored
1199  // as little endian in the WAV file
1200  //
1201  v=AFMT_S16_NE; if (ioctl(fd, SNDCTL_DSP_SETFMT, &v))
1202  qWarning("Could not set format %d",v);
1203  if (AFMT_S16_NE != v)
1204  qDebug("Want format %d got %d", AFMT_S16_LE, v);
1205 #else
1206  v=AFMT_U8; if (ioctl(fd, SNDCTL_DSP_SETFMT, &v))
1207  qWarning("Could not set format %d",v);
1208  if (AFMT_U8 != v)
1209  qDebug("Want format %d got %d", AFMT_U8, v);
1210 #endif
1211  v=sound_stereo; if (ioctl(fd, SNDCTL_DSP_STEREO, &v))
1212  qWarning("Could not set stereo %d",v);
1213  if (sound_stereo != v)
1214  qDebug("Want stereo %d got %d", sound_stereo, v);
1215 #ifdef QT_QWS_SOUND_STEREO
1216  sound_stereo=v;
1217 #endif
1218  v=sound_speed; if (ioctl(fd, SNDCTL_DSP_SPEED, &sound_speed))
1219  qWarning("Could not set speed %d",v);
1220  if (v != sound_speed)
1221  qDebug("Want speed %d got %d", v, sound_speed);
1222 
1223  int delay = 1000*(sound_buffer_size>>(sound_stereo+sound_16bit))
1224  /sound_speed/2;
1225  // qDebug("QSS delay: %d", delay);
1226  timerId = startTimer(delay);
1227 
1228  //
1229  // Check system volume
1230  //
1231  int mixerHandle = QT_OPEN( "/dev/mixer", O_RDWR|O_NONBLOCK );
1232  if ( mixerHandle >= 0 ) {
1233  int volume;
1234  ioctl( mixerHandle, MIXER_READ(0), &volume );
1235  close( mixerHandle );
1236  if ( volume < 1<<(sound_stereo+sound_16bit) )
1237  qDebug("Want sound at %d got %d",
1238  1<<(sound_stereo+sound_16bit), volume);
1239  } else
1240  qDebug( "get volume of audio device failed" );
1241 
1242  }
1243  return true;
1244 }
int startTimer(int interval)
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer...
Definition: qobject.cpp:1623
static int sound_stereo
static int sound_speed
Q_CORE_EXPORT void qDebug(const char *,...)
static const int sound_fragment_size
Q_CORE_EXPORT void qWarning(const char *,...)
int fcntl(int, int,...)
#define QT_OPEN
Definition: qcore_unix_p.h:186
static bool sound_16bit
#define O_RDWR
#define O_WRONLY
static const int sound_buffer_size

◆ openFile()

int QWSSoundServerPrivate::openFile ( int  wid,
int  sid,
const QString filename 
)
private

Definition at line 1143 of file qsoundqss_qws.cpp.

1144 {
1145  stopFile(wid, sid); // close and re-open.
1146  int f = QT_OPEN(QFile::encodeName(filename), O_RDONLY|O_NONBLOCK);
1147  if (f == -1) {
1148  // XXX check ferror, check reason.
1149  qDebug("Failed opening \"%s\"",filename.toLatin1().data());
1150 #ifndef QT_NO_QWS_SOUNDSERVER
1151  emit deviceError(wid, sid, (int)QWSSoundClient::ErrOpeningFile );
1152 #endif
1153  } else if ( openDevice() ) {
1154  return f;
1155  }
1156 #ifndef QT_NO_QWS_SOUNDSERVER
1157  emit deviceError(wid, sid, (int)QWSSoundClient::ErrOpeningAudioDevice );
1158 #endif
1159  return 0;
1160 }
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
#define O_RDONLY
Q_CORE_EXPORT void qDebug(const char *,...)
void deviceError(int, int, int)
#define emit
Definition: qobjectdefs.h:76
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
#define QT_OPEN
Definition: qcore_unix_p.h:186
void stopFile(int wid, int sid)
static QByteArray encodeName(const QString &fileName)
By default, this function converts fileName to the local 8-bit encoding determined by the user&#39;s loca...
Definition: qfile.cpp:528

◆ pauseFile

void QWSSoundServerPrivate::pauseFile ( int  wid,
int  sid 
)
slot

Definition at line 989 of file qsoundqss_qws.cpp.

990 {
991  QWSSoundServerProvider *bucket;
992  for (int i = 0; i < active.size(); ++i ) {
993  bucket = active.at(i);
994  if (bucket->equal(wid, sid)) {
995  // found bucket....
996  active.removeAt(i);
997  inactive.append(bucket);
998  return;
999  }
1000  }
1001 }
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< QWSSoundServerProvider * > inactive
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< QWSSoundServerProvider * > active
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool equal(int wid, int sid)
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ playFile [1/2]

void QWSSoundServerPrivate::playFile ( int  wid,
int  sid,
const QString filename 
)
slot

Definition at line 943 of file qsoundqss_qws.cpp.

944 {
945  int f = openFile(wid, sid, filename);
946  if ( f ) {
947  QWSSoundServerProvider *b = new QWSSoundServerBucket(f, wid, sid);
948  checkPresetVolumes(wid, sid, b);
949  active.append( b );
950  emit deviceReady(wid, sid);
951  }
952 }
void deviceReady(int, int)
void checkPresetVolumes(int wid, int sid, QWSSoundServerProvider *p)
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
#define emit
Definition: qobjectdefs.h:76
int openFile(int wid, int sid, const QString &filename)
QList< QWSSoundServerProvider * > active

◆ playFile [2/2]

void QWSSoundServerPrivate::playFile ( int  wid,
int  sid,
const QString filename,
int  v,
int  flags 
)
slot

Definition at line 954 of file qsoundqss_qws.cpp.

956 {
957 #ifdef QT_NO_QWS_SOUNDSERVER
958  Q_UNUSED(flags);
959 #endif
960  int f = openFile(wid, sid, filename);
961  if ( f ) {
962  QWSSoundServerProvider *b = new QWSSoundServerBucket(f, wid, sid);
963  checkPresetVolumes(wid, sid, b);
964  b->setVolume(v, v);
965 #ifndef QT_NO_QWS_SOUNDSERVER
966  b->setPriority((flags & QWSSoundClient::Priority) == QWSSoundClient::Priority);
967 #endif
968  active.append(b);
969  emit deviceReady(wid, sid);
970  }
971 }
void deviceReady(int, int)
void setVolume(int lv, int rv)
void checkPresetVolumes(int wid, int sid, QWSSoundServerProvider *p)
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
#define emit
Definition: qobjectdefs.h:76
int openFile(int wid, int sid, const QString &filename)
QList< QWSSoundServerProvider * > active
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ playPriorityOnly

void QWSSoundServerPrivate::playPriorityOnly ( bool  p)
slot

Definition at line 1128 of file qsoundqss_qws.cpp.

1129 {
1131 }
static void setPlayPriorityOnly(bool p)

◆ playRawFile

void QWSSoundServerPrivate::playRawFile ( int  wid,
int  sid,
const QString filename,
int  freq,
int  channels,
int  bitspersample,
int  flags 
)
slot

Definition at line 924 of file qsoundqss_qws.cpp.

926 {
927 #ifdef QT_NO_QWS_SOUNDSERVER
928  Q_UNUSED(flags);
929 #endif
930  int f = openFile(wid, sid, filename);
931  if ( f ) {
932  QWSSoundServerStream *b = new QWSSoundServerStream(f, channels, freq, bitspersample, wid, sid);
933  // check preset volumes.
934  checkPresetVolumes(wid, sid, b);
935 #ifndef QT_NO_QWS_SOUNDSERVER
936  b->setPriority((flags & QWSSoundClient::Priority) == QWSSoundClient::Priority);
937 #endif
938  active.append(b);
939  emit deviceReady(wid, sid);
940  }
941 }
void deviceReady(int, int)
void checkPresetVolumes(int wid, int sid, QWSSoundServerProvider *p)
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
#define emit
Definition: qobjectdefs.h:76
int openFile(int wid, int sid, const QString &filename)
QList< QWSSoundServerProvider * > active
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ resumeFile

void QWSSoundServerPrivate::resumeFile ( int  wid,
int  sid 
)
slot

Definition at line 1003 of file qsoundqss_qws.cpp.

1004 {
1005  QWSSoundServerProvider *bucket;
1006  for (int i = 0; i < inactive.size(); ++i ) {
1007  bucket = inactive.at(i);
1008  if (bucket->equal(wid, sid)) {
1009  // found bucket....
1010  inactive.removeAt(i);
1011  active.append(bucket);
1012  return;
1013  }
1014  }
1015 }
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
QList< QWSSoundServerProvider * > inactive
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< QWSSoundServerProvider * > active
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool equal(int wid, int sid)
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ sendCompletedSignals

void QWSSoundServerPrivate::sendCompletedSignals ( )
slot

Definition at line 1133 of file qsoundqss_qws.cpp.

1134 {
1135  while( !completed.isEmpty() ) {
1136  emit soundFileCompleted( (*completed.begin()).groupId,
1137  (*completed.begin()).soundId );
1138  completed.erase( completed.begin() );
1139  }
1140 }
void soundFileCompleted(int, int)
#define emit
Definition: qobjectdefs.h:76
QList< CompletedInfo > completed

◆ setMute

void QWSSoundServerPrivate::setMute ( int  wid,
int  sid,
bool  m 
)
slot

Definition at line 1097 of file qsoundqss_qws.cpp.

1098 {
1099  QWSSoundServerProvider *bucket;
1100  for( int i = 0; i < active.size(); ++i ) {
1101  bucket = active.at(i);
1102  if (bucket->equal(wid, sid)) {
1103  bucket->setMute(m);
1104  return;
1105  }
1106  }
1107  // if gotten here then setting is being applied before item
1108  // is created.
1110  while (it != volumes.end()) {
1111  PresetVolume v = *it;
1112  if (v.wid == wid && v.sid == sid) {
1113  (*it).mute = m;
1114  return;
1115  }
1116  }
1117  if (m) {
1118  PresetVolume nv;
1119  nv.wid = wid;
1120  nv.sid = sid;
1121  nv.left = maxVolume>>1;
1122  nv.right = maxVolume>>1;
1123  nv.mute = true;
1124  volumes.append(nv);
1125  }
1126 }
#define it(className, varName)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< PresetVolume > volumes
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
Definition: qlist.h:181
QList< QWSSoundServerProvider * > active
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
static const int maxVolume
bool equal(int wid, int sid)

◆ setSilent

void QWSSoundServerPrivate::setSilent ( bool  enabled)
slot

Definition at line 895 of file qsoundqss_qws.cpp.

896 {
897  // Close output device
898  closeDevice();
899  if( !unwritten && !active.count() ) {
901  }
902  // Stop processing audio
903  killTimer( timerId );
904  silent = enabled;
905  // If audio remaining, open output device and continue processing
906  if( unwritten || active.count() ) {
907  openDevice();
908  }
909 }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
QList< QWSSoundServerProvider * > active
#define enabled
void killTimer(int id)
Kills the timer with timer identifier, id.
Definition: qobject.cpp:1650

◆ setVolume

void QWSSoundServerPrivate::setVolume ( int  wid,
int  sid,
int  lv,
int  rv 
)
slot

Definition at line 1067 of file qsoundqss_qws.cpp.

1068 {
1069  QWSSoundServerProvider *bucket;
1070  for( int i = 0; i < active.size(); ++i ) {
1071  bucket = active.at(i);
1072  if (bucket->equal(wid, sid)) {
1073  bucket->setVolume(lv,rv);
1074  return;
1075  }
1076  }
1077  // If gotten here, then it means wid/sid wasn't set up yet.
1078  // first find and remove current preset volumes, then add this one.
1080  while (it != volumes.end()) {
1081  PresetVolume v = *it;
1082  if (v.wid == wid && v.sid == sid)
1083  it = volumes.erase(it);
1084  else
1085  ++it;
1086  }
1087  // and then add this volume
1088  PresetVolume nv;
1089  nv.wid = wid;
1090  nv.sid = sid;
1091  nv.left = lv;
1092  nv.right = rv;
1093  nv.mute = false;
1094  volumes.append(nv);
1095 }
#define it(className, varName)
void setVolume(int lv, int rv)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< PresetVolume > volumes
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
Definition: qlist.h:181
QList< QWSSoundServerProvider * > active
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool equal(int wid, int sid)

◆ soundFileCompleted

void QWSSoundServerPrivate::soundFileCompleted ( int  ,
int   
)
signal

◆ stopAll

void QWSSoundServerPrivate::stopAll ( int  wid)
slot

Definition at line 1038 of file qsoundqss_qws.cpp.

1039 {
1040  QWSSoundServerProvider *bucket;
1041  if (!active.isEmpty()) {
1043  while (it != active.end()) {
1044  bucket = *it;
1045  if (bucket->groupId() == wid) {
1046  it = active.erase(it);
1047  delete bucket;
1048  } else {
1049  ++it;
1050  }
1051  }
1052  }
1053  if (!inactive.isEmpty()) {
1055  while (it != inactive.end()) {
1056  bucket = *it;
1057  if (bucket->groupId() == wid) {
1058  it = inactive.erase(it);
1059  delete bucket;
1060  } else {
1061  ++it;
1062  }
1063  }
1064  }
1065 }
#define it(className, varName)
iterator begin()
Returns an STL-style iterator pointing to the first item in the list.
Definition: qlist.h:267
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QList< QWSSoundServerProvider * > inactive
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the list...
Definition: qlist.h:270
The QList::iterator class provides an STL-style non-const iterator for QList and QQueue.
Definition: qlist.h:181
iterator erase(iterator pos)
Removes the item associated with the iterator pos from the list, and returns an iterator to the next ...
Definition: qlist.h:464
QList< QWSSoundServerProvider * > active

◆ stopFile

void QWSSoundServerPrivate::stopFile ( int  wid,
int  sid 
)
slot

Definition at line 1017 of file qsoundqss_qws.cpp.

1018 {
1019  QWSSoundServerProvider *bucket;
1020  for (int i = 0; i < active.size(); ++i ) {
1021  bucket = active.at(i);
1022  if (bucket->equal(wid, sid)) {
1023  active.removeAt(i);
1024  delete bucket;
1025  return;
1026  }
1027  }
1028  for (int i = 0; i < inactive.size(); ++i ) {
1029  bucket = inactive.at(i);
1030  if (bucket->equal(wid, sid)) {
1031  inactive.removeAt(i);
1032  delete bucket;
1033  return;
1034  }
1035  }
1036 }
QList< QWSSoundServerProvider * > inactive
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QList< QWSSoundServerProvider * > active
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
bool equal(int wid, int sid)
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

◆ timerEvent()

void QWSSoundServerPrivate::timerEvent ( QTimerEvent event)
protectedvirtual

This event handler can be reimplemented in a subclass to receive timer events for the object.

QTimer provides a higher-level interface to the timer functionality, and also more general information about timers. The timer event is passed in the event parameter.

See also
startTimer(), killTimer(), event()

Reimplemented from QObject.

Definition at line 911 of file qsoundqss_qws.cpp.

912 {
913  // qDebug("QSS timer event");
914  if( event->timerId() == timerId ) {
915  if (fd >= 0)
916  feedDevice(fd);
917  if (fd < 0) {
919  timerId = 0;
920  }
921  }
922 }
int timerId() const
Returns the unique timer identifier, which is the same identifier as returned from QObject::startTime...
Definition: qcoreevent.h:346
void killTimer(int id)
Kills the timer with timer identifier, id.
Definition: qobject.cpp:1650

Properties

◆ active

QList<QWSSoundServerProvider*> QWSSoundServerPrivate::active
private

Definition at line 864 of file qsoundqss_qws.cpp.

◆ can_GETOSPACE

bool QWSSoundServerPrivate::can_GETOSPACE
private

Definition at line 889 of file qsoundqss_qws.cpp.

◆ completed

QList<CompletedInfo> QWSSoundServerPrivate::completed
private

Definition at line 880 of file qsoundqss_qws.cpp.

◆ cursor

char* QWSSoundServerPrivate::cursor
private

Definition at line 887 of file qsoundqss_qws.cpp.

◆ data

short QWSSoundServerPrivate::data[sound_buffer_size *2]
private

Definition at line 888 of file qsoundqss_qws.cpp.

◆ fd

int QWSSoundServerPrivate::fd
private

Definition at line 884 of file qsoundqss_qws.cpp.

◆ inactive

QList<QWSSoundServerProvider*> QWSSoundServerPrivate::inactive
private

Definition at line 865 of file qsoundqss_qws.cpp.

◆ server

QWSSoundServerSocket* QWSSoundServerPrivate::server
private

Definition at line 891 of file qsoundqss_qws.cpp.

◆ silent

bool QWSSoundServerPrivate::silent
private

Definition at line 882 of file qsoundqss_qws.cpp.

◆ timerId

int QWSSoundServerPrivate::timerId
private

Definition at line 886 of file qsoundqss_qws.cpp.

◆ unwritten

int QWSSoundServerPrivate::unwritten
private

Definition at line 885 of file qsoundqss_qws.cpp.

◆ volumes

QList<PresetVolume> QWSSoundServerPrivate::volumes
private

Definition at line 873 of file qsoundqss_qws.cpp.


The documentation for this class was generated from the following file: