]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
transcode: add default sample rates to make webui work
authorJaroslav Kysela <perex@perex.cz>
Sat, 6 Jan 2018 19:11:55 +0000 (20:11 +0100)
committerJaroslav Kysela <perex@perex.cz>
Sat, 6 Jan 2018 19:11:55 +0000 (20:11 +0100)
src/transcoding/codec/codec.c
src/transcoding/codec/profile_audio_class.c
src/transcoding/transcode/audio.c

index 9ee1c61cd7d1c3709a0a3a97ee8816dca577bd20..54d7dc2a761d44c702e464270f1a21582f4807dd 100644 (file)
@@ -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;
index 667565cd9ffb20464cbb38b6bae39e6cd1487b42..3ad752597be57888f1b3d945a0a1b83940d3f3e5 100644 (file)
@@ -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);
                 }
index 86965e048e18383848127120979179988134bae3..27bc32b339630a5301fe61de1c3dde1211ec28c7 100644 (file)
@@ -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);
 }