aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2017-01-16 10:22:47 +0000
committertrialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38>2017-01-16 10:22:47 +0000
commit49e42f5876622a312560a2d5a18fa18cd844cf51 (patch)
treefd5408b4aae6941ad21e0d4b39934809904fb9c0 /src
parent726fd5077f211d047b6bfb906276f5de2b3dcf0b (diff)
downloadqmmp-49e42f5876622a312560a2d5a18fa18cd844cf51.tar.gz
qmmp-49e42f5876622a312560a2d5a18fa18cd844cf51.tar.bz2
qmmp-49e42f5876622a312560a2d5a18fa18cd844cf51.zip
alsa: fixed returned delay value
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@6983 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src')
-rw-r--r--src/plugins/Output/alsa/outputalsa.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/plugins/Output/alsa/outputalsa.cpp b/src/plugins/Output/alsa/outputalsa.cpp
index f8135f3f0..afb31a8a2 100644
--- a/src/plugins/Output/alsa/outputalsa.cpp
+++ b/src/plugins/Output/alsa/outputalsa.cpp
@@ -1,5 +1,5 @@
/***************************************************************************
- * Copyright (C) 2006-2014 by Ilya Kotov *
+ * Copyright (C) 2006-2017 by Ilya Kotov *
* forkotov02@hotmail.ru *
* *
* This program is free software; you can redistribute it and/or modify *
@@ -243,7 +243,10 @@ bool OutputALSA::initialize(quint32 freq, ChannelMap map, Qmmp::AudioFormat form
qint64 OutputALSA::latency()
{
- return m_prebuf_fill * 1000 / sampleRate() / channels() / sampleSize();
+ snd_pcm_sframes_t delay = 0;
+ snd_pcm_delay(pcm_handle, &delay);
+ delay = qBound(3000L, delay, 30000L); //filter out possible invalid values
+ return m_prebuf_fill * 1000 / sampleRate() / channels() / sampleSize() + delay * 1000 / sampleRate();
}
void OutputALSA::drain()