CoreAudio: fix properties for input/output
Also, check that audio devices are available before setting defaults
This commit is contained in:
parent
03fc5b92b3
commit
806837873a
@ -48,8 +48,30 @@ OBSBasic::OBSBasic(QWidget *parent)
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
static inline bool HasAudioDevices(const char *source_id)
|
||||
{
|
||||
const char *output_id = source_id;
|
||||
obs_properties_t props = obs_source_properties(
|
||||
OBS_SOURCE_TYPE_INPUT, output_id, App()->GetLocale());
|
||||
size_t count = 0;
|
||||
|
||||
if (!props)
|
||||
return false;
|
||||
|
||||
obs_property_t devices = obs_properties_get(props, "device_id");
|
||||
if (devices)
|
||||
count = obs_property_list_item_count(devices);
|
||||
|
||||
obs_properties_destroy(props);
|
||||
|
||||
return count != 0;
|
||||
}
|
||||
|
||||
bool OBSBasic::InitBasicConfigDefaults()
|
||||
{
|
||||
bool hasDesktopAudio = HasAudioDevices(App()->OutputAudioSource());
|
||||
bool hasInputAudio = HasAudioDevices(App()->InputAudioSource());
|
||||
|
||||
config_set_default_int(basicConfig, "Window", "PosX", -1);
|
||||
config_set_default_int(basicConfig, "Window", "PosY", -1);
|
||||
config_set_default_int(basicConfig, "Window", "SizeX", -1);
|
||||
@ -93,11 +115,11 @@ bool OBSBasic::InitBasicConfigDefaults()
|
||||
config_set_default_uint (basicConfig, "Audio", "BufferingTime", 1000);
|
||||
|
||||
config_set_default_string(basicConfig, "Audio", "DesktopDevice1",
|
||||
"default");
|
||||
hasDesktopAudio ? "default" : "disabled");
|
||||
config_set_default_string(basicConfig, "Audio", "DesktopDevice2",
|
||||
"disabled");
|
||||
config_set_default_string(basicConfig, "Audio", "AuxDevice1",
|
||||
"default");
|
||||
hasInputAudio ? "default" : "disabled");
|
||||
config_set_default_string(basicConfig, "Audio", "AuxDevice2",
|
||||
"disabled");
|
||||
config_set_default_string(basicConfig, "Audio", "AuxDevice3",
|
||||
|
@ -371,34 +371,32 @@ void OBSBasicSettings::LoadListValues(QComboBox *widget, obs_property_t prop,
|
||||
|
||||
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
|
||||
const char *input_id;
|
||||
const char *output_id;
|
||||
return;
|
||||
#endif
|
||||
const char *input_id = App()->InputAudioSource();
|
||||
const char *output_id = App()->OutputAudioSource();
|
||||
|
||||
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");
|
||||
if (input_props) {
|
||||
obs_property_t inputs = obs_properties_get(input_props,
|
||||
"device_id");
|
||||
LoadListValues(ui->auxAudioDevice1, inputs, "AuxDevice1");
|
||||
LoadListValues(ui->auxAudioDevice2, inputs, "AuxDevice2");
|
||||
LoadListValues(ui->auxAudioDevice3, inputs, "AuxDevice3");
|
||||
obs_properties_destroy(input_props);
|
||||
}
|
||||
|
||||
LoadListValues(ui->desktopAudioDevice1, outputs, "DesktopDevice1");
|
||||
LoadListValues(ui->desktopAudioDevice2, outputs, "DesktopDevice2");
|
||||
LoadListValues(ui->auxAudioDevice1, inputs, "AuxDevice1");
|
||||
LoadListValues(ui->auxAudioDevice2, inputs, "AuxDevice2");
|
||||
LoadListValues(ui->auxAudioDevice3, inputs, "AuxDevice3");
|
||||
|
||||
obs_properties_destroy(input_props);
|
||||
obs_properties_destroy(output_props);
|
||||
if (output_props) {
|
||||
obs_property_t outputs = obs_properties_get(output_props,
|
||||
"device_id");
|
||||
LoadListValues(ui->desktopAudioDevice1, outputs,
|
||||
"DesktopDevice1");
|
||||
LoadListValues(ui->desktopAudioDevice2, outputs,
|
||||
"DesktopDevice2");
|
||||
obs_properties_destroy(output_props);
|
||||
}
|
||||
}
|
||||
|
||||
void OBSBasicSettings::LoadAudioSettings()
|
||||
|
@ -749,7 +749,7 @@ struct obs_source_info coreaudio_input_capture_info = {
|
||||
.create = coreaudio_create_input_capture,
|
||||
.destroy = coreaudio_destroy,
|
||||
.defaults = coreaudio_defaults,
|
||||
.properties = coreaudio_output_properties
|
||||
.properties = coreaudio_input_properties
|
||||
};
|
||||
|
||||
struct obs_source_info coreaudio_output_capture_info = {
|
||||
@ -760,5 +760,5 @@ struct obs_source_info coreaudio_output_capture_info = {
|
||||
.create = coreaudio_create_output_capture,
|
||||
.destroy = coreaudio_destroy,
|
||||
.defaults = coreaudio_defaults,
|
||||
.properties = coreaudio_input_properties
|
||||
.properties = coreaudio_output_properties
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user