mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 21:30:19 -06:00
Swapped FFDShow's DPL2 decoder by FreeSurround
Added class in AudioCommon for the surround decoder
This commit is contained in:
@ -7,7 +7,6 @@
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
#include "AudioCommon/DPL2Decoder.h"
|
||||
#include "Common/ChunkFile.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/Logging/Log.h"
|
||||
@ -16,10 +15,10 @@
|
||||
#include "Core/ConfigManager.h"
|
||||
|
||||
Mixer::Mixer(unsigned int BackendSampleRate)
|
||||
: m_sampleRate(BackendSampleRate), m_stretcher(BackendSampleRate)
|
||||
: m_sampleRate(BackendSampleRate), m_stretcher(BackendSampleRate),
|
||||
m_surround_decoder(BackendSampleRate, SURROUND_BLOCK_SIZE)
|
||||
{
|
||||
INFO_LOG(AUDIO_INTERFACE, "Mixer is initialized");
|
||||
DPL2Reset();
|
||||
}
|
||||
|
||||
Mixer::~Mixer()
|
||||
@ -167,20 +166,23 @@ unsigned int Mixer::MixSurround(float* samples, unsigned int num_samples)
|
||||
if (!num_samples)
|
||||
return 0;
|
||||
|
||||
memset(samples, 0, num_samples * 6 * sizeof(float));
|
||||
memset(samples, 0, num_samples * SURROUND_CHANNELS * sizeof(float));
|
||||
|
||||
// Mix() may also use m_scratch_buffer internally, but is safe because it alternates reads and
|
||||
// writes.
|
||||
unsigned int available_samples = Mix(m_scratch_buffer.data(), num_samples);
|
||||
for (size_t i = 0; i < static_cast<size_t>(available_samples) * 2; ++i)
|
||||
size_t needed_frames = m_surround_decoder.QueryFramesNeededForSurroundOutput(num_samples);
|
||||
|
||||
// Mix() may also use m_scratch_buffer internally, but is safe because it alternates reads
|
||||
// and writes.
|
||||
size_t available_frames = Mix(m_scratch_buffer.data(), static_cast<u32>(needed_frames));
|
||||
if (available_frames != needed_frames)
|
||||
{
|
||||
m_float_conversion_buffer[i] =
|
||||
m_scratch_buffer[i] / static_cast<float>(std::numeric_limits<short>::max());
|
||||
ERROR_LOG(AUDIO, "Error decoding surround frames.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
DPL2Decode(m_float_conversion_buffer.data(), available_samples, samples);
|
||||
m_surround_decoder.PutFrames(m_scratch_buffer.data(), needed_frames);
|
||||
m_surround_decoder.ReceiveFrames(samples, num_samples);
|
||||
|
||||
return available_samples;
|
||||
return num_samples;
|
||||
}
|
||||
|
||||
void Mixer::MixerFifo::PushSamples(const short* samples, unsigned int num_samples)
|
||||
|
Reference in New Issue
Block a user