]> code.delx.au - pulseaudio/commitdiff
use single array for storing pa_core hook lists, add sink state changed hook, drop...
authorLennart Poettering <lennart@poettering.net>
Sat, 11 Aug 2007 19:08:06 +0000 (19:08 +0000)
committerLennart Poettering <lennart@poettering.net>
Sat, 11 Aug 2007 19:08:06 +0000 (19:08 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1640 fefdeb5f-60dc-0310-8127-8f9354f1896f

src/modules/module-rescue-streams.c
src/modules/module-suspend-on-idle.c
src/modules/module-volume-restore.c
src/pulsecore/core.c
src/pulsecore/core.h
src/pulsecore/sink-input.c
src/pulsecore/sink-input.h
src/pulsecore/sink.c
src/pulsecore/source-output.c
src/pulsecore/source-output.h
src/pulsecore/source.c

index fa22d60a6f84000fa928cfe9b83ed6f54e055f42..e0eed0361a8bf90737cff223209b66c5d85c00c7 100644 (file)
@@ -138,8 +138,8 @@ int pa__init(pa_module*m) {
     }
 
     m->userdata = u = pa_xnew(struct userdata, 1);
-    u->sink_slot = pa_hook_connect(&m->core->hook_sink_disconnect, (pa_hook_cb_t) sink_hook_callback, NULL);
-    u->source_slot = pa_hook_connect(&m->core->hook_source_disconnect, (pa_hook_cb_t) source_hook_callback, NULL);
+    u->sink_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_DISCONNECT], (pa_hook_cb_t) sink_hook_callback, NULL);
+    u->source_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_DISCONNECT], (pa_hook_cb_t) source_hook_callback, NULL);
 
     pa_modargs_free(ma);
     return 0;
index ad148644d194878360f63d88621c692e673a5fc6..0d21cfbe8372dc50cca2ffae1e385709de441fc9 100644 (file)
@@ -50,7 +50,7 @@ struct userdata {
     pa_core *core;
     pa_usec_t timeout;
     pa_hashmap *device_infos;
-    pa_hook_slot *sink_new_slot, *source_new_slot, *sink_disconnect_slot, *source_disconnect_slot;
+    pa_hook_slot *sink_new_slot, *source_new_slot, *sink_disconnect_slot, *source_disconnect_slot, *sink_state_changed_slot, *source_state_changed_slot;
     pa_hook_slot *sink_input_new_slot, *source_output_new_slot, *sink_input_disconnect_slot, *source_output_disconnect_slot;
 };
 
