Browse Source

V2.1.1

1.解决wav文件不能播放的bug
叶海辉 6 years ago
parent
commit
911c2e8a40

BIN
bin32/VideoPlayer.exe


+ 1 - 1
module/VideoPlayer/src/AppConfig.cpp

@@ -17,7 +17,7 @@ void Sleep(long mSeconds)
 #endif
 
 int AppConfig::VERSION = 1;
-char AppConfig::VERSION_NAME[32] = "2.1.0";
+char AppConfig::VERSION_NAME[32] = "2.1.1";
 
 LogWriter* AppConfig::gLogWriter = new LogWriter;
 

+ 13 - 2
module/VideoPlayer/src/VideoPlayer/VideoPlayer.cpp

@@ -361,13 +361,24 @@ void VideoPlayer::readVideoFile()
 
             out_ch_layout &= ~AV_CH_LAYOUT_STEREO_DOWNMIX;
 
+            /// 2019-5-13添加
+            /// wav文件获取到的aCodecCtx->channel_layout为0会导致后面的初始化失败,因为这里需要加个判断。
+            if (in_ch_layout <= 0)
+            {
+                in_ch_layout = av_get_default_channel_layout(aCodecCtx->channels);
+            }
+
             swrCtx = swr_alloc_set_opts(nullptr, out_ch_layout, out_sample_fmt, out_sample_rate,
                                                  in_ch_layout, in_sample_fmt, in_sample_rate, 0, nullptr);
 
             /** Open the resampler with the specified parameters. */
-            if (swr_init(swrCtx) < 0)
+            int ret = swr_init(swrCtx);
+            if (ret < 0)
             {
-                OUTPUT("Could not open resample context\n");
+                char buff[128]={0};
+                av_strerror(ret, buff, 128);
+
+                OUTPUT("Could not open resample context %s\n", buff);
                 swr_free(&swrCtx);
                 swrCtx = nullptr;
                 doOpenVideoFileFailed();