1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-12 09:04:33 +02:00

Changes to make Spotify resolver work

This commit is contained in:
Leo Franchi
2011-04-10 17:03:16 -04:00
parent 252a48196c
commit a9a9ffa40f
15 changed files with 233 additions and 119 deletions

View File

@@ -53,32 +53,31 @@ include( CheckTagLibFileName )
check_taglib_filename( COMPLEX_TAGLIB_FILENAME ) check_taglib_filename( COMPLEX_TAGLIB_FILENAME )
# optional # optional
IF( ENABLE_JREEN ) macro_optional_find_package(Jreen)
macro_optional_find_package(Jreen) IF( ENABLE_JREEN AND NOT LIBJREEN_FOUND )
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 )
ADD_SUBDIRECTORY( thirdparty/jreen ) ADD_SUBDIRECTORY( thirdparty/jreen )
SET( LIBJREEN_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/include ) SET( LIBJREEN_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/include )
IF( UNIX AND NOT APPLE ) IF( UNIX AND NOT APPLE )
SET( LIBJREEN_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/libjreen.so ) SET( LIBJREEN_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/thirdparty/jreen/libjreen.so )
ENDIF( UNIX AND NOT APPLE ) ENDIF( UNIX AND NOT APPLE )
IF( WIN32 ) 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 ) ENDIF( WIN32 )
SET( LIBJREEN_FOUND true ) SET( LIBJREEN_FOUND true )
MESSAGE(STATUS "Internal libjreen: ${LIBJREEN_INCLUDE_DIR}, ${LIBJREEN_LIBRARY}") MESSAGE(STATUS "Internal libjreen: ${LIBJREEN_INCLUDE_DIR}, ${LIBJREEN_LIBRARY}")
ENDIF( LIBJREEN_FOUND ) ENDIF( ENABLE_JREEN AND NOT 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 )
IF( WIN32 ) IF( WIN32 )
find_library(QTSPARKLE_LIBRARIES qtsparkle) find_library(QTSPARKLE_LIBRARIES qtsparkle)
ENDIF( WIN32 ) 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 #show dep log
macro_display_feature_log() macro_display_feature_log()
MESSAGE("WARNING!") MESSAGE("WARNING!")

View File

@@ -112,7 +112,7 @@ public:
virtual void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData ) = 0; virtual void getInfo( const QString &caller, const InfoType type, const QVariant &data, InfoCustomData customData ) = 0;
signals: 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 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 info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
void finished( QString, Tomahawk::InfoSystem::InfoType ); void finished( QString, Tomahawk::InfoSystem::InfoType );

View File

@@ -178,7 +178,7 @@ LastFmPlugin::fetchCoverArt( const QString &caller, const InfoType type, const Q
criteria["artist"] = hash["artist"].toString(); criteria["artist"] = hash["artist"].toString();
criteria["album"] = hash["album"].toString(); criteria["album"] = hash["album"].toString();
emit getCachedInfo( criteria, 2419200000, caller, type, data, customData ); emit getCachedInfo( criteria, caller, type, data, customData );
} }
void void

View File