@@ -69,13 +69,13 @@ static void timeout_cb(pa_mainloop_api*a, pa_time_event* e, const struct timeval
 
     d->userdata->core->mainloop->time_restart(d->time_event, NULL);
     
-    if (d->sink && pa_sink_used_by(d->sink) <= 0) {
+    if (d->sink && pa_sink_used_by(d->sink) <= 0 && pa_sink_get_state(d->sink) != PA_SINK_SUSPENDED) {
         pa_log_info("Sink %s idle for too long, suspending ...", d->sink->name);
         pa_sink_suspend(d->sink, 1);
         pa_source_suspend(d->sink->monitor_source, 1);
     }
 
-    if (d->source && pa_source_used_by(d->source) <= 0) {
+    if (d->source && pa_source_used_by(d->source) <= 0 && pa_source_get_state(d->source) != PA_SOURCE_SUSPENDED) {
         pa_log_info("Source %s idle for too long, suspending ...", d->source->name);
         pa_source_suspend(d->source, 1);
     }
@@ -209,6 +209,40 @@ static pa_hook_result_t device_disconnect_hook_cb(pa_core *c, pa_object *o, stru
     return PA_HOOK_OK;
 }
 
+static pa_hook_result_t device_state_changed_hook_cb(pa_core *c, pa_object *o, struct userdata *u) {
+    struct device_info *d;
+
+    pa_assert(c);
+    pa_object_assert_ref(o);
+    pa_assert(u);
+
+    if (!(d = pa_hashmap_get(u->device_infos, o)))
+        return PA_HOOK_OK;
+
+    if (pa_sink_isinstance(o)) {
+        pa_sink *s = PA_SINK(o);
+        
+        if (pa_sink_used_by(s) <= 0) {
+            pa_sink_state_t state = pa_sink_get_state(s);
+
+            if (state == PA_SINK_RUNNING || state == PA_SINK_IDLE)
+                restart(d);
+        }
+        
+    } else if (pa_source_isinstance(o)) {
+        pa_source *s = PA_SOURCE(o);
+
+        if (pa_source_used_by(s) <= 0) {
+            pa_sink_state_t state = pa_source_get_state(s);
+
+            if (state == PA_SINK_RUNNING || state == PA_SINK_IDLE)
+                restart(d);
+        }
+    }
+            
+    return PA_HOOK_OK;
+}
+
 int pa__init(pa_module*m) {
     pa_modargs *ma = NULL;
     struct userdata *u;
@@ -240,15 +274,17 @@ int pa__init(pa_module*m) {
     for (source = pa_idxset_first(m->core->sources, &idx); source; source = pa_idxset_next(m->core->sources, &idx))
         device_new_hook_cb(m->core, PA_OBJECT(source), u);
 
-    u->sink_new_slot = pa_hook_connect(&m->core->hook_sink_new_post, (pa_hook_cb_t) device_new_hook_cb, u);
-    u->source_new_slot = pa_hook_connect(&m->core->hook_source_new_post, (pa_hook_cb_t) device_new_hook_cb, u);
-    u->sink_disconnect_slot = pa_hook_connect(&m->core->hook_sink_disconnect_post, (pa_hook_cb_t) device_disconnect_hook_cb, u);
-    u->source_disconnect_slot = pa_hook_connect(&m->core->hook_source_disconnect_post, (pa_hook_cb_t) device_disconnect_hook_cb, u);
-
-    u->sink_input_new_slot = pa_hook_connect(&m->core->hook_sink_input_new_post, (pa_hook_cb_t) sink_input_new_hook_cb, u);
-    u->source_output_new_slot = pa_hook_connect(&m->core->hook_source_output_new_post, (pa_hook_cb_t) source_output_new_hook_cb, u);
-    u->sink_input_disconnect_slot = pa_hook_connect(&m->core->hook_sink_input_disconnect_post, (pa_hook_cb_t) sink_input_disconnect_hook_cb, u);
-    u->source_output_disconnect_slot = pa_hook_connect(&m->core->hook_source_output_disconnect_post, (pa_hook_cb_t) source_output_disconnect_hook_cb, u);
+    u->sink_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_NEW_POST], (pa_hook_cb_t) device_new_hook_cb, u);
+    u->source_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_NEW_POST], (pa_hook_cb_t) device_new_hook_cb, u);
+    u->sink_disconnect_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_DISCONNECT], (pa_hook_cb_t) device_disconnect_hook_cb, u);
+    u->source_disconnect_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_DISCONNECT], (pa_hook_cb_t) device_disconnect_hook_cb, u);
+    u->sink_state_changed_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_STATE_CHANGED], (pa_hook_cb_t) device_state_changed_hook_cb, u);
+    u->source_state_changed_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_STATE_CHANGED], (pa_hook_cb_t) device_state_changed_hook_cb, u);
+
+    u->sink_input_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT], (pa_hook_cb_t) sink_input_new_hook_cb, u);
+    u->source_output_new_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_PUT], (pa_hook_cb_t) source_output_new_hook_cb, u);
+    u->sink_input_disconnect_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_DISCONNECT_POST], (pa_hook_cb_t) sink_input_disconnect_hook_cb, u);
+    u->source_output_disconnect_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_DISCONNECT_POST], (pa_hook_cb_t) source_output_disconnect_hook_cb, u);
     
     pa_modargs_free(ma);
     return 0;
