]> code.delx.au - pulseaudio/blobdiff - polyp/sink.c
new features:
[pulseaudio] / polyp / sink.c
index 6df92e76c5e23e521a34a881842d2e6f992de91d..43fd351cf67fa5a7ad39956b4a99db1422b7754f 100644 (file)
@@ -34,6 +34,7 @@
 #include "util.h"
 #include "sample-util.h"
 #include "xmalloc.h"
+#include "subscribe.h"
 
 #define MAX_MIX_CHANNELS 32
 
@@ -64,6 +65,7 @@ struct pa_sink* pa_sink_new(struct pa_core *core, const char *name, int fail, co
     assert(s->monitor_source);
     pa_xfree(n);
     s->monitor_source->monitor_of = s;
+    s->monitor_source->description = pa_sprintf_malloc("Monitor source of sink '%s'", s->name);
     
     s->volume = PA_VOLUME_NORM;
 
@@ -74,8 +76,10 @@ struct pa_sink* pa_sink_new(struct pa_core *core, const char *name, int fail, co
     r = pa_idxset_put(core->sinks, s, &s->index);
     assert(s->index != PA_IDXSET_INVALID && r >= 0);
     
-    pa_sample_snprint(st, sizeof(st), spec);
+    pa_sample_spec_snprint(st, sizeof(st), spec);
     fprintf(stderr, "sink: created %u \"%s\" with sample spec \"%s\"\n", s->index, s->name, st);
+
+    pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_NEW, s->index);
     
     return s;
 }
@@ -97,6 +101,8 @@ void pa_sink_free(struct pa_sink *s) {
     pa_idxset_remove_by_data(s->core->sinks, s, NULL);
 
     fprintf(stderr, "sink: freed %u \"%s\"\n", s->index, s->name);
+
+    pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_REMOVE, s->index);
     
     pa_xfree(s->name);
     pa_xfree(s->description);
@@ -141,8 +147,8 @@ static void inputs_drop(struct pa_sink *s, struct pa_mix_info *info, unsigned ma
         struct pa_sink_input *i = info->userdata;
         assert(i && info->chunk.memblock);
         
+        pa_sink_input_drop(i, &info->chunk, length);
         pa_memblock_unref(info->chunk.memblock);
-        pa_sink_input_drop(i, length);
     }
 }
         
@@ -173,11 +179,11 @@ int pa_sink_render(struct pa_sink*s, size_t length, struct pa_memchunk *result)
             volume = pa_volume_multiply(s->volume, info[0].volume);
         
         if (volume != PA_VOLUME_NORM) {
-            pa_memchunk_make_writable(result);
+            pa_memchunk_make_writable(result, s->core->memblock_stat);
             pa_volume_memchunk(result, &s->sample_spec, volume);
         }
     } else {
-        result->memblock = pa_memblock_new(length);
+        result->memblock = pa_memblock_new(length, s->core->memblock_stat);
         assert(result->memblock);
 
         result->length = l = pa_mix(info, n, result->memblock->data, length, &s->sample_spec, s->volume);
@@ -270,10 +276,18 @@ uint32_t pa_sink_get_latency(struct pa_sink *s) {
     return s->get_latency(s);
 }
 
-
 void pa_sink_set_owner(struct pa_sink *sink, struct pa_module *m) {
     sink->owner = m;
 
     if (sink->monitor_source)
         pa_source_set_owner(sink->monitor_source, m);
 }
+
+void pa_sink_set_volume(struct pa_sink *sink, pa_volume_t volume) {
+    assert(sink);
+    
+    if (sink->volume != volume) {
+        sink->volume = volume;
+        pa_subscription_post(sink->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, sink->index);
+    }
+}