diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-03-26 17:16:46 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2009-03-26 17:16:46 +0000 |
| commit | 3c32ca73d3524e7037b8704bff230c96a0a47670 (patch) | |
| tree | 5e25fb3354b2a74f79ea0a37ee67c7dc07e7c82c /src | |
| parent | 547f2a48338c4a43adce196c0eea57ccbdd98523 (diff) | |
| download | qmmp-3c32ca73d3524e7037b8704bff230c96a0a47670.tar.gz qmmp-3c32ca73d3524e7037b8704bff230c96a0a47670.tar.bz2 qmmp-3c32ca73d3524e7037b8704bff230c96a0a47670.zip | |
fixed alsa buffer underrun
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@879 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
| -rw-r--r-- | src/plugins/Output/alsa/outputalsa.cpp | 12 | ||||
| -rw-r--r-- | src/plugins/Output/alsa/outputalsa.h | 2 | ||||
| -rw-r--r-- | src/qmmp/output.h | 3 |
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. */ |