@@ -276,11 +312,15 @@ void pa__done(pa_module*m) {
         pa_hook_slot_free(u->sink_new_slot);
     if (u->sink_disconnect_slot)
         pa_hook_slot_free(u->sink_disconnect_slot);
+    if (u->sink_state_changed_slot)
+        pa_hook_slot_free(u->sink_state_changed_slot);
 
     if (u->source_new_slot)
         pa_hook_slot_free(u->source_new_slot);
     if (u->source_disconnect_slot)
         pa_hook_slot_free(u->source_disconnect_slot);
+    if (u->source_state_changed_slot)
+        pa_hook_slot_free(u->source_state_changed_slot);
 
     if (u->sink_input_new_slot)
         pa_hook_slot_free(u->sink_input_new_slot);
index addd937b56c60806a43eed3766381437e879cf89..0041760bade9ec2383fedefc51f445601146bb4d 100644 (file)
@@ -444,8 +444,8 @@ int pa__init(pa_module*m) {
         goto fail;
 
     u->subscription = pa_subscription_new(m->core, PA_SUBSCRIPTION_MASK_SINK_INPUT|PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT, subscribe_callback, u);
-    u->sink_input_hook_slot = pa_hook_connect(&m->core->hook_sink_input_new, (pa_hook_cb_t) sink_input_hook_callback, u);
-    u->source_output_hook_slot = pa_hook_connect(&m->core->hook_source_output_new, (pa_hook_cb_t) source_output_hook_callback, u);
+    u->sink_input_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_NEW], (pa_hook_cb_t) sink_input_hook_callback, u);
+    u->source_output_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_NEW], (pa_hook_cb_t) source_output_hook_callback, u);
 
     pa_modargs_free(ma);
     return 0;
