mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
Changes to make Spotify resolver work
This commit is contained in:
@@ -53,32 +53,31 @@ include( CheckTagLibFileName )
|
||||
check_taglib_filename( COMPLEX_TAGLIB_FILENAME )
|
||||
|
||||
# optional
|
||||
IF( ENABLE_JREEN )
|
||||
macro_optional_find_package(Jreen)
|
||||
IF( LIBJREEN_FOUND )
|
||||
macro_log_feature(JREEN_FOUND "Jreen" "Qt XMPP library" "http://gitorious.org/jreen" FALSE "" "Jreen is needed for the alternative/new Jabber SIP plugin. Built automatically inside Tomahawk, if not installed systemwide and ENABLE_JREEN is true")
|
||||
ELSE( LIBJREEN_FOUND )
|
||||
macro_optional_find_package(Jreen)
|
||||
IF( ENABLE_JREEN AND NOT LIBJREEN_FOUND )
|
||||
ADD_SUBDIRECTORY( thirdparty/jreen )
|
||||
SET( LIBJREEN_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/include )
|
||||
IF( UNIX AND NOT APPLE )
|
||||
SET( LIBJREEN_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/libjreen.so )
|
||||
ENDIF( UNIX AND NOT APPLE )
|
||||
IF( WIN32 )
|
||||
SET( LIBJREEN_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/libjreen.dll )
|
||||
SET( LIBJREEN_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/libjreen.dll )
|
||||
ENDIF( WIN32 )
|
||||
SET( LIBJREEN_FOUND true )
|
||||
MESSAGE(STATUS "Internal libjreen: ${LIBJREEN_INCLUDE_DIR}, ${LIBJREEN_LIBRARY}")
|
||||
ENDIF( LIBJREEN_FOUND )
|
||||
ELSE( LIBJREEN_FOUND )
|
||||
macro_optional_find_package(Gloox 1.0)
|
||||
macro_log_feature(GLOOX_FOUND "Gloox" "A portable high-level Jabber/XMPP library for C++" "http://camaya.net/gloox" FALSE "" "Gloox is needed for the Jabber SIP plugin and the XMPP-Bot")
|
||||
|
||||
ENDIF( ENABLE_JREEN )
|
||||
ENDIF( ENABLE_JREEN AND NOT LIBJREEN_FOUND )
|
||||
|
||||
IF( WIN32 )
|
||||
find_library(QTSPARKLE_LIBRARIES qtsparkle)
|
||||
ENDIF( WIN32 )
|
||||
|
||||
macro_log_feature(JREEN_FOUND "Jreen" "Qt XMPP library" "http://gitorious.org/jreen" FALSE "" "Jreen is needed for the alternative/new Jabber SIP plugin. Built automatically inside Tomahawk, if not installed systemwide and ENABLE_JREEN is true")
|
||||
|
||||
macro_optional_find_package(Gloox 1.0)
|
||||
IF( ENABLE_JREEN )
|
||||
set( GLOOX_FOUND false )
|
||||
ENDIF( ENABLE_JREEN)
|
||||
macro_log_feature(GLOOX_FOUND "Gloox" "A portable high-level Jabber/XMPP library for C++" "http://camaya.net/gloox" FALSE "" "Gloox is needed for the Jabber SIP plugin and the XMPP-Bot")
|
||||
#show dep log
|
||||
macro_display_feature_log()
|
||||
MESSAGE("WARNING!")
|
||||
|
@@ -112,7 +112,7 @@ public:
|
||||
virtual void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData ) = 0;
|
||||
|
||||
signals:
|
||||
void getCachedInfo( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
void getCachedInfo( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
void updateCache( Tomahawk::InfoSystem::InfoCacheCriteria criteria, Tomahawk::InfoSystem::InfoType type, QVariant output );
|
||||
void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
void finished( QString, Tomahawk::InfoSystem::InfoType );
|
||||
|
@@ -45,11 +45,11 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
|
||||
QFont font( ui->artistTrackLabel->font() );
|
||||
font.setPixelSize( 12 );
|
||||
|
||||
|
||||
#ifdef Q_WS_MAC
|
||||
font.setPointSize( font.pointSize() - 2 );
|
||||
#endif
|
||||
|
||||
|
||||
ui->artistTrackLabel->setFont( font );
|
||||
ui->artistTrackLabel->setElideMode( Qt::ElideMiddle );
|
||||
ui->artistTrackLabel->setType( QueryLabel::ArtistAndTrack );
|
||||
@@ -144,10 +144,10 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
connect( ui->volumeLowButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( lowerVolume() ) );
|
||||
connect( ui->volumeHighButton, SIGNAL( clicked() ), AudioEngine::instance(), SLOT( raiseVolume() ) );
|
||||
|
||||
|
||||
|
||||
connect( ui->playPauseButton, SIGNAL( clicked() ), this, SIGNAL( playPressed() ) );
|
||||
connect( ui->pauseButton, SIGNAL( clicked() ), this, SIGNAL( pausePressed() ) );
|
||||
|
||||
|
||||
connect( ui->repeatButton, SIGNAL( clicked() ), SLOT( onRepeatClicked() ) );
|
||||
connect( ui->shuffleButton, SIGNAL( clicked() ), SLOT( onShuffleClicked() ) );
|
||||
|
||||
@@ -170,7 +170,7 @@ AudioControls::AudioControls( QWidget* parent )
|
||||
connect( TomahawkApp::instance()->infoSystem(),
|
||||
SIGNAL( info( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ),
|
||||
SLOT( infoSystemInfo( QString, Tomahawk::InfoSystem::InfoType, QVariant, QVariant, Tomahawk::InfoSystem::InfoCustomData ) ) );
|
||||
|
||||
|
||||
connect( TomahawkApp::instance()->infoSystem(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) );
|
||||
|
||||
onPlaybackStopped(); // initial state
|
||||
@@ -251,9 +251,9 @@ AudioControls::onPlaybackStarted( const Tomahawk::result_ptr& result )
|
||||
|
||||
QString artistName = result->artist()->name();
|
||||
QString albumName = result->album()->name();
|
||||
|
||||
|
||||
Tomahawk::InfoSystem::InfoCustomData trackInfo;
|
||||
|
||||
|
||||
trackInfo["artist"] = QVariant::fromValue< QString >( result->artist()->name() );
|
||||
trackInfo["album"] = QVariant::fromValue< QString >( result->album()->name() );
|
||||
TomahawkApp::instance()->infoSystem()->getInfo(
|
||||
@@ -270,7 +270,7 @@ AudioControls::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType ty
|
||||
qDebug() << "info of wrong type or not with our identifier";
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( m_currentTrack.isNull() )
|
||||
{
|
||||
qDebug() << "Current track is null when trying to apply fetched cover art";
|
||||
@@ -281,7 +281,7 @@ AudioControls::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType ty
|
||||
{
|
||||
qDebug() << "Cannot convert fetched art from a QByteArray";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Tomahawk::InfoSystem::InfoCustomData returnedData = output.value< Tomahawk::InfoSystem::InfoCustomData >();
|
||||
const QByteArray ba = returnedData["imgbytes"].toByteArray();
|
||||
@@ -296,7 +296,7 @@ AudioControls::infoSystemInfo( QString caller, Tomahawk::InfoSystem::InfoType ty
|
||||
ui->coverImage->setPixmap( pm.scaled( ui->coverImage->size(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioControls::infoSystemFinished( QString target )
|
||||
{
|
||||
@@ -356,7 +356,7 @@ AudioControls::onPlaybackResumed()
|
||||
ui->pauseButton->setVisible( true );
|
||||
ui->pauseButton->setEnabled( true );
|
||||
ui->playPauseButton->setVisible( false );
|
||||
ui->playPauseButton->setEnabled( false );
|
||||
ui->playPauseButton->setEnabled( false );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -178,7 +178,7 @@ LastFmPlugin::fetchCoverArt( const QString &caller, const InfoType type, const Q
|
||||
criteria["artist"] = hash["artist"].toString();
|
||||
criteria["album"] = hash["album"].toString();
|
||||
|
||||
emit getCachedInfo( criteria, 2419200000, caller, type, data, customData );
|
||||
emit getCachedInfo( criteria, caller, type, data, customData );
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -53,10 +53,10 @@ InfoSystemCache::~InfoSystemCache()
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
qDebug() << "Saving infosystemcache to disk";
|
||||
QString cacheBaseDir = QDesktopServices::storageLocation( QDesktopServices::CacheLocation );
|
||||
for ( int i = 0; i <= InfoNoInfo; i++ )
|
||||
for( int i = 0; i <= InfoNoInfo; i++ )
|
||||
{
|
||||
InfoType type = (InfoType)(i);
|
||||
if ( m_dirtySet.contains( type ) && m_dataCache.contains( type ) )
|
||||
if( m_dirtySet.contains( type ) && m_dataCache.contains( type ) )
|
||||
{
|
||||
QString cacheDir = cacheBaseDir + "/InfoSystemCache/" + QString::number( i );
|
||||
saveCache( type, cacheDir );
|
||||
@@ -66,57 +66,29 @@ InfoSystemCache::~InfoSystemCache()
|
||||
|
||||
|
||||
void
|
||||
InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData )
|
||||
InfoSystemCache::getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
if ( !m_dataCache.contains( type ) || !m_dataCache[type].contains( criteria ) )
|
||||
if( !m_dataCache.contains( type ) || !m_dataCache[type].contains( criteria ) )
|
||||
{
|
||||
emit notInCache( criteria, caller, type, input, customData );
|
||||
return;
|
||||
}
|
||||
|
||||
QHash< InfoCacheCriteria, QDateTime > typemaxtimecache = m_maxTimeCache[type];
|
||||
|
||||
if ( typemaxtimecache[criteria].toMSecsSinceEpoch() < QDateTime::currentMSecsSinceEpoch() )
|
||||
{
|
||||
QHash< InfoCacheCriteria, QVariant > typedatacache = m_dataCache[type];
|
||||
QHash< InfoCacheCriteria, QDateTime > typeinserttimecache = m_insertTimeCache[type];
|
||||
typemaxtimecache.remove( criteria );
|
||||
m_maxTimeCache[type] = typemaxtimecache;
|
||||
typedatacache.remove( criteria );
|
||||
m_dataCache[type] = typedatacache;
|
||||
typeinserttimecache.remove( criteria );
|
||||
m_insertTimeCache[type] = typeinserttimecache;
|
||||
m_dirtySet.insert( type );
|
||||
emit notInCache( criteria, caller, type, input, customData );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( newMaxAge > 0 )
|
||||
{
|
||||
QHash< InfoCacheCriteria, QDateTime > typemaxtimecache = m_maxTimeCache[type];
|
||||
typemaxtimecache[criteria] = QDateTime::fromMSecsSinceEpoch( QDateTime::currentMSecsSinceEpoch() + newMaxAge );
|
||||
m_maxTimeCache[type] = typemaxtimecache;
|
||||
m_dirtySet.insert( type );
|
||||
}
|
||||
|
||||
emit info( caller, type, input, m_dataCache[type][criteria], customData );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output )
|
||||
InfoSystemCache::updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, Tomahawk::InfoSystem::InfoType type, QVariant output )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
QHash< InfoCacheCriteria, QVariant > typedatacache = m_dataCache[type];
|
||||
QHash< InfoCacheCriteria, QDateTime > typeinserttimecache = m_insertTimeCache[type];
|
||||
QHash< InfoCacheCriteria, QDateTime > typemaxtimecache = m_maxTimeCache[type];
|
||||
QHash< InfoCacheCriteria, QDateTime > typetimecache = m_timeCache[type];
|
||||
typedatacache[criteria] = output;
|
||||
typeinserttimecache[criteria] = QDateTime::currentDateTimeUtc();
|
||||
typemaxtimecache[criteria] = QDateTime::fromMSecsSinceEpoch( QDateTime::currentMSecsSinceEpoch() + maxAge );
|
||||
typetimecache[criteria] = QDateTime::currentDateTimeUtc();
|
||||
m_dataCache[type] = typedatacache;
|
||||
m_insertTimeCache[type] = typeinserttimecache;
|
||||
m_maxTimeCache[type] = typemaxtimecache;
|
||||
m_timeCache[type] = typetimecache;
|
||||
m_dirtySet.insert( type );
|
||||
}
|
||||
|
||||
@@ -127,31 +99,26 @@ InfoSystemCache::loadCache( InfoType type, const QString &cacheFile )
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
QSettings cachedSettings( cacheFile, QSettings::IniFormat );
|
||||
|
||||
foreach ( QString group, cachedSettings.childGroups() )
|
||||
foreach( QString group, cachedSettings.childGroups() )
|
||||
{
|
||||
cachedSettings.beginGroup( group );
|
||||
if ( cachedSettings.value( "maxtime" ).toDateTime().toMSecsSinceEpoch() < QDateTime::currentMSecsSinceEpoch() )
|
||||
continue;
|
||||
QHash< InfoCacheCriteria, QVariant > dataHash = m_dataCache[type];
|
||||
QHash< InfoCacheCriteria, QDateTime > insertDateHash = m_insertTimeCache[type];
|
||||
QHash< InfoCacheCriteria, QDateTime > maxDateHash = m_maxTimeCache[type];
|
||||
QHash< InfoCacheCriteria, QDateTime > dateHash = m_timeCache[type];
|
||||
InfoCacheCriteria criteria;
|
||||
cachedSettings.beginGroup( group );
|
||||
int numCriteria = cachedSettings.beginReadArray( "criteria" );
|
||||
for ( int i = 0; i < numCriteria; i++ )
|
||||
for( int i = 0; i < numCriteria; i++ )
|
||||
{
|
||||
cachedSettings.setArrayIndex( i );
|
||||
QStringList criteriaValues = cachedSettings.value( QString::number( i ) ).toStringList();
|
||||
for ( int j = 0; j < criteriaValues.length(); j += 2 )
|
||||
for( int j = 0; j < criteriaValues.length(); j += 2 )
|
||||
criteria[criteriaValues.at( j )] = criteriaValues.at( j + 1 );
|
||||
}
|
||||
cachedSettings.endArray();
|
||||
dataHash[criteria] = cachedSettings.value( "data" );
|
||||
insertDateHash[criteria] = cachedSettings.value( "inserttime" ).toDateTime();
|
||||
maxDateHash[criteria] = cachedSettings.value( "maxtime" ).toDateTime();
|
||||
dateHash[criteria] = cachedSettings.value( "time" ).toDateTime();
|
||||
cachedSettings.endGroup();
|
||||
m_dataCache[type] = dataHash;
|
||||
m_insertTimeCache[type] = insertDateHash;
|
||||
m_maxTimeCache[type] = maxDateHash;
|
||||
m_timeCache[type] = dateHash;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,8 +156,7 @@ InfoSystemCache::saveCache( InfoType type, const QString &cacheDir )
|
||||
}
|
||||
cachedSettings.endArray();
|
||||
cachedSettings.setValue( "data", m_dataCache[type][criteria] );
|
||||
cachedSettings.setValue( "inserttime", m_insertTimeCache[type][criteria] );
|
||||
cachedSettings.setValue( "maxtime", m_maxTimeCache[type][criteria] );
|
||||
cachedSettings.setValue( "time", m_timeCache[type][criteria] );
|
||||
cachedSettings.endGroup();
|
||||
++criteriaNumber;
|
||||
}
|
||||
|
@@ -45,16 +45,15 @@ signals:
|
||||
void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
|
||||
public slots:
|
||||
void getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
void updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 maxAge, Tomahawk::InfoSystem::InfoType type, QVariant output );
|
||||
void getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData );
|
||||
void updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, Tomahawk::InfoSystem::InfoType type, QVariant output );
|
||||
|
||||
private:
|
||||
void loadCache( InfoType type, const QString &cacheFile );
|
||||
void saveCache( InfoType type, const QString &cacheDir );
|
||||
|
||||
QHash< InfoType, QHash< InfoCacheCriteria, QVariant > > m_dataCache;
|
||||
QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_insertTimeCache;
|
||||
QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_maxTimeCache;
|
||||
QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_timeCache;
|
||||
QSet< InfoType > m_dirtySet;
|
||||
};
|
||||
|
||||
|
@@ -29,6 +29,7 @@ set( libSources
|
||||
sip/SipPlugin.cpp
|
||||
|
||||
audio/madtranscode.cpp
|
||||
audio/dummytranscode.cpp
|
||||
audio/vorbistranscode.cpp
|
||||
audio/flactranscode.cpp
|
||||
audio/audioengine.cpp
|
||||
@@ -96,8 +97,8 @@ set( libSources
|
||||
playlist/albumview.cpp
|
||||
|
||||
playlist/topbar/topbar.cpp
|
||||
playlist/topbar/clearbutton.cpp
|
||||
playlist/topbar/searchlineedit.cpp
|
||||
playlist/topbar/clearbutton.cpp
|
||||
playlist/topbar/searchlineedit.cpp
|
||||
playlist/topbar/lineedit.cpp
|
||||
playlist/topbar/searchbutton.cpp
|
||||
|
||||
@@ -175,6 +176,7 @@ set( libHeaders
|
||||
|
||||
audio/transcodeinterface.h
|
||||
audio/madtranscode.h
|
||||
audio/dummytranscode.h
|
||||
audio/vorbistranscode.h
|
||||
audio/flactranscode.h
|
||||
audio/audioengine.h
|
||||
@@ -251,7 +253,7 @@ set( libHeaders
|
||||
|
||||
playlist/topbar/topbar.h
|
||||
playlist/topbar/clearbutton.h
|
||||
playlist/topbar/searchlineedit.h
|
||||
playlist/topbar/searchlineedit.h
|
||||
playlist/topbar/lineedit.h
|
||||
playlist/topbar/lineedit_p.h
|
||||
playlist/topbar/searchbutton.h
|
||||
@@ -297,8 +299,8 @@ set( libHeaders
|
||||
kdsingleapplicationguard/kdlockedsharedmemorypointer.h
|
||||
)
|
||||
|
||||
set( libHeaders_NoMOC
|
||||
playlist/dynamic/GeneratorInterface.h
|
||||
set( libHeaders_NoMOC
|
||||
playlist/dynamic/GeneratorInterface.h
|
||||
)
|
||||
set( libUI ${libUI}
|
||||
widgets/newplaylistwidget.ui
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "network/servent.h"
|
||||
|
||||
#include "madtranscode.h"
|
||||
#include "dummytranscode.h"
|
||||
#ifndef NO_OGG
|
||||
#include "vorbistranscode.h"
|
||||
#endif
|
||||
@@ -205,7 +206,9 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||
else
|
||||
{
|
||||
setCurrentTrack( result );
|
||||
qDebug() << "Getting IODEVICE, on thread:" << QThread::currentThread() << QThread::currentThreadId();
|
||||
io = Servent::instance()->getIODeviceForUrl( m_currentTrack );
|
||||
qDebug() << "GOT IODEVICE:" << io.data();
|
||||
if ( m_currentTrack->url().startsWith( "http://" ) )
|
||||
{
|
||||
m_readReady = false;
|
||||
@@ -228,12 +231,15 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||
qDebug() << "Starting new song from url:" << m_currentTrack->url();
|
||||
emit loading( m_currentTrack );
|
||||
|
||||
qDebug() << "input is:" << m_input.isNull();
|
||||
if ( !m_input.isNull() )
|
||||
{
|
||||
m_input->close();
|
||||
m_input.clear();
|
||||
}
|
||||
|
||||
if( !m_lastTrack.isNull() ) qDebug() << "LAST TRACK:" << m_lastTrack->mimetype();
|
||||
qDebug() << "LOADING SONG:" << m_currentTrack->mimetype();
|
||||
if ( m_lastTrack.isNull() || ( m_currentTrack->mimetype() != m_lastTrack->mimetype() ) )
|
||||
{
|
||||
if ( !m_transcode.isNull() )
|
||||
@@ -241,7 +247,10 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||
m_transcode.clear();
|
||||
}
|
||||
|
||||
if ( m_currentTrack->mimetype() == "audio/mpeg" )
|
||||
if ( m_currentTrack->mimetype() == "audio/basic" )
|
||||
{
|
||||
m_transcode = QSharedPointer<TranscodeInterface>(new DummyTranscode());
|
||||
} else if ( m_currentTrack->mimetype() == "audio/mpeg" )
|
||||
{
|
||||
m_transcode = QSharedPointer<TranscodeInterface>(new MADTranscode());
|
||||
}
|
||||
@@ -428,8 +437,10 @@ AudioEngine::setCurrentTrack( const Tomahawk::result_ptr& result )
|
||||
void
|
||||
AudioEngine::onDownloadProgress( qint64 recv, qint64 total )
|
||||
{
|
||||
if ( ( recv > 1024 * 32 ) || recv > total )
|
||||
if ( ( recv > 1024 * 32 ) || recv > total )
|
||||
m_readReady = true;
|
||||
|
||||
// qDebug() << "Got onDownloadProgress from reading http stream, received enough?" << m_readReady << "(" << recv << "> 1024 * 32 and" << recv << "<" << total << ")";
|
||||
}
|
||||
|
||||
|
||||
@@ -454,28 +465,30 @@ void
|
||||
AudioEngine::loop()
|
||||
{
|
||||
m_i++;
|
||||
//if( m_i % 500 == 0 ) qDebug() << Q_FUNC_INFO << thread();
|
||||
// if( m_i % 500 == 0 ) qDebug() << Q_FUNC_INFO << thread();
|
||||
|
||||
{
|
||||
QMutexLocker lock( &m_mutex );
|
||||
|
||||
/* if ( m_i % 200 == 0 )
|
||||
{
|
||||
if ( !m_input.isNull() )
|
||||
qDebug() << "Outer audio loop" << m_input->bytesAvailable() << m_audio->needData();
|
||||
}*/
|
||||
// if ( m_i % 200 == 0 )
|
||||
// {
|
||||
// if ( !m_input.isNull() )
|
||||
// qDebug() << "Outer audio loop" << m_input->bytesAvailable() << m_audio->needData();
|
||||
// }
|
||||
|
||||
if ( m_i % 10 == 0 && m_audio->isPlaying() )
|
||||
m_audio->triggerTimers();
|
||||
|
||||
// qDebug() << !m_transcode.isNull() << !m_input.isNull() << m_audio->needData() << !m_audio->isPaused();
|
||||
// if( !m_input.isNull() ) qDebug() << "INPUT has bytes:" << m_input->bytesAvailable();
|
||||
if( !m_transcode.isNull() &&
|
||||
!m_input.isNull() &&
|
||||
m_input->bytesAvailable() &&
|
||||
m_audio->needData() &&
|
||||
!m_audio->isPaused() )
|
||||
{
|
||||
//if ( m_i % 50 == 0 )
|
||||
// qDebug() << "Inner audio loop";
|
||||
// if ( m_i % 50 == 0 )
|
||||
// qDebug() << "Inner audio loop";
|
||||
|
||||
if ( m_transcode->needData() > 0 )
|
||||
{
|
||||
@@ -498,11 +511,12 @@ AudioEngine::loop()
|
||||
// are we cleanly at the end of a track, and ready for the next one?
|
||||
if ( !m_input.isNull() &&
|
||||
m_input->atEnd() &&
|
||||
m_readReady &&
|
||||
m_readReady &&
|
||||
!m_input->bytesAvailable() &&
|
||||
!m_audio->haveData() &&
|
||||
!m_audio->isPaused() )
|
||||
{
|
||||
qDebug() << !m_input.isNull() << m_input->atEnd() << m_readReady << !m_input->bytesAvailable() << !m_audio->haveData() << !m_audio->isPaused();
|
||||
qDebug() << "Starting next track then";
|
||||
loadNextTrack();
|
||||
// will need data immediately:
|
||||
|
62
src/libtomahawk/audio/dummytranscode.cpp
Normal file
62
src/libtomahawk/audio/dummytranscode.cpp
Normal file
@@ -0,0 +1,62 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Tomahawk is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "dummytranscode.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
DummyTranscode::DummyTranscode()
|
||||
: m_init( false )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
|
||||
DummyTranscode::~DummyTranscode()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DummyTranscode::processData( const QByteArray &buffer, bool finish )
|
||||
{
|
||||
m_buffer.append( buffer );
|
||||
// qDebug() << "DUMMYTRANSCODING:" << buffer.size();
|
||||
|
||||
if( !m_init && m_buffer.size() >= 16364 ) {
|
||||
m_init = true;
|
||||
emit streamInitialized( 44100, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DummyTranscode::onSeek( int seconds )
|
||||
{
|
||||
m_buffer.clear();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DummyTranscode::clearBuffers()
|
||||
{
|
||||
m_buffer.clear();
|
||||
m_init = false;
|
||||
}
|
||||
|
63
src/libtomahawk/audio/dummytranscode.h
Normal file
63
src/libtomahawk/audio/dummytranscode.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 2011 Leo Franchi <leo@kdab.com>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef DUMMYTRANSCODE_H
|
||||
#define DUMMYTRANSCODE_H
|
||||
|
||||
#include "audio/transcodeinterface.h"
|
||||
#include "dllmacro.h"
|
||||
|
||||
#define _BUFFER_PREFERRED 32768
|
||||
|
||||
class DLLEXPORT DummyTranscode : public TranscodeInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DummyTranscode();
|
||||
virtual ~DummyTranscode();
|
||||
|
||||
const QStringList supportedTypes() const { QStringList l; l << "audio/basic"; return l; }
|
||||
|
||||
int needData() { return true; } // always eats data
|
||||
bool haveData() { return !m_buffer.isEmpty(); }
|
||||
|
||||
unsigned int preferredDataSize() { return _BUFFER_PREFERRED; }
|
||||
|
||||
QByteArray data() { QByteArray b = m_buffer; m_buffer.clear(); return b; }
|
||||
|
||||
virtual void setBufferCapacity( int bytes ) { m_bufferCapacity = bytes; }
|
||||
int bufferSize() { return m_buffer.size(); }
|
||||
|
||||
public slots:
|
||||
virtual void clearBuffers();
|
||||
virtual void onSeek( int seconds );
|
||||
virtual void processData( const QByteArray& data, bool finish );
|
||||
|
||||
signals:
|
||||
void streamInitialized( long sampleRate, int channels );
|
||||
void timeChanged( int seconds );
|
||||
|
||||
private:
|
||||
QByteArray m_buffer;
|
||||
int m_bufferCapacity;
|
||||
bool m_init;
|
||||
};
|
||||
|
||||
#endif // DUMMYTRANSCODE_H
|
@@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@@ -62,7 +62,7 @@ Servent::Servent( QObject* parent )
|
||||
, m_portfwd( 0 )
|
||||
{
|
||||
s_instance = this;
|
||||
|
||||
|
||||
new ACLSystem( this );
|
||||
|
||||
setProxy( QNetworkProxy::NoProxy );
|
||||
@@ -126,7 +126,7 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
|
||||
// --lanhack means to advertise your LAN IP over jabber as if it were externallyVisible
|
||||
qDebug() << "Address mode = " << (int)(TomahawkSettings::instance()->externalAddressMode());
|
||||
qDebug() << "Static host/port preferred ? = " << ( TomahawkSettings::instance()->preferStaticHostPort() ? "true" : "false" );
|
||||
|
||||
|
||||
if( TomahawkSettings::instance()->preferStaticHostPort() )
|
||||
{
|
||||
qDebug() << "Forcing static preferred host and port";
|
||||
@@ -136,7 +136,7 @@ Servent::startListening( QHostAddress ha, bool upnp, int port )
|
||||
emit ready();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
switch( TomahawkSettings::instance()->externalAddressMode() )
|
||||
{
|
||||
case TomahawkSettings::Lan:
|
||||
@@ -318,7 +318,7 @@ Servent::readyRead()
|
||||
pport = m.value( "port" ).toInt();
|
||||
nodeid = m.value( "nodeid" ).toString();
|
||||
controlid = m.value( "controlid" ).toString();
|
||||
|
||||
|
||||
qDebug() << "Incoming connection details: " << m;
|
||||
|
||||
if( !nodeid.isEmpty() ) // only control connections send nodeid
|
||||
@@ -367,7 +367,7 @@ Servent::readyRead()
|
||||
{
|
||||
qDebug() << "Invalid or unhandled conntype";
|
||||
}
|
||||
|
||||
|
||||
// fallthru to cleanup:
|
||||
closeconnection:
|
||||
qDebug() << "Closing incoming connection, something was wrong.";
|
||||
@@ -562,7 +562,7 @@ Connection*
|
||||
Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString &key, const QHostAddress peer )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
|
||||
bool noauth = qApp->arguments().contains( "--noauth" );
|
||||
|
||||
// magic key for stream connections:
|
||||
@@ -629,9 +629,9 @@ Servent::claimOffer( ControlConnection* cc, const QString &nodeid, const QString
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
qDebug() << "ACL has allowed the connection";
|
||||
|
||||
|
||||
if( conn->onceOnly() )
|
||||
{
|
||||
m_offers.remove( key );
|
||||
@@ -672,7 +672,7 @@ Servent::checkACL( const Connection* conn, const QString &nodeid, bool showDialo
|
||||
{
|
||||
if( !showDialog )
|
||||
return false;
|
||||
|
||||
|
||||
qDebug() << "ACL for this node not found";
|
||||
QMessageBox msgBox;
|
||||
msgBox.setIcon( QMessageBox::Question );
|
||||
@@ -682,7 +682,7 @@ Servent::checkACL( const Connection* conn, const QString &nodeid, bool showDialo
|
||||
QPushButton *alwaysDenyButton = msgBox.addButton( tr( "Always Deny" ), QMessageBox::YesRole );
|
||||
QPushButton *allowButton = msgBox.addButton( tr( "Allow" ), QMessageBox::NoRole );
|
||||
QPushButton *alwaysAllowButton = msgBox.addButton( tr( "Always Allow" ), QMessageBox::ActionRole );
|
||||
|
||||
|
||||
msgBox.setDefaultButton( denyButton );
|
||||
msgBox.setEscapeButton( denyButton );
|
||||
|
||||
@@ -701,7 +701,7 @@ Servent::checkACL( const Connection* conn, const QString &nodeid, bool showDialo
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
QSharedPointer<QIODevice>
|
||||
Servent::remoteIODeviceFactory( const result_ptr& result )
|
||||
@@ -832,7 +832,6 @@ Servent::registerIODeviceFactory( const QString &proto, boost::function<QSharedP
|
||||
}
|
||||
|
||||
|
||||
|
||||
QSharedPointer<QIODevice>
|
||||
Servent::getIODeviceForUrl( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
@@ -845,9 +844,9 @@ Servent::getIODeviceForUrl( const Tomahawk::result_ptr& result )
|
||||
|
||||
const QString proto = rx.cap( 1 );
|
||||
//const QString urlpart = rx.cap( 2 );
|
||||
qDebug() << "Getting IODevice for URL:" << proto << m_iofactories.contains( proto );
|
||||
if ( !m_iofactories.contains( proto ) )
|
||||
return sp;
|
||||
|
||||
return m_iofactories.value( proto )( result );
|
||||
}
|
||||
|
||||
@@ -870,5 +869,5 @@ Servent::httpIODeviceFactory( const Tomahawk::result_ptr& result )
|
||||
qDebug() << Q_FUNC_INFO << result->url();
|
||||
QNetworkRequest req( result->url() );
|
||||
QNetworkReply* reply = TomahawkUtils::nam()->get( req );
|
||||
return QSharedPointer<QIODevice>( reply );
|
||||
return QSharedPointer<QIODevice>( reply, &QObject::deleteLater );
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@@ -46,7 +46,7 @@ StreamConnection::StreamConnection( Servent* s, ControlConnection* cc, QString f
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
BufferIODevice* bio = new BufferIODevice( result->size() );
|
||||
m_iodev = QSharedPointer<QIODevice>( bio ); // device audio data gets written to
|
||||
m_iodev = QSharedPointer<QIODevice>( bio, &QObject::deleteLater ); // device audio data gets written to
|
||||
m_iodev->open( QIODevice::ReadWrite );
|
||||
|
||||
Servent::instance()->registerStreamConnection( this );
|
||||
@@ -108,7 +108,7 @@ StreamConnection::id() const
|
||||
}
|
||||
|
||||
|
||||
Tomahawk::source_ptr
|
||||
Tomahawk::source_ptr
|
||||
StreamConnection::source() const
|
||||
{
|
||||
return m_source;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
@@ -46,6 +46,8 @@ ScriptResolver::ScriptResolver( const QString& exe )
|
||||
|
||||
ScriptResolver::~ScriptResolver()
|
||||
{
|
||||
stop();
|
||||
|
||||
Tomahawk::Pipeline::instance()->removeResolver( this );
|
||||
}
|
||||
|
||||
@@ -175,7 +177,7 @@ ScriptResolver::cmdExited( int code, QProcess::ExitStatus status )
|
||||
qDebug() << Q_FUNC_INFO << "SCRIPT EXITED, code" << code << "status" << status << filePath();
|
||||
Tomahawk::Pipeline::instance()->removeResolver( this );
|
||||
|
||||
if( m_stopped )
|
||||
if( m_stopped )
|
||||
{
|
||||
qDebug() << "*** Script resolver stopped ";
|
||||
emit finished();
|
||||
@@ -233,10 +235,11 @@ ScriptResolver::doSetup( const QVariantMap& m )
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
ScriptResolver::stop()
|
||||
{
|
||||
m_stopped = true;
|
||||
qDebug() << "KILLING PROCESS!";
|
||||
m_proc.kill();
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
|
||||
*
|
||||
*
|
||||
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
|
||||
*
|
||||
* Tomahawk is free software: you can redistribute it and/or modify
|
||||
|
@@ -223,7 +223,7 @@ TomahawkApp::init()
|
||||
qDebug() << "Init Scrobbler.";
|
||||
m_scrobbler = new Scrobbler( this );
|
||||
qDebug() << "Setting NAM.";
|
||||
TomahawkUtils::setNam( new lastfm::NetworkAccessManager( this ) );
|
||||
TomahawkUtils::setNam( lastfm::nam() );
|
||||
|
||||
#else
|
||||
qDebug() << "Setting NAM.";
|
||||
@@ -290,6 +290,13 @@ TomahawkApp::~TomahawkApp()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
// stop script resolvers
|
||||
foreach( Tomahawk::ExternalResolver* r, m_scriptResolvers )
|
||||
{
|
||||
delete r;
|
||||
}
|
||||
m_scriptResolvers.clear();
|
||||
|
||||
delete m_sipHandler;
|
||||
delete m_servent;
|
||||
delete m_scanManager;
|
||||
|
Reference in New Issue
Block a user