1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-17 19:37:09 +02:00

* Keep current transcoder in memory if we keep using it for the next track.

This commit is contained in:
Christian Muehlhaeuser
2010-10-25 03:59:57 +02:00
parent fd0a27fc7c
commit 883be50062
3 changed files with 27 additions and 20 deletions

View File

@@ -147,6 +147,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
err = true; err = true;
else else
{ {
m_lastTrack = m_currentTrack;
m_currentTrack = result; m_currentTrack = result;
io = TomahawkApp::instance()->getIODeviceForUrl( m_currentTrack ); io = TomahawkApp::instance()->getIODeviceForUrl( m_currentTrack );
@@ -170,9 +171,10 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
m_input.clear(); m_input.clear();
} }
if ( m_lastTrack.isNull() || ( m_currentTrack->mimetype() != m_lastTrack->mimetype() ) )
{
if ( !m_transcode.isNull() ) if ( !m_transcode.isNull() )
{ {
m_transcode->clearBuffers();
m_transcode.clear(); m_transcode.clear();
} }
@@ -180,18 +182,22 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
{ {
m_transcode = QSharedPointer<TranscodeInterface>(new MADTranscode()); m_transcode = QSharedPointer<TranscodeInterface>(new MADTranscode());
} }
#ifndef NO_OGG #ifndef NO_OGG
else if ( m_currentTrack->mimetype() == "application/ogg" ) else if ( m_currentTrack->mimetype() == "application/ogg" )
{ {
m_transcode = QSharedPointer<TranscodeInterface>(new VorbisTranscode()); m_transcode = QSharedPointer<TranscodeInterface>(new VorbisTranscode());
} }
#endif #endif
else else
qDebug() << "Could NOT find suitable transcoder! Stopping audio."; qDebug() << "Could NOT find suitable transcoder! Stopping audio.";
if ( !m_transcode.isNull() ) if ( !m_transcode.isNull() )
{
connect( m_transcode.data(), SIGNAL( streamInitialized( long, int ) ), SLOT( setStreamData( long, int ) ), Qt::DirectConnection ); connect( m_transcode.data(), SIGNAL( streamInitialized( long, int ) ), SLOT( setStreamData( long, int ) ), Qt::DirectConnection );
}
if ( !m_transcode.isNull() )
{
m_transcode->clearBuffers();
m_input = io; m_input = io;
m_audio->clearBuffers(); m_audio->clearBuffers();

View File

@@ -84,6 +84,7 @@ private:
#endif #endif
Tomahawk::result_ptr m_currentTrack; Tomahawk::result_ptr m_currentTrack;
Tomahawk::result_ptr m_lastTrack;
PlaylistInterface* m_playlist; PlaylistInterface* m_playlist;
QMutex m_mutex; QMutex m_mutex;

View File

@@ -98,7 +98,7 @@ TrackModel::data( const QModelIndex& index, int role ) const
return QSize( 0, 18 ); return QSize( 0, 18 );
} }
if ( role != Qt::DisplayRole ) if ( role != Qt::DisplayRole ) // && role != Qt::ToolTipRole )
return QVariant(); return QVariant();
const query_ptr& query = entry->query(); const query_ptr& query = entry->query();