pulse: make a few things smaller by making them bitfields
authorLennart Poettering <lennart@poettering.net>
Fri, 16 Oct 2009 15:28:42 +0000 (17:28 +0200)
committerSebastian Dröge <sebastian.droege@collabora.co.uk>
Sat, 17 Oct 2009 06:48:21 +0000 (08:48 +0200)
ext/pulse/pulsemixerctrl.c
ext/pulse/pulsemixerctrl.h
ext/pulse/pulseprobe.c
ext/pulse/pulseprobe.h
ext/pulse/pulsesink.c
ext/pulse/pulsesink.h
ext/pulse/pulsesrc.h

index f0bc646..cd3c8e2 100644 (file)
@@ -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) {
index 0dbc139..e6b67ad 100644 (file)
@@ -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,
index 3c601c2..b393b2c 100644 (file)
@@ -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;
 }
index bd20591..28cdbb8 100644 (file)
@@ -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,
index 58344e2..d84c49d 100644 (file)
@@ -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
index c7ff2e8..ae0ad95 100644 (file)
@@ -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
index 2358eba..be89434 100644 (file)
@@ -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