2020-12-05 13:08:24 +01:00
|
|
|
#include "stdafx.h"
|
2016-03-21 20:43:03 +01:00
|
|
|
#include "Emu/Cell/PPUModule.h"
|
2022-05-28 13:35:28 +02:00
|
|
|
#include "Emu/Cell/lv2/sys_rsxaudio.h"
|
2022-05-28 12:43:15 +02:00
|
|
|
#include "Emu/IdManager.h"
|
2022-05-28 13:35:28 +02:00
|
|
|
#include "Emu/System.h"
|
2015-08-01 18:14:49 +02:00
|
|
|
|
|
|
|
|
#include "cellAudioOut.h"
|
2022-05-28 12:43:15 +02:00
|
|
|
#include "cellAudio.h"
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2020-01-31 10:01:17 +01:00
|
|
|
LOG_CHANNEL(cellSysutil);
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
template<>
|
|
|
|
|
void fmt_class_string<CellAudioOutError>::format(std::string& out, u64 arg)
|
|
|
|
|
{
|
|
|
|
|
format_enum(out, arg, [](auto error)
|
|
|
|
|
{
|
|
|
|
|
switch (error)
|
|
|
|
|
{
|
|
|
|
|
STR_CASE(CELL_AUDIO_OUT_ERROR_NOT_IMPLEMENTED);
|
|
|
|
|
STR_CASE(CELL_AUDIO_OUT_ERROR_ILLEGAL_CONFIGURATION);
|
|
|
|
|
STR_CASE(CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER);
|
|
|
|
|
STR_CASE(CELL_AUDIO_OUT_ERROR_PARAMETER_OUT_OF_RANGE);
|
|
|
|
|
STR_CASE(CELL_AUDIO_OUT_ERROR_DEVICE_NOT_FOUND);
|
|
|
|
|
STR_CASE(CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT);
|
|
|
|
|
STR_CASE(CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE);
|
|
|
|
|
STR_CASE(CELL_AUDIO_OUT_ERROR_CONDITION_BUSY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return unknown;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-28 13:35:28 +02:00
|
|
|
audio_out_configuration::audio_out_configuration()
|
|
|
|
|
{
|
|
|
|
|
CellAudioOutSoundMode mode{};
|
|
|
|
|
|
|
|
|
|
mode.type = CELL_AUDIO_OUT_CODING_TYPE_LPCM;
|
|
|
|
|
mode.channel = CELL_AUDIO_OUT_CHNUM_8;
|
|
|
|
|
mode.fs = CELL_AUDIO_OUT_FS_48KHZ;
|
|
|
|
|
mode.layout = CELL_AUDIO_OUT_SPEAKER_LAYOUT_8CH_LREClrxy;
|
|
|
|
|
|
|
|
|
|
out.at(CELL_AUDIO_OUT_PRIMARY).sound_modes.push_back(mode);
|
|
|
|
|
out.at(CELL_AUDIO_OUT_SECONDARY).sound_modes.push_back(mode);
|
|
|
|
|
|
|
|
|
|
mode.type = CELL_AUDIO_OUT_CODING_TYPE_LPCM;
|
|
|
|
|
mode.channel = CELL_AUDIO_OUT_CHNUM_6;
|
|
|
|
|
mode.fs = CELL_AUDIO_OUT_FS_48KHZ;
|
|
|
|
|
mode.layout = CELL_AUDIO_OUT_SPEAKER_LAYOUT_6CH_LREClr;
|
|
|
|
|
|
|
|
|
|
out.at(CELL_AUDIO_OUT_PRIMARY).sound_modes.push_back(mode);
|
|
|
|
|
out.at(CELL_AUDIO_OUT_SECONDARY).sound_modes.push_back(mode);
|
|
|
|
|
|
|
|
|
|
mode.type = CELL_AUDIO_OUT_CODING_TYPE_LPCM;
|
|
|
|
|
mode.channel = CELL_AUDIO_OUT_CHNUM_2;
|
|
|
|
|
mode.fs = CELL_AUDIO_OUT_FS_48KHZ;
|
|
|
|
|
mode.layout = CELL_AUDIO_OUT_SPEAKER_LAYOUT_2CH;
|
|
|
|
|
|
|
|
|
|
out.at(CELL_AUDIO_OUT_PRIMARY).sound_modes.push_back(mode);
|
|
|
|
|
out.at(CELL_AUDIO_OUT_SECONDARY).sound_modes.push_back(mode);
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-30 09:39:25 +02:00
|
|
|
error_code cellAudioOutGetNumberOfDevice(u32 audioOut);
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellAudioOutGetSoundAvailability(u32 audioOut, u32 type, u32 fs, u32 option)
|
2015-08-01 18:14:49 +02:00
|
|
|
{
|
2016-01-12 22:57:16 +01:00
|
|
|
cellSysutil.warning("cellAudioOutGetSoundAvailability(audioOut=%d, type=%d, fs=0x%x, option=%d)", audioOut, type, fs, option);
|
2015-08-01 18:14:49 +02:00
|
|
|
|
|
|
|
|
s32 available = 8; // should be at least 2
|
|
|
|
|
|
|
|
|
|
switch (fs)
|
|
|
|
|
{
|
|
|
|
|
case CELL_AUDIO_OUT_FS_32KHZ:
|
|
|
|
|
case CELL_AUDIO_OUT_FS_44KHZ:
|
|
|
|
|
case CELL_AUDIO_OUT_FS_48KHZ:
|
|
|
|
|
case CELL_AUDIO_OUT_FS_88KHZ:
|
|
|
|
|
case CELL_AUDIO_OUT_FS_96KHZ:
|
|
|
|
|
case CELL_AUDIO_OUT_FS_176KHZ:
|
|
|
|
|
case CELL_AUDIO_OUT_FS_192KHZ:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case CELL_AUDIO_OUT_CODING_TYPE_LPCM: break;
|
|
|
|
|
case CELL_AUDIO_OUT_CODING_TYPE_AC3: available = 0; break;
|
|
|
|
|
case CELL_AUDIO_OUT_CODING_TYPE_DTS: available = 0; break;
|
|
|
|
|
|
|
|
|
|
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (audioOut)
|
|
|
|
|
{
|
2019-11-15 20:15:00 +01:00
|
|
|
case CELL_AUDIO_OUT_PRIMARY: return not_an_error(available);
|
|
|
|
|
case CELL_AUDIO_OUT_SECONDARY: return not_an_error(0);
|
2015-08-01 18:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_CONFIGURATION;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellAudioOutGetSoundAvailability2(u32 audioOut, u32 type, u32 fs, u32 ch, u32 option)
|
2015-08-01 18:14:49 +02:00
|
|
|
{
|
2016-01-12 22:57:16 +01:00
|
|
|
cellSysutil.warning("cellAudioOutGetSoundAvailability2(audioOut=%d, type=%d, fs=0x%x, ch=%d, option=%d)", audioOut, type, fs, ch, option);
|
2015-08-01 18:14:49 +02:00
|
|
|
|
|
|
|
|
s32 available = 8; // should be at least 2
|
|
|
|
|
|
|
|
|
|
switch (fs)
|
|
|
|
|
{
|
|
|
|
|
case CELL_AUDIO_OUT_FS_32KHZ:
|
|
|
|
|
case CELL_AUDIO_OUT_FS_44KHZ:
|
|
|
|
|
case CELL_AUDIO_OUT_FS_48KHZ:
|
|
|
|
|
case CELL_AUDIO_OUT_FS_88KHZ:
|
|
|
|
|
case CELL_AUDIO_OUT_FS_96KHZ:
|
|
|
|
|
case CELL_AUDIO_OUT_FS_176KHZ:
|
|
|
|
|
case CELL_AUDIO_OUT_FS_192KHZ:
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (ch)
|
|
|
|
|
{
|
|
|
|
|
case 2: break;
|
|
|
|
|
case 6: available = 0; break;
|
|
|
|
|
case 8: available = 0; break;
|
|
|
|
|
|
|
|
|
|
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case CELL_AUDIO_OUT_CODING_TYPE_LPCM: break;
|
|
|
|
|
case CELL_AUDIO_OUT_CODING_TYPE_AC3: available = 0; break;
|
|
|
|
|
case CELL_AUDIO_OUT_CODING_TYPE_DTS: available = 0; break;
|
|
|
|
|
|
|
|
|
|
default: return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_SOUND_MODE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (audioOut)
|
|
|
|
|
{
|
2019-11-15 20:15:00 +01:00
|
|
|
case CELL_AUDIO_OUT_PRIMARY: return not_an_error(available);
|
|
|
|
|
case CELL_AUDIO_OUT_SECONDARY: return not_an_error(0);
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2015-08-01 18:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_CONFIGURATION;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellAudioOutGetState(u32 audioOut, u32 deviceIndex, vm::ptr<CellAudioOutState> state)
|
2015-08-01 18:14:49 +02:00
|
|
|
{
|
2016-01-12 22:57:16 +01:00
|
|
|
cellSysutil.warning("cellAudioOutGetState(audioOut=0x%x, deviceIndex=0x%x, state=*0x%x)", audioOut, deviceIndex, state);
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
if (!state)
|
|
|
|
|
{
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2020-04-30 09:39:25 +02:00
|
|
|
const auto num = cellAudioOutGetNumberOfDevice(audioOut);
|
|
|
|
|
|
|
|
|
|
if (num < 0)
|
2015-08-01 18:14:49 +02:00
|
|
|
{
|
2020-04-30 09:39:25 +02:00
|
|
|
return num;
|
|
|
|
|
}
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2022-05-28 12:43:15 +02:00
|
|
|
CellAudioOutState _state{};
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2020-04-30 09:39:25 +02:00
|
|
|
if (deviceIndex >= num + 0u)
|
|
|
|
|
{
|
|
|
|
|
if (audioOut == CELL_AUDIO_OUT_SECONDARY)
|
|
|
|
|
{
|
|
|
|
|
// Error codes are not returned here
|
|
|
|
|
// Random (uninitialized) data from the stack seems to be returned here
|
|
|
|
|
// Although it was constant on my tests so let's write that
|
|
|
|
|
_state.state = 0x10;
|
|
|
|
|
_state.soundMode.layout = 0xD00C1680;
|
2022-05-28 12:43:15 +02:00
|
|
|
*state = _state;
|
2020-04-30 09:39:25 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_PARAMETER_OUT_OF_RANGE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (audioOut)
|
|
|
|
|
{
|
|
|
|
|
case CELL_AUDIO_OUT_PRIMARY:
|
2015-08-01 18:14:49 +02:00
|
|
|
case CELL_AUDIO_OUT_SECONDARY:
|
2020-04-30 09:39:25 +02:00
|
|
|
{
|
2022-05-28 13:35:28 +02:00
|
|
|
const AudioChannelCnt channels = AudioBackend::get_channel_count(g_cfg.audio.audio_channel_downmix);
|
|
|
|
|
|
|
|
|
|
audio_out_configuration& cfg = g_fxo->get<audio_out_configuration>();
|
|
|
|
|
std::lock_guard lock(cfg.mtx);
|
|
|
|
|
audio_out_configuration::audio_out& out = cfg.out.at(audioOut);
|
|
|
|
|
|
|
|
|
|
const auto it = std::find_if(out.sound_modes.cbegin(), out.sound_modes.cend(), [&channels, &out](const CellAudioOutSoundMode& mode)
|
|
|
|
|
{
|
|
|
|
|
if (mode.type == out.encoder)
|
|
|
|
|
{
|
|
|
|
|
switch (mode.type)
|
|
|
|
|
{
|
|
|
|
|
case CELL_AUDIO_OUT_CODING_TYPE_LPCM:
|
|
|
|
|
return mode.channel == static_cast<u8>(channels);
|
|
|
|
|
case CELL_AUDIO_OUT_CODING_TYPE_AC3:
|
|
|
|
|
case CELL_AUDIO_OUT_CODING_TYPE_DTS:
|
|
|
|
|
return true; // We currently only have one possible sound mode for these types
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ensure(it != out.sound_modes.cend());
|
|
|
|
|
|
|
|
|
|
_state.state = out.state;
|
|
|
|
|
_state.encoder = out.encoder;
|
|
|
|
|
_state.downMixer = out.downmixer;
|
|
|
|
|
_state.soundMode = *it;
|
2020-04-30 09:39:25 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
|
2015-08-01 18:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
2022-05-28 12:43:15 +02:00
|
|
|
*state = _state;
|
2020-04-30 09:39:25 +02:00
|
|
|
return CELL_OK;
|
2015-08-01 18:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellAudioOutConfigure(u32 audioOut, vm::ptr<CellAudioOutConfiguration> config, vm::ptr<CellAudioOutOption> option, u32 waitForEvent)
|
2015-08-01 18:14:49 +02:00
|
|
|
{
|
2016-01-12 22:57:16 +01:00
|
|
|
cellSysutil.warning("cellAudioOutConfigure(audioOut=%d, config=*0x%x, option=*0x%x, waitForEvent=%d)", audioOut, config, option, waitForEvent);
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
if (!config)
|
|
|
|
|
{
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-01 18:14:49 +02:00
|
|
|
switch (audioOut)
|
|
|
|
|
{
|
|
|
|
|
case CELL_AUDIO_OUT_PRIMARY:
|
2022-05-28 12:43:15 +02:00
|
|
|
break;
|
|
|
|
|
case CELL_AUDIO_OUT_SECONDARY:
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT;
|
|
|
|
|
default:
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
audio_out_configuration::audio_out out_old;
|
|
|
|
|
audio_out_configuration::audio_out out_new;
|
|
|
|
|
|
2022-05-28 13:35:28 +02:00
|
|
|
audio_out_configuration& cfg = g_fxo->get<audio_out_configuration>();
|
2020-04-30 09:39:25 +02:00
|
|
|
{
|
2022-05-28 12:43:15 +02:00
|
|
|
std::lock_guard lock(cfg.mtx);
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2022-05-28 12:43:15 +02:00
|
|
|
audio_out_configuration::audio_out& out = cfg.out.at(audioOut);
|
2022-05-28 13:35:28 +02:00
|
|
|
|
|
|
|
|
if (out.sound_modes.cend() == std::find_if(out.sound_modes.cbegin(), out.sound_modes.cend(), [&config](const CellAudioOutSoundMode& mode)
|
|
|
|
|
{
|
|
|
|
|
return mode.channel == config->channel && mode.type == config->encoder && config->downMixer <= CELL_AUDIO_OUT_DOWNMIXER_TYPE_B;
|
|
|
|
|
}))
|
|
|
|
|
{
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_CONFIGURATION; // TODO: confirm
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-28 12:43:15 +02:00
|
|
|
out_old = out;
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2022-05-28 12:43:15 +02:00
|
|
|
out.channels = config->channel;
|
|
|
|
|
out.encoder = config->encoder;
|
|
|
|
|
out.downmixer = config->downMixer;
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2022-05-28 12:43:15 +02:00
|
|
|
out_new = out;
|
2020-04-30 09:39:25 +02:00
|
|
|
}
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2022-05-28 12:43:15 +02:00
|
|
|
if (g_cfg.audio.audio_channel_downmix == audio_downmix::use_application_settings &&
|
|
|
|
|
std::memcmp(&out_old, &out_new, sizeof(audio_out_configuration::audio_out)) != 0)
|
|
|
|
|
{
|
2022-05-28 13:35:28 +02:00
|
|
|
const auto reset_audio = [audioOut]() -> void
|
|
|
|
|
{
|
|
|
|
|
audio_out_configuration& cfg = g_fxo->get<audio_out_configuration>();
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard lock(cfg.mtx);
|
|
|
|
|
cfg.out.at(audioOut).state = CELL_AUDIO_OUT_OUTPUT_STATE_DISABLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
audio::configure_audio();
|
|
|
|
|
audio::configure_rsxaudio();
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
std::lock_guard lock(cfg.mtx);
|
|
|
|
|
cfg.out.at(audioOut).state = CELL_AUDIO_OUT_OUTPUT_STATE_ENABLED;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (waitForEvent)
|
|
|
|
|
{
|
|
|
|
|
reset_audio();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Emu.CallFromMainThread(reset_audio);
|
|
|
|
|
}
|
2015-08-01 18:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
2022-05-28 12:43:15 +02:00
|
|
|
cellSysutil.notice("cellAudioOutConfigure: channels=%d, encoder=%d, downMixer=%d", config->channel, config->encoder, config->downMixer);
|
|
|
|
|
|
|
|
|
|
return CELL_OK;
|
2015-08-01 18:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellAudioOutGetConfiguration(u32 audioOut, vm::ptr<CellAudioOutConfiguration> config, vm::ptr<CellAudioOutOption> option)
|
2015-08-01 18:14:49 +02:00
|
|
|
{
|
2016-01-12 22:57:16 +01:00
|
|
|
cellSysutil.warning("cellAudioOutGetConfiguration(audioOut=%d, config=*0x%x, option=*0x%x)", audioOut, config, option);
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
if (!config)
|
|
|
|
|
{
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-01 18:14:49 +02:00
|
|
|
switch (audioOut)
|
|
|
|
|
{
|
|
|
|
|
case CELL_AUDIO_OUT_PRIMARY:
|
2020-04-30 09:39:25 +02:00
|
|
|
break;
|
2015-08-01 18:14:49 +02:00
|
|
|
case CELL_AUDIO_OUT_SECONDARY:
|
2020-04-30 09:39:25 +02:00
|
|
|
return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT;
|
2019-11-15 20:15:00 +01:00
|
|
|
default:
|
2020-04-30 09:39:25 +02:00
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
|
2015-08-01 18:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
2022-05-28 12:43:15 +02:00
|
|
|
audio_out_configuration& cfg = g_fxo->get<audio_out_configuration>();
|
|
|
|
|
std::lock_guard lock(cfg.mtx);
|
|
|
|
|
|
|
|
|
|
CellAudioOutConfiguration _config{};
|
|
|
|
|
|
|
|
|
|
audio_out_configuration::audio_out& out = cfg.out.at(audioOut);
|
|
|
|
|
_config.channel = out.channels;
|
|
|
|
|
_config.encoder = out.encoder;
|
|
|
|
|
_config.downMixer = out.downmixer;
|
|
|
|
|
|
|
|
|
|
*config = _config;
|
2020-04-30 09:39:25 +02:00
|
|
|
return CELL_OK;
|
2015-08-01 18:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellAudioOutGetNumberOfDevice(u32 audioOut)
|
2015-08-01 18:14:49 +02:00
|
|
|
{
|
2016-01-12 22:57:16 +01:00
|
|
|
cellSysutil.warning("cellAudioOutGetNumberOfDevice(audioOut=%d)", audioOut);
|
2015-08-01 18:14:49 +02:00
|
|
|
|
|
|
|
|
switch (audioOut)
|
|
|
|
|
{
|
2019-11-15 20:15:00 +01:00
|
|
|
case CELL_AUDIO_OUT_PRIMARY:
|
|
|
|
|
return not_an_error(1);
|
|
|
|
|
case CELL_AUDIO_OUT_SECONDARY:
|
|
|
|
|
return not_an_error(0);
|
|
|
|
|
default:
|
|
|
|
|
break;
|
2015-08-01 18:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-30 09:39:25 +02:00
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
|
2015-08-01 18:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellAudioOutGetDeviceInfo(u32 audioOut, u32 deviceIndex, vm::ptr<CellAudioOutDeviceInfo> info)
|
2015-08-01 18:14:49 +02:00
|
|
|
{
|
2016-01-12 22:57:16 +01:00
|
|
|
cellSysutil.todo("cellAudioOutGetDeviceInfo(audioOut=%d, deviceIndex=%d, info=*0x%x)", audioOut, deviceIndex, info);
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
if (!info)
|
|
|
|
|
{
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-30 09:39:25 +02:00
|
|
|
const auto num = cellAudioOutGetNumberOfDevice(audioOut);
|
|
|
|
|
|
|
|
|
|
if (num < 0)
|
2019-11-15 20:15:00 +01:00
|
|
|
{
|
2020-04-30 09:39:25 +02:00
|
|
|
return num;
|
2019-11-15 20:15:00 +01:00
|
|
|
}
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2020-04-30 09:39:25 +02:00
|
|
|
if (deviceIndex >= num + 0u)
|
|
|
|
|
{
|
|
|
|
|
if (audioOut == CELL_AUDIO_OUT_SECONDARY)
|
|
|
|
|
{
|
|
|
|
|
// Error codes are not returned here
|
2022-05-28 12:43:15 +02:00
|
|
|
*info = {};
|
2020-04-30 09:39:25 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_PARAMETER_OUT_OF_RANGE;
|
|
|
|
|
}
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2022-05-28 13:35:28 +02:00
|
|
|
audio_out_configuration& cfg = g_fxo->get<audio_out_configuration>();
|
|
|
|
|
std::lock_guard lock(cfg.mtx);
|
|
|
|
|
ensure(audioOut < cfg.out.size());
|
|
|
|
|
audio_out_configuration::audio_out& out = cfg.out.at(audioOut);
|
|
|
|
|
ensure(out.sound_modes.size() <= 16);
|
|
|
|
|
|
2022-05-28 12:43:15 +02:00
|
|
|
CellAudioOutDeviceInfo _info{};
|
2020-04-30 09:39:25 +02:00
|
|
|
|
|
|
|
|
_info.portType = CELL_AUDIO_OUT_PORT_HDMI;
|
2022-05-28 13:35:28 +02:00
|
|
|
_info.availableModeCount = ::narrow<u8>(out.sound_modes.size());
|
2020-04-30 09:39:25 +02:00
|
|
|
_info.state = CELL_AUDIO_OUT_DEVICE_STATE_AVAILABLE;
|
|
|
|
|
_info.latency = 1000;
|
2022-05-28 13:35:28 +02:00
|
|
|
|
|
|
|
|
for (usz i = 0; i < out.sound_modes.size(); i++)
|
|
|
|
|
{
|
|
|
|
|
_info.availableModes[i] = out.sound_modes.at(i);
|
|
|
|
|
}
|
2020-04-30 09:39:25 +02:00
|
|
|
|
2022-05-28 12:43:15 +02:00
|
|
|
*info = _info;
|
2015-08-01 18:14:49 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellAudioOutSetCopyControl(u32 audioOut, u32 control)
|
2015-08-01 18:14:49 +02:00
|
|
|
{
|
2016-01-12 22:57:16 +01:00
|
|
|
cellSysutil.warning("cellAudioOutSetCopyControl(audioOut=%d, control=%d)", audioOut, control);
|
2015-08-01 18:14:49 +02:00
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
if (control > CELL_AUDIO_OUT_COPY_CONTROL_COPY_NEVER)
|
2015-08-01 18:14:49 +02:00
|
|
|
{
|
2019-11-15 20:15:00 +01:00
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
|
2015-08-01 18:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
switch (audioOut)
|
2015-08-01 18:14:49 +02:00
|
|
|
{
|
2019-11-15 20:15:00 +01:00
|
|
|
case CELL_AUDIO_OUT_PRIMARY:
|
2015-08-01 18:14:49 +02:00
|
|
|
break;
|
2020-04-30 09:39:25 +02:00
|
|
|
case CELL_AUDIO_OUT_SECONDARY:
|
2019-11-15 20:15:00 +01:00
|
|
|
return CELL_AUDIO_OUT_ERROR_UNSUPPORTED_AUDIO_OUT;
|
2020-04-30 09:39:25 +02:00
|
|
|
default:
|
|
|
|
|
return CELL_AUDIO_OUT_ERROR_ILLEGAL_PARAMETER;
|
2015-08-01 18:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
2022-05-28 12:43:15 +02:00
|
|
|
audio_out_configuration& cfg = g_fxo->get<audio_out_configuration>();
|
|
|
|
|
std::lock_guard lock(cfg.mtx);
|
|
|
|
|
|
|
|
|
|
cfg.out.at(audioOut).copy_control = control;
|
|
|
|
|
|
2015-08-01 18:14:49 +02:00
|
|
|
return CELL_OK;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellAudioOutRegisterCallback()
|
2015-08-01 18:14:49 +02:00
|
|
|
{
|
2019-09-02 13:41:57 +02:00
|
|
|
cellSysutil.todo("cellAudioOutRegisterCallback()");
|
|
|
|
|
return CELL_OK;
|
2015-08-01 18:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
2019-11-15 20:15:00 +01:00
|
|
|
error_code cellAudioOutUnregisterCallback()
|
2015-08-01 18:14:49 +02:00
|
|
|
{
|
2019-09-02 13:41:57 +02:00
|
|
|
cellSysutil.todo("cellAudioOutUnregisterCallback()");
|
|
|
|
|
return CELL_OK;
|
2015-08-01 18:14:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void cellSysutil_AudioOut_init()
|
|
|
|
|
{
|
|
|
|
|
REG_FUNC(cellSysutil, cellAudioOutGetState);
|
|
|
|
|
REG_FUNC(cellSysutil, cellAudioOutConfigure);
|
|
|
|
|
REG_FUNC(cellSysutil, cellAudioOutGetSoundAvailability);
|
|
|
|
|
REG_FUNC(cellSysutil, cellAudioOutGetSoundAvailability2);
|
|
|
|
|
REG_FUNC(cellSysutil, cellAudioOutGetDeviceInfo);
|
|
|
|
|
REG_FUNC(cellSysutil, cellAudioOutGetNumberOfDevice);
|
|
|
|
|
REG_FUNC(cellSysutil, cellAudioOutGetConfiguration);
|
|
|
|
|
REG_FUNC(cellSysutil, cellAudioOutSetCopyControl);
|
|
|
|
|
REG_FUNC(cellSysutil, cellAudioOutRegisterCallback);
|
|
|
|
|
REG_FUNC(cellSysutil, cellAudioOutUnregisterCallback);
|
|
|
|
|
}
|