index 8b10d398a6be4accecb798f26b1d6532de68743a..2e9d96b1d93a08a7d4f1fbcc09741739f852bac4 100644 (file)
@@ -72,7 +72,8 @@ static void core_free(pa_object *o);
 pa_core* pa_core_new(pa_mainloop_api *m, int shared) {
     pa_core* c;
     pa_mempool *pool;
-
+    int j;
+    
     pa_assert(m);
 
     if (shared) {
@@ -138,22 +139,8 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) {
 
     c->is_system_instance = 0;
 
-    pa_hook_init(&c->hook_sink_new, c);
-    pa_hook_init(&c->hook_sink_new_post, c);
-    pa_hook_init(&c->hook_sink_disconnect, c);
-    pa_hook_init(&c->hook_sink_disconnect_post, c);
-    pa_hook_init(&c->hook_source_new, c);
-    pa_hook_init(&c->hook_source_new_post, c);
-    pa_hook_init(&c->hook_source_disconnect, c);
-    pa_hook_init(&c->hook_source_disconnect_post, c);
-    pa_hook_init(&c->hook_sink_input_new, c);
-    pa_hook_init(&c->hook_sink_input_new_post, c);
-    pa_hook_init(&c->hook_sink_input_disconnect, c);
-    pa_hook_init(&c->hook_sink_input_disconnect_post, c);
-    pa_hook_init(&c->hook_source_output_new, c);
-    pa_hook_init(&c->hook_source_output_new_post, c);
-    pa_hook_init(&c->hook_source_output_disconnect, c);
-    pa_hook_init(&c->hook_source_output_disconnect_post, c);
+    for (j = 0; j < PA_CORE_HOOK_MAX; j++)
+        pa_hook_init(&c->hooks[j], c);
 
     pa_property_init(c);
 
@@ -168,6 +155,7 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) {
 
 static void core_free(pa_object *o) {
     pa_core *c = PA_CORE(o);
+    int j;
     pa_assert(c);
 
     pa_module_unload_all(c);
@@ -203,22 +191,8 @@ static void core_free(pa_object *o) {
 
     pa_property_cleanup(c);
 
-    pa_hook_free(&c->hook_sink_new);
-    pa_hook_free(&c->hook_sink_new_post);
-    pa_hook_free(&c->hook_sink_disconnect);
-    pa_hook_free(&c->hook_sink_disconnect_post);
-    pa_hook_free(&c->hook_source_new);
-    pa_hook_free(&c->hook_source_new_post);
-    pa_hook_free(&c->hook_source_disconnect);
-    pa_hook_free(&c->hook_source_disconnect_post);
-    pa_hook_free(&c->hook_sink_input_new);
-    pa_hook_free(&c->hook_sink_input_new_post);
-    pa_hook_free(&c->hook_sink_input_disconnect);
-    pa_hook_free(&c->hook_sink_input_disconnect_post);
-    pa_hook_free(&c->hook_source_output_new);
-    pa_hook_free(&c->hook_source_output_new_post);
-    pa_hook_free(&c->hook_source_output_disconnect);
-    pa_hook_free(&c->hook_source_output_disconnect_post);
+    for (j = 0; j < PA_CORE_HOOK_MAX; j++)
+        pa_hook_free(&c->hooks[j]);
 
     pa_xfree(c);
 }
index 003b24b1163cf841655e6b41c11f82e70e23986e..c49a77d57795aa9d89f961fac03bc23a051818b0 100644 (file)
@@ -42,6 +42,26 @@ typedef struct pa_core pa_core;
 #include <pulsecore/sink-input.h>
 #include <pulsecore/msgobject.h>
 
+typedef enum pa_core_hook {
+    PA_CORE_HOOK_SINK_NEW_POST,
+    PA_CORE_HOOK_SINK_DISCONNECT,
+    PA_CORE_HOOK_SINK_DISCONNECT_POST,
+    PA_CORE_HOOK_SINK_STATE_CHANGED,
+    PA_CORE_HOOK_SOURCE_NEW_POST,
+    PA_CORE_HOOK_SOURCE_DISCONNECT,
+    PA_CORE_HOOK_SOURCE_DISCONNECT_POST,
+    PA_CORE_HOOK_SOURCE_STATE_CHANGED,
+    PA_CORE_HOOK_SINK_INPUT_NEW,
+    PA_CORE_HOOK_SINK_INPUT_PUT,
+    PA_CORE_HOOK_SINK_INPUT_DISCONNECT,
+    PA_CORE_HOOK_SINK_INPUT_DISCONNECT_POST,
+    PA_CORE_HOOK_SOURCE_OUTPUT_NEW,
+    PA_CORE_HOOK_SOURCE_OUTPUT_PUT,
+    PA_CORE_HOOK_SOURCE_OUTPUT_DISCONNECT,
+    PA_CORE_HOOK_SOURCE_OUTPUT_DISCONNECT_POST,
+    PA_CORE_HOOK_MAX
+} pa_core_hook_t;
+
 /* The core structure of PulseAudio. Every PulseAudio daemon contains
  * exactly one of these. It is used for storing kind of global
  * variables for the daemon. */
@@ -89,23 +109,7 @@ struct pa_core {
     int is_system_instance;
 
     /* hooks */
-    pa_hook
-        hook_sink_new,
-        hook_sink_new_post,
-        hook_sink_disconnect,
-        hook_sink_disconnect_post,
-        hook_source_new,
-        hook_source_new_post,
-        hook_source_disconnect,
-        hook_source_disconnect_post,
-        hook_sink_input_new,
-        hook_sink_input_new_post,
-        hook_sink_input_disconnect,
-        hook_sink_input_disconnect_post,
-        hook_source_output_new,
-        hook_source_output_new_post,
-        hook_source_output_disconnect,
-        hook_source_output_disconnect_post;
+    pa_hook hooks[PA_CORE_HOOK_MAX];
 };
 
 PA_DECLARE_CLASS(pa_core);
index d1bf0acc573a8f214f5d0609bbb35ee126fe2b8f..77b95feb4432cb8f03c5d6acdcbc368df66b956f 100644 (file)
@@ -98,9 +98,8 @@ pa_sink_input* pa_sink_input_new(
     pa_assert(core);
     pa_assert(data);
 
-    if (!(flags & PA_SINK_INPUT_NO_HOOKS))
-        if (pa_hook_fire(&core->hook_sink_input_new, data) < 0)
-            return NULL;
+    if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_INPUT_NEW], data) < 0)
+        return NULL;
 
     pa_return_null_if_fail(!data->driver || pa_utf8_valid(data->driver));
     pa_return_null_if_fail(!data->name || pa_utf8_valid(data->name));
@@ -249,7 +248,7 @@ void pa_sink_input_disconnect(pa_sink_input *i) {
     pa_assert(i);
     pa_return_if_fail(i->state != PA_SINK_INPUT_DISCONNECTED);
 
-    pa_hook_fire(&i->sink->core->hook_sink_input_disconnect, i);
+    pa_hook_fire(&i->sink->core->hooks[PA_CORE_HOOK_SINK_INPUT_DISCONNECT], i);
     
     if (i->sync_prev)
         i->sync_prev->sync_next = i->sync_next;
@@ -273,7 +272,7 @@ void pa_sink_input_disconnect(pa_sink_input *i) {
     i->get_latency = NULL;
     i->underrun = NULL;
 
-    pa_hook_fire(&i->sink->core->hook_sink_input_disconnect_post, i);
+    pa_hook_fire(&i->sink->core->hooks[PA_CORE_HOOK_SINK_INPUT_DISCONNECT_POST], i);
     i->sink = NULL;
     pa_sink_input_unref(i);
 }
@@ -313,7 +312,7 @@ void pa_sink_input_put(pa_sink_input *i) {
     pa_sink_update_status(i->sink);
 
     pa_subscription_post(i->sink->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_NEW, i->index);
-    pa_hook_fire(&i->sink->core->hook_sink_input_new_post, i);
+    pa_hook_fire(&i->sink->core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT], i);
 }
 
 void pa_sink_input_kill(pa_sink_input*i) {
index 0168805a241fa11c024bba57308753aabd4a557c..5a48418c10c4eb42cba757debf89987223644a20 100644 (file)
@@ -47,7 +47,6 @@ typedef enum pa_sink_input_state {
 
 typedef enum pa_sink_input_flags {
     PA_SINK_INPUT_VARIABLE_RATE = 1,
-    PA_SINK_INPUT_NO_HOOKS = 2
 } pa_sink_input_flags_t;
 
 struct pa_sink_input {
index 905fe3ff0800368c404ce1577bbd75e224a75a5b..929542ccfb014c253fa3005040b4b2d6e57c0a3b 100644 (file)
@@ -80,9 +80,6 @@ pa_sink* pa_sink_new(
     pa_return_null_if_fail(!driver || pa_utf8_valid(driver));
     pa_return_null_if_fail(name && pa_utf8_valid(name) && *name);
 
-    if (pa_hook_fire(&core->hook_sink_new, NULL) < 0) /* FIXME */
-        return NULL;
-    
     s = pa_msgobject_new(pa_sink);
 
     if (!(name = pa_namereg_register(core, name, PA_NAMEREG_SINK, s, fail))) {
@@ -149,7 +146,7 @@ pa_sink* pa_sink_new(
 
     pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_NEW, s->index);
 
-    pa_hook_fire(&core->hook_sink_new_post, s);
+    pa_hook_fire(&core->hooks[PA_CORE_HOOK_SINK_NEW_POST], s);
 
     return s;
 }
@@ -170,6 +167,8 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state) {
         return -1;
 
     s->state = state;
+    
+    pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_STATE_CHANGED], s);
     return 0;
 }
 
@@ -179,7 +178,7 @@ void pa_sink_disconnect(pa_sink* s) {
     pa_assert(s);
     pa_return_if_fail(s->state != PA_SINK_DISCONNECTED);
 
-    pa_hook_fire(&s->core->hook_sink_disconnect, s);
+    pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_DISCONNECT], s);
     
     pa_namereg_unregister(s->core, s->name);
     pa_idxset_remove_by_data(s->core->sinks, s, NULL);
@@ -204,7 +203,7 @@ void pa_sink_disconnect(pa_sink* s) {
 
     pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_REMOVE, s->index);
 
-    pa_hook_fire(&s->core->hook_sink_disconnect_post, s);
+    pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_DISCONNECT_POST], s);
 }
 
 static void sink_free(pa_object *o) {
index 95755f3b90978b6a39fbf5b23674a09754b37a77..2dc66bfafb6b50a4ba119d31e623aae81ccda17d 100644 (file)
@@ -76,9 +76,8 @@ pa_source_output* pa_source_output_new(
     pa_assert(core);
     pa_assert(data);
 
-    if (!(flags & PA_SOURCE_OUTPUT_NO_HOOKS))
-        if (pa_hook_fire(&core->hook_source_output_new, data) < 0)
-            return NULL;
+    if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_NEW], data) < 0)
+        return NULL;
 
     pa_return_null_if_fail(!data->driver || pa_utf8_valid(data->driver));
     pa_return_null_if_fail(!data->name || pa_utf8_valid(data->name));
