diff options
Diffstat (limited to 'src/pulsecore')
-rw-r--r-- | src/pulsecore/hook-list.c | 6 | ||||
-rw-r--r-- | src/pulsecore/hook-list.h | 2 | ||||
-rw-r--r-- | src/pulsecore/macro.h | 20 | ||||
-rw-r--r-- | src/pulsecore/protocol-native.c | 2 | ||||
-rw-r--r-- | src/pulsecore/sink-input.c | 22 | ||||
-rw-r--r-- | src/pulsecore/sink-input.h | 1 | ||||
-rw-r--r-- | src/pulsecore/sink.c | 26 | ||||
-rw-r--r-- | src/pulsecore/sink.h | 2 | ||||
-rw-r--r-- | src/pulsecore/source.c | 27 | ||||
-rw-r--r-- | src/pulsecore/source.h | 2 |
10 files changed, 104 insertions, 6 deletions
diff --git a/src/pulsecore/hook-list.c b/src/pulsecore/hook-list.c index 5f7a8665..a00116d1 100644 --- a/src/pulsecore/hook-list.c +++ b/src/pulsecore/hook-list.c @@ -121,3 +121,9 @@ pa_hook_result_t pa_hook_fire(pa_hook *hook, void *data) { return result; } + +pa_bool_t pa_hook_is_firing(pa_hook *hook) { + pa_assert(hook); + + return hook->n_firing > 0; +} diff --git a/src/pulsecore/hook-list.h b/src/pulsecore/hook-list.h index 8514cced..86ce9d25 100644 --- a/src/pulsecore/hook-list.h +++ b/src/pulsecore/hook-list.h @@ -71,4 +71,6 @@ void pa_hook_slot_free(pa_hook_slot *slot); pa_hook_result_t pa_hook_fire(pa_hook *hook, void *data); +pa_bool_t pa_hook_is_firing(pa_hook *hook); + #endif diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h index 20015bf5..309f1a0d 100644 --- a/src/pulsecore/macro.h +++ b/src/pulsecore/macro.h @@ -164,8 +164,8 @@ typedef int pa_bool_t; #define pa_return_null_if_fail(expr) pa_return_val_if_fail(expr, NULL) -/* An assert which guarantees side effects of x, i.e. is never - * optimized away */ +/* pa_assert_se() is an assert which guarantees side effects of x, + * i.e. is never optimized away, regardless of NDEBUG or FASTPATH. */ #define pa_assert_se(expr) \ do { \ if (PA_UNLIKELY(!(expr))) { \ @@ -174,11 +174,23 @@ typedef int pa_bool_t; } \ } while (FALSE) -/* An assert that may be optimized away by defining NDEBUG */ +/* Does exactly nothing */ +#define pa_nop() do {} while (FALSE) + +/* pa_assert() is an assert that may be optimized away by defining + * NDEBUG. pa_assert_fp() is an assert that may be optimized away by + * defining FASTPATH. It is supposed to be used in inner loops. It's + * there for extra paranoia checking and should probably be removed in + * production builds. */ #ifdef NDEBUG -#define pa_assert(expr) do {} while (FALSE) +#define pa_assert(expr) pa_nop() +#define pa_assert_fp(expr) pa_nop() +#elif defined (FASTPATH) +#define pa_assert(expr) pa_assert_se(expr) +#define pa_assert_fp(expr) pa_nop() #else #define pa_assert(expr) pa_assert_se(expr) +#define pa_assert_fp(expr) pa_assert_se(expr) #endif #define pa_assert_not_reached() \ diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index 50a9191b..4860860b 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -775,7 +775,7 @@ static int playback_stream_process_msg(pa_msgobject *o, int code, void*userdata, if (s->connection->version >= 13) { pa_tagstruct *t; - /* Notify the user we're overflowed*/ + /* Notify the user we started playback */ t = pa_tagstruct_new(NULL, 0); pa_tagstruct_putu32(t, PA_COMMAND_STARTED); pa_tagstruct_putu32(t, (uint32_t) -1); /* tag */ diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index 53e727bb..ae2c6f54 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -924,6 +924,28 @@ const pa_cvolume *pa_sink_input_get_volume(pa_sink_input *i) { } /* Called from main context */ +pa_cvolume *pa_sink_input_get_relative_volume(pa_sink_input *i, pa_cvolume *v) { + pa_sink_input_assert_ref(i); + pa_assert(v); + pa_assert(PA_SINK_INPUT_IS_LINKED(i->state)); + + *v = i->virtual_volume; + + /* This always returns a relative volume, even in flat volume mode */ + + if (i->sink->flags & PA_SINK_FLAT_VOLUME) { + pa_cvolume sv; + + sv = *pa_sink_get_volume(i->sink, FALSE); + + pa_sw_cvolume_divide(v, v, + pa_cvolume_remap(&sv, &i->sink->channel_map, &i->channel_map)); + } + + return v; +} + +/* Called from main context */ void pa_sink_input_set_mute(pa_sink_input *i, pa_bool_t mute, pa_bool_t save) { pa_assert(i); pa_sink_input_assert_ref(i); diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h index e3801687..0bcb9d56 100644 --- a/src/pulsecore/sink-input.h +++ b/src/pulsecore/sink-input.h @@ -302,6 +302,7 @@ pa_usec_t pa_sink_input_get_latency(pa_sink_input *i, pa_usec_t *sink_latency); void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume, pa_bool_t save); const pa_cvolume *pa_sink_input_get_volume(pa_sink_input *i); +pa_cvolume *pa_sink_input_get_relative_volume(pa_sink_input *i, pa_cvolume *v); void pa_sink_input_set_mute(pa_sink_input *i, pa_bool_t mute, pa_bool_t save); pa_bool_t pa_sink_input_get_mute(pa_sink_input *i); void pa_sink_input_update_proplist(pa_sink_input *i, pa_update_mode_t mode, pa_proplist *p); diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c index c725595f..147926a0 100644 --- a/src/pulsecore/sink.c +++ b/src/pulsecore/sink.c @@ -1135,6 +1135,19 @@ const pa_cvolume *pa_sink_get_volume(pa_sink *s, pa_bool_t force_refresh) { } /* Called from main thread */ +void pa_sink_volume_changed(pa_sink *s, const pa_cvolume *new_volume) { + pa_sink_assert_ref(s); + + /* The sink implementor may call this if the volume changed to make sure everyone is notified */ + + if (pa_cvolume_equal(&s->virtual_volume, new_volume)) + return; + + s->virtual_volume = *new_volume; + pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index); +} + +/* Called from main thread */ void pa_sink_set_mute(pa_sink *s, pa_bool_t mute) { pa_bool_t old_muted; @@ -1174,6 +1187,19 @@ pa_bool_t pa_sink_get_mute(pa_sink *s, pa_bool_t force_refresh) { } /* Called from main thread */ +void pa_sink_mute_changed(pa_sink *s, pa_bool_t new_muted) { + pa_sink_assert_ref(s); + + /* The sink implementor may call this if the volume changed to make sure everyone is notified */ + + if (s->muted == new_muted) + return; + + s->muted = new_muted; + pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index); +} + +/* Called from main thread */ pa_bool_t pa_sink_update_proplist(pa_sink *s, pa_update_mode_t mode, pa_proplist *p) { pa_sink_assert_ref(s); diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h index 0d33679f..448f2805 100644 --- a/src/pulsecore/sink.h +++ b/src/pulsecore/sink.h @@ -224,6 +224,8 @@ void pa_sink_detach(pa_sink *s); void pa_sink_attach(pa_sink *s); void pa_sink_set_soft_volume(pa_sink *s, const pa_cvolume *volume); +void pa_sink_volume_changed(pa_sink *s, const pa_cvolume *new_volume); +void pa_sink_mute_changed(pa_sink *s, pa_bool_t new_muted); pa_bool_t pa_device_init_description(pa_proplist *p); pa_bool_t pa_device_init_icon(pa_proplist *p, pa_bool_t is_sink); diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c index cc6dfc40..ac1ef1e7 100644 --- a/src/pulsecore/source.c +++ b/src/pulsecore/source.c @@ -675,6 +675,19 @@ const pa_cvolume *pa_source_get_volume(pa_source *s, pa_bool_t force_refresh) { } /* Called from main thread */ +void pa_source_volume_changed(pa_source *s, const pa_cvolume *new_volume) { + pa_source_assert_ref(s); + + /* The source implementor may call this if the volume changed to make sure everyone is notified */ + + if (pa_cvolume_equal(&s->virtual_volume, new_volume)) + return; + + s->virtual_volume = *new_volume; + pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE, s->index); +} + +/* Called from main thread */ void pa_source_set_mute(pa_source *s, pa_bool_t mute) { pa_bool_t old_muted; @@ -695,7 +708,6 @@ void pa_source_set_mute(pa_source *s, pa_bool_t mute) { /* Called from main thread */ pa_bool_t pa_source_get_mute(pa_source *s, pa_bool_t force_refresh) { - pa_source_assert_ref(s); pa_assert(PA_SOURCE_IS_LINKED(s->state)); @@ -715,6 +727,19 @@ pa_bool_t pa_source_get_mute(pa_source *s, pa_bool_t force_refresh) { } /* Called from main thread */ +void pa_source_mute_changed(pa_source *s, pa_bool_t new_muted) { + pa_source_assert_ref(s); + + /* The source implementor may call this if the mute state changed to make sure everyone is notified */ + + if (s->muted == new_muted) + return; + + s->muted = new_muted; + pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE, s->index); +} + +/* Called from main thread */ pa_bool_t pa_source_update_proplist(pa_source *s, pa_update_mode_t mode, pa_proplist *p) { pa_source_assert_ref(s); pa_assert(p); diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h index 26471de0..68bf2f06 100644 --- a/src/pulsecore/source.h +++ b/src/pulsecore/source.h @@ -211,6 +211,8 @@ void pa_source_detach(pa_source *s); void pa_source_attach(pa_source *s); void pa_source_set_soft_volume(pa_source *s, const pa_cvolume *volume); +void pa_source_volume_changed(pa_source *s, const pa_cvolume *new_volume); +void pa_source_mute_changed(pa_source *s, pa_bool_t new_muted); int pa_source_sync_suspend(pa_source *s); |