From 5f640f2965583dc05cfd4f9fcc71ec9d6544ff68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 30 Dec 2019 11:41:42 +0100 Subject: [PATCH 1/2] don't use WavpackContext in the public soundsourcewv interface --- src/sources/soundsourcewv.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/sources/soundsourcewv.h b/src/sources/soundsourcewv.h index 84a2b681a3e..314158b630e 100644 --- a/src/sources/soundsourcewv.h +++ b/src/sources/soundsourcewv.h @@ -6,8 +6,6 @@ class QFile; -typedef void WavpackContext; - namespace mixxx { class SoundSourceWV : public SoundSource { @@ -35,7 +33,13 @@ class SoundSourceWV : public SoundSource { OpenMode mode, const OpenParams& params) override; - WavpackContext* m_wpc; + // A WavpackContext* type + // we cannot use the type directly, because it has + // changing definitions with different wavpack.h versions. + // wavpack.h can't be included here, bacause it has concurrent definitions + // with other decoder's header. + void* m_wpc; + CSAMPLE m_sampleScaleFactor; QFile* m_pWVFile; QFile* m_pWVCFile; From 70387c6b28d18e3fb42e32e42ba415fbe91ad053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Mon, 30 Dec 2019 16:50:33 +0100 Subject: [PATCH 2/2] use static_cast(m_wpc) --- src/sources/soundsourcewv.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/sources/soundsourcewv.cpp b/src/sources/soundsourcewv.cpp index 0d94775be3b..e1abfc08356 100644 --- a/src/sources/soundsourcewv.cpp +++ b/src/sources/soundsourcewv.cpp @@ -64,17 +64,17 @@ SoundSource::OpenResult SoundSourceWV::tryOpen( return OpenResult::Failed; } - setChannelCount(WavpackGetReducedChannels(m_wpc)); - setSampleRate(WavpackGetSampleRate(m_wpc)); + setChannelCount(WavpackGetReducedChannels(static_cast(m_wpc))); + setSampleRate(WavpackGetSampleRate(static_cast(m_wpc))); initFrameIndexRangeOnce( mixxx::IndexRange::forward( 0, - WavpackGetNumSamples(m_wpc))); + WavpackGetNumSamples(static_cast(m_wpc)))); - if (WavpackGetMode(m_wpc) & MODE_FLOAT) { + if (WavpackGetMode(static_cast(m_wpc)) & MODE_FLOAT) { m_sampleScaleFactor = CSAMPLE_PEAK; } else { - const int bitsPerSample = WavpackGetBitsPerSample(m_wpc); + const int bitsPerSample = WavpackGetBitsPerSample(static_cast(m_wpc)); if ((bitsPerSample >= 8) && (bitsPerSample <= 32)) { // Range of signed sample values: [-2 ^ (bitsPerSample - 1), 2 ^ (bitsPerSample - 1) - 1] const uint32_t absSamplePeak = 1u << (bitsPerSample - 1); @@ -96,7 +96,7 @@ SoundSource::OpenResult SoundSourceWV::tryOpen( void SoundSourceWV::close() { if (m_wpc) { - WavpackCloseFile(m_wpc); + WavpackCloseFile(static_cast(m_wpc)); m_wpc = nullptr; } if (m_pWVFile) { @@ -116,13 +116,13 @@ ReadableSampleFrames SoundSourceWV::readSampleFramesClamped( const SINT firstFrameIndex = writableSampleFrames.frameIndexRange().start(); if (m_curFrameIndex != firstFrameIndex) { - if (WavpackSeekSample(m_wpc, firstFrameIndex)) { + if (WavpackSeekSample(static_cast(m_wpc), firstFrameIndex)) { m_curFrameIndex = firstFrameIndex; } else { kLogger.warning() << "Could not seek to first frame index" << firstFrameIndex; - m_curFrameIndex = WavpackGetSampleIndex(m_wpc); + m_curFrameIndex = WavpackGetSampleIndex(static_cast(m_wpc)); return ReadableSampleFrames(IndexRange::between(m_curFrameIndex, m_curFrameIndex)); } } @@ -133,12 +133,12 @@ ReadableSampleFrames SoundSourceWV::readSampleFramesClamped( static_assert(sizeof(CSAMPLE) == sizeof(int32_t), "CSAMPLE and int32_t must have the same size"); CSAMPLE* pOutputBuffer = writableSampleFrames.writableData(); - SINT unpackCount = WavpackUnpackSamples(m_wpc, + SINT unpackCount = WavpackUnpackSamples(static_cast(m_wpc), reinterpret_cast(pOutputBuffer), numberOfFramesTotal); DEBUG_ASSERT(unpackCount >= 0); DEBUG_ASSERT(unpackCount <= numberOfFramesTotal); - if (!(WavpackGetMode(m_wpc) & MODE_FLOAT)) { + if (!(WavpackGetMode(static_cast(m_wpc)) & MODE_FLOAT)) { // signed integer -> float const SINT sampleCount = frames2samples(unpackCount); for (SINT i = 0; i < sampleCount; ++i) {