summaryrefslogtreecommitdiffstats
path: root/src/sources
diff options
context:
space:
mode:
authorUwe Klotz <uklotz@mixxx.org>2021-06-16 13:09:51 +0200
committerUwe Klotz <uklotz@mixxx.org>2021-06-16 13:09:51 +0200
commitde3999305cce5555fcd1d4a056e34793c83dd6f8 (patch)
tree47473ea46f54e88888edac5135afc2d326fc26dd /src/sources
parent38e51a49d283d55b3f6eaf66dcdf930a52335b19 (diff)
parent513da6dd21621ac10ecd74988d61e55eb517e6ba (diff)
Merge branch 'main' of git@github.com:mixxxdj/mixxx.git into source-synchronized-timestamp
# Conflicts: # src/track/trackrecord.cpp
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)