diff --git a/src/libtomahawk/audio/AudioOutput.cpp b/src/libtomahawk/audio/AudioOutput.cpp index 57da92714..e2232d7cc 100644 --- a/src/libtomahawk/audio/AudioOutput.cpp +++ b/src/libtomahawk/audio/AudioOutput.cpp @@ -173,6 +173,13 @@ AudioOutput::setCurrentSource( QIODevice* stream ) } +int readCallback ( void* data, const char* cookie, int64_t* dts, int64_t* pts, unsigned* flags, size_t* bufferSize, void** buffer ) +{ + MediaStream* mediaStream = static_cast< MediaStream * >( data ); + return mediaStream->readCallback( cookie, dts, pts, flags, bufferSize, buffer ); +} + + void AudioOutput::setCurrentSource( MediaStream* stream ) { @@ -248,7 +255,7 @@ AudioOutput::setCurrentSource( MediaStream* stream ) libvlc_media_add_option_flag(m_vlcMedia, "imem-cat=4", libvlc_media_option_trusted); const char* imemData = QString( "imem-data=%1" ).arg( (uintptr_t)stream ).toLatin1().constData(); libvlc_media_add_option_flag(m_vlcMedia, imemData, libvlc_media_option_trusted); - const char* imemGet = QString( "imem-get=%1" ).arg( (uintptr_t)&MediaStream::readCallback ).toLatin1().constData(); + const char* imemGet = QString( "imem-get=%1" ).arg( (uintptr_t)&readCallback ).toLatin1().constData(); libvlc_media_add_option_flag(m_vlcMedia, imemGet, libvlc_media_option_trusted); const char* imemRelease = QString( "imem-release=%1" ).arg( (uintptr_t)&MediaStream::readDoneCallback ).toLatin1().constData(); libvlc_media_add_option_flag(m_vlcMedia, imemRelease, libvlc_media_option_trusted); diff --git a/src/libtomahawk/audio/MediaStream.cpp b/src/libtomahawk/audio/MediaStream.cpp index d563a3a24..f5dd36e06 100644 --- a/src/libtomahawk/audio/MediaStream.cpp +++ b/src/libtomahawk/audio/MediaStream.cpp @@ -98,38 +98,43 @@ MediaStream::bufferingFinished() int -MediaStream::readCallback ( void* data, const char* cookie, int64_t* dts, int64_t* pts, unsigned* flags, size_t* bufferSize, void** buffer ) +MediaStream::readCallback ( const char* cookie, int64_t* dts, int64_t* pts, unsigned* flags, size_t* bufferSize, void** buffer ) { Q_UNUSED(cookie); Q_UNUSED(dts); Q_UNUSED(pts); Q_UNUSED(flags); - MediaStream* that = static_cast < MediaStream * > ( data ); qint64 bufsize = 0; *bufferSize = 0; - if ( that->m_eos == true ) { + if ( m_eos == true ) + { return -1; } - if ( that->m_type == Stream ) { - bufsize = that->needData(buffer); + if ( m_type == Stream ) + { + bufsize = needData( buffer ); } - else if ( that->m_type == IODevice ) { - bufsize = that->m_ioDevice->read( that->m_buffer, BLOCK_SIZE ); - *buffer = that->m_buffer; + else if ( m_type == IODevice ) + { + bufsize = m_ioDevice->read( m_buffer, BLOCK_SIZE ); + *buffer = m_buffer; } - if ( bufsize > 0 ) { - that->m_started = true; + if ( bufsize > 0 ) + { + m_started = true; } - if ( that->m_type == IODevice && bufsize == 0 && that->m_started && that->m_bufferingFinished == true ) { - that->m_eos = true; + if ( m_type == IODevice && bufsize == 0 && m_started && m_bufferingFinished == true ) + { + m_eos = true; return -1; } - if ( bufsize < 0 ) { - that->m_eos = true; + if ( bufsize < 0 ) + { + m_eos = true; return -1; } diff --git a/src/libtomahawk/audio/MediaStream.h b/src/libtomahawk/audio/MediaStream.h index 4d2b472f5..7192c14ef 100644 --- a/src/libtomahawk/audio/MediaStream.h +++ b/src/libtomahawk/audio/MediaStream.h @@ -54,7 +54,7 @@ public: virtual void seekStream( qint64 offset ) { (void)offset; } virtual qint64 needData ( void** buffer ) { (void)buffer; return 0; } - static int readCallback ( void* data, const char* cookie, int64_t* dts, int64_t* pts, unsigned* flags, size_t* bufferSize, void** buffer ); + int readCallback( const char* cookie, int64_t* dts, int64_t* pts, unsigned* flags, size_t* bufferSize, void** buffer ); static int readDoneCallback ( void *data, const char *cookie, size_t bufferSize, void *buffer ); static int seekCallback ( void *data, const uint64_t pos );