PSF: move sound format flags to enum

This commit is contained in:
Megamouse 2022-06-01 20:19:45 +02:00
parent 350d3ad386
commit 60d80fd5fc
5 changed files with 35 additions and 19 deletions

View File

@ -44,11 +44,11 @@ audio_out_configuration::audio_out_configuration()
const psf::registry psf = psf::load_object(fs::file(Emu.GetSfoDir() + "/PARAM.SFO"));
if (psf.contains("SOUND_FORMAT")) sound_format = psf.at("SOUND_FORMAT").as_integer();
const bool supports_lpcm_2 = (sound_format & (1 << 0)); // Linear PCM 2 Ch.
const bool supports_lpcm_5_1 = (sound_format & (1 << 2)); // Linear PCM 5.1 Ch.
const bool supports_lpcm_7_1 = (sound_format & (1 << 4)); // Linear PCM 7.1 Ch.
const bool supports_ac3 = (sound_format & (1 << 8)); // Dolby Digital 5.1 Ch.
const bool supports_dts = (sound_format & (1 << 9)); // DTS 5.1 Ch.
const bool supports_lpcm_2 = (sound_format & psf::sound_format_flag::lpcm_2); // Linear PCM 2 Ch.
const bool supports_lpcm_5_1 = (sound_format & psf::sound_format_flag::lpcm_5_1); // Linear PCM 5.1 Ch.
const bool supports_lpcm_7_1 = (sound_format & psf::sound_format_flag::lpcm_7_1); // Linear PCM 7.1 Ch.
const bool supports_ac3 = (sound_format & psf::sound_format_flag::ac3); // Dolby Digital 5.1 Ch.
const bool supports_dts = (sound_format & psf::sound_format_flag::dts); // DTS 5.1 Ch.
if (supports_lpcm_2) cellSysutil.notice("cellAudioOut: found support for Linear PCM 2 Ch.");
if (supports_lpcm_5_1) cellSysutil.notice("cellAudioOut: found support for Linear PCM 5.1 Ch.");

View File

@ -12,6 +12,15 @@ namespace fs
namespace psf
{
enum sound_format_flag : s32
{
lpcm_2 = 1 << 0, // Linear PCM 2 Ch.
lpcm_5_1 = 1 << 2, // Linear PCM 5.1 Ch.
lpcm_7_1 = 1 << 4, // Linear PCM 7.1 Ch.
ac3 = 1 << 8, // Dolby Digital 5.1 Ch.
dts = 1 << 9, // DTS 5.1 Ch.
};
enum class format : u16
{
array = 0x0004, // claimed to be a non-NTS string (char array)

View File

@ -1,4 +1,5 @@
#include "localized.h"
#include "Loader/PSF.h"
QString Localized::GetVerboseTimeByMs(quint64 elapsed_ms, bool show_days) const
{
@ -45,3 +46,14 @@ QString Localized::GetVerboseTimeByMs(quint64 elapsed_ms, bool show_days) const
return str_seconds;
}
Localized::sound::sound()
: format({
{ psf::sound_format_flag::lpcm_2, tr("LPCM 2.0") },
{ psf::sound_format_flag::lpcm_5_1, tr("LPCM 5.1") },
{ psf::sound_format_flag::lpcm_7_1, tr("LPCM 7.1") },
{ psf::sound_format_flag::ac3, tr("Dolby Digital 5.1") },
{ psf::sound_format_flag::dts, tr("DTS 5.1") },
})
{
}

View File

@ -124,14 +124,7 @@ public:
const struct sound
{
const std::map<u32, QString> format
{
{ 1 << 0, tr("LPCM 2.0") },
//{ 1 << 1, tr("LPCM ???") },
{ 1 << 2, tr("LPCM 5.1") },
{ 1 << 4, tr("LPCM 7.1") },
{ 1 << 8, tr("Dolby Digital 5.1") },
{ 1 << 9, tr("DTS 5.1") },
};
sound();
const std::map<u32, QString> format;
} sound;
};

View File

@ -28,6 +28,8 @@
#include "Emu/system_config.h"
#include "Emu/title.h"
#include "Loader/PSF.h"
#include <set>
#include <unordered_set>
#include <thread>
@ -963,11 +965,11 @@ settings_dialog::settings_dialog(std::shared_ptr<gui_settings> gui_settings, std
{
const std::map<u32, std::vector<audio_format>> formats
{
{ 1 << 0, { audio_format::lpcm_2_48khz } },
{ 1 << 2, { audio_format::lpcm_5_1_48khz } },
{ 1 << 4, { audio_format::lpcm_7_1_48khz } },
{ 1 << 8, { audio_format::ac3 } },
{ 1 << 9, { audio_format::dts } },
{ psf::sound_format_flag::lpcm_2, { audio_format::lpcm_2_48khz } },
{ psf::sound_format_flag::lpcm_5_1, { audio_format::lpcm_5_1_48khz } },
{ psf::sound_format_flag::lpcm_7_1, { audio_format::lpcm_7_1_48khz } },
{ psf::sound_format_flag::ac3, { audio_format::ac3 } },
{ psf::sound_format_flag::dts, { audio_format::dts } },
};
const int saved_index = ui->combo_audio_format->currentIndex();