summaryrefslogtreecommitdiffstats
path: root/src/sources
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2021-06-15 01:03:18 +0200
committerUwe Klotz <uklotz@mixxx.org>2021-06-15 01:03:18 +0200
commit747dd041c21ae439a8b04598ec0f8aa6830f43b7 (patch)
tree2877aa1affddfbca3623555e353cd74f2d0aeef6 /src/sources
parent7c7d406c6c0e27e72b382f6420d6ef9f231ae9cf (diff)
parent7585ce91606b618ee575a78248a9bf4a4a649046 (diff)
Merge branch '2.3' of git@github.com:mixxxdj/mixxx.git
Diffstat (limited to 'src/sources')
-rw-r--r--src/sources/soundsourceflac.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/sources/soundsourceflac.cpp b/src/sources/soundsourceflac.cpp
index 8f508bb046..a6624a7e82 100644
--- a/src/sources/soundsourceflac.cpp
+++ b/src/sources/soundsourceflac.cpp
@@ -415,19 +415,26 @@ inline CSAMPLE convertDecodedSample(FLAC__int32 decodedSample, int bitsPerSample
FLAC__StreamDecoderWriteStatus SoundSourceFLAC::flacWrite(
const FLAC__Frame* frame, const FLAC__int32* const buffer[]) {
- const SINT numChannels = frame->header.channels;
- if (getSignalInfo().getChannelCount() > numChannels) {
+ VERIFY_OR_DEBUG_ASSERT(frame->header.channels > 0) {
+ return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
+ }
+ const auto channelCount = mixxx::audio::ChannelCount::fromInt(frame->header.channels);
+ if (getSignalInfo().getChannelCount() > channelCount) {
kLogger.warning()
<< "Corrupt or unsupported FLAC file:"
<< "Invalid number of channels in FLAC frame header"
- << frame->header.channels << "<>" << getSignalInfo().getChannelCount();
+ << channelCount << "<>" << getSignalInfo().getChannelCount();
+ return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
+ }
+ VERIFY_OR_DEBUG_ASSERT(frame->header.sample_rate > 0) {
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
}
- if (getSignalInfo().getSampleRate() != SINT(frame->header.sample_rate)) {
+ const auto sampleRate = mixxx::audio::SampleRate(frame->header.sample_rate);
+ if (getSignalInfo().getSampleRate() != sampleRate) {
kLogger.warning()
<< "Corrupt or unsupported FLAC file:"
<< "Invalid sample rate in FLAC frame header"
- << frame->header.sample_rate << "<>" << getSignalInfo().getSampleRate();
+ << sampleRate << "<>" << getSignalInfo().getSampleRate();
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
}
const SINT numReadableFrames = frame->header.blocksize;
@@ -460,7 +467,7 @@ FLAC__StreamDecoderWriteStatus SoundSourceFLAC::flacWrite(
}
CSAMPLE* pSampleBuffer = writableSlice.data();
- DEBUG_ASSERT(getSignalInfo().getChannelCount() <= numChannels);
+ DEBUG_ASSERT(getSignalInfo().getChannelCount() <= channelCount);
switch (getSignalInfo().getChannelCount()) {
case 1: {
// optimized code for 1 channel (mono)