summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure12
-rw-r--r--libavdevice/alsa.c4
-rw-r--r--libavdevice/alsa_dec.c4
3 files changed, 18 insertions, 2 deletions
diff --git a/configure b/configure
index 1de90e9..9273076 100755
--- a/configure
+++ b/configure
@@ -2186,6 +2186,7 @@ SYSTEM_FEATURES="
SYSTEM_FUNCS="
access
aligned_malloc
+ alsa_hr_ts
arc4random
clock_gettime
closesocket
@@ -6515,8 +6516,15 @@ else
EOF
fi
-enabled alsa && { check_pkg_config alsa alsa "alsa/asoundlib.h" snd_pcm_htimestamp ||
- check_lib alsa alsa/asoundlib.h snd_pcm_htimestamp -lasound; }
+if enabled alsa; then
+ check_pkg_config alsa alsa "alsa/asoundlib.h" snd_pcm_htimestamp ||
+ check_lib alsa alsa/asoundlib.h snd_pcm_htimestamp -lasound
+ if check_type "alsa/asoundlib.h alsa/pcm.h" snd_pcm_tstamp_type_t; then
+ enable alsa_hr_ts
+ else
+ warn "High resolution timestamps not supported by your ALSA version. Streaming A/V sync may suffer!"
+ fi
+fi
enabled libjack &&
require_pkg_config libjack jack jack/jack.h jack_port_get_latency_range
diff --git a/libavdevice/alsa.c b/libavdevice/alsa.c
index 10ffe56..903ed94 100644
--- a/libavdevice/alsa.c
+++ b/libavdevice/alsa.c
@@ -272,6 +272,7 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
}
s->use_driver_timestamps = 0;
+#if HAVE_ALSA_HR_TS
if (snd_pcm_hw_params_supports_audio_ts_type(hw_params, 0)) {
av_log(ctx, AV_LOG_INFO, "capture device supports compat timestamps\n");
s->use_driver_timestamps |= 1;
@@ -296,6 +297,7 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
av_log(ctx, AV_LOG_INFO, "capture device supports link synchronized timestamps\n");
s->use_driver_timestamps |= 32;
}
+#endif
res = snd_pcm_sw_params_malloc(&sw_params);
if (res < 0) {
@@ -320,6 +322,7 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
goto fail;
}
+#if HAVE_ALSA_HR_TS
res = snd_pcm_sw_params_set_tstamp_type(h, sw_params, SND_PCM_TSTAMP_TYPE_MONOTONIC_RAW);
if (res < 0) {
av_log(ctx, AV_LOG_ERROR, "cannot set timestamp mode (%s)\n",
@@ -327,6 +330,7 @@ av_cold int ff_alsa_open(AVFormatContext *ctx, snd_pcm_stream_t mode,
snd_pcm_sw_params_free(sw_params);
goto fail;
}
+#endif
res = snd_pcm_sw_params(h, sw_params);
if (res < 0) {
diff --git a/libavdevice/alsa_dec.c b/libavdevice/alsa_dec.c
index 902fba3..0b3b7e4 100644
--- a/libavdevice/alsa_dec.c
+++ b/libavdevice/alsa_dec.c
@@ -104,7 +104,9 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
int res;
int64_t dts;
snd_pcm_sframes_t delay = 0;
+#if HAVE_ALSA_HR_TS
snd_pcm_audio_tstamp_config_t tstamp_config;
+#endif
if (av_new_packet(pkt, s->period_size * s->frame_size) < 0) {
return AVERROR(EIO);
@@ -127,6 +129,7 @@ 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;
tstamp_config.report_delay = 1;
@@ -142,6 +145,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
delay = snd_pcm_status_get_delay(s->st);
}
}
+#endif
if (dts == 0) {
// Driver timestamps not supported
// Fall back to system timestamps
OpenPOWER on IntegriCloud