mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-05-19 13:56:06 -04:00
UI: Use get_new_source_name instead of strprintf
Remove a bit of duplicated code, and fix non-Windows compilation. This is a bit of a workaround to not have to modify cmake, but might as well reuse a function that already exists anyway rather than duplicate the code.
This commit is contained in:
@@ -4412,24 +4412,7 @@ bool OBSBasic::ResetAudio()
|
||||
return obs_reset_audio(&ai);
|
||||
}
|
||||
|
||||
extern std::string strprintf(const char *format, ...);
|
||||
|
||||
static std::string GetDupName(const char *name)
|
||||
{
|
||||
std::string newName = name;
|
||||
int inc = 1;
|
||||
|
||||
for (;;) {
|
||||
OBSSourceAutoRelease existing_source =
|
||||
obs_get_source_by_name(newName.c_str());
|
||||
if (!existing_source)
|
||||
break;
|
||||
|
||||
newName = strprintf("%s (%d)", name, ++inc);
|
||||
}
|
||||
|
||||
return newName;
|
||||
}
|
||||
extern char *get_new_source_name(const char *name, const char *format);
|
||||
|
||||
void OBSBasic::ResetAudioDevice(const char *sourceId, const char *deviceId,
|
||||
const char *deviceDesc, int channel)
|
||||
@@ -4454,12 +4437,11 @@ void OBSBasic::ResetAudioDevice(const char *sourceId, const char *deviceId,
|
||||
}
|
||||
|
||||
} else if (!disable) {
|
||||
std::string name = GetDupName(deviceDesc);
|
||||
BPtr<char> name = get_new_source_name(deviceDesc, "%s (%d)");
|
||||
|
||||
settings = obs_data_create();
|
||||
obs_data_set_string(settings, "device_id", deviceId);
|
||||
source = obs_source_create(sourceId, name.c_str(), settings,
|
||||
nullptr);
|
||||
source = obs_source_create(sourceId, name, settings, nullptr);
|
||||
|
||||
obs_set_output_source(channel, source);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user