aboutsummaryrefslogtreecommitdiff
path: root/src/sound.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-10-02 01:04:57 +0200
committerdec05eba <dec05eba@protonmail.com>2022-10-02 01:04:57 +0200
commit5871abc42ff0c05726adb0be3b5a6dd4ee095b50 (patch)
tree30e2a849db11d0ce1dcde119ec0919c9bab878a5 /src/sound.cpp
parenta1f7fedcb8ef87787b19c9eac86e8394b27ad3e5 (diff)
Allow giving audio inputs names by prefixing them with <name>/
Diffstat (limited to 'src/sound.cpp')
-rw-r--r--src/sound.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/src/sound.cpp b/src/sound.cpp
index fc3bf97..3eea498 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -257,9 +257,7 @@ 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) {
+int sound_device_get_by_name(SoundDevice *device, const char *device_name, const char *description, unsigned int num_channels, unsigned int period_frame_size) {
pa_sample_spec ss;
ss.format = PA_SAMPLE_S16LE;
ss.rate = 48000;
@@ -273,14 +271,9 @@ int sound_device_get_by_name(SoundDevice *device, const char *name, unsigned int
buffer_attr.maxlength = period_frame_size * 2 * num_channels; // 2 bytes/sample, @num_channels channels
buffer_attr.fragsize = buffer_attr.maxlength;
- // 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-%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);
+ pa_handle *handle = pa_sound_device_new(nullptr, description, device_name, description, &ss, &buffer_attr, &error);
if(!handle) {
- fprintf(stderr, "pa_sound_device_new() failed: %s. Audio input device %s might not be valid\n", pa_strerror(error), name);
+ fprintf(stderr, "pa_sound_device_new() failed: %s. Audio input device %s might not be valid\n", pa_strerror(error), description);
return -1;
}