[FFmpeg-devel] [PATCH] ffplay: use 48 kHz for ALSA output
Marton Balint
cus at passwd.hu
Wed Apr 20 23:59:12 CEST 2016
Signed-off-by: Marton Balint <cus at passwd.hu>
---
ffplay.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/ffplay.c b/ffplay.c
index 804bcbc..89a34d2 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -2578,12 +2578,17 @@ static int audio_open(void *opaque, int64_t wanted_channel_layout, int wanted_nb
static const int next_nb_channels[] = {0, 0, 1, 6, 2, 6, 4, 6};
static const int next_sample_rates[] = {0, 44100, 48000, 96000, 192000};
int next_sample_rate_idx = FF_ARRAY_ELEMS(next_sample_rates) - 1;
+ char driver_name[32];
env = SDL_getenv("SDL_AUDIO_CHANNELS");
if (env) {
wanted_nb_channels = atoi(env);
wanted_channel_layout = av_get_default_channel_layout(wanted_nb_channels);
}
+ /* By using the default dmix sample rate we should be able to avoid the
+ * ALSA resampler because using it causes small buffers and underruns. */
+ if (SDL_AudioDriverName(driver_name, sizeof(driver_name)) && !strcmp(driver_name, "alsa") && wanted_sample_rate < 48000)
+ wanted_sample_rate = 48000;
if (!wanted_channel_layout || wanted_nb_channels != av_get_channel_layout_nb_channels(wanted_channel_layout)) {
wanted_channel_layout = av_get_default_channel_layout(wanted_nb_channels);
wanted_channel_layout &= ~AV_CH_LAYOUT_STEREO_DOWNMIX;
--
2.6.6
More information about the ffmpeg-devel
mailing list