From: Jaroslav Kysela Date: Sat, 6 Jan 2018 19:11:55 +0000 (+0100) Subject: transcode: add default sample rates to make webui work X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=151f4a0a36bb85f7b66b3818008cb1a1acde86d3;p=thirdparty%2Ftvheadend.git transcode: add default sample rates to make webui work --- diff --git a/src/transcoding/codec/codec.c b/src/transcoding/codec/codec.c index 9ee1c61cd..54d7dc2a7 100644 --- a/src/transcoding/codec/codec.c +++ b/src/transcoding/codec/codec.c @@ -120,15 +120,20 @@ tvh_codec_video_init(TVHVideoCodec *self, AVCodec *codec) } } - static void tvh_codec_audio_init(TVHAudioCodec *self, AVCodec *codec) { + static int default_sample_rates[] = { + 44100, 48000, 96000, 192000, 0 + }; + if (!self->sample_fmts) { self->sample_fmts = codec->sample_fmts; } if (!self->sample_rates) { self->sample_rates = codec->supported_samplerates; + if (!self->sample_rates) + self->sample_rates = default_sample_rates; } if (!self->channel_layouts) { self->channel_layouts = codec->channel_layouts; diff --git a/src/transcoding/codec/profile_audio_class.c b/src/transcoding/codec/profile_audio_class.c index 667565cd9..3ad752597 100644 --- a/src/transcoding/codec/profile_audio_class.c +++ b/src/transcoding/codec/profile_audio_class.c @@ -22,7 +22,6 @@ #include "lang_codes.h" - /* TVHCodec ================================================================= */ static htsmsg_t * @@ -107,7 +106,7 @@ tvh_codec_audio_get_list_channel_layouts(TVHAudioCodec *self) list = NULL; break; } - memset(l_buf, 0, sizeof(l_buf)); + l_buf[0] = '\0'; av_get_channel_layout_string(l_buf, sizeof(l_buf), 0, l); ADD_ENTRY(list, map, s64, l, str, l_buf); } diff --git a/src/transcoding/transcode/audio.c b/src/transcoding/transcode/audio.c index 86965e048..27bc32b33 100644 --- a/src/transcoding/transcode/audio.c +++ b/src/transcoding/transcode/audio.c @@ -28,6 +28,7 @@ _audio_context_sample_fmt(TVHContext *self, AVDictionary **opts) tvh_codec_profile_audio_get_sample_fmts(self->profile); enum AVSampleFormat ifmt = self->iavctx->sample_fmt; enum AVSampleFormat ofmt = AV_SAMPLE_FMT_NONE; + enum AVSampleFormat altfmt = AV_SAMPLE_FMT_NONE; int i; if (!tvh_context_get_int_opt(opts, "sample_fmt", &ofmt) && @@ -38,13 +39,18 @@ _audio_context_sample_fmt(TVHContext *self, AVDictionary **opts) break; } } - ofmt = (ofmt != AV_SAMPLE_FMT_NONE) ? ofmt : sample_fmts[0]; + altfmt = (ofmt != AV_SAMPLE_FMT_NONE) ? ofmt : sample_fmts[0]; } else { - ofmt = ifmt; + altfmt = ifmt; } } - return ofmt; + if (tvhtrace_enabled()) + tvh_context_log(self, LOG_TRACE, "audio format selection: old %s, alt %s, in %s", + av_get_sample_fmt_name(ofmt), + av_get_sample_fmt_name(altfmt), + av_get_sample_fmt_name(ifmt)); + return ofmt == AV_SAMPLE_FMT_NONE ? altfmt : ofmt; } @@ -66,6 +72,9 @@ _audio_context_sample_rate(TVHContext *self, AVDictionary **opts) } } } + if (tvhtrace_enabled()) + tvh_context_log(self, LOG_TRACE, "audio rate selection: old %i, alt %i, in %i", + orate, altrate, irate); return orate ? orate : (altrate ? altrate : 48000); } @@ -78,7 +87,7 @@ _audio_context_channel_layout(TVHContext *self, AVDictionary **opts) uint64_t ilayout = self->iavctx->channel_layout; uint64_t altlayout = 0, olayout = 0; int tmp = 0, ichannels = 0, i; - + char obuf[64], abuf[64], ibuf[64]; if (!tvh_context_get_int_opt(opts, "channel_layout", &tmp) && !(olayout = tmp) && channel_layouts) { @@ -92,6 +101,16 @@ _audio_context_channel_layout(TVHContext *self, AVDictionary **opts) } } } + if (tvhtrace_enabled()) { + strcpy(obuf, "none"); + av_get_channel_layout_string(obuf, sizeof(obuf), 0, olayout); + strcpy(abuf, "none"); + av_get_channel_layout_string(abuf, sizeof(abuf), 0, altlayout); + strcpy(ibuf, "none"); + av_get_channel_layout_string(ibuf, sizeof(ibuf), 0, ilayout); + tvh_context_log(self, LOG_TRACE, "audio layout selection: old %s, alt %s, in %s", + obuf, abuf, ibuf); + } return olayout ? olayout : (altlayout ? altlayout : AV_CH_LAYOUT_STEREO); }