245 m_tick(0), m_volume(100), m_prefinishMark(0), |
245 m_tick(0), m_volume(100), m_prefinishMark(0), |
246 m_tickIntervalResolution(0), m_bufferPrepared(0), |
246 m_tickIntervalResolution(0), m_bufferPrepared(0), |
247 m_stopped(0) |
247 m_stopped(0) |
248 { |
248 { |
249 m_thread = new WorkerThread(); |
249 m_thread = new WorkerThread(); |
250 connect(this, SIGNAL(outOfData(QIODevice*, QByteArray*, bool*)), m_thread, SLOT(stream(QIODevice*, QByteArray*, bool*))); |
250 connect(this, SIGNAL(outOfData(QIODevice*,QByteArray*,bool*)), m_thread, SLOT(stream(QIODevice*,QByteArray*,bool*))); |
251 m_thread->start(); |
251 m_thread->start(); |
252 m_soundBuffer1.waveHeader = new WAVEHDR; |
252 m_soundBuffer1.waveHeader = new WAVEHDR; |
253 m_soundBuffer2.waveHeader = new WAVEHDR; |
253 m_soundBuffer2.waveHeader = new WAVEHDR; |
254 setParent(parent); |
254 setParent(parent); |
255 setState(Phonon::LoadingState); |
255 setState(Phonon::LoadingState); |
256 } |
256 } |
257 |
257 |
258 MediaObject::~MediaObject() |
258 MediaObject::~MediaObject() |
259 { |
259 { |
260 stop(); |
260 stop(); |
261 disconnect(this, SIGNAL(outOfData(QIODevice*, QByteArray*, bool*)), m_thread, SLOT(stream(QIODevice*, QByteArray*, bool*))); |
261 disconnect(this, SIGNAL(outOfData(QIODevice*,QByteArray*,bool*)), m_thread, SLOT(stream(QIODevice*,QByteArray*,bool*))); |
262 do { //The event loop of m_thread might not be started, yet |
262 do { //The event loop of m_thread might not be started, yet |
263 m_thread->quit(); //If the event loop is not started yet quit() does nothing |
263 m_thread->quit(); //If the event loop is not started yet quit() does nothing |
264 m_thread->wait(100); |
264 m_thread->wait(100); |
265 } while (m_thread->isRunning()); |
265 } while (m_thread->isRunning()); |
266 delete m_thread; |
266 delete m_thread; |