diff options
author | Lukasz Marek <lukasz.m.luki@gmail.com> | 2013-10-26 01:19:31 +0200 |
---|---|---|
committer | Nicolas George <george@nsup.org> | 2013-11-03 10:28:15 +0100 |
commit | 6ac9afd16e385fc450c58b8a3fb44baa99ea4af9 (patch) | |
tree | ccb5e6801196bb1bf5f26036db77b16f539b7c61 /libavdevice | |
parent | 8a701ef7ddbb2d80ef77b14287d286fc9760f131 (diff) | |
download | ffmpeg-6ac9afd16e385fc450c58b8a3fb44baa99ea4af9.tar.gz |
lavd/alsa: fix timestamp calculation
Current implementation didn't include duration of
last processed packet.
Device may return negative timestamps without
this correction.
Signed-off-by: Lukasz Marek <lukasz.m.luki@gmail.com>
Diffstat (limited to 'libavdevice')
-rw-r--r-- | libavdevice/alsa-audio-enc.c | 6 | ||||
-rw-r--r-- | libavdevice/alsa-audio.h | 1 |
2 files changed, 6 insertions, 1 deletions
diff --git a/libavdevice/alsa-audio-enc.c b/libavdevice/alsa-audio-enc.c index 0f4e4a2c7a..5033a4894e 100644 --- a/libavdevice/alsa-audio-enc.c +++ b/libavdevice/alsa-audio-enc.c @@ -80,6 +80,10 @@ static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt) uint8_t *buf = pkt->data; size /= s->frame_size; + if (pkt->dts != AV_NOPTS_VALUE) + s->timestamp = pkt->dts; + s->timestamp += pkt->duration ? pkt->duration : size; + if (s->reorder_func) { if (size > s->reorder_buf_size) if (ff_alsa_extend_reorder_buf(s, size)) @@ -112,7 +116,7 @@ audio_get_output_timestamp(AVFormatContext *s1, int stream, snd_pcm_sframes_t delay = 0; *wall = av_gettime(); snd_pcm_delay(s->h, &delay); - *dts = s1->streams[0]->cur_dts - delay; + *dts = s->timestamp - delay; } AVOutputFormat ff_alsa_muxer = { diff --git a/libavdevice/alsa-audio.h b/libavdevice/alsa-audio.h index 44b7c72fc0..583c9119ac 100644 --- a/libavdevice/alsa-audio.h +++ b/libavdevice/alsa-audio.h @@ -57,6 +57,7 @@ typedef struct AlsaData { void (*reorder_func)(const void *, void *, int); void *reorder_buf; int reorder_buf_size; ///< in frames + int64_t timestamp; ///< current timestamp, without latency applied. } AlsaData; /** |