pulse: make a few things smaller by making them bitfields

This commit is contained in:
Lennart Poettering 2009-10-16 17:28:42 +02:00 committed by Sebastian Dröge
parent abd7ec63cf
commit d64200f46b
7 changed files with 63 additions and 38 deletions

View file

@ -1,3 +1,5 @@
/*-*- Mode: C; c-basic-offset: 2 -*-*/
/* /*
* GStreamer pulseaudio plugin * 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) { if (!i && eol < 0) {
c->operation_success = 0; c->operation_success = FALSE;
pa_threaded_mainloop_signal (c->mainloop, 0); pa_threaded_mainloop_signal (c->mainloop, 0);
return; return;
} }
@ -89,7 +91,7 @@ gst_pulsemixer_ctrl_sink_info_cb (pa_context * context, const pa_sink_info * i,
c->index = i->index; c->index = i->index;
c->channel_map = i->channel_map; c->channel_map = i->channel_map;
c->volume = i->volume; c->volume = i->volume;
c->muted = i->mute; c->muted = !!i->mute;
c->type = GST_PULSEMIXER_SINK; c->type = GST_PULSEMIXER_SINK;
if (c->track) { 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->track->flags = flags;
} }
c->operation_success = 1; c->operation_success = TRUE;
pa_threaded_mainloop_signal (c->mainloop, 0); pa_threaded_mainloop_signal (c->mainloop, 0);
} }
@ -124,7 +126,7 @@ gst_pulsemixer_ctrl_source_info_cb (pa_context * context,
} }
if (!i && eol < 0) { if (!i && eol < 0) {
c->operation_success = 0; c->operation_success = FALSE;
pa_threaded_mainloop_signal (c->mainloop, 0); pa_threaded_mainloop_signal (c->mainloop, 0);
return; return;
} }
@ -139,7 +141,7 @@ gst_pulsemixer_ctrl_source_info_cb (pa_context * context,
c->index = i->index; c->index = i->index;
c->channel_map = i->channel_map; c->channel_map = i->channel_map;
c->volume = i->volume; c->volume = i->volume;
c->muted = i->mute; c->muted = !!i->mute;
c->type = GST_PULSEMIXER_SOURCE; c->type = GST_PULSEMIXER_SOURCE;
if (c->track) { if (c->track) {
@ -150,7 +152,7 @@ gst_pulsemixer_ctrl_source_info_cb (pa_context * context,
c->track->flags = flags; c->track->flags = flags;
} }
c->operation_success = 1; c->operation_success = TRUE;
pa_threaded_mainloop_signal (c->mainloop, 0); 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; GstPulseMixerCtrl *c = (GstPulseMixerCtrl *) userdata;
c->operation_success = success; c->operation_success = !!success;
pa_threaded_mainloop_signal (c->mainloop, 0); pa_threaded_mainloop_signal (c->mainloop, 0);
} }
@ -260,7 +262,7 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c)
goto unlock_and_fail; goto unlock_and_fail;
} }
c->operation_success = 0; c->operation_success = FALSE;
while (pa_operation_get_state (o) != PA_OPERATION_DONE) { while (pa_operation_get_state (o) != PA_OPERATION_DONE) {
pa_threaded_mainloop_wait (c->mainloop); pa_threaded_mainloop_wait (c->mainloop);
CHECK_DEAD_GOTO (c, unlock_and_fail); CHECK_DEAD_GOTO (c, unlock_and_fail);
@ -286,7 +288,7 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c)
goto unlock_and_fail; goto unlock_and_fail;
} }
c->operation_success = 0; c->operation_success = FALSE;
while (pa_operation_get_state (o) != PA_OPERATION_DONE) { while (pa_operation_get_state (o) != PA_OPERATION_DONE) {
pa_threaded_mainloop_wait (c->mainloop); pa_threaded_mainloop_wait (c->mainloop);
CHECK_DEAD_GOTO (c, unlock_and_fail); CHECK_DEAD_GOTO (c, unlock_and_fail);
@ -312,7 +314,7 @@ gst_pulsemixer_ctrl_open (GstPulseMixerCtrl * c)
goto unlock_and_fail; goto unlock_and_fail;
} }
c->operation_success = 0; c->operation_success = FALSE;
while (pa_operation_get_state (o) != PA_OPERATION_DONE) { while (pa_operation_get_state (o) != PA_OPERATION_DONE) {
pa_threaded_mainloop_wait (c->mainloop); pa_threaded_mainloop_wait (c->mainloop);
CHECK_DEAD_GOTO (c, unlock_and_fail); 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_cvolume_mute (&c->volume, PA_CHANNELS_MAX);
pa_channel_map_init (&c->channel_map); pa_channel_map_init (&c->channel_map);
c->muted = 0; c->muted = FALSE;
c->index = PA_INVALID_INDEX; c->index = PA_INVALID_INDEX;
c->type = type; c->type = type;
c->name = NULL; 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->update_mute) {
if (c->type == GST_PULSEMIXER_SINK) 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); NULL, NULL);
else 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); NULL, NULL);
if (!o) if (!o)
@ -576,7 +578,7 @@ gst_pulsemixer_ctrl_set_mute (GstPulseMixerCtrl * c, GstMixerTrack * track,
pa_threaded_mainloop_lock (c->mainloop); pa_threaded_mainloop_lock (c->mainloop);
c->muted = !!mute; c->muted = mute;
c->update_mute = TRUE; c->update_mute = TRUE;
if (c->track) { if (c->track) {

View file

@ -1,3 +1,5 @@
/*-*- Mode: C; c-basic-offset: 2 -*-*/
/* /*
* GStreamer pulseaudio plugin * GStreamer pulseaudio plugin
* *
@ -53,11 +55,17 @@ struct _GstPulseMixerCtrl
gchar *name, *description; gchar *name, *description;
pa_channel_map channel_map; pa_channel_map channel_map;
pa_cvolume volume; pa_cvolume volume;
int muted; gboolean muted:1;
gboolean update_volume:1;
gboolean update_mute:1;
gboolean operation_success:1;
guint32 index; guint32 index;
GstPulseMixerType type; GstPulseMixerType type;
int operation_success;
GstMixerTrack *track; GstMixerTrack *track;
@ -66,7 +74,6 @@ struct _GstPulseMixerCtrl
int outstandig_queries; int outstandig_queries;
int ignore_queries; int ignore_queries;
gboolean update_volume, update_mute;
}; };
GstPulseMixerCtrl *gst_pulsemixer_ctrl_new (GObject *object, const gchar * server, GstPulseMixerCtrl *gst_pulsemixer_ctrl_new (GObject *object, const gchar * server,

View file

@ -201,7 +201,7 @@ gst_pulseprobe_enumerate (GstPulseProbe * c)
goto unlock_and_fail; goto unlock_and_fail;
} }
c->operation_success = 0; c->operation_success = FALSE;
while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) { while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) {
@ -232,7 +232,7 @@ gst_pulseprobe_enumerate (GstPulseProbe * c)
goto unlock_and_fail; goto unlock_and_fail;
} }
c->operation_success = 0; c->operation_success = FALSE;
while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) { while (pa_operation_get_state (o) == PA_OPERATION_RUNNING) {
if (gst_pulseprobe_is_dead (c)) if (gst_pulseprobe_is_dead (c))
@ -308,8 +308,11 @@ gst_pulseprobe_new (GObject * object, GObjectClass * klass,
c->prop_id = prop_id; c->prop_id = prop_id;
c->properties = c->properties =
g_list_append (NULL, g_object_class_find_property (klass, "device")); g_list_append (NULL, g_object_class_find_property (klass, "device"));
c->devices = NULL; c->devices = NULL;
c->devices_valid = 0; c->devices_valid = FALSE;
c->operation_success = FALSE;
return c; return c;
} }

View file

@ -1,3 +1,5 @@
/*-*- Mode: C; c-basic-offset: 2 -*-*/
/* /*
* GStreamer pulseaudio plugin * GStreamer pulseaudio plugin
* *
@ -36,17 +38,20 @@ struct _GstPulseProbe
{ {
GObject *object; GObject *object;
gchar *server; gchar *server;
GList *devices; 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_threaded_mainloop *mainloop;
pa_context *context; pa_context *context;
GList *properties; GList *properties;
guint prop_id; guint prop_id;
int enumerate_sinks, enumerate_sources;
int operation_success;
}; };
GstPulseProbe *gst_pulseprobe_new (GObject *object, GObjectClass * klass, GstPulseProbe *gst_pulseprobe_new (GObject *object, GObjectClass * klass,

View file

@ -1,3 +1,5 @@
/*-*- Mode: C; c-basic-offset: 2 -*-*/
/* GStreamer pulseaudio plugin /* GStreamer pulseaudio plugin
* *
* Copyright (c) 2004-2008 Lennart Poettering * Copyright (c) 2004-2008 Lennart Poettering
@ -109,10 +111,9 @@ struct _GstPulseRingBuffer
pa_sample_spec sample_spec; pa_sample_spec sample_spec;
gboolean corked; gboolean corked:1;
gboolean in_commit; gboolean in_commit:1;
gboolean paused; gboolean paused:1;
guint required;
}; };
struct _GstPulseRingBufferClass struct _GstPulseRingBufferClass
@ -218,8 +219,9 @@ gst_pulseringbuffer_init (GstPulseRingBuffer * pbuf,
pbuf->sample_spec.channels = 0; pbuf->sample_spec.channels = 0;
#endif #endif
pbuf->paused = FALSE;
pbuf->corked = TRUE; pbuf->corked = TRUE;
pbuf->in_commit = FALSE;
pbuf->paused = FALSE;
} }
static void static void

View file

@ -1,3 +1,5 @@
/*-*- Mode: C; c-basic-offset: 2 -*-*/
/* /*
* GStreamer pulseaudio plugin * GStreamer pulseaudio plugin
* *
@ -60,14 +62,16 @@ struct _GstPulseSink
GstPulseProbe *probe; GstPulseProbe *probe;
gdouble volume; gdouble volume;
gboolean volume_set; gboolean volume_set:1;
gboolean mute; gboolean mute:1;
gboolean mute_set; gboolean mute_set:1;
gint notify;
gboolean pa_defer_ran:1;
gint notify; /* atomic */
const gchar *pa_version; const gchar *pa_version;
gboolean pa_defer_ran;
}; };
struct _GstPulseSinkClass struct _GstPulseSinkClass

View file

@ -1,3 +1,5 @@
/*-*- Mode: C; c-basic-offset: 2 -*-*/
/* /*
* GStreamer pulseaudio plugin * GStreamer pulseaudio plugin
* *
@ -70,10 +72,10 @@ struct _GstPulseSrc
GstPulseMixerCtrl *mixer; GstPulseMixerCtrl *mixer;
GstPulseProbe *probe; GstPulseProbe *probe;
gboolean corked; gboolean corked:1;
gboolean operation_success; gboolean operation_success:1;
gboolean paused; gboolean paused:1;
gboolean in_read; gboolean in_read:1;
}; };
struct _GstPulseSrcClass struct _GstPulseSrcClass