summaryrefslogtreecommitdiffstats
path: root/plugins/alsa/alsa-api-sink.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/alsa/alsa-api-sink.c')
-rw-r--r--plugins/alsa/alsa-api-sink.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/plugins/alsa/alsa-api-sink.c b/plugins/alsa/alsa-api-sink.c
index e38621a..c8f9f9d 100644
--- a/plugins/alsa/alsa-api-sink.c
+++ b/plugins/alsa/alsa-api-sink.c
@@ -55,6 +55,8 @@ PUBLIC AlsaSndPcmT *ApiSinkGetByUid(SoftMixerT *mixer, const char *target) {
PUBLIC int ApiSinkAttach(SoftMixerT *mixer, AFB_ReqT request, const char *uid, json_object * argsJ) {
int index;
+ char *dmixUid = NULL;
+
for (index = 0; index < mixer->max.sinks; index++) {
if (!mixer->sinks[index]) break;
}
@@ -66,7 +68,7 @@ PUBLIC int ApiSinkAttach(SoftMixerT *mixer, AFB_ReqT request, const char *uid, j
switch (json_object_get_type(argsJ)) {
long count;
- char *dmixUid;
+
AlsaPcmCtlT* dmixConfig;
case json_type_object:
@@ -77,7 +79,8 @@ PUBLIC int ApiSinkAttach(SoftMixerT *mixer, AFB_ReqT request, const char *uid, j
}
// move from hardware to DMIX attach to sndcard
- (void) asprintf(&dmixUid, "dmix-%s", mixer->sinks[index]->uid);
+ if (asprintf(&dmixUid, "dmix-%s", mixer->sinks[index]->uid) == -1)
+ goto OnErrorExit;
dmixConfig = AlsaCreateDmix(mixer, dmixUid, mixer->sinks[index], 0);
if (!dmixConfig) {
@@ -103,7 +106,8 @@ PUBLIC int ApiSinkAttach(SoftMixerT *mixer, AFB_ReqT request, const char *uid, j
}
// move from hardware to DMIX attach to sndcard
- (void) asprintf(&dmixUid, "dmix-%s", mixer->sinks[index]->uid);
+ if (asprintf(&dmixUid, "dmix-%s", mixer->sinks[index]->uid) == -1)
+ goto OnErrorExit;
dmixConfig = AlsaCreateDmix(mixer, dmixUid, mixer->sinks[index], 0);
if (!dmixConfig) {
@@ -120,5 +124,6 @@ PUBLIC int ApiSinkAttach(SoftMixerT *mixer, AFB_ReqT request, const char *uid, j
return 0;
OnErrorExit:
+ free(dmixUid);
return -1;
-} \ No newline at end of file
+}