diff options
| -rw-r--r-- | src/plugins/Transports/http/downloader.cpp | 2 | ||||
| -rw-r--r-- | src/plugins/Transports/http/downloader.h | 3 | ||||
| -rw-r--r-- | src/plugins/Transports/http/streamreader.cpp | 4 | ||||
| -rw-r--r-- | src/plugins/Transports/http/streamreader.h | 1 | ||||
| -rw-r--r-- | src/qmmp/soundcore.cpp | 9 | ||||
| -rw-r--r-- | src/qmmp/statehandler.cpp | 9 | ||||
| -rw-r--r-- | src/qmmp/statehandler.h | 12 | ||||
| -rw-r--r-- | src/ui/mainwindow.cpp | 2 |
8 files changed, 28 insertions, 14 deletions
diff --git a/src/plugins/Transports/http/downloader.cpp b/src/plugins/Transports/http/downloader.cpp index 06653fde9..e47eeb4b9 100644 --- a/src/plugins/Transports/http/downloader.cpp +++ b/src/plugins/Transports/http/downloader.cpp @@ -303,7 +303,7 @@ void Downloader::checkBuffer() } else if (!m_ready) { - emit bufferingProgress(100 * m_stream.buf_fill / BUFFER_SIZE); + StateHandler::instance()->dispatchBuffer(100 * m_stream.buf_fill / BUFFER_SIZE); qApp->processEvents(); } diff --git a/src/plugins/Transports/http/downloader.h b/src/plugins/Transports/http/downloader.h index 0ac96786d..34f046b66 100644 --- a/src/plugins/Transports/http/downloader.h +++ b/src/plugins/Transports/http/downloader.h @@ -27,7 +27,7 @@ #include <curl/curl.h> -#define BUFFER_SIZE 128000 +#define BUFFER_SIZE 128000 /*! @internal * @author Ilya Kotov <forkotov02@hotmail.ru> @@ -65,7 +65,6 @@ public: signals: void readyRead(); - void bufferingProgress(int); private: qint64 readBuffer(char* data, qint64 maxlen); diff --git a/src/plugins/Transports/http/streamreader.cpp b/src/plugins/Transports/http/streamreader.cpp index 5d61c76d1..f6a9cba0c 100644 --- a/src/plugins/Transports/http/streamreader.cpp +++ b/src/plugins/Transports/http/streamreader.cpp @@ -19,7 +19,6 @@ ***************************************************************************/ #include <QApplication> #include <QUrl> - #include "downloader.h" #include "streamreader.h" @@ -28,13 +27,12 @@ StreamReader::StreamReader(const QString &name, QObject *parent) { m_downloader = new Downloader(this, name); connect(m_downloader, SIGNAL(readyRead()), SIGNAL(readyRead())); - connect(m_downloader, SIGNAL(bufferingProgress(int)), SIGNAL(bufferingProgress(int))); } StreamReader::~StreamReader() { m_downloader->abort(); - qDebug("StreamReader::~StreamReader()"); + qDebug("%s", Q_FUNC_INFO); } bool StreamReader::atEnd () const diff --git a/src/plugins/Transports/http/streamreader.h b/src/plugins/Transports/http/streamreader.h index e73f65389..4a8fcb169 100644 --- a/src/plugins/Transports/http/streamreader.h +++ b/src/plugins/Transports/http/streamreader.h @@ -64,7 +64,6 @@ public: signals: void readyRead(); - void bufferingProgress(int); protected: qint64 readData(char*, qint64); diff --git a/src/qmmp/soundcore.cpp b/src/qmmp/soundcore.cpp index 671a83348..b0b988d7e 100644 --- a/src/qmmp/soundcore.cpp +++ b/src/qmmp/soundcore.cpp @@ -62,6 +62,7 @@ SoundCore::SoundCore(QObject *parent) connect(m_handler, SIGNAL(stateChanged (Qmmp::State)), SIGNAL(stateChanged(Qmmp::State))); connect(m_handler, SIGNAL(stateChanged (Qmmp::State)), SLOT(startPendingEngine())); connect(m_handler, SIGNAL(aboutToFinish()), SIGNAL(aboutToFinish())); + connect(m_handler, SIGNAL(bufferingProgress(int)), SIGNAL(bufferingProgress(int))); m_volumeControl = VolumeControl::create(this); connect(m_volumeControl, SIGNAL(volumeChanged(int, int)), SIGNAL(volumeChanged(int, int))); } @@ -84,6 +85,8 @@ bool SoundCore::play(const QString &source, bool queue) InputSource *s = InputSource::create(source, this); m_pendingSources.append(s); + if(state() == Qmmp::Stopped) + m_handler->dispatch(Qmmp::Buffering); connect(s, SIGNAL(ready(InputSource *)), SLOT(enqueue(InputSource *))); bool ok = s->initialize(); if(!ok) @@ -109,8 +112,8 @@ void SoundCore::stop() delete m_volumeControl; m_volumeControl = VolumeControl::create(this); connect(m_volumeControl, SIGNAL(volumeChanged(int, int)), SIGNAL(volumeChanged(int, int))); - if(state() == Qmmp::NormalError || state() == Qmmp::FatalError) //clear error state - StateHandler::instance()->dispatch(Qmmp::Stopped); + if(state() == Qmmp::NormalError || state() == Qmmp::FatalError || state() == Qmmp::Buffering) + StateHandler::instance()->dispatch(Qmmp::Stopped); //clear error and buffering state } void SoundCore::pause() @@ -243,7 +246,7 @@ bool SoundCore::enqueue(InputSource *s) if(m_engine->enqueue(s)) { m_source = s->url(); - if(state() == Qmmp::Stopped) + if(state() == Qmmp::Stopped || state() == Qmmp::Buffering) m_engine->play(); } else diff --git a/src/qmmp/statehandler.cpp b/src/qmmp/statehandler.cpp index d5fcc20f6..dcfea90e1 100644 --- a/src/qmmp/statehandler.cpp +++ b/src/qmmp/statehandler.cpp @@ -26,7 +26,6 @@ #define TICK_INTERVAL 250 #define PREFINISH_TIME 2000 - StateHandler* StateHandler::m_instance = 0; StateHandler::StateHandler(QObject *parent) @@ -120,7 +119,7 @@ void StateHandler::dispatch(const QMap<Qmmp::MetaData, QString> &metaData) m_mutex.unlock(); } -void StateHandler::dispatch(const Qmmp::State &state) +void StateHandler::dispatch(Qmmp::State state) { m_mutex.lock(); //clear @@ -154,6 +153,12 @@ void StateHandler::dispatch(const Qmmp::State &state) m_mutex.unlock(); } +void StateHandler::dispatchBuffer(int percent) +{ + if(m_state == Qmmp::Buffering) + emit bufferingProgress(percent); +} + qint64 StateHandler::elapsed() { return m_elapsed; diff --git a/src/qmmp/statehandler.h b/src/qmmp/statehandler.h index b83ca635b..3bcb089f4 100644 --- a/src/qmmp/statehandler.h +++ b/src/qmmp/statehandler.h @@ -62,7 +62,12 @@ public: /*! * Sends playback state. */ - virtual void dispatch(const Qmmp::State &state); + virtual void dispatch(Qmmp::State state); + /*! + * Sends buffering progress. + * @param \b percent Indicates the current percentage of buffering completed. + */ + virtual void dispatchBuffer(int percent); /*! * Returns the current time (in milliseconds). */ @@ -142,6 +147,11 @@ signals: * */ void aboutToFinish(); + /*! + * This signal is emitted when the stream reader fills it's buffer. + * The argument \b progress indicates the current percentage of buffering completed. + */ + void bufferingProgress(int progress); private: qint64 m_elapsed; diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 1080bec23..c31a5d9d1 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -586,7 +586,7 @@ void MainWindow::handleCloseRequest() void MainWindow::addUrl() { - AddUrlDialog::popup(this, m_pl_manager->currentPlayList()); + AddUrlDialog::popup(this, m_pl_manager->selectedPlayList()); } SoundCore * MainWindow::soundCore() const |
