mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
cellAudio: relax FAudio error handling
This commit is contained in:
parent
3f3b4bc363
commit
5f7e5a9844
@ -62,7 +62,11 @@ FAudioBackend::~FAudioBackend()
|
||||
|
||||
void FAudioBackend::Play()
|
||||
{
|
||||
ensure(m_source_voice != nullptr);
|
||||
if (m_source_voice == nullptr)
|
||||
{
|
||||
FAudio_.error("Play() called uninitialized");
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_playing) return;
|
||||
|
||||
@ -78,19 +82,23 @@ void FAudioBackend::Play()
|
||||
|
||||
void FAudioBackend::Pause()
|
||||
{
|
||||
ensure(m_source_voice != nullptr);
|
||||
|
||||
if (m_source_voice)
|
||||
{
|
||||
u32 res = FAudioSourceVoice_Stop(m_source_voice, 0, FAUDIO_COMMIT_NOW);
|
||||
if (res)
|
||||
{
|
||||
FAudio_.error("FAudioSourceVoice_Stop() failed(0x%08x)", res);
|
||||
}
|
||||
|
||||
res = FAudioSourceVoice_FlushSourceBuffers(m_source_voice);
|
||||
if (res)
|
||||
if (res = FAudioSourceVoice_FlushSourceBuffers(m_source_voice))
|
||||
{
|
||||
FAudio_.error("FAudioSourceVoice_FlushSourceBuffers() failed(0x%08x)", res);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
FAudio_.error("Pause() called uninitialized");
|
||||
}
|
||||
|
||||
std::lock_guard lock(m_cb_mutex);
|
||||
m_playing = false;
|
||||
@ -164,7 +172,12 @@ void FAudioBackend::Open(AudioFreq freq, AudioSampleSize sample_size, AudioChann
|
||||
FAudio_.error("FAudio_CreateSourceVoice() failed(0x%08x)", res);
|
||||
}
|
||||
|
||||
ensure(m_source_voice != nullptr);
|
||||
if (m_source_voice == nullptr)
|
||||
{
|
||||
FAudio_.fatal("Failed to open audio backend. Make sure that no other application is running that might block audio access (e.g. Netflix).");
|
||||
return;
|
||||
}
|
||||
|
||||
FAudioVoice_SetVolume(m_source_voice, 1.0f, FAUDIO_COMMIT_NOW);
|
||||
|
||||
m_data_buf_len = get_sampling_rate() * get_sample_size() * get_channels() * INTERNAL_BUF_SIZE_MS * static_cast<u32>(FAUDIO_DEFAULT_FREQ_RATIO) / 1000;
|
||||
@ -173,17 +186,19 @@ void FAudioBackend::Open(AudioFreq freq, AudioSampleSize sample_size, AudioChann
|
||||
|
||||
bool FAudioBackend::IsPlaying()
|
||||
{
|
||||
ensure(m_source_voice != nullptr);
|
||||
|
||||
return m_playing;
|
||||
}
|
||||
|
||||
f32 FAudioBackend::SetFrequencyRatio(f32 new_ratio)
|
||||
{
|
||||
ensure(m_source_voice != nullptr);
|
||||
|
||||
new_ratio = std::clamp(new_ratio, FAUDIO_MIN_FREQ_RATIO, FAUDIO_DEFAULT_FREQ_RATIO);
|
||||
|
||||
if (m_source_voice == nullptr)
|
||||
{
|
||||
FAudio_.error("SetFrequencyRatio() called uninitialized");
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
const u32 res = FAudioSourceVoice_SetFrequencyRatio(m_source_voice, new_ratio, FAUDIO_COMMIT_NOW);
|
||||
if (res)
|
||||
{
|
||||
@ -202,10 +217,15 @@ void FAudioBackend::SetWriteCallback(std::function<u32(u32, void *)> cb)
|
||||
|
||||
f64 FAudioBackend::GetCallbackFrameLen()
|
||||
{
|
||||
ensure(m_source_voice != nullptr);
|
||||
constexpr f64 _10ms = 0.01;
|
||||
|
||||
if (m_instance == nullptr)
|
||||
{
|
||||
FAudio_.error("GetCallbackFrameLen() called uninitialized");
|
||||
return _10ms;
|
||||
}
|
||||
|
||||
f64 min_latency{};
|
||||
const f64 _10ms = 0.01;
|
||||
|
||||
u32 samples_per_q = 0, freq = 0;
|
||||
FAudio_GetProcessingQuantum(m_instance, &samples_per_q, &freq);
|
||||
|
Loading…
Reference in New Issue
Block a user