Ver código fonte

ijkplayer修复dsf dff高采样率的播放

onecold 6 meses atrás
pai
commit
63ba0a920d

BIN
entry/libs/ijkplayer.har


+ 1 - 1
entry/oh-package.json5

@@ -6,7 +6,7 @@
   "author": "",
   "license": "LGPLv2.1 or later",
   "dependencies": {
-//    "@ohos/ijkplayer": "file:../ijkplayer",//注释掉这个代码,用ohpm install @ohos/ijkplayer去装2.0.6版本
+    "@ohos/ijkplayer": "file:../ijkplayer",//注释掉这个代码,用ohpm install @ohos/ijkplayer去装2.0.6版本
     "@tencent/wechat_open_sdk": "1.0.0"
   }
 }

+ 12 - 2
ijkplayer/src/main/cpp/ijkplayer/ff_ffplay.c

@@ -2774,8 +2774,18 @@ static int audio_open(FFPlayer *opaque, int64_t wanted_channel_layout, int wante
         av_log(NULL, AV_LOG_ERROR, "Invalid sample rate or channel count!\n");
         return -1;
     }
-    while (next_sample_rate_idx && next_sample_rates[next_sample_rate_idx] >= wanted_spec.freq)
-        next_sample_rate_idx--;
+//    while (next_sample_rate_idx && next_sample_rates[next_sample_rate_idx] >= wanted_spec.freq)
+//        next_sample_rate_idx--;
+     //修复dsf dff格式的播放
+     if (wanted_spec.freq > next_sample_rates[next_sample_rate_idx]) {
+         av_log(NULL, AV_LOG_INFO, "A high sampling rate of %d Hz has been detected, forcing fallback to %d Hz\n",
+             wanted_spec.freq, next_sample_rates[next_sample_rate_idx]);
+         wanted_spec.freq = next_sample_rates[next_sample_rate_idx];
+     } else {
+         while (next_sample_rate_idx && next_sample_rates[next_sample_rate_idx] >= wanted_spec.freq) {
+             next_sample_rate_idx--;
+         }
+     }
     wanted_spec.format = AUDIO_S16SYS;
     wanted_spec.silence = 0;
     wanted_spec.samples = FFMAX(SDL_AUDIO_MIN_BUFFER_SIZE, 2 << av_log2(wanted_spec.freq / SDL_AoutGetAudioPerSecondCallBacks(ffp->aout)));