aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Output/alsa/outputalsa.cpp12
-rw-r--r--src/plugins/Output/alsa/outputalsa.h2
-rw-r--r--src/qmmp/output.h3
3 files changed, 16 insertions, 1 deletions
diff --git a/src/plugins/Output/alsa/outputalsa.cpp b/src/plugins/Output/alsa/outputalsa.cpp
index 63922ead1..5e9c02938 100644
--- a/src/plugins/Output/alsa/outputalsa.cpp
+++ b/src/plugins/Output/alsa/outputalsa.cpp
@@ -48,6 +48,7 @@ OutputALSA::OutputALSA(QObject * parent)
m_prebuf = 0;
m_prebuf_size = 0;
m_prebuf_fill = 0;
+ m_pause = FALSE;
}
OutputALSA::~OutputALSA()
@@ -225,6 +226,17 @@ qint64 OutputALSA::latency()
return m_prebuf_fill * 8000 / sampleRate() / numChannels() / sampleSize();
}
+void OutputALSA::pause()
+{
+ m_pause = !m_pause;
+ if (m_pause && pcm_handle)
+ {
+ snd_pcm_drop(pcm_handle);
+ snd_pcm_prepare(pcm_handle);
+ }
+ Output::pause();
+}
+
qint64 OutputALSA::writeAudio(unsigned char *data, qint64 maxSize)
{
//increase buffer size if needed
diff --git a/src/plugins/Output/alsa/outputalsa.h b/src/plugins/Output/alsa/outputalsa.h
index 3ddf4278c..9b8118dda 100644
--- a/src/plugins/Output/alsa/outputalsa.h
+++ b/src/plugins/Output/alsa/outputalsa.h
@@ -44,6 +44,7 @@ public:
bool initialize();
void configure(quint32, int, int);
qint64 latency();
+ void pause();
private:
//output api
@@ -66,6 +67,7 @@ private:
uchar *m_prebuf;
qint64 m_prebuf_size;
qint64 m_prebuf_fill;
+ bool m_pause;
};
class VolumeControlALSA : public VolumeControl
diff --git a/src/qmmp/output.h b/src/qmmp/output.h
index f217eadb1..6a81ece8f 100644
--- a/src/qmmp/output.h
+++ b/src/qmmp/output.h
@@ -60,8 +60,9 @@ public:
virtual void configure(quint32 freq, int chan, int bits);
/*!
* Requests playback to pause. If it was paused already, playback should resume.
+ * Subclasses that reimplement this function must call the base implementation.
*/
- void pause();
+ virtual void pause();
/*!
* Requests playback to stop.
*/