@@ -187,7 +186,7 @@ void pa_source_output_disconnect(pa_source_output*o) {
     pa_assert(o);
     pa_return_if_fail(o->state != PA_SOURCE_OUTPUT_DISCONNECTED);
 
-    pa_hook_fire(&o->source->core->hook_source_output_disconnect, o);
+    pa_hook_fire(&o->source->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_DISCONNECT], o);
     
     pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o->source), PA_SOURCE_MESSAGE_REMOVE_OUTPUT, o, 0, NULL);
 
@@ -203,7 +202,7 @@ void pa_source_output_disconnect(pa_source_output*o) {
     o->kill = NULL;
     o->get_latency = NULL;
 
-    pa_hook_fire(&o->source->core->hook_source_output_disconnect_post, o);
+    pa_hook_fire(&o->source->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_DISCONNECT_POST], o);
 
     o->source = NULL;
     pa_source_output_unref(o);
@@ -235,7 +234,7 @@ void pa_source_output_put(pa_source_output *o) {
 
     pa_subscription_post(o->source->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_NEW, o->index);
 
-    pa_hook_fire(&o->source->core->hook_source_output_new_post, o);
+    pa_hook_fire(&o->source->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_PUT], o);
 }
 
 void pa_source_output_kill(pa_source_output*o) {
index 47cc8c4057206b5af65995a98401ffa7911b7e67..b17adcb5e539da9a76eaae920a70656dfd750259 100644 (file)
@@ -42,8 +42,7 @@ typedef enum pa_source_output_state {
 } pa_source_output_state_t;
 
 typedef enum pa_source_output_flags {
-    PA_SOURCE_OUTPUT_NO_HOOKS = 1,
-    PA_SOURCE_OUTPUT_VARIABLE_RATE = 2
+    PA_SOURCE_OUTPUT_VARIABLE_RATE = 1
 } pa_source_output_flags_t;
 
 struct pa_source_output {
index f7825931a0e55c14636c46ac0392fd41601456f2..0e448f60e8740b498e0dc14a8fb6146e2629ea79 100644 (file)
@@ -73,9 +73,6 @@ pa_source* pa_source_new(
     pa_return_null_if_fail(!driver || pa_utf8_valid(driver));
     pa_return_null_if_fail(pa_utf8_valid(name) && *name);
 
-    if (pa_hook_fire(&core->hook_sink_new, NULL) < 0) /* FIXME */
-        return NULL;
-    
     s = pa_msgobject_new(pa_source);
 
     if (!(name = pa_namereg_register(core, name, PA_NAMEREG_SOURCE, s, fail))) {
@@ -128,7 +125,7 @@ pa_source* pa_source_new(
 
     pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_SOURCE | PA_SUBSCRIPTION_EVENT_NEW, s->index);
 
-    pa_hook_fire(&core->hook_source_new_post, s);
+    pa_hook_fire(&core->hooks[PA_CORE_HOOK_SOURCE_NEW_POST], s);
     
     return s;
 }
@@ -149,6 +146,7 @@ static int source_set_state(pa_source *s, pa_source_state_t state) {
         return -1;
 
     s->state = state;
+    pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_STATE_CHANGED], s);
     return 0;
 }
 
@@ -158,7 +156,7 @@ void pa_source_disconnect(pa_source *s) {
     pa_assert(s);
     pa_return_if_fail(s->state != PA_SOURCE_DISCONNECTED);
 
-    pa_hook_fire(&s->core->hook_source_disconnect, s);
+    pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_DISCONNECT], s);    
 
     pa_namereg_unregister(s->core, s->name);
     pa_idxset_remove_by_data(s->core->sources, s, NULL);
@@ -180,7 +178,7 @@ void pa_source_disconnect(pa_source *s) {
 
     pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE | PA_SUBSCRIPTION_EVENT_REMOVE, s->index);
 
-    pa_hook_fire(&s->core->hook_source_disconnect_post, s);
+    pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_DISCONNECT_POST], s);    
 }
 
 static void source_free(pa_object *o) {