AudioCommon/Mixer: Allow input sample rate changes

This commit is contained in:
booto 2014-07-24 11:20:19 +08:00
parent e91db62f1b
commit 7d920bbb3a
3 changed files with 25 additions and 4 deletions

View File

@ -181,11 +181,26 @@ void CMixer::PushStreamingSamples(const short *samples, unsigned int num_samples
m_streaming_mixer.PushSamples(samples, num_samples);
}
void CMixer::SetDMAInputSampleRate(unsigned int rate)
{
m_dma_mixer.SetInputSampleRate(rate);
}
void CMixer::SetStreamInputSampleRate(unsigned int rate)
{
m_streaming_mixer.SetInputSampleRate(rate);
}
void CMixer::SetStreamingVolume(unsigned int lvolume, unsigned int rvolume)
{
m_streaming_mixer.SetVolume(lvolume, rvolume);
}
void CMixer::MixerFifo::SetInputSampleRate(unsigned int rate)
{
m_input_sample_rate = rate;
}
void CMixer::MixerFifo::SetVolume(unsigned int lvolume, unsigned int rvolume)
{
m_LVolume = lvolume + (lvolume >> 7);

View File

@ -41,6 +41,9 @@ public:
virtual void PushSamples(const short* samples, unsigned int num_samples);
virtual void PushStreamingSamples(const short* samples, unsigned int num_samples);
unsigned int GetSampleRate() const { return m_sampleRate; }
void SetDMAInputSampleRate(unsigned int rate);
void SetStreamInputSampleRate(unsigned int rate);
void SetStreamingVolume(unsigned int lvolume, unsigned int rvolume);
void SetThrottle(bool use) { m_throttle = use;}
@ -97,6 +100,7 @@ protected:
}
void PushSamples(const short* samples, unsigned int num_samples);
unsigned int Mix(short* samples, unsigned int numSamples, bool consider_framelimit = true);
void SetInputSampleRate(unsigned int rate);
void SetVolume(unsigned int lvolume, unsigned int rvolume);
private:
CMixer *m_mixer;

View File

@ -183,20 +183,22 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
// Set frequency of streaming audio
if (tmpAICtrl.AISFR != m_Control.AISFR)
{
// AISFR rates below are intentionally inverted wrt yagcd
DEBUG_LOG(AUDIO_INTERFACE, "Change AISFR to %s", tmpAICtrl.AISFR ? "48khz":"32khz");
m_Control.AISFR = tmpAICtrl.AISFR;
g_AISSampleRate = tmpAICtrl.AISFR ? 48000 : 32000;
soundStream->GetMixer()->SetStreamInputSampleRate(g_AISSampleRate);
g_CPUCyclesPerSample = SystemTimers::GetTicksPerSecond() / g_AISSampleRate;
}
// Set frequency of DMA
if (tmpAICtrl.AIDFR != m_Control.AIDFR)
{
DEBUG_LOG(AUDIO_INTERFACE, "Change AIDFR to %s", tmpAICtrl.AIDFR ? "32khz":"48khz");
m_Control.AIDFR = tmpAICtrl.AIDFR;
g_AIDSampleRate = tmpAICtrl.AIDFR ? 32000 : 48000;
soundStream->GetMixer()->SetDMAInputSampleRate(g_AIDSampleRate);
}
g_AISSampleRate = tmpAICtrl.AISFR ? 48000 : 32000;
g_AIDSampleRate = tmpAICtrl.AIDFR ? 32000 : 48000;
g_CPUCyclesPerSample = SystemTimers::GetTicksPerSecond() / g_AISSampleRate;
// Streaming counter
if (tmpAICtrl.PSTAT != m_Control.PSTAT)