diff --git a/src/audio_provider_bestsource.cpp b/src/audio_provider_bestsource.cpp index 7229df827..5390788dc 100644 --- a/src/audio_provider_bestsource.cpp +++ b/src/audio_provider_bestsource.cpp @@ -75,37 +75,8 @@ catch (AudioException const& err) { throw agi::AudioProviderError("Failed to create BestAudioSource"); } -// Taken from BestSource code and reversed -template -static void PackChannels(const uint8_t *Src, void *Dst, size_t Length, size_t Channels) { - const T *S = reinterpret_cast(Src); - T *D = reinterpret_cast(Dst); - for (size_t i = 0; i < Length; i++) { - for (size_t c = 0; c < Channels; c++) - D[c] = S[Length * c]; - S += 1; - D += Channels; - } -} - void BSAudioProvider::FillBuffer(void *Buf, int64_t Start, int64_t Count) const { - // BS unpacked the channels, so until it gets a feature to disable that, let's just - // pack them in the same way they were unpacked - std::vector unpacked_buf(channels * bytes_per_sample * Count); - std::vector bufs(channels); - for (int i = 0; i < channels; i++) { - bufs[i] = unpacked_buf.data() + i * bytes_per_sample * Count; - } - const_cast(bs).GetAudio(bufs.data(), Start, Count); - - if (bytes_per_sample == 1) - PackChannels(unpacked_buf.data(), Buf, Count, channels); - else if (bytes_per_sample == 2) - PackChannels(unpacked_buf.data(), Buf, Count, channels); - else if (bytes_per_sample == 4) - PackChannels(unpacked_buf.data(), Buf, Count, channels); - else if (bytes_per_sample == 8) - PackChannels(unpacked_buf.data(), Buf, Count, channels); + const_cast(bs).GetPackedAudio(reinterpret_cast(Buf), Start, Count); } }