aboutsummaryrefslogtreecommitdiff
path: root/src/qmmpui
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmmpui')
-rw-r--r--src/qmmpui/mediaplayer.cpp14
-rw-r--r--src/qmmpui/mediaplayer.h1
2 files changed, 14 insertions, 1 deletions
diff --git a/src/qmmpui/mediaplayer.cpp b/src/qmmpui/mediaplayer.cpp
index 168204a67..f15517d09 100644
--- a/src/qmmpui/mediaplayer.cpp
+++ b/src/qmmpui/mediaplayer.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2008 by Ilya Kotov *
+ * Copyright (C) 2008-2009 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -29,6 +29,8 @@
#include "mediaplayer.h"
+#define MAX_SKIPS 5
+
MediaPlayer *MediaPlayer::m_instance = 0;
MediaPlayer::MediaPlayer(QObject *parent)
@@ -37,6 +39,7 @@ MediaPlayer::MediaPlayer(QObject *parent)
m_instance = this;
m_model = 0;
m_core = 0;
+ m_skips = 0;
m_repeat = FALSE;
QTranslator *translator = new QTranslator(parent);
QString locale = QLocale::system().name();
@@ -101,6 +104,13 @@ void MediaPlayer::play()
case Qmmp::NormalError:
{
//error in decoder, so we should try to play next song
+ m_skips++;
+ if (m_skips > MAX_SKIPS)
+ {
+ stop();
+ qWarning("MediaPlayer: skip limit exceeded");
+ break;
+ }
qApp->processEvents();
if (!m_model->isEmptyQueue())
{
@@ -117,6 +127,8 @@ void MediaPlayer::play()
}
}
}
+ else
+ m_skips = 0;
}
void MediaPlayer::stop()
diff --git a/src/qmmpui/mediaplayer.h b/src/qmmpui/mediaplayer.h
index 920ef6908..cb52ffa37 100644
--- a/src/qmmpui/mediaplayer.h
+++ b/src/qmmpui/mediaplayer.h
@@ -57,6 +57,7 @@ private:
SoundCore *m_core;
static MediaPlayer* m_instance;
bool m_repeat;
+ int m_skips;
};