diff --git a/include/Void/System/Audio.hpp b/include/Void/System/Audio.hpp index ae50c80..a57bbef 100644 --- a/include/Void/System/Audio.hpp +++ b/include/Void/System/Audio.hpp @@ -263,6 +263,7 @@ class AudioDevice HWAVEOUT wave{}; WAVEHDR header{}; WAVEFORMATEX format{}; + std::vector playback; bool prepared{false}; #endif }; @@ -343,11 +344,14 @@ class AudioDevice "waveOutOpen failed"}}; } voice.header = WAVEHDR{}; + // waveOut only reads the samples, but WAVEHDR exposes a mutable + // buffer; keep an owned mutable copy instead of casting away + // constness of the shared buffer. + voice.playback = voice.buffer->samples; voice.header.lpData = - reinterpret_cast( - const_cast(voice.buffer->samples.data())); + reinterpret_cast(voice.playback.data()); voice.header.dwBufferLength = static_cast( - voice.buffer->samples.size() * sizeof(PcmSample)); + voice.playback.size() * sizeof(PcmSample)); if (::waveOutPrepareHeader(voice.wave, &voice.header, sizeof(WAVEHDR)) != MMSYSERR_NOERROR) {