@@ -53,10 +53,10 @@ InfoSystemCache::~InfoSystemCache()
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
qDebug() << "Saving infosystemcache to disk"; qDebug() << "Saving infosystemcache to disk";
QString cacheBaseDir = QDesktopServices::storageLocation( QDesktopServices::CacheLocation ); QString cacheBaseDir = QDesktopServices::storageLocation( QDesktopServices::CacheLocation );
for ( int i = 0; i <= InfoNoInfo; i++ ) for( int i = 0; i <= InfoNoInfo; i++ )
{ {
InfoType type = (InfoType)(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 ); QString cacheDir = cacheBaseDir + "/InfoSystemCache/" + QString::number( i );
saveCache( type, cacheDir ); saveCache( type, cacheDir );
@@ -66,57 +66,29 @@ InfoSystemCache::~InfoSystemCache()
void 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; 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 ); emit notInCache( criteria, caller, type, input, customData );
return; 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 ); emit info( caller, type, input, m_dataCache[type][criteria], customData );
} }
void 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; qDebug() << Q_FUNC_INFO;
QHash< InfoCacheCriteria, QVariant > typedatacache = m_dataCache[type]; QHash< InfoCacheCriteria, QVariant > typedatacache = m_dataCache[type];
QHash< InfoCacheCriteria, QDateTime > typeinserttimecache = m_insertTimeCache[type]; QHash< InfoCacheCriteria, QDateTime > typetimecache = m_timeCache[type];
QHash< InfoCacheCriteria, QDateTime > typemaxtimecache = m_maxTimeCache[type];
typedatacache[criteria] = output; typedatacache[criteria] = output;
typeinserttimecache[criteria] = QDateTime::currentDateTimeUtc(); typetimecache[criteria] = QDateTime::currentDateTimeUtc();
typemaxtimecache[criteria] = QDateTime::fromMSecsSinceEpoch( QDateTime::currentMSecsSinceEpoch() + maxAge );
m_dataCache[type] = typedatacache; m_dataCache[type] = typedatacache;
m_insertTimeCache[type] = typeinserttimecache; m_timeCache[type] = typetimecache;
m_maxTimeCache[type] = typemaxtimecache;
m_dirtySet.insert( type ); m_dirtySet.insert( type );
} }
@@ -127,31 +99,26 @@ InfoSystemCache::loadCache( InfoType type, const QString &cacheFile )
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
QSettings cachedSettings( cacheFile, QSettings::IniFormat ); 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, QVariant > dataHash = m_dataCache[type];
QHash< InfoCacheCriteria, QDateTime > insertDateHash = m_insertTimeCache[type]; QHash< InfoCacheCriteria, QDateTime > dateHash = m_timeCache[type];
QHash< InfoCacheCriteria, QDateTime > maxDateHash = m_maxTimeCache[type];
InfoCacheCriteria criteria; InfoCacheCriteria criteria;
cachedSettings.beginGroup( group );
int numCriteria = cachedSettings.beginReadArray( "criteria" ); int numCriteria = cachedSettings.beginReadArray( "criteria" );
for ( int i = 0; i < numCriteria; i++ ) for( int i = 0; i < numCriteria; i++ )
{ {
cachedSettings.setArrayIndex( i ); cachedSettings.setArrayIndex( i );
QStringList criteriaValues = cachedSettings.value( QString::number( i ) ).toStringList(); 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 ); criteria[criteriaValues.at( j )] = criteriaValues.at( j + 1 );
} }
cachedSettings.endArray(); cachedSettings.endArray();
dataHash[criteria] = cachedSettings.value( "data" ); dataHash[criteria] = cachedSettings.value( "data" );
insertDateHash[criteria] = cachedSettings.value( "inserttime" ).toDateTime(); dateHash[criteria] = cachedSettings.value( "time" ).toDateTime();
maxDateHash[criteria] = cachedSettings.value( "maxtime" ).toDateTime();
cachedSettings.endGroup(); cachedSettings.endGroup();
m_dataCache[type] = dataHash; m_dataCache[type] = dataHash;
m_insertTimeCache[type] = insertDateHash; m_timeCache[type] = dateHash;
m_maxTimeCache[type] = maxDateHash;
} }
} }
@@ -189,8 +156,7 @@ InfoSystemCache::saveCache( InfoType type, const QString &cacheDir )
} }
cachedSettings.endArray(); cachedSettings.endArray();
cachedSettings.setValue( "data", m_dataCache[type][criteria] ); cachedSettings.setValue( "data", m_dataCache[type][criteria] );
cachedSettings.setValue( "inserttime", m_insertTimeCache[type][criteria] ); cachedSettings.setValue( "time", m_timeCache[type][criteria] );
cachedSettings.setValue( "maxtime", m_maxTimeCache[type][criteria] );
cachedSettings.endGroup(); cachedSettings.endGroup();
++criteriaNumber; ++criteriaNumber;
} }

View File

