Qt: Fix incorrect minimum latency display

This commit is contained in:
Stenzek 2024-05-12 17:09:03 +10:00
parent a4a35b7e58
commit c803c4fbef
No known key found for this signature in database
4 changed files with 8 additions and 7 deletions

View file

@ -209,7 +209,8 @@ void AudioSettingsWidget::updateDeviceNames()
const AudioBackend backend = getEffectiveBackend();
const std::string driver_name = m_dialog->getEffectiveStringValue("Audio", "Driver", "");
const std::string current_device = m_dialog->getEffectiveStringValue("Audio", "Device", "");
const std::vector<AudioStream::DeviceInfo> devices = AudioStream::GetOutputDevices(backend, driver_name.c_str());
const std::vector<AudioStream::DeviceInfo> devices =
AudioStream::GetOutputDevices(backend, driver_name.c_str(), SPU::SAMPLE_RATE);
m_ui.outputDevice->disconnect();
m_ui.outputDevice->clear();

View file

@ -88,14 +88,14 @@ std::vector<std::pair<std::string, std::string>> AudioStream::GetDriverNames(Aud
return ret;
}
std::vector<AudioStream::DeviceInfo> AudioStream::GetOutputDevices(AudioBackend backend, const char* driver)
std::vector<AudioStream::DeviceInfo> AudioStream::GetOutputDevices(AudioBackend backend, const char* driver, u32 sample_rate)
{
std::vector<AudioStream::DeviceInfo> ret;
switch (backend)
{
#ifndef __ANDROID__
case AudioBackend::Cubeb:
ret = GetCubebOutputDevices(driver);
ret = GetCubebOutputDevices(driver, sample_rate);
break;
#endif

View file

@ -192,7 +192,7 @@ public:
void SetStretchMode(AudioStretchMode mode);
static std::vector<std::pair<std::string, std::string>> GetDriverNames(AudioBackend backend);
static std::vector<DeviceInfo> GetOutputDevices(AudioBackend backend, const char* driver);
static std::vector<DeviceInfo> GetOutputDevices(AudioBackend backend, const char* driver, u32 sample_rate);
static std::unique_ptr<AudioStream> CreateStream(AudioBackend backend, u32 sample_rate,
const AudioStreamParameters& parameters, const char* driver_name,
const char* device_name, Error* error = nullptr);
@ -242,7 +242,7 @@ private:
#ifndef __ANDROID__
static std::vector<std::pair<std::string, std::string>> GetCubebDriverNames();
static std::vector<DeviceInfo> GetCubebOutputDevices(const char* driver);
static std::vector<DeviceInfo> GetCubebOutputDevices(const char* driver, u32 sample_rate);
static std::unique_ptr<AudioStream> CreateCubebAudioStream(u32 sample_rate, const AudioStreamParameters& parameters,
const char* driver_name, const char* device_name,
Error* error);

View file

@ -311,7 +311,7 @@ std::vector<std::pair<std::string, std::string>> AudioStream::GetCubebDriverName
return names;
}
std::vector<AudioStream::DeviceInfo> AudioStream::GetCubebOutputDevices(const char* driver)
std::vector<AudioStream::DeviceInfo> AudioStream::GetCubebOutputDevices(const char* driver, u32 sample_rate)
{
std::vector<AudioStream::DeviceInfo> ret;
ret.emplace_back(std::string(), TRANSLATE_STR("AudioStream", "Default"), 0);
@ -339,7 +339,7 @@ std::vector<AudioStream::DeviceInfo> AudioStream::GetCubebOutputDevices(const ch
// we need stream parameters to query latency
cubeb_stream_params params = {};
params.format = CUBEB_SAMPLE_S16LE;
params.rate = 48000;
params.rate = sample_rate;
params.channels = 2;
params.layout = CUBEB_LAYOUT_UNDEFINED;
params.prefs = CUBEB_STREAM_PREF_NONE;