diff --git a/src/libtomahawk/audio/Qnr_IoDeviceStream.cpp b/src/libtomahawk/audio/Qnr_IoDeviceStream.cpp index b4b4d0b5a..b78888eb0 100644 --- a/src/libtomahawk/audio/Qnr_IoDeviceStream.cpp +++ b/src/libtomahawk/audio/Qnr_IoDeviceStream.cpp @@ -74,15 +74,13 @@ QNR_IODeviceStream::QNR_IODeviceStream( const QSharedPointer& rep QNR_IODeviceStream::~QNR_IODeviceStream() { - tDebug() << Q_FUNC_INFO; } void QNR_IODeviceStream::seekStream( qint64 offset ) { - tDebug() << Q_FUNC_INFO; - + QMutexLocker locker( &m_mutex ); m_pos = offset; } @@ -90,6 +88,7 @@ QNR_IODeviceStream::seekStream( qint64 offset ) qint64 QNR_IODeviceStream::needData ( void** buffer ) { + QMutexLocker locker( &m_mutex ); QByteArray data = m_data.mid( m_pos, BLOCK_SIZE ); m_pos += data.size(); if ( ( data.size() == 0 ) && m_networkReply->atEnd() && m_networkReply->isFinished() ) @@ -101,13 +100,13 @@ QNR_IODeviceStream::needData ( void** buffer ) *buffer = new char[data.size()]; memcpy(*buffer, data.data(), data.size()); -// tDebug() << Q_FUNC_INFO << " Returning buffer with size " << data.size(); return data.size(); } void QNR_IODeviceStream::readyRead() { + QMutexLocker locker( &m_mutex ); m_data += m_networkReply->readAll(); } diff --git a/src/libtomahawk/audio/Qnr_IoDeviceStream.h b/src/libtomahawk/audio/Qnr_IoDeviceStream.h index 6a679c5f1..b295b8596 100644 --- a/src/libtomahawk/audio/Qnr_IoDeviceStream.h +++ b/src/libtomahawk/audio/Qnr_IoDeviceStream.h @@ -26,6 +26,7 @@ #include "DllMacro.h" #include +#include #include #include @@ -52,6 +53,7 @@ private slots: void readyRead(); private: + QMutex m_mutex; QByteArray m_data; QSharedPointer m_networkReply; QTimer* m_timer;