]> code.delx.au - pulseaudio/blobdiff - polyp/sink-input.c
Documentation work
[pulseaudio] / polyp / sink-input.c
index 25d8022f359e32110bb96e68136841f6ae14f43b..7629bfb964475e55573582b221e5dce17ddde9e4 100644 (file)
@@ -30,6 +30,8 @@
 
 #include "sink-input.h"
 #include "sample-util.h"
+#include "xmalloc.h"
+#include "subscribe.h"
 
 #define CONVERT_BUFFER_LENGTH 4096
 
@@ -44,9 +46,8 @@ struct pa_sink_input* pa_sink_input_new(struct pa_sink *s, const char *name, con
         if (!(resampler = pa_resampler_new(spec, &s->sample_spec)))
             return NULL;
     
-    i = malloc(sizeof(struct pa_sink_input));
-    assert(i);
-    i->name = name ? strdup(name) : NULL;
+    i = pa_xmalloc(sizeof(struct pa_sink_input));
+    i->name = pa_xstrdup(name);
     i->client = NULL;
     i->owner = NULL;
     i->sink = s;
@@ -72,6 +73,8 @@ struct pa_sink_input* pa_sink_input_new(struct pa_sink *s, const char *name, con
 
     pa_sample_snprint(st, sizeof(st), spec);
     fprintf(stderr, "sink-input: created %u \"%s\" on %u with sample spec \"%s\"\n", i->index, i->name, s->index, st);
+
+    pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_NEW, i->index);
     
     return i;    
 }
@@ -87,9 +90,11 @@ void pa_sink_input_free(struct pa_sink_input* i) {
         pa_memblock_unref(i->resampled_chunk.memblock);
     if (i->resampler)
         pa_resampler_free(i->resampler);
+
+    pa_subscription_post(i->sink->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_REMOVE, i->index);
     
-    free(i->name);
-    free(i);
+    pa_xfree(i->name);
+    pa_xfree(i);
 }
 
 void pa_sink_input_kill(struct pa_sink_input*i) {
@@ -163,3 +168,12 @@ void pa_sink_input_drop(struct pa_sink_input *i, size_t length) {
         i->resampled_chunk.index = i->resampled_chunk.length = 0;
     }
 }
+
+void pa_sink_input_set_volume(struct pa_sink_input *i, pa_volume_t volume) {
+    assert(i && i->sink && i->sink->core);
+
+    if (i->volume != volume) {
+        i->volume = volume;
+        pa_subscription_post(i->sink->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
+    }
+}