mirror of
https://github.com/RetroDECK/Duckstation.git
synced 2025-01-20 15:25:38 +00:00
Qt: Add default option for cubeb driver
This commit is contained in:
parent
fea00d0149
commit
d6e80de3bf
|
@ -181,7 +181,7 @@ AudioBackend AudioSettingsWidget::getEffectiveBackend() const
|
|||
void AudioSettingsWidget::updateDriverNames()
|
||||
{
|
||||
const AudioBackend backend = getEffectiveBackend();
|
||||
const std::vector<std::string> names = AudioStream::GetDriverNames(backend);
|
||||
const std::vector<std::pair<std::string, std::string>> names = AudioStream::GetDriverNames(backend);
|
||||
|
||||
m_ui.driver->disconnect();
|
||||
m_ui.driver->clear();
|
||||
|
@ -193,11 +193,11 @@ void AudioSettingsWidget::updateDriverNames()
|
|||
else
|
||||
{
|
||||
m_ui.driver->setEnabled(true);
|
||||
for (const std::string& name : names)
|
||||
m_ui.driver->addItem(QString::fromStdString(name));
|
||||
for (const auto& [name, display_name] : names)
|
||||
m_ui.driver->addItem(QString::fromStdString(display_name), QString::fromStdString(name));
|
||||
|
||||
SettingWidgetBinder::BindWidgetToStringSetting(m_dialog->getSettingsInterface(), m_ui.driver, "Audio", "Driver",
|
||||
std::move(names.front()));
|
||||
std::move(names.front().first));
|
||||
connect(m_ui.driver, &QComboBox::currentIndexChanged, this, &AudioSettingsWidget::updateDeviceNames);
|
||||
}
|
||||
|
||||
|
@ -223,11 +223,22 @@ void AudioSettingsWidget::updateDeviceNames()
|
|||
else
|
||||
{
|
||||
m_ui.outputDevice->setEnabled(true);
|
||||
|
||||
bool is_known_device = false;
|
||||
for (const AudioStream::DeviceInfo& di : devices)
|
||||
{
|
||||
m_ui.outputDevice->addItem(QString::fromStdString(di.display_name), QString::fromStdString(di.name));
|
||||
if (di.name == current_device)
|
||||
{
|
||||
m_output_device_latency = di.minimum_latency_frames;
|
||||
is_known_device = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!is_known_device)
|
||||
{
|
||||
m_ui.outputDevice->addItem(tr("Unknown Device \"%1\"").arg(QString::fromStdString(current_device)),
|
||||
QString::fromStdString(current_device));
|
||||
}
|
||||
|
||||
SettingWidgetBinder::BindWidgetToStringSetting(m_dialog->getSettingsInterface(), m_ui.outputDevice, "Audio",
|
||||
|
|
|
@ -249,7 +249,7 @@
|
|||
<item>
|
||||
<widget class="QToolButton" name="resetVolume">
|
||||
<property name="toolTip">
|
||||
<string>Stretch Settings</string>
|
||||
<string>Reset Volume</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="refresh-line"/>
|
||||
|
@ -298,7 +298,7 @@
|
|||
<item>
|
||||
<widget class="QToolButton" name="resetFastForwardVolume">
|
||||
<property name="toolTip">
|
||||
<string>Stretch Settings</string>
|
||||
<string>Reset Fast Forward Volume</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset theme="refresh-line"/>
|
||||
|
|
|
@ -70,16 +70,16 @@ std::unique_ptr<AudioStream> AudioStream::CreateNullStream(u32 sample_rate, u32
|
|||
return stream;
|
||||
}
|
||||
|
||||
#ifndef __ANDROID__
|
||||
|
||||
std::vector<std::string> AudioStream::GetDriverNames(AudioBackend backend)
|
||||
std::vector<std::pair<std::string, std::string>> AudioStream::GetDriverNames(AudioBackend backend)
|
||||
{
|
||||
std::vector<std::string> ret;
|
||||
std::vector<std::pair<std::string, std::string>> ret;
|
||||
switch (backend)
|
||||
{
|
||||
#ifndef __ANDROID__
|
||||
case AudioBackend::Cubeb:
|
||||
ret = GetCubebDriverNames();
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -93,9 +93,11 @@ std::vector<AudioStream::DeviceInfo> AudioStream::GetOutputDevices(AudioBackend
|
|||
std::vector<AudioStream::DeviceInfo> ret;
|
||||
switch (backend)
|
||||
{
|
||||
#ifndef __ANDROID__
|
||||
case AudioBackend::Cubeb:
|
||||
ret = GetCubebOutputDevices(driver);
|
||||
break;
|
||||
#endif
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -110,11 +112,19 @@ std::unique_ptr<AudioStream> AudioStream::CreateStream(AudioBackend backend, u32
|
|||
{
|
||||
switch (backend)
|
||||
{
|
||||
#ifndef __ANDROID__
|
||||
case AudioBackend::Cubeb:
|
||||
return CreateCubebAudioStream(sample_rate, parameters, driver_name, device_name, error);
|
||||
|
||||
case AudioBackend::SDL:
|
||||
return CreateSDLAudioStream(sample_rate, parameters, error);
|
||||
#else
|
||||
case AudioBackend::AAudio:
|
||||
return CreateAAudioAudioStream(sample_rate, parameters, error);
|
||||
|
||||
case AudioBackend::OpenSLES:
|
||||
return CreateOpenSLESAudioStream(sample_rate, parameters, error);
|
||||
#endif
|
||||
|
||||
case AudioBackend::Null:
|
||||
return CreateNullStream(sample_rate, parameters.buffer_ms);
|
||||
|
@ -125,8 +135,6 @@ std::unique_ptr<AudioStream> AudioStream::CreateStream(AudioBackend backend, u32
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
u32 AudioStream::GetAlignedBufferSize(u32 size)
|
||||
{
|
||||
static_assert(Common::IsPow2(CHUNK_SIZE));
|
||||
|
|
|
@ -191,7 +191,7 @@ public:
|
|||
|
||||
void SetStretchMode(AudioStretchMode mode);
|
||||
|
||||
static std::vector<std::string> GetDriverNames(AudioBackend backend);
|
||||
static std::vector<std::pair<std::string, std::string>> GetDriverNames(AudioBackend backend);
|
||||
static std::vector<DeviceInfo> GetOutputDevices(AudioBackend backend, const char* driver);
|
||||
static std::unique_ptr<AudioStream> CreateStream(AudioBackend backend, u32 sample_rate,
|
||||
const AudioStreamParameters& parameters, const char* driver_name,
|
||||
|
@ -241,13 +241,18 @@ private:
|
|||
static constexpr u32 TARGET_IPS = 691;
|
||||
|
||||
#ifndef __ANDROID__
|
||||
static std::vector<std::string> GetCubebDriverNames();
|
||||
static std::vector<std::pair<std::string, std::string>> GetCubebDriverNames();
|
||||
static std::vector<DeviceInfo> GetCubebOutputDevices(const char* driver);
|
||||
static std::unique_ptr<AudioStream> CreateCubebAudioStream(u32 sample_rate, const AudioStreamParameters& parameters,
|
||||
const char* driver_name, const char* device_name,
|
||||
Error* error);
|
||||
static std::unique_ptr<AudioStream> CreateSDLAudioStream(u32 sample_rate, const AudioStreamParameters& parameters,
|
||||
Error* error);
|
||||
#else
|
||||
static std::unique_ptr<AudioStream> CreateAAudioAudioStream(u32 sample_rate, const AudioStreamParameters& parameters,
|
||||
Error* error);
|
||||
static std::unique_ptr<AudioStream> CreateOpenSLESAudioStream(u32 sample_rate,
|
||||
const AudioStreamParameters& parameters, Error* error);
|
||||
#endif
|
||||
|
||||
ALWAYS_INLINE bool IsExpansionEnabled() const { return m_parameters.expansion_mode != AudioExpansionMode::Disabled; }
|
||||
|
|
|
@ -300,19 +300,21 @@ std::unique_ptr<AudioStream> AudioStream::CreateCubebAudioStream(u32 sample_rate
|
|||
return stream;
|
||||
}
|
||||
|
||||
std::vector<std::string> AudioStream::GetCubebDriverNames()
|
||||
std::vector<std::pair<std::string, std::string>> AudioStream::GetCubebDriverNames()
|
||||
{
|
||||
std::vector<std::string> names;
|
||||
std::vector<std::pair<std::string, std::string>> names;
|
||||
names.emplace_back(std::string(), TRANSLATE_STR("AudioStream", "Default"));
|
||||
|
||||
const char** cubeb_names = cubeb_get_backend_names();
|
||||
for (u32 i = 0; cubeb_names[i] != nullptr; i++)
|
||||
names.emplace_back(cubeb_names[i]);
|
||||
names.emplace_back(cubeb_names[i], cubeb_names[i]);
|
||||
return names;
|
||||
}
|
||||
|
||||
std::vector<AudioStream::DeviceInfo> AudioStream::GetCubebOutputDevices(const char* driver)
|
||||
{
|
||||
std::vector<AudioStream::DeviceInfo> ret;
|
||||
ret.emplace_back(std::string(), TRANSLATE_STR("AudioStream", "Default Output Device"), 0);
|
||||
ret.emplace_back(std::string(), TRANSLATE_STR("AudioStream", "Default"), 0);
|
||||
|
||||
cubeb* context;
|
||||
int rv = cubeb_init(&context, "DuckStation", (driver && *driver) ? driver : nullptr);
|
||||
|
|
Loading…
Reference in a new issue