From 49e42f5876622a312560a2d5a18fa18cd844cf51 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Mon, 16 Jan 2017 10:22:47 +0000 Subject: 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 --- src/plugins/Output/alsa/outputalsa.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') 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() -- cgit v1.2.3-13-gbd6f