aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2011-03-02 19:13:55 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2011-03-02 19:13:55 +0000
commitffef9491700965c061f4bdb7dd61c125d2eb2bf9 (patch)
treee1f08a8187996e57943c692a33d7af6b540e37a6 /src
parent402f1a35b2cbe029381fd94a2b538beb4323e3f6 (diff)
downloadqmmp-ffef9491700965c061f4bdb7dd61c125d2eb2bf9.tar.gz
qmmp-ffef9491700965c061f4bdb7dd61c125d2eb2bf9.tar.bz2
qmmp-ffef9491700965c061f4bdb7dd61c125d2eb2bf9.zip
added possibility to skip invalid tracks (Fixes issue 400) (Fixes issue
413) git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2079 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Transports/http/httpinputsource.cpp1
-rw-r--r--src/plugins/Transports/http/httpstreamreader.cpp11
-rw-r--r--src/plugins/Transports/mms/mmsinputsource.cpp1
-rw-r--r--src/plugins/Transports/mms/mmsstreamreader.cpp9
-rw-r--r--src/qmmp/soundcore.cpp23
-rw-r--r--src/qmmp/soundcore.h6
-rw-r--r--src/qmmp/statehandler.cpp3
-rw-r--r--src/qmmpui/mediaplayer.cpp31
-rw-r--r--src/qmmpui/mediaplayer.h1
9 files changed, 70 insertions, 16 deletions
diff --git a/src/plugins/Transports/http/httpinputsource.cpp b/src/plugins/Transports/http/httpinputsource.cpp
index c64a3c445..8e806cb66 100644
--- a/src/plugins/Transports/http/httpinputsource.cpp
+++ b/src/plugins/Transports/http/httpinputsource.cpp
@@ -25,6 +25,7 @@ HTTPInputSource::HTTPInputSource(const QString &url, QObject *parent) : InputSou
{
m_reader = new HttpStreamReader(url, this);
connect(m_reader, SIGNAL(ready()),SIGNAL(ready()));
+ connect(m_reader, SIGNAL(error()),SIGNAL(error()));
}
QIODevice *HTTPInputSource::ioDevice()
diff --git a/src/plugins/Transports/http/httpstreamreader.cpp b/src/plugins/Transports/http/httpstreamreader.cpp
index 83617c8a3..3df0c432c 100644
--- a/src/plugins/Transports/http/httpstreamreader.cpp
+++ b/src/plugins/Transports/http/httpstreamreader.cpp
@@ -271,6 +271,7 @@ qint64 HttpStreamReader::bytesAvailable() const
void HttpStreamReader::run()
{
qDebug("HttpStreamReader: starting download thread");
+ char errorBuffer[CURL_ERROR_SIZE];
m_handle = curl_easy_init();
//proxy
if (QmmpSettings::instance()->isProxyEnabled())
@@ -316,6 +317,8 @@ void HttpStreamReader::run()
QString user_agent = QString("qmmp/%1").arg(Qmmp::strVersion());
curl_easy_setopt(m_handle, CURLOPT_USERAGENT, qPrintable(user_agent));
curl_easy_setopt(m_handle, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
+ // error message
+ curl_easy_setopt(m_handle, CURLOPT_ERRORBUFFER, errorBuffer);
struct curl_slist *http200_aliases = curl_slist_append(NULL, "ICY");
struct curl_slist *http_headers = curl_slist_append(NULL, "Icy-MetaData: 1");
@@ -331,8 +334,12 @@ void HttpStreamReader::run()
qDebug("HttpStreamReader: starting libcurl");
m_mutex.unlock();
return_code = curl_easy_perform(m_handle);
- qDebug("curl_easy_perform %d", return_code);
- qDebug("HttpStreamReader: thread finished");
+ qDebug("HttpStreamReader: curl thread finished with code %d (%s)", return_code, errorBuffer);
+ if(!m_stream.aborted && !m_ready)
+ {
+ setErrorString(errorBuffer);
+ emit error();
+ }
}
qint64 HttpStreamReader::readBuffer(char* data, qint64 maxlen)
diff --git a/src/plugins/Transports/mms/mmsinputsource.cpp b/src/plugins/Transports/mms/mmsinputsource.cpp
index d6b303800..436b3c033 100644
--- a/src/plugins/Transports/mms/mmsinputsource.cpp
+++ b/src/plugins/Transports/mms/mmsinputsource.cpp
@@ -25,6 +25,7 @@ MMSInputSource::MMSInputSource(const QString &url, QObject *parent) : InputSourc
{
m_reader = new MMSStreamReader(url, this);
connect(m_reader, SIGNAL(ready()),SIGNAL(ready()));
+ connect(m_reader, SIGNAL(error()),SIGNAL(error()));
}
QIODevice *MMSInputSource::ioDevice()
diff --git a/src/plugins/Transports/mms/mmsstreamreader.cpp b/src/plugins/Transports/mms/mmsstreamreader.cpp
index 712432546..4d4ce34af 100644
--- a/src/plugins/Transports/mms/mmsstreamreader.cpp
+++ b/src/plugins/Transports/mms/mmsstreamreader.cpp
@@ -139,6 +139,8 @@ void MMSStreamReader::run()
if(!m_handle)
{
qWarning("MMSStreamReader: connection failed");
+ setErrorString("connection failed");
+ emit error();
return;
}
m_mutex.lock();
@@ -162,8 +164,13 @@ void MMSStreamReader::run()
len = mmsx_read (0, m_handle, m_buffer + m_buffer_at, to_read);
if(len < 0)
{
- qWarning("MMSStreamReader: error: %s", strerror(len));
m_mutex.unlock();
+ qWarning("MMSStreamReader: mms thread funished with code %lld (%s)", len, strerror(len));
+ if(!m_aborted && !m_ready)
+ {
+ setErrorString(strerror(len));
+ emit error();
+ }
break;
}
m_buffer_at += len;
diff --git a/src/qmmp/soundcore.cpp b/src/qmmp/soundcore.cpp
index 4caf7de3f..ad33a6e7c 100644
--- a/src/qmmp/soundcore.cpp
+++ b/src/qmmp/soundcore.cpp
@@ -41,10 +41,7 @@ SoundCore::SoundCore(QObject *parent)
{
m_instance = this;
m_decoder = 0;
- m_paused = false;
- m_update = false;
- m_block = false;
- m_vis = 0;
+ m_error = false;
m_parentWidget = 0;
m_engine = 0;
m_pendingEngine = 0;
@@ -94,6 +91,7 @@ bool SoundCore::play(const QString &source, bool queue, qint64 offset)
if(state() == Qmmp::Stopped)
m_handler->dispatch(Qmmp::Buffering);
connect(s, SIGNAL(ready()), SLOT(enqueue()));
+ connect(s, SIGNAL(error()), SLOT(enqueue()));
bool ok = s->initialize();
if(!ok)
{
@@ -241,11 +239,16 @@ bool SoundCore::enqueue()
qWarning("SoundCore: input error: %s", qPrintable(s->ioDevice()->errorString()));
m_url.clear();
s->deleteLater();
+ if(state() == Qmmp::Stopped || state() == Qmmp::Buffering)
+ {
+ m_handler->dispatch(Qmmp::NormalError);
+ }
+ else
+ m_error = true;
return false;
}
}
-
if(!m_engine)
{
if((m_engine = AbstractEngine::create(s, this)))
@@ -259,6 +262,7 @@ bool SoundCore::enqueue()
{
s->deleteLater();
m_handler->setCurrentEngine(0);
+ m_handler->dispatch(Qmmp::NormalError);
return false;
}
}
@@ -278,6 +282,10 @@ bool SoundCore::enqueue()
{
s->deleteLater();
m_handler->setCurrentEngine(0);
+ if(state() == Qmmp::Stopped || state() == Qmmp::Buffering)
+ m_handler->dispatch(Qmmp::NormalError);
+ else
+ m_error = true;
return false;
}
connect(engine, SIGNAL(playbackFinished()), SIGNAL(finished()));
@@ -311,6 +319,11 @@ void SoundCore::startPendingEngine()
m_engine->play();
m_handler->setCurrentEngine(m_engine);
}
+ else if(state() == Qmmp::Stopped && m_error)
+ {
+ m_error = false;
+ m_handler->dispatch(Qmmp::NormalError);
+ }
}
SoundCore* SoundCore::instance()
diff --git a/src/qmmp/soundcore.h b/src/qmmp/soundcore.h
index 68d32df9a..affa728f6 100644
--- a/src/qmmp/soundcore.h
+++ b/src/qmmp/soundcore.h
@@ -204,11 +204,7 @@ private slots:
private:
Decoder* m_decoder;
QString m_url;
- uint m_error;
- bool m_paused;
- bool m_update;
- bool m_block;
- Visual *m_vis;
+ bool m_error;
QList <Visual*> m_visuals;
QWidget *m_parentWidget;
static SoundCore* m_instance;
diff --git a/src/qmmp/statehandler.cpp b/src/qmmp/statehandler.cpp
index 520346bde..2ba0b9e9e 100644
--- a/src/qmmp/statehandler.cpp
+++ b/src/qmmp/statehandler.cpp
@@ -29,7 +29,7 @@
StateHandler* StateHandler::m_instance = 0;
StateHandler::StateHandler(QObject *parent)
- : QObject(parent)
+ : QObject(parent), m_mutex(QMutex::Recursive)
{
if (!m_instance)
m_instance = this;
@@ -42,6 +42,7 @@ StateHandler::StateHandler(QObject *parent)
m_state = Qmmp::Stopped;
m_next_engine = 0;
m_current_engine = 0;
+ //m_mutex = QMutex(QMutex::Recursive);
}
diff --git a/src/qmmpui/mediaplayer.cpp b/src/qmmpui/mediaplayer.cpp
index 721a71ae8..ea45c2b78 100644
--- a/src/qmmpui/mediaplayer.cpp
+++ b/src/qmmpui/mediaplayer.cpp
@@ -62,6 +62,7 @@ void MediaPlayer::initialize(SoundCore *core, PlayListManager *pl_manager)
m_noPlaylistAdvance = false;
connect(m_core, SIGNAL(nextTrackRequest()), SLOT(updateNextUrl()));
connect(m_core, SIGNAL(finished()), SLOT(playNext()));
+ connect(m_core, SIGNAL(stateChanged(Qmmp::State)), SLOT(processState(Qmmp::State)));
}
PlayListManager *MediaPlayer::playListManager()
@@ -103,7 +104,7 @@ void MediaPlayer::play(qint64 offset)
return;
}
- if (!m_core->play(s, false, offset))
+ /*if (!m_core->play(s, false, offset))
{
//find out the reason why playback failed
switch ((int) m_core->state())
@@ -139,7 +140,10 @@ void MediaPlayer::play(qint64 offset)
}
}
else
- m_skips = 0;
+ m_skips = 0;*/
+
+ m_core->play(s, false, offset);
+ m_skips = 0;
}
void MediaPlayer::stop()
@@ -245,3 +249,26 @@ void MediaPlayer::updateNextUrl()
qDebug("MediaPlayer: next track state: unknown");
}
+
+void MediaPlayer::processState(Qmmp::State state)
+{
+ switch ((int) state)
+ {
+ case Qmmp::NormalError:
+ stop();
+ //playNext();
+ if (m_skips < MAX_SKIPS)
+ {
+ //stop();
+ //qWarning("MediaPlayer: skip limit exceeded");
+ playNext();
+ m_skips++;
+ }
+ break;
+ case Qmmp::FatalError:
+ stop();
+ break;
+ default:
+ m_skips = 0;
+ }
+}
diff --git a/src/qmmpui/mediaplayer.h b/src/qmmpui/mediaplayer.h
index 06c80ec30..446eb627b 100644
--- a/src/qmmpui/mediaplayer.h
+++ b/src/qmmpui/mediaplayer.h
@@ -109,6 +109,7 @@ signals:
private slots:
void playNext();
void updateNextUrl();
+ void processState(Qmmp::State state);
private:
PlayListManager *m_pl_manager;