Skip to content

Commit 23ba8b4

Browse files
feliwirOmniBlade
authored andcommitted
Just fix the build error due to const correctness
1 parent ec2ec82 commit 23ba8b4

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/platform/audio/ffmpegaudiofilecache.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ bool FFmpegAudioFileCache::Decode_FFmpeg(FFmpegOpenAudioFile *file)
202202
}
203203

204204
int frame_data_size = av_samples_get_buffer_size(
205-
NULL, file->codec_ctx->ch_layout.nb_channels, frame->nb_samples, file->codec_ctx->sample_fmt, 1);
205+
NULL, file->codec_ctx->channels, frame->nb_samples, file->codec_ctx->sample_fmt, 1);
206206
file->wave_data = static_cast<uint8_t *>(av_realloc(file->wave_data, file->data_size + frame_data_size));
207207
memcpy(file->wave_data + file->data_size, frame->data[0], frame_data_size);
208208
file->data_size += frame_data_size;
@@ -244,12 +244,11 @@ void FFmpegAudioFileCache::Fill_Wave_Data(FFmpegOpenAudioFile *open_audio)
244244
WavHeader wav;
245245
wav.chunk_size = open_audio->data_size - (offsetof(WavHeader, chunk_size) + sizeof(uint32_t));
246246
wav.subchunk2_size = open_audio->data_size - (offsetof(WavHeader, subchunk2_size) + sizeof(uint32_t));
247-
wav.channels = open_audio->codec_ctx->ch_layout.nb_channels;
247+
wav.channels = open_audio->codec_ctx->channels;
248248
wav.bits_per_sample = av_get_bytes_per_sample(open_audio->codec_ctx->sample_fmt) * 8;
249249
wav.samples_per_sec = open_audio->codec_ctx->sample_rate;
250-
wav.bytes_per_sec =
251-
open_audio->codec_ctx->sample_rate * open_audio->codec_ctx->ch_layout.nb_channels * wav.bits_per_sample / 8;
252-
wav.block_align = open_audio->codec_ctx->ch_layout.nb_channels * wav.bits_per_sample / 8;
250+
wav.bytes_per_sec = open_audio->codec_ctx->sample_rate * open_audio->codec_ctx->channels * wav.bits_per_sample / 8;
251+
wav.block_align = open_audio->codec_ctx->channels * wav.bits_per_sample / 8;
253252
memcpy(open_audio->wave_data, &wav, sizeof(WavHeader));
254253
}
255254

@@ -378,7 +377,7 @@ AudioDataHandle FFmpegAudioFileCache::Open_File(AudioEventRTS *audio_event)
378377
return nullptr;
379378
}
380379

381-
if (audio_event->Is_Positional_Audio() && open_audio.codec_ctx->ch_layout.nb_channels > 1) {
380+
if (audio_event->Is_Positional_Audio() && open_audio.codec_ctx->channels > 1) {
382381
captainslog_error("Audio marked as positional audio cannot have more than one channel.");
383382
return nullptr;
384383
}

0 commit comments

Comments
 (0)