diff options
author | Uwe Klotz <uklotz@mixxx.org> | 2021-06-14 20:09:26 +0200 |
---|---|---|
committer | Uwe Klotz <uklotz@mixxx.org> | 2021-06-14 20:15:37 +0200 |
commit | 6e50a347093886f0e4a8e42daf560c628595b2ad (patch) | |
tree | a52dd790940d6d36f920f5910cf494777092c2e6 /src/sources | |
parent | 8e6b3a80d683d8b29bbfe9fc23709d1f74ee7cd2 (diff) |
SoundSourceFLAC: Fix armv7hl build on gcc 11.1
../src/sources/soundsourceflac.cpp: In member function 'FLAC__StreamDecoderWriteStatus mixxx::SoundSourceFLAC::flacWrite(const FLAC__Frame*, const FLAC__int32* const*)':
../src/sources/soundsourceflac.cpp:426:41: error: comparison of integer expressions of different signedness: 'mixxx::audio::SampleRate::value_t' {aka 'unsigned int'} and 'SINT' {aka 'int'} [-Werror=sign-compare]
426 | if (getSignalInfo().getSampleRate() != SINT(frame->header.sample_rate)) {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
Diffstat (limited to 'src/sources')
-rw-r--r-- | src/sources/soundsourceflac.cpp | 19 |
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) |