summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Pearson <tpearson@raptorengineering.com>2019-11-25 17:30:39 -0600
committerTimothy Pearson <kb9vqf@pearsoncomputing.net>2019-12-09 00:46:43 -0600
commit4e1e8784aa254b16ca506001227450da66eaa2c3 (patch)
tree1b01c6a00970963b1db41a219048850f3d1125f0
parent3de2fd9b5378a9c472433baa7556c8fef61a482e (diff)
downloadffmpeg-streaming-master.zip
ffmpeg-streaming-master.tar.gz
Add support for ALSA link timestampsHEADmaster
This allows certain drivers, such as the Raptor/Magewell ProCapture PerfectSync driver stack, to guarantee correct timestamps and A/V sync
-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