summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian.droege@collabora.co.uk>2009-02-22 18:08:59 +0100
committerSebastian Dröge <sebastian.droege@collabora.co.uk>2009-02-22 18:08:59 +0100
commitdfa627da30dd44e170f3249ff3bdda333ea1edf1 (patch)
treed97e948b73fe70047d0567f15656c3073ee2eb2b
parent64a91fcf8a40e660a75ee1e427cb23d6a2febdd8 (diff)
pulsemixer: Don't use g_atomic_int_(get|set) for accessing the mixer track flags
g_atomic_int_(get|set) only work on ints and the flags are an enum (which on most architectures is stored as an int). Also the way the flags were accessed atomically would still leave a possible race condition and we don't do it in any other mixer track implementation, let alone at any other place where an integer could be changed from different threads. Removing the g_atomic_int_(get|set) will only introduce a new race condition on architectures where integers could be half-written while reading them which shouldn't be the case for any modern architecture and if we really care about this we need to use g_atomic_int_(get|set) at many other places too. Apart from that g_atomic_int_(set|get) will result in aliasing warnings if their argument is explicitely casted to an int *. Fixes bug #571153.
-rw-r--r--ext/pulse/pulsemixerctrl.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/ext/pulse/pulsemixerctrl.c b/ext/pulse/pulsemixerctrl.c
index 41b68cfc..ae807c66 100644
--- a/ext/pulse/pulsemixerctrl.c
+++ b/ext/pulse/pulsemixerctrl.c
@@ -93,10 +93,11 @@ gst_pulsemixer_ctrl_sink_info_cb (pa_context * context, const pa_sink_info * i,
c->type = GST_PULSEMIXER_SINK;
if (c->track) {
- int i = g_atomic_int_get ((gint *) & c->track->flags);
+ GstMixerTrackFlags flags = c->track->flags;
- i = (i & ~GST_MIXER_TRACK_MUTE) | (c->muted ? GST_MIXER_TRACK_MUTE : 0);
- g_atomic_int_set ((gint *) & c->track->flags, i);
+ flags =
+ (flags & ~GST_MIXER_TRACK_MUTE) | (c->muted ? GST_MIXER_TRACK_MUTE : 0);
+ c->track->flags = flags;
}
c->operation_success = 1;
@@ -142,10 +143,11 @@ gst_pulsemixer_ctrl_source_info_cb (pa_context * context,
c->type = GST_PULSEMIXER_SOURCE;
if (c->track) {
- int i = g_atomic_int_get ((gint *) & c->track->flags);
+ GstMixerTrackFlags flags = c->track->flags;
- i = (i & ~GST_MIXER_TRACK_MUTE) | (c->muted ? GST_MIXER_TRACK_MUTE : 0);
- g_atomic_int_set ((gint *) & c->track->flags, i);
+ flags =
+ (flags & ~GST_MIXER_TRACK_MUTE) | (c->muted ? GST_MIXER_TRACK_MUTE : 0);
+ c->track->flags = flags;
}
c->operation_success = 1;
@@ -572,10 +574,11 @@ gst_pulsemixer_ctrl_set_mute (GstPulseMixerCtrl * c, GstMixerTrack * track,
c->update_mute = TRUE;
if (c->track) {
- int i = g_atomic_int_get ((gint *) & c->track->flags);
+ GstMixerTrackFlags flags = c->track->flags;
- i = (i & ~GST_MIXER_TRACK_MUTE) | (c->muted ? GST_MIXER_TRACK_MUTE : 0);
- g_atomic_int_set ((gint *) & c->track->flags, i);
+ flags =
+ (flags & ~GST_MIXER_TRACK_MUTE) | (c->muted ? GST_MIXER_TRACK_MUTE : 0);
+ c->track->flags = flags;
}
restart_time_event (c);