@@ -45,16 +45,15 @@ signals:
void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData ); void info( QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, QVariant output, Tomahawk::InfoSystem::InfoCustomData customData );
public slots: public slots:
void getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, qint64 newMaxAge, QString caller, Tomahawk::InfoSystem::InfoType type, QVariant input, Tomahawk::InfoSystem::InfoCustomData customData ); void getCachedInfoSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, 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 updateCacheSlot( Tomahawk::InfoSystem::InfoCacheCriteria criteria, Tomahawk::InfoSystem::InfoType type, QVariant output );
private: private:
void loadCache( InfoType type, const QString &cacheFile ); void loadCache( InfoType type, const QString &cacheFile );
void saveCache( InfoType type, const QString &cacheDir ); void saveCache( InfoType type, const QString &cacheDir );
QHash< InfoType, QHash< InfoCacheCriteria, QVariant > > m_dataCache; QHash< InfoType, QHash< InfoCacheCriteria, QVariant > > m_dataCache;
QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_insertTimeCache; QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_timeCache;
QHash< InfoType, QHash< InfoCacheCriteria, QDateTime > > m_maxTimeCache;
QSet< InfoType > m_dirtySet; QSet< InfoType > m_dirtySet;
}; };

View File

@@ -29,6 +29,7 @@ set( libSources
sip/SipPlugin.cpp sip/SipPlugin.cpp
audio/madtranscode.cpp audio/madtranscode.cpp
audio/dummytranscode.cpp
audio/vorbistranscode.cpp audio/vorbistranscode.cpp
audio/flactranscode.cpp audio/flactranscode.cpp
audio/audioengine.cpp audio/audioengine.cpp
@@ -175,6 +176,7 @@ set( libHeaders
audio/transcodeinterface.h audio/transcodeinterface.h
audio/madtranscode.h audio/madtranscode.h
audio/dummytranscode.h
audio/vorbistranscode.h audio/vorbistranscode.h
audio/flactranscode.h audio/flactranscode.h
audio/audioengine.h audio/audioengine.h

View File

@@ -28,6 +28,7 @@
#include "network/servent.h" #include "network/servent.h"
#include "madtranscode.h" #include "madtranscode.h"
#include "dummytranscode.h"
#ifndef NO_OGG #ifndef NO_OGG
#include "vorbistranscode.h" #include "vorbistranscode.h"
#endif #endif
@@ -205,7 +206,9 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
else else
{ {
setCurrentTrack( result ); setCurrentTrack( result );
qDebug() << "Getting IODEVICE, on thread:" << QThread::currentThread() << QThread::currentThreadId();
io = Servent::instance()->getIODeviceForUrl( m_currentTrack ); io = Servent::instance()->getIODeviceForUrl( m_currentTrack );
qDebug() << "GOT IODEVICE:" << io.data();
if ( m_currentTrack->url().startsWith( "http://" ) ) if ( m_currentTrack->url().startsWith( "http://" ) )
{ {
m_readReady = false; m_readReady = false;
@@ -228,12 +231,15 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
qDebug() << "Starting new song from url:" << m_currentTrack->url(); qDebug() << "Starting new song from url:" << m_currentTrack->url();
emit loading( m_currentTrack ); emit loading( m_currentTrack );
qDebug() << "input is:" << m_input.isNull();
if ( !m_input.isNull() ) if ( !m_input.isNull() )
{ {
m_input->close(); m_input->close();
m_input.clear(); 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_lastTrack.isNull() || ( m_currentTrack->mimetype() != m_lastTrack->mimetype() ) )
{ {
if ( !m_transcode.isNull() ) if ( !m_transcode.isNull() )
@@ -241,7 +247,10 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
m_transcode.clear(); 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()); m_transcode = QSharedPointer<TranscodeInterface>(new MADTranscode());
} }
@@ -430,6 +439,8 @@ AudioEngine::onDownloadProgress( qint64 recv, qint64 total )
{ {
if ( ( recv > 1024 * 32 ) || recv > total ) if ( ( recv > 1024 * 32 ) || recv > total )
m_readReady = true; 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() AudioEngine::loop()
{ {
m_i++; 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 ); QMutexLocker lock( &m_mutex );
/* if ( m_i % 200 == 0 ) // if ( m_i % 200 == 0 )
{ // {
if ( !m_input.isNull() ) // if ( !m_input.isNull() )
qDebug() << "Outer audio loop" << m_input->bytesAvailable() << m_audio->needData(); // qDebug() << "Outer audio loop" << m_input->bytesAvailable() << m_audio->needData();
}*/ // }
if ( m_i % 10 == 0 && m_audio->isPlaying() ) if ( m_i % 10 == 0 && m_audio->isPlaying() )
m_audio->triggerTimers(); 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() && if( !m_transcode.isNull() &&
!m_input.isNull() && !m_input.isNull() &&
m_input->bytesAvailable() && m_input->bytesAvailable() &&
m_audio->needData() && m_audio->needData() &&
!m_audio->isPaused() ) !m_audio->isPaused() )
{ {
//if ( m_i % 50 == 0 ) // if ( m_i % 50 == 0 )
// qDebug() << "Inner audio loop"; // qDebug() << "Inner audio loop";
if ( m_transcode->needData() > 0 ) if ( m_transcode->needData() > 0 )
{ {
@@ -503,6 +516,7 @@ AudioEngine::loop()
!m_audio->haveData() && !m_audio->haveData() &&
!m_audio->isPaused() ) !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"; qDebug() << "Starting next track then";
loadNextTrack(); loadNextTrack();
// will need data immediately: // will need data immediately:

View 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;
}

View 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

View File

@@ -832,7 +832,6 @@ Servent::registerIODeviceFactory( const QString &proto, boost::function<QSharedP
} }
QSharedPointer<QIODevice> QSharedPointer<QIODevice>
Servent::getIODeviceForUrl( const Tomahawk::result_ptr& result ) 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 proto = rx.cap( 1 );
//const QString urlpart = rx.cap( 2 ); //const QString urlpart = rx.cap( 2 );
qDebug() << "Getting IODevice for URL:" << proto << m_iofactories.contains( proto );
if ( !m_iofactories.contains( proto ) ) if ( !m_iofactories.contains( proto ) )
return sp; return sp;
return m_iofactories.value( proto )( result ); return m_iofactories.value( proto )( result );
} }
@@ -870,5 +869,5 @@ Servent::httpIODeviceFactory( const Tomahawk::result_ptr& result )
qDebug() << Q_FUNC_INFO << result->url(); qDebug() << Q_FUNC_INFO << result->url();
QNetworkRequest req( result->url() ); QNetworkRequest req( result->url() );
QNetworkReply* reply = TomahawkUtils::nam()->get( req ); QNetworkReply* reply = TomahawkUtils::nam()->get( req );
return QSharedPointer<QIODevice>( reply ); return QSharedPointer<QIODevice>( reply, &QObject::deleteLater );
} }

View File

@@ -46,7 +46,7 @@ StreamConnection::StreamConnection( Servent* s, ControlConnection* cc, QString f
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
BufferIODevice* bio = new BufferIODevice( result->size() ); 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 ); m_iodev->open( QIODevice::ReadWrite );
Servent::instance()->registerStreamConnection( this ); Servent::instance()->registerStreamConnection( this );

View File

@@ -46,6 +46,8 @@ ScriptResolver::ScriptResolver( const QString& exe )
ScriptResolver::~ScriptResolver() ScriptResolver::~ScriptResolver()
{ {
stop();
Tomahawk::Pipeline::instance()->removeResolver( this ); Tomahawk::Pipeline::instance()->removeResolver( this );
} }
@@ -237,6 +239,7 @@ void
ScriptResolver::stop() ScriptResolver::stop()
{ {
m_stopped = true; m_stopped = true;
qDebug() << "KILLING PROCESS!";
m_proc.kill(); m_proc.kill();
} }

View File

@@ -223,7 +223,7 @@ TomahawkApp::init()
qDebug() << "Init Scrobbler."; qDebug() << "Init Scrobbler.";
m_scrobbler = new Scrobbler( this ); m_scrobbler = new Scrobbler( this );
qDebug() << "Setting NAM."; qDebug() << "Setting NAM.";
TomahawkUtils::setNam( new lastfm::NetworkAccessManager( this ) ); TomahawkUtils::setNam( lastfm::nam() );
#else #else
qDebug() << "Setting NAM."; qDebug() << "Setting NAM.";
@@ -290,6 +290,13 @@ TomahawkApp::~TomahawkApp()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
// stop script resolvers
foreach( Tomahawk::ExternalResolver* r, m_scriptResolvers )
{
delete r;
}
m_scriptResolvers.clear();
delete m_sipHandler; delete m_sipHandler;
delete m_servent; delete m_servent;
delete m_scanManager; delete m_scanManager;