From 98d27997ef22c29fabbebeb36472ef446f61b499 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 16 Oct 2009 17:28:42 +0200 Subject: pulse: make a few things smaller by making them bitfields --- ext/pulse/pulsemixerctrl.c | 30 ++++++++++++++++-------------- ext/pulse/pulsemixerctrl.h | 13 ++++++++++--- ext/pulse/pulseprobe.c | 9 ++++++--- ext/pulse/pulseprobe.h | 13 +++++++++---- ext/pulse/pulsesink.c | 12 +++++++----- ext/pulse/pulsesink.h | 14 +++++++++----- ext/pulse/pulsesrc.h | 10 ++++++---- 7 files changed, 63 insertions(+), 38 deletions(-) diff --git a/ext/pulse/pulsemixerctrl.c b/ext/pulse/pulsemixerctrl.c index f0bc6463..cd3c8e24 100644 --- a/ext/pulse/pulsemixerctrl.c +++ b/ext/pulse/pulsemixerctrl.c @@ -1,3 +1,5 @@ +/*-*- Mode: C; c-basic-offset: 2 -*-*/ + /* * GStreamer pulseaudio plugin * @@ -74,7 +76,7 @@ gst_pulsemixer_ctrl_sink_info_cb (pa_context * context, const pa_sink_info * i, } if (!i && eol < 0) { - c->operation_success = 0; + c->operation_success = FALSE; pa_threaded_mainloop_signal (c->mainloop, 0); return; } @@ -89,7 +91,7 @@ gst_pulsemixer_ctrl_sink_info_cb (pa_context * context, const pa_sink_info * i, c->index = i->index; c->channel_map = i->channel_map; c->volume = i->volume; - c->muted = i->mute; + c->muted = !!i->mute; c->type = GST_PULSEMIXER_SINK; if (c->track) { @@ -100,7 +102,7 @@ gst_pulsemixer_ctrl_sink_info_cb (pa_context * context, const pa_sink_info * i, c->track->flags = flags; } - c->operation_success = 1; + c->operation_success = TRUE; pa_threaded_mainloop_signal (c->mainloop, 0); } @@ -124,7 +126,7 @@ gst_pulsemixer_ctrl_source_info_cb (pa_context * context, } if (!i && eol < 0) { - c->operation_success = 0; + c->operation_success = FALSE; pa_threaded_mainloop_signal (c->mainloop, 0); return; } @@ -139,7 +141,7 @@ gst_pulsemixer_ctrl_source_info_cb (pa_context * context, c->index = i->index; c->channel_map = i->channel_map; c->volume = i->volume; - c->muted = i->mute; + c->muted = !!i->mute; c->type = GST_PULSEMIXER_SOURCE; if (c->track) { @@ -150,7 +152,7 @@ gst_pulsemixer_ctrl_source_info_cb (pa_context * context, c->track->flags = flags; } - c->operation_success = 1; + c->operation_success = TRUE; pa_threaded_mainloop_signal (c->mainloop, 0); } @@ -193,7 +195,7 @@ gst_pulsemixer_ctrl_success_cb (pa_context * context, int success, { GstPulseMixerCtrl *c = (GstPulseMixerCtrl *) userdata; - c->operation_success = success; + c->operation_success = !!success; pa_threaded_mainloop_signal (c->mainloop, 0); } @@ -260,7 +262,7 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) goto unlock_and_fail; } - c->operation_success = 0; + c->operation_success = FALSE; while (pa_operation_get_state (o) != PA_OPERATION_DONE) { pa_threaded_mainloop_wait (c->mainloop); CHECK_DEAD_GOTO (c, unlock_and_fail); @@ -286,7 +288,7 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) goto unlock_and_fail; } - c->operation_success = 0; + c->operation_success = FALSE; while (pa_operation_get_state (o) != PA_OPERATION_DONE) { pa_threaded_mainloop_wait (c->mainloop); CHECK_DEAD_GOTO (c, unlock_and_fail); @@ -312,7 +314,7 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c) goto unlock_and_fail; } - c->operation_success = 0; + c->operation_success = FALSE; while (pa_operation_get_state (o) != PA_OPERATION_DONE) { pa_threaded_mainloop_wait (c->mainloop); CHECK_DEAD_GOTO (c, unlock_and_fail); @@ -404,7 +406,7 @@ gst_pulsemixer_ctrl_new (GObject * object, const gchar * server, pa_cvolume_mute (&c->volume, PA_CHANNELS_MAX); pa_channel_map_init (&c->channel_map); - c->muted = 0; + c->muted = FALSE; c->index = PA_INVALID_INDEX; c->type = type; c->name = NULL; @@ -470,10 +472,10 @@ gst_pulsemixer_ctrl_timeout_event (pa_mainloop_api * a, pa_time_event * e, if (c->update_mute) { if (c->type == GST_PULSEMIXER_SINK) - o = pa_context_set_sink_mute_by_index (c->context, c->index, !!c->muted, + o = pa_context_set_sink_mute_by_index (c->context, c->index, c->muted, NULL, NULL); else - o = pa_context_set_source_mute_by_index (c->context, c->index, !!c->muted, + o = pa_context_set_source_mute_by_index (c->context, c->index, c->muted, NULL, NULL); if (!o) @@ -576,7 +578,7 @@ gst_pulsemixer_ctrl_set_mute (GstPulseMixerCtrl * c, GstMixerTrack * track, pa_threaded_mainloop_lock (c->mainloop); - c->muted = !!mute; + c->muted = mute; c->update_mute = TRUE; if (c->track) { diff --git a/ext/pulse/pulsemixerctrl.h b/ext/pulse/pulsemixerctrl.h index 0dbc1391..e6b67ad2 100644 --- a/ext/pulse/pulsemixerctrl.h +++ b/ext/pulse/pulsemixerctrl.h @@ -1,3 +1,5 @@ +/*-*- Mode: C; c-basic-offset: 2 -*-*/ + /* * GStreamer pulseaudio plugin * @@ -53,11 +55,17 @@ struct _GstPulseMixerCtrl gchar *name, *description; pa_channel_map channel_map; + pa_cvolume volume; - int muted; + gboolean muted:1; + + gboolean update_volume:1; + gboolean update_mute:1; + + gboolean operation_success:1; + guint32 index; GstPulseMixerType type; - int operation_success; GstMixerTrack *track; @@ -66,7 +74,6 @@ struct _GstPulseMixerCtrl int outstandig_queries; int ignore_queries; - gboolean update_volume, update_mute; }; GstPulseMixerCtrl *gst_pulsemixer_ctrl_new (GObject *object, const gchar * server, diff --git a/ext/pulse/pulseprobe.c b/ext/pulse/pulseprobe.c index 3c601c2f..b393b2c2 100644 --- a/ext/pulse/pulseprobe.c +++ b/ext/pulse/pulseprobe.c @@ -201,7 +201,7 @@ gst_pulseprobe_enumerate (GstPulseProbe * c) goto unlock_and_fail; } - c->operation_success = 0; + c->operation_success = FALSE; while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) { @@ -232,7 +232,7 @@ gst_pulseprobe_enumerate (GstPulseProbe * c) goto unlock_and_fail; } - c->operation_success = 0; + c->operation_success = FALSE; while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) { if (gst_pulseprobe_is_dead (c)) @@ -308,8 +308,11 @@ gst_pulseprobe_new (GObject * object, GObjectClass * klass, c->prop_id = prop_id; c->properties = g_list_append (NULL, g_object_class_find_property (klass, "device")); + c->devices = NULL; - c->devices_valid = 0; + c->devices_valid = FALSE; + + c->operation_success = FALSE; return c; } diff --git a/ext/pulse/pulseprobe.h b/ext/pulse/pulseprobe.h index bd20591a..28cdbb8d 100644 --- a/ext/pulse/pulseprobe.h +++ b/ext/pulse/pulseprobe.h @@ -1,3 +1,5 @@ +/*-*- Mode: C; c-basic-offset: 2 -*-*/ + /* * GStreamer pulseaudio plugin * @@ -36,17 +38,20 @@ struct _GstPulseProbe { GObject *object; gchar *server; + GList *devices; - gboolean devices_valid; + gboolean devices_valid:1; + + gboolean operation_success:1; + + gboolean enumerate_sinks:1; + gboolean enumerate_sources:1; pa_threaded_mainloop *mainloop; pa_context *context; GList *properties; guint prop_id; - - int enumerate_sinks, enumerate_sources; - int operation_success; }; GstPulseProbe *gst_pulseprobe_new (GObject *object, GObjectClass * klass, diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c index 58344e26..d84c49d4 100644 --- a/ext/pulse/pulsesink.c +++ b/ext/pulse/pulsesink.c @@ -1,3 +1,5 @@ +/*-*- Mode: C; c-basic-offset: 2 -*-*/ + /* GStreamer pulseaudio plugin * * Copyright (c) 2004-2008 Lennart Poettering @@ -109,10 +111,9 @@ struct _GstPulseRingBuffer pa_sample_spec sample_spec; - gboolean corked; - gboolean in_commit; - gboolean paused; - guint required; + gboolean corked:1; + gboolean in_commit:1; + gboolean paused:1; }; struct _GstPulseRingBufferClass @@ -218,8 +219,9 @@ gst_pulseringbuffer_init (GstPulseRingBuffer * pbuf, pbuf->sample_spec.channels = 0; #endif - pbuf->paused = FALSE; pbuf->corked = TRUE; + pbuf->in_commit = FALSE; + pbuf->paused = FALSE; } static void diff --git a/ext/pulse/pulsesink.h b/ext/pulse/pulsesink.h index c7ff2e87..ae0ad95f 100644 --- a/ext/pulse/pulsesink.h +++ b/ext/pulse/pulsesink.h @@ -1,3 +1,5 @@ +/*-*- Mode: C; c-basic-offset: 2 -*-*/ + /* * GStreamer pulseaudio plugin * @@ -60,14 +62,16 @@ struct _GstPulseSink GstPulseProbe *probe; gdouble volume; - gboolean volume_set; - gboolean mute; - gboolean mute_set; - gint notify; + gboolean volume_set:1; + gboolean mute:1; + gboolean mute_set:1; + + gboolean pa_defer_ran:1; + + gint notify; /* atomic */ const gchar *pa_version; - gboolean pa_defer_ran; }; struct _GstPulseSinkClass diff --git a/ext/pulse/pulsesrc.h b/ext/pulse/pulsesrc.h index 2358eba1..be894347 100644 --- a/ext/pulse/pulsesrc.h +++ b/ext/pulse/pulsesrc.h @@ -1,3 +1,5 @@ +/*-*- Mode: C; c-basic-offset: 2 -*-*/ + /* * GStreamer pulseaudio plugin * @@ -70,10 +72,10 @@ struct _GstPulseSrc GstPulseMixerCtrl *mixer; GstPulseProbe *probe; - gboolean corked; - gboolean operation_success; - gboolean paused; - gboolean in_read; + gboolean corked:1; + gboolean operation_success:1; + gboolean paused:1; + gboolean in_read:1; }; struct _GstPulseSrcClass -- cgit