diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-10-02 00:40:49 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-10-02 00:40:49 +0200 |
commit | a1f7fedcb8ef87787b19c9eac86e8394b27ad3e5 (patch) | |
tree | fc7908ec8d31706a6289cae3038ed3ae753146a8 /src | |
parent | f7606a144b7147e493304278d321ab2ed7996bb8 (diff) |
Add unique index to each audio input device name
Diffstat (limited to 'src')
-rw-r--r-- | src/sound.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/sound.cpp b/src/sound.cpp index 0fd1333..fc3bf97 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -257,6 +257,8 @@ static int pa_sound_device_read(pa_handle *p) { return success ? 0 : -1; } +static uint32_t sound_device_index = 0; + int sound_device_get_by_name(SoundDevice *device, const char *name, unsigned int num_channels, unsigned int period_frame_size) { pa_sample_spec ss; ss.format = PA_SAMPLE_S16LE; @@ -273,7 +275,8 @@ int sound_device_get_by_name(SoundDevice *device, const char *name, unsigned int // We want a unique stream name for every device which allows each input to be a different box in pipewire graph software char stream_name[1024]; - snprintf(stream_name, sizeof(stream_name), "gpu-screen-recorder-%s", name); + snprintf(stream_name, sizeof(stream_name), "gpu-screen-recorder-%u-%s", sound_device_index, name); + ++sound_device_index; pa_handle *handle = pa_sound_device_new(nullptr, stream_name, name, stream_name, &ss, &buffer_attr, &error); if(!handle) { |