summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2011-11-29 23:22:05 +0100
committerYoann Lopes <yoann.lopes@nokia.com>2011-11-29 23:22:05 +0100
commit1de5be2ec9c1022d8449186b60d863e0ad7501fa (patch)
tree7cd49a7e8371cbf6569e9806045ddd2089c4db42
parent6ea9c1fc57cc0dd5bc9534f1a1036144b8fedfe5 (diff)
Fix a crash when seeking before playback has actually started.
-rw-r--r--libQtSpotify/qspotifysession.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/libQtSpotify/qspotifysession.cpp b/libQtSpotify/qspotifysession.cpp
index eab98bd..a6b73be 100644
--- a/libQtSpotify/qspotifysession.cpp
+++ b/libQtSpotify/qspotifysession.cpp
@@ -252,21 +252,23 @@ bool QSpotifyAudioThreadWorker::event(QEvent *e)
return true;
} else if (e->type() == QEvent::User + 9) {
// Reset buffers
- QMutexLocker lock(&g_mutex);
- killTimer(m_audioTimerID);
- m_audioOutput->suspend();
- m_audioOutput->stop();
- g_buffer.close();
- g_buffer.setData(QByteArray());
- g_buffer.open(QIODevice::ReadWrite);
- g_readPos = 0;
- g_writePos = 0;
- m_audioOutput->reset();
- m_iodevice = m_audioOutput->start();
- m_audioOutput->suspend();
- m_audioTimerID = startTimer(AUDIOSTREAM_UPDATE_INTERVAL);
- m_timeCounter = 0;
- m_previousElapsedTime = 0;
+ if (m_audioOutput) {
+ QMutexLocker lock(&g_mutex);
+ killTimer(m_audioTimerID);
+ m_audioOutput->suspend();
+ m_audioOutput->stop();
+ g_buffer.close();
+ g_buffer.setData(QByteArray());
+ g_buffer.open(QIODevice::ReadWrite);
+ g_readPos = 0;
+ g_writePos = 0;
+ m_audioOutput->reset();
+ m_iodevice = m_audioOutput->start();
+ m_audioOutput->suspend();
+ m_audioTimerID = startTimer(AUDIOSTREAM_UPDATE_INTERVAL);
+ m_timeCounter = 0;
+ m_previousElapsedTime = 0;
+ }
e->accept();
return true;
} else if (e->type() == QEvent::Timer) {