[FFmpeg-cvslog] pulse: get latency only when needed

Federico Simoncelli git at videolan.org
Sun Jan 5 18:54:28 CET 2014


ffmpeg | branch: master | Federico Simoncelli <federico.simoncelli at gmail.com> | Sun Jan  5 13:04:46 2014 +0100| [b53d6ce3fdefb48b4844efc1572b8ae9da0c4ecc] | committer: Michael Niedermayer

pulse: get latency only when needed

Signed-off-by: Federico Simoncelli <fsimonce at redhat.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b53d6ce3fdefb48b4844efc1572b8ae9da0c4ecc
---

 libavdevice/pulse_audio_dec.c |   15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/libavdevice/pulse_audio_dec.c b/libavdevice/pulse_audio_dec.c
index 38f2ad0..3b5cebb 100644
--- a/libavdevice/pulse_audio_dec.c
+++ b/libavdevice/pulse_audio_dec.c
@@ -109,7 +109,6 @@ static int pulse_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     PulseData *pd  = s->priv_data;
     int res;
-    pa_usec_t latency;
 
     if (av_new_packet(pkt, pd->frame_size) < 0) {
         return AVERROR(ENOMEM);
@@ -122,13 +121,15 @@ static int pulse_read_packet(AVFormatContext *s, AVPacket *pkt)
         return AVERROR(EIO);
     }
 
-    if ((latency = pa_simple_get_latency(pd->s, &res)) == (pa_usec_t) -1) {
-        av_log(s, AV_LOG_ERROR, "pa_simple_get_latency() failed: %s\n",
-               pa_strerror(res));
-        return AVERROR(EIO);
-    }
-
     if (pd->pts == AV_NOPTS_VALUE) {
+        pa_usec_t latency;
+
+        if ((latency = pa_simple_get_latency(pd->s, &res)) == (pa_usec_t) -1) {
+            av_log(s, AV_LOG_ERROR, "pa_simple_get_latency() failed: %s\n",
+                   pa_strerror(res));
+            return AVERROR(EIO);
+        }
+
         pd->pts = -latency;
     }
 



More information about the ffmpeg-cvslog mailing list