mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 13:20:27 -06:00
AudioInterface: Use anonymous namespace for static functions
This commit is contained in:
@ -132,13 +132,64 @@ void DoState(PointerWrap& p)
|
|||||||
sound_stream->GetMixer()->DoState(p);
|
sound_stream->GetMixer()->DoState(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GenerateAudioInterrupt();
|
namespace
|
||||||
static void UpdateInterrupts();
|
{
|
||||||
static void IncreaseSampleCount(u32 amount);
|
CoreTiming::EventType* event_type_ai;
|
||||||
static int GetAIPeriod();
|
|
||||||
static void Update(u64 userdata, s64 cycles_late);
|
|
||||||
|
|
||||||
static CoreTiming::EventType* event_type_ai;
|
void UpdateInterrupts()
|
||||||
|
{
|
||||||
|
ProcessorInterface::SetInterrupt(ProcessorInterface::INT_CAUSE_AI,
|
||||||
|
s_control.AIINT & s_control.AIINTMSK);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GenerateAudioInterrupt()
|
||||||
|
{
|
||||||
|
s_control.AIINT = 1;
|
||||||
|
UpdateInterrupts();
|
||||||
|
}
|
||||||
|
|
||||||
|
void IncreaseSampleCount(const u32 amount)
|
||||||
|
{
|
||||||
|
if (!IsPlaying())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const u32 old_sample_counter = s_sample_counter + 1;
|
||||||
|
s_sample_counter += amount;
|
||||||
|
|
||||||
|
if ((s_interrupt_timing - old_sample_counter) <= (s_sample_counter - old_sample_counter))
|
||||||
|
{
|
||||||
|
DEBUG_LOG_FMT(AUDIO_INTERFACE,
|
||||||
|
"GenerateAudioInterrupt {:08x}:{:08x} at PC {:08x} s_control.AIINTVLD={}",
|
||||||
|
s_sample_counter, s_interrupt_timing, PowerPC::ppcState.pc, s_control.AIINTVLD);
|
||||||
|
GenerateAudioInterrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetAIPeriod()
|
||||||
|
{
|
||||||
|
u64 period = s_cpu_cycles_per_sample * (s_interrupt_timing - s_sample_counter);
|
||||||
|
u64 s_period =
|
||||||
|
s_cpu_cycles_per_sample * Mixer::FIXED_SAMPLE_RATE_DIVIDEND / s_ais_sample_rate_divisor;
|
||||||
|
if (period == 0)
|
||||||
|
return static_cast<int>(s_period);
|
||||||
|
return static_cast<int>(std::min(period, s_period));
|
||||||
|
}
|
||||||
|
|
||||||
|
void Update(u64 userdata, s64 cycles_late)
|
||||||
|
{
|
||||||
|
if (!IsPlaying())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const u64 diff = CoreTiming::GetTicks() - s_last_cpu_time;
|
||||||
|
if (diff > s_cpu_cycles_per_sample)
|
||||||
|
{
|
||||||
|
const u32 samples = static_cast<u32>(diff / s_cpu_cycles_per_sample);
|
||||||
|
s_last_cpu_time += samples * s_cpu_cycles_per_sample;
|
||||||
|
IncreaseSampleCount(samples);
|
||||||
|
}
|
||||||
|
CoreTiming::ScheduleEvent(GetAIPeriod() - cycles_late, event_type_ai);
|
||||||
|
}
|
||||||
|
} // namespace
|
||||||
|
|
||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
@ -276,40 +327,11 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UpdateInterrupts()
|
|
||||||
{
|
|
||||||
ProcessorInterface::SetInterrupt(ProcessorInterface::INT_CAUSE_AI,
|
|
||||||
s_control.AIINT & s_control.AIINTMSK);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void GenerateAudioInterrupt()
|
|
||||||
{
|
|
||||||
s_control.AIINT = 1;
|
|
||||||
UpdateInterrupts();
|
|
||||||
}
|
|
||||||
|
|
||||||
void GenerateAISInterrupt()
|
void GenerateAISInterrupt()
|
||||||
{
|
{
|
||||||
GenerateAudioInterrupt();
|
GenerateAudioInterrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void IncreaseSampleCount(const u32 amount)
|
|
||||||
{
|
|
||||||
if (!IsPlaying())
|
|
||||||
return;
|
|
||||||
|
|
||||||
const u32 old_sample_counter = s_sample_counter + 1;
|
|
||||||
s_sample_counter += amount;
|
|
||||||
|
|
||||||
if ((s_interrupt_timing - old_sample_counter) <= (s_sample_counter - old_sample_counter))
|
|
||||||
{
|
|
||||||
DEBUG_LOG_FMT(AUDIO_INTERFACE,
|
|
||||||
"GenerateAudioInterrupt {:08x}:{:08x} at PC {:08x} s_control.AIINTVLD={}",
|
|
||||||
s_sample_counter, s_interrupt_timing, PowerPC::ppcState.pc, s_control.AIINTVLD);
|
|
||||||
GenerateAudioInterrupt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsPlaying()
|
bool IsPlaying()
|
||||||
{
|
{
|
||||||
return (s_control.PSTAT == 1);
|
return (s_control.PSTAT == 1);
|
||||||
@ -334,30 +356,4 @@ u32 Get48KHzSampleRateDivisor()
|
|||||||
{
|
{
|
||||||
return (SConfig::GetInstance().bWii ? 1125 : 1124) * 2;
|
return (SConfig::GetInstance().bWii ? 1125 : 1124) * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Update(u64 userdata, s64 cycles_late)
|
|
||||||
{
|
|
||||||
if (!IsPlaying())
|
|
||||||
return;
|
|
||||||
|
|
||||||
const u64 diff = CoreTiming::GetTicks() - s_last_cpu_time;
|
|
||||||
if (diff > s_cpu_cycles_per_sample)
|
|
||||||
{
|
|
||||||
const u32 samples = static_cast<u32>(diff / s_cpu_cycles_per_sample);
|
|
||||||
s_last_cpu_time += samples * s_cpu_cycles_per_sample;
|
|
||||||
IncreaseSampleCount(samples);
|
|
||||||
}
|
|
||||||
CoreTiming::ScheduleEvent(GetAIPeriod() - cycles_late, event_type_ai);
|
|
||||||
}
|
|
||||||
|
|
||||||
int GetAIPeriod()
|
|
||||||
{
|
|
||||||
u64 period = s_cpu_cycles_per_sample * (s_interrupt_timing - s_sample_counter);
|
|
||||||
u64 s_period =
|
|
||||||
s_cpu_cycles_per_sample * Mixer::FIXED_SAMPLE_RATE_DIVIDEND / s_ais_sample_rate_divisor;
|
|
||||||
if (period == 0)
|
|
||||||
return static_cast<int>(s_period);
|
|
||||||
return static_cast<int>(std::min(period, s_period));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace AudioInterface
|
} // namespace AudioInterface
|
||||||
|
Reference in New Issue
Block a user