MCPcopy Create free account
hub / github.com/RPCSX/rpcsx / cellAudioOutConfigure

Function cellAudioOutConfigure

ps3fw/cellAudioOut.cpp:344–440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

342}
343
344error_code cellAudioOutConfigure(u32 audioOut, vm::ptr<CellAudioOutConfiguration> config, vm::ptr<CellAudioOutOption> option, u32 waitForEvent)
345{
346 cellSysutil.warning("cellAudioOutConfigure(audioOut=%d, config=*0x%x, option=*0x%x, waitForEvent=%d)", audioOut, config, option, waitForEvent);
347
348 if (!config)
349 {
350 return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
351 }
352
353 switch (audioOut)
354 {
355 case CELL_AUDIO_OUT_PRIMARY:
356 break;
357 case CELL_AUDIO_OUT_SECONDARY:
358 return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT; // The secondary output only supports one format and can't be reconfigured
359 default:
360 return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
361 }
362
363 bool needs_reset = false;
364
365 audio_out_configuration& cfg = g_fxo->get<audio_out_configuration>();
366 {
367 std::lock_guard lock(cfg.mtx);
368
369 audio_out_configuration::audio_out& out = ::at32(cfg.out, audioOut);
370
371 // Apparently the set config does not necessarily have to exist in the list of sound modes.
372
373 if (out.channels != config->channel || out.encoder != config->encoder || out.downmixer != config->downMixer)
374 {
375 out.channels = config->channel;
376 out.encoder = config->encoder;
377
378 if (config->downMixer > CELL_AUDIO_OUT_DOWNMIXER_TYPE_B) // PS3 ignores invalid downMixer values and keeps the previous valid one instead
379 {
380 cellSysutil.warning("cellAudioOutConfigure: Invalid downmixing mode configured: %d. Keeping old mode: downMixer=%d",
381 config->downMixer, out.downmixer);
382 }
383 else
384 {
385 out.downmixer = config->downMixer;
386 }
387
388 // Try to find the best sound mode for this configuration
389 const auto it = std::find_if(out.sound_modes.cbegin(), out.sound_modes.cend(), [&out](const CellAudioOutSoundMode& mode)
390 {
391 return mode.type == out.encoder && mode.channel == out.channels;
392 });
393
394 if (it != out.sound_modes.cend())
395 {
396 out.sound_mode = *it;
397 }
398 else
399 {
400 cellSysutil.warning("cellAudioOutConfigure: Could not find an ideal sound mode for %d channel output. Keeping old mode: channels=%d, encoder=%d, fs=%d",
401 config->channel, out.sound_mode.channel, out.sound_mode.type, out.sound_mode.fs);

Callers

nothing calls this directly

Calls 5

configure_audioFunction · 0.85
configure_rsxaudioFunction · 0.85
cbeginMethod · 0.45
cendMethod · 0.45
CallFromMainThreadMethod · 0.45

Tested by

no test coverage detected