Load up the lists of audio devices in settings

It will now load up a the list of audio input/output devices in the
combo boxes in audio settings.
master
jp9000 2014-03-06 07:02:25 -07:00
parent 4f7ab552df
commit 2448d0f229
6 changed files with 71 additions and 12 deletions

View File

@ -289,7 +289,7 @@ void obs_property_list_add_item(obs_property_t p,
.value = bstrdup(value)
};
da_insert(data->items, data->items.num-1, &item);
da_push_back(data->items, &item);
}
}

View File

@ -205,7 +205,7 @@
<item row="2" column="1">
<widget class="QComboBox" name="desktopAudioDevice1">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
@ -222,7 +222,7 @@
<item row="3" column="1">
<widget class="QComboBox" name="desktopAudioDevice2">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
@ -236,7 +236,7 @@
<item row="4" column="1">
<widget class="QComboBox" name="auxAudioDevice1">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
@ -250,7 +250,7 @@
<item row="5" column="1">
<widget class="QComboBox" name="auxAudioDevice2">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
@ -264,7 +264,7 @@
<item row="6" column="1">
<widget class="QComboBox" name="auxAudioDevice3">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>

View File

@ -271,6 +271,55 @@ void OBSBasicSettings::LoadVideoSettings()
loading = false;
}
static inline void LoadListValue(QComboBox *widget, const char *text,
const char *val)
{
widget->addItem(QT_UTF8(text), QT_UTF8(val));
}
static void LoadListValues(QComboBox *widget, obs_property_t prop)
{
size_t count = obs_property_list_item_count(prop);
widget->addItem(QTStr("Disabled"), "disabled");
for (size_t i = 0; i < count; i++) {
const char *name = obs_property_list_item_name(prop, i);
const char *val = obs_property_list_item_value(prop, i);
LoadListValue(widget, name, val);
}
}
void OBSBasicSettings::LoadAudioDevices()
{
#ifdef __APPLE__
const char *input_id = "coreaudio_input_capture";
const char *output_id = "coreaudio_output_capture";
#elif _WIN32
const char *input_id = "wasapi_input_capture";
const char *output_id = "wasapi_output_capture";
#else
return;
#endif
obs_properties_t input_props = obs_source_properties(
OBS_SOURCE_TYPE_INPUT, input_id, App()->GetLocale());
obs_properties_t output_props = obs_source_properties(
OBS_SOURCE_TYPE_INPUT, output_id, App()->GetLocale());
obs_property_t inputs = obs_properties_get(input_props, "device_id");
obs_property_t outputs = obs_properties_get(output_props, "device_id");
LoadListValues(ui->desktopAudioDevice1, outputs);
LoadListValues(ui->desktopAudioDevice2, outputs);
LoadListValues(ui->auxAudioDevice1, inputs);
LoadListValues(ui->auxAudioDevice2, inputs);
LoadListValues(ui->auxAudioDevice3, inputs);
obs_properties_destroy(input_props);
obs_properties_destroy(output_props);
}
void OBSBasicSettings::LoadAudioSettings()
{
uint32_t sampleRate = config_get_uint(GetGlobalConfig(), "Audio",
@ -301,6 +350,8 @@ void OBSBasicSettings::LoadAudioSettings()
ui->audioBufferingTime->setValue(bufferingTime);
LoadAudioDevices();
loading = false;
}

View File

@ -63,6 +63,9 @@ private:
/* general */
void LoadLanguageList();
/* audio */
void LoadAudioDevices();
/* video */
void LoadRendererList();
void ResetDownscales(uint32_t cx, uint32_t cy);

View File

@ -76,6 +76,8 @@ void GetWASAPIAudioDevices_(vector<AudioDeviceInfo> &devices, bool input)
size = os_wcs_to_utf8(w_id, 0, nullptr);
info.id.resize(size);
os_wcs_to_utf8(w_id, size, &info.id[0]);
devices.push_back(info);
}
}

View File

@ -431,6 +431,9 @@ static obs_properties_t GetWASAPIProperties(const char *locale, bool input)
GetWASAPIAudioDevices(devices, input);
if (devices.size())
obs_property_list_add_item(device_prop, "Default", "default");
for (size_t i = 0; i < devices.size(); i++) {
AudioDeviceInfo &device = devices[i];
obs_property_list_add_item(device_prop,
@ -461,9 +464,9 @@ struct obs_source_info wasapiInput {
CreateWASAPIInput,
DestroyWASAPISource,
GetWASAPIPropertiesInput,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr,
};
struct obs_source_info wasapiOutput {
@ -474,7 +477,7 @@ struct obs_source_info wasapiOutput {
CreateWASAPIOutput,
DestroyWASAPISource,
GetWASAPIPropertiesOutput,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL,
nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr,
nullptr, nullptr, nullptr, nullptr,
};