Qt 4.8
Public Slots | Public Functions | Private Functions | Properties | List of all members
QAuServerNAS Class Reference
Inheritance diagram for QAuServerNAS:
QAuServer QObject

Public Slots

void dataReceived ()
 
void soundDestroyed (QObject *o)
 
- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 

Public Functions

void init (QSound *)
 Initializes the sound. More...
 
bool okay ()
 
void play (const QString &filename)
 
void play (QSound *)
 
 QAuServerNAS (QObject *parent)
 
void setDone (QSound *)
 
void stop (QSound *)
 
 ~QAuServerNAS ()
 
- Public Functions inherited from QAuServer
 QAuServer (QObject *parent)
 
 ~QAuServer ()
 
- 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...
 

Private Functions

QAuBucketNASbucket (QSound *s)
 

Properties

QSocketNotifiersn
 

Additional Inherited Members

- 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...
 
- 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 Functions inherited from QAuServer
QAuBucketbucket (QSound *)
 Returns the internal bucket record of sound s. More...
 
int decLoop (QSound *)
 Decrements the QSound::loopRemaining() value for sound s, returning the result. More...
 
void setBucket (QSound *, QAuBucket *)
 Sets the internal bucket record of sound s to b, deleting any previous setting. 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
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 92 of file qsound_x11.cpp.

Constructors and Destructors

◆ QAuServerNAS()

QAuServerNAS::QAuServerNAS ( QObject parent)

Definition at line 119 of file qsound_x11.cpp.

119  :
120  QAuServer(parent)
121 {
122  setObjectName(QLatin1String("Network Audio System"));
123  nas = AuOpenServer(NULL, 0, NULL, 0, NULL, NULL);
124  if (nas) {
125  AuSetCloseDownMode(nas, AuCloseDownDestroy, NULL);
126  // Ask Qt for async messages...
127  sn=new QSocketNotifier(AuServerConnectionNumber(nas),
129  QObject::connect(sn, SIGNAL(activated(int)),
130  this, SLOT(dataReceived()));
131  } else {
132  sn = 0;
133  }
134 }
#define SLOT(a)
Definition: qobjectdefs.h:226
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
void setObjectName(const QString &name)
Definition: qobject.cpp:1112
#define SIGNAL(a)
Definition: qobjectdefs.h:227
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
QAuServer(QObject *parent)
Definition: qsound.cpp:54
QSocketNotifier * sn
Definition: qsound_x11.cpp:95
static AuServer * nas
Definition: qsound_x11.cpp:60
void dataReceived()
Definition: qsound_x11.cpp:253

◆ ~QAuServerNAS()

QAuServerNAS::~QAuServerNAS ( )

Definition at line 136 of file qsound_x11.cpp.

137 {
138  if (nas)
139  AuCloseServer(nas);
140  delete sn;
141  nas = 0;
142 }
QSocketNotifier * sn
Definition: qsound_x11.cpp:95
static AuServer * nas
Definition: qsound_x11.cpp:60

Functions

◆ bucket()

QAuBucketNAS* QAuServerNAS::bucket ( QSound s)
inlineprivate

Definition at line 113 of file qsound_x11.cpp.

Referenced by play(), setDone(), and stop().

114  {
115  return (QAuBucketNAS*)QAuServer::bucket(s);
116  }
QAuBucket * bucket(QSound *)
Returns the internal bucket record of sound s.
Definition: qsound.cpp:365

◆ dataReceived

void QAuServerNAS::dataReceived ( )
slot

Definition at line 253 of file qsound_x11.cpp.

Referenced by play(), QAuServerNAS(), and stop().

254 {
255  AuHandleEvents(nas);
256 }
static AuServer * nas
Definition: qsound_x11.cpp:60

◆ init()

void QAuServerNAS::init ( QSound )
virtual

Initializes the sound.

The default implementation does nothing.

Reimplemented from QAuServer.

Definition at line 235 of file qsound_x11.cpp.

236 {
238  this, SLOT(soundDestroyed(QObject*)));
239 
240  if (nas) {
241  AuBucketID b_id =
242  AuSoundCreateBucketFromFile(nas, s->fileName().toLocal8Bit().constData(),
243  0 /*AuAccessAllMasks*/, NULL, NULL);
244  setBucket(s, new QAuBucketNAS(b_id));
245  }
246 }
#define SLOT(a)
Definition: qobjectdefs.h:226
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define SIGNAL(a)
Definition: qobjectdefs.h:227
void destroyed(QObject *=0)
This signal is emitted immediately before the object obj is destroyed, and can not be blocked...
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 setBucket(QSound *, QAuBucket *)
Sets the internal bucket record of sound s to b, deleting any previous setting.
Definition: qsound.cpp:356
static AuServer * nas
Definition: qsound_x11.cpp:60
void soundDestroyed(QObject *o)
Definition: qsound_x11.cpp:147

◆ okay()

bool QAuServerNAS::okay ( )
virtual

Implements QAuServer.

Definition at line 248 of file qsound_x11.cpp.

249 {
250  return !!nas;
251 }
static AuServer * nas
Definition: qsound_x11.cpp:60

◆ play() [1/2]

void QAuServerNAS::play ( const QString filename)
virtual

Reimplemented from QAuServer.

Definition at line 156 of file qsound_x11.cpp.

Referenced by setDone().

157 {
158  if (nas) {
159  int iv=100;
160  AuFixedPoint volume=AuFixedPointFromFraction(iv,100);
161  AuSoundPlayFromFile(nas, filename.toLocal8Bit().constData(), AuNone, volume,
162  NULL, NULL, NULL, NULL, NULL, NULL);
163  AuFlush(nas);
164  dataReceived();
165  AuFlush(nas);
166  qApp->flush();
167  }
168 }
#define qApp
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
Definition: qstring.cpp:4049
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
static AuServer * nas
Definition: qsound_x11.cpp:60
void dataReceived()
Definition: qsound_x11.cpp:253

◆ play() [2/2]

void QAuServerNAS::play ( QSound s)
virtual

Implements QAuServer.

Definition at line 199 of file qsound_x11.cpp.

200 {
201  if (nas) {
202  ++(bucket(s)->numplaying);
203  if (!bucket(s)->stopped) {
204  stop(s);
205  }
206 
207  bucket(s)->stopped = false;
208  if (!inprogress)
209  inprogress = new AuServerHash;
210  inprogress->insert(s,this);
211  int iv=100;
212  AuFixedPoint volume=AuFixedPointFromFraction(iv,100);
213  QAuBucketNAS *b = bucket(s);
214  AuSoundPlayFromBucket(nas, b->id, AuNone, volume,
215  callback, s, 0, &b->flow, NULL, NULL, NULL);
216  AuFlush(nas);
217  dataReceived();
218  AuFlush(nas);
219  qApp->flush();
220  }
221 }
static void callback(AuServer *, AuEventHandlerRec *, AuEvent *e, AuPointer p)
Definition: qsound_x11.cpp:170
void stop(QSound *)
Definition: qsound_x11.cpp:223
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
QAuBucketNAS * bucket(QSound *s)
Definition: qsound_x11.cpp:113
#define qApp
static AuServerHash * inprogress
Definition: qsound_x11.cpp:145
QHash< void *, QAuServerNAS * > AuServerHash
Definition: qsound_x11.cpp:144
static AuServer * nas
Definition: qsound_x11.cpp:60
AuBucketID id
Definition: qsound_x11.cpp:86
void dataReceived()
Definition: qsound_x11.cpp:253
AuFlowID flow
Definition: qsound_x11.cpp:87

◆ setDone()

void QAuServerNAS::setDone ( QSound s)

Definition at line 184 of file qsound_x11.cpp.

185 {
186  if (nas) {
187  decLoop(s);
188  if (s->loopsRemaining() && !bucket(s)->stopped) {
189  bucket(s)->stopped = true;
190  play(s);
191  } else {
192  if (--(bucket(s)->numplaying) == 0)
193  bucket(s)->stopped = true;
194  inprogress->remove(s);
195  }
196  }
197 }
int remove(const Key &key)
Removes all the items that have the key from the hash.
Definition: qhash.h:784
void play(const QString &filename)
Definition: qsound_x11.cpp:156
int decLoop(QSound *)
Decrements the QSound::loopRemaining() value for sound s, returning the result.
Definition: qsound.cpp:374
int loopsRemaining() const
Returns the remaining number of times the sound will loop (this value decreases each time the sound i...
Definition: qsound.cpp:281
QAuBucketNAS * bucket(QSound *s)
Definition: qsound_x11.cpp:113
static AuServerHash * inprogress
Definition: qsound_x11.cpp:145
static AuServer * nas
Definition: qsound_x11.cpp:60

◆ soundDestroyed

void QAuServerNAS::soundDestroyed ( QObject o)
slot

Definition at line 147 of file qsound_x11.cpp.

Referenced by init().

148 {
149  if (inprogress) {
150  QSound *so = static_cast<QSound *>(o);
151  while (inprogress->remove(so))
152  ; // Loop while remove returns true
153  }
154 }
int remove(const Key &key)
Removes all the items that have the key from the hash.
Definition: qhash.h:784
static AuServerHash * inprogress
Definition: qsound_x11.cpp:145
The QSound class provides access to the platform audio facilities.
Definition: qsound.h:57

◆ stop()

void QAuServerNAS::stop ( QSound s)
virtual

Implements QAuServer.

Definition at line 223 of file qsound_x11.cpp.

Referenced by play().

224 {
225  if (nas && !bucket(s)->stopped) {
226  bucket(s)->stopped = true;
227  AuStopFlow(nas, bucket(s)->flow, NULL);
228  AuFlush(nas);
229  dataReceived();
230  AuFlush(nas);
231  qApp->flush();
232  }
233 }
QAuBucketNAS * bucket(QSound *s)
Definition: qsound_x11.cpp:113
#define qApp
static AuServer * nas
Definition: qsound_x11.cpp:60
void dataReceived()
Definition: qsound_x11.cpp:253

Properties

◆ sn

QSocketNotifier* QAuServerNAS::sn
private

Definition at line 95 of file qsound_x11.cpp.

Referenced by QAuServerNAS(), and ~QAuServerNAS().


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