summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libavdevice/alsa_dec.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/libavdevice/alsa_dec.c b/libavdevice/alsa_dec.c
index 0b3b7e4..f59b043 100644
--- a/libavdevice/alsa_dec.c
+++ b/libavdevice/alsa_dec.c
@@ -131,18 +131,30 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
dts = 0;
#if HAVE_ALSA_HR_TS
if (s->use_driver_timestamps) {
- tstamp_config.type_requested = 1;
+ if (s->use_driver_timestamps & 4) {
+ tstamp_config.type_requested = 2;
+ }
+ else {
+ tstamp_config.type_requested = 1;
+ }
tstamp_config.report_delay = 1;
snd_pcm_status_set_audio_htstamp_config(s->st, &tstamp_config);
if (snd_pcm_status(s->h, s->st) >= 0) {
struct timespec ts;
- snd_pcm_status_get_driver_htstamp(s->st, &ts);
+ if (s->use_driver_timestamps & 4) {
+ snd_pcm_status_get_audio_htstamp(s->st, &ts);
+ delay = 0;
+ }
if ((ts.tv_sec == 0) && (ts.tv_nsec == 0)) {
- // Try alternate access method
+ // Try alternate access method #1
+ snd_pcm_status_get_driver_htstamp(s->st, &ts);
+ }
+ if ((ts.tv_sec == 0) && (ts.tv_nsec == 0)) {
+ // Try alternate access method #2
snd_pcm_status_get_htstamp(s->st, &ts);
}
- dts = (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
delay = snd_pcm_status_get_delay(s->st);
+ dts = (int64_t)ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
}
}
#endif
@@ -152,9 +164,14 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
dts = av_gettime();
snd_pcm_delay(s->h, &delay);
}
-
dts -= av_rescale(delay + res, 1000000, s->sample_rate);
- pkt->pts = ff_timefilter_update(s->timefilter, dts, s->last_period);
+
+ if (s->use_driver_timestamps & 4) {
+ pkt->pts = dts;
+ }
+ else {
+ pkt->pts = ff_timefilter_update(s->timefilter, dts, s->last_period);
+ }
s->last_period = res;
pkt->size = res * s->frame_size;
OpenPOWER on IntegriCloud