aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/pulseaudio.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2010-06-09 18:22:05 -0700
committerChris Robinson <[email protected]>2010-06-09 18:22:05 -0700
commit25a941666ad8691dfc0f389baf642fa2690ba334 (patch)
tree8a7584af26cbc2983ccabc8bb640f19f2cc48a8c /Alc/pulseaudio.c
parent8c59849ea431ef121205292d31f130bdc8a8670f (diff)
Prevent multiple PulseAudio devices from getting the same name
Diffstat (limited to 'Alc/pulseaudio.c')
-rw-r--r--Alc/pulseaudio.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c
index e4c6f2fc..594126cf 100644
--- a/Alc/pulseaudio.c
+++ b/Alc/pulseaudio.c
@@ -410,7 +410,10 @@ static void sink_info_callback(pa_context *context, const pa_sink_info *info, in
static void sink_device_callback(pa_context *context, const pa_sink_info *info, int eol, void *pdata) //{{{
{
pa_threaded_mainloop *loop = pdata;
+ char str[1024];
void *temp;
+ int count;
+ ALuint i;
(void)context;
@@ -420,12 +423,24 @@ static void sink_device_callback(pa_context *context, const pa_sink_info *info,
return;
}
+ count = 0;
+ do {
+ if(count == 0)
+ snprintf(str, sizeof(str), "%s via PulseAudio", info->description);
+ else
+ snprintf(str, sizeof(str), "%s #%d via PulseAudio", info->description, count+1);
+ count++;
+
+ for(i = 0;i < numDevNames;i++)
+ {
+ if(strcmp(str, allDevNameMap[i].name) == 0)
+ break;
+ }
+ } while(i != numDevNames);
+
temp = realloc(allDevNameMap, (numDevNames+1) * sizeof(*allDevNameMap));
if(temp)
{
- char str[1024];
- snprintf(str, sizeof(str), "%s via PulseAudio", info->description);
-
allDevNameMap = temp;
allDevNameMap[numDevNames].name = strdup(str);
allDevNameMap[numDevNames].device_name = strdup(info->name);
@@ -436,7 +451,10 @@ static void sink_device_callback(pa_context *context, const pa_sink_info *info,
static void source_device_callback(pa_context *context, const pa_source_info *info, int eol, void *pdata) //{{{
{
pa_threaded_mainloop *loop = pdata;
+ char str[1024];
void *temp;
+ int count;
+ ALuint i;
(void)context;
@@ -446,12 +464,24 @@ static void source_device_callback(pa_context *context, const pa_source_info *in
return;
}
+ count = 0;
+ do {
+ if(count == 0)
+ snprintf(str, sizeof(str), "%s via PulseAudio", info->description);
+ else
+ snprintf(str, sizeof(str), "%s #%d via PulseAudio", info->description, count+1);
+ count++;
+
+ for(i = 0;i < numCaptureDevNames;i++)
+ {
+ if(strcmp(str, allCaptureDevNameMap[i].name) == 0)
+ break;
+ }
+ } while(i != numCaptureDevNames);
+
temp = realloc(allCaptureDevNameMap, (numCaptureDevNames+1) * sizeof(*allCaptureDevNameMap));
if(temp)
{
- char str[256];
- snprintf(str, sizeof(str), "%s via PulseAudio", info->description);
-
allCaptureDevNameMap = temp;
allCaptureDevNameMap[numCaptureDevNames].name = strdup(str);
allCaptureDevNameMap[numCaptureDevNames].device_name = strdup(info->name);