Merge branch 'master' into 0.11

This commit is contained in:
Tim-Philipp Müller 2011-06-05 15:46:54 +01:00
commit 5a8273e527
9 changed files with 50 additions and 22 deletions

View file

@ -26,6 +26,26 @@ typedef struct stat GStatBuf;
#define GLIB_HAS_GDATETIME #define GLIB_HAS_GDATETIME
#endif #endif
/* See bug #651514 */
#if GLIB_CHECK_VERSION(2,29,5)
#define G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE(a,b,c) \
g_atomic_pointer_compare_and_exchange ((a),(b),(c))
#define G_ATOMIC_INT_COMPARE_AND_EXCHANGE(a,b,c) \
g_atomic_int_compare_and_exchange ((a),(b),(c))
#else
#define G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE(a,b,c) \
g_atomic_pointer_compare_and_exchange ((volatile gpointer *)(a),(b),(c))
#define G_ATOMIC_INT_COMPARE_AND_EXCHANGE(a,b,c) \
g_atomic_int_compare_and_exchange ((volatile int *)(a),(b),(c))
#endif
/* See bug #651514 */
#if GLIB_CHECK_VERSION(2,29,5)
#define G_ATOMIC_INT_ADD(a,b) g_atomic_int_add ((a),(b))
#else
#define G_ATOMIC_INT_ADD(a,b) g_atomic_int_exchange_and_add ((a),(b))
#endif
/* copies */ /* copies */
/* adaptations */ /* adaptations */

View file

@ -26,6 +26,7 @@
#include <gst/gst.h> #include <gst/gst.h>
#include "gstatomicqueue.h" #include "gstatomicqueue.h"
#include "glib-compat-private.h"
/** /**
* SECTION:gstatomicqueue * SECTION:gstatomicqueue
@ -112,8 +113,8 @@ add_to_free_list (GstAtomicQueue * queue, GstAQueueMem * mem)
{ {
do { do {
mem->free = g_atomic_pointer_get (&queue->free_list); mem->free = g_atomic_pointer_get (&queue->free_list);
} while (!g_atomic_pointer_compare_and_exchange ((gpointer *) & } while (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->free_list,
queue->free_list, mem->free, mem)); mem->free, mem));
} }
static void static void
@ -126,8 +127,8 @@ clear_free_list (GstAtomicQueue * queue)
free_list = g_atomic_pointer_get (&queue->free_list); free_list = g_atomic_pointer_get (&queue->free_list);
if (free_list == NULL) if (free_list == NULL)
return; return;
} while (!g_atomic_pointer_compare_and_exchange ((gpointer *) & } while (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->free_list, free_list,
queue->free_list, free_list, NULL)); NULL));
while (free_list) { while (free_list) {
GstAQueueMem *next = free_list->free; GstAQueueMem *next = free_list->free;
@ -247,8 +248,8 @@ gst_atomic_queue_peek (GstAtomicQueue * queue)
/* now we try to move the next array as the head memory. If we fail to do that, /* now we try to move the next array as the head memory. If we fail to do that,
* some other reader managed to do it first and we retry */ * some other reader managed to do it first and we retry */
if (!g_atomic_pointer_compare_and_exchange ((gpointer *) & if (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->head_mem, head_mem,
queue->head_mem, head_mem, next)) next))
continue; continue;
/* when we managed to swing the head pointer the old head is now /* when we managed to swing the head pointer the old head is now
@ -304,8 +305,8 @@ gst_atomic_queue_pop (GstAtomicQueue * queue)
/* now we try to move the next array as the head memory. If we fail to do that, /* now we try to move the next array as the head memory. If we fail to do that,
* some other reader managed to do it first and we retry */ * some other reader managed to do it first and we retry */
if (!g_atomic_pointer_compare_and_exchange ((gpointer *) & if (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->head_mem, head_mem,
queue->head_mem, head_mem, next)) next))
continue; continue;
/* when we managed to swing the head pointer the old head is now /* when we managed to swing the head pointer the old head is now
@ -362,8 +363,8 @@ gst_atomic_queue_push (GstAtomicQueue * queue, gpointer data)
mem = new_queue_mem ((size << 1) + 1, tail); mem = new_queue_mem ((size << 1) + 1, tail);
/* try to make our new array visible to other writers */ /* try to make our new array visible to other writers */
if (!g_atomic_pointer_compare_and_exchange ((gpointer *) & if (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->tail_mem, tail_mem,
queue->tail_mem, tail_mem, mem)) { mem)) {
/* we tried to swap the new writer array but something changed. This is /* we tried to swap the new writer array but something changed. This is
* because some other writer beat us to it, we free our memory and try * because some other writer beat us to it, we free our memory and try
* again */ * again */

View file

@ -394,8 +394,8 @@ gst_element_factory_create (GstElementFactory * factory, const gchar * name)
* an element at the same moment * an element at the same moment
*/ */
oclass = GST_ELEMENT_GET_CLASS (element); oclass = GST_ELEMENT_GET_CLASS (element);
if (!g_atomic_pointer_compare_and_exchange ( if (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&oclass->elementfactory, NULL,
(gpointer) & oclass->elementfactory, NULL, factory)) factory))
gst_object_unref (factory); gst_object_unref (factory);
GST_DEBUG ("created element \"%s\"", GST_OBJECT_NAME (factory)); GST_DEBUG ("created element \"%s\"", GST_OBJECT_NAME (factory));

View file

@ -57,6 +57,7 @@
#endif #endif
#include "gst_private.h" #include "gst_private.h"
#include "glib-compat-private.h"
#include <sys/types.h> #include <sys/types.h>
@ -154,8 +155,8 @@ static gboolean gst_poll_add_fd_unlocked (GstPoll * set, GstPollFD * fd);
#define IS_FLUSHING(s) (g_atomic_int_get(&(s)->flushing)) #define IS_FLUSHING(s) (g_atomic_int_get(&(s)->flushing))
#define SET_FLUSHING(s,val) (g_atomic_int_set(&(s)->flushing, (val))) #define SET_FLUSHING(s,val) (g_atomic_int_set(&(s)->flushing, (val)))
#define INC_WAITING(s) (g_atomic_int_exchange_and_add(&(s)->waiting, 1)) #define INC_WAITING(s) (G_ATOMIC_INT_ADD(&(s)->waiting, 1))
#define DEC_WAITING(s) (g_atomic_int_exchange_and_add(&(s)->waiting, -1)) #define DEC_WAITING(s) (G_ATOMIC_INT_ADD(&(s)->waiting, -1))
#define GET_WAITING(s) (g_atomic_int_get(&(s)->waiting)) #define GET_WAITING(s) (g_atomic_int_get(&(s)->waiting))
#define TEST_REBUILD(s) (g_atomic_int_compare_and_exchange(&(s)->rebuild, 1, 0)) #define TEST_REBUILD(s) (g_atomic_int_compare_and_exchange(&(s)->rebuild, 1, 0))
@ -176,7 +177,7 @@ raise_wakeup (GstPoll * set)
{ {
gboolean result = TRUE; gboolean result = TRUE;
if (g_atomic_int_exchange_and_add (&set->control_pending, 1) == 0) { if (G_ATOMIC_INT_ADD (&set->control_pending, 1) == 0) {
/* raise when nothing pending */ /* raise when nothing pending */
result = WAKE_EVENT (set); result = WAKE_EVENT (set);
} }
@ -214,7 +215,7 @@ release_all_wakeup (GstPoll * set)
break; break;
else else
/* retry again until we read it successfully */ /* retry again until we read it successfully */
g_atomic_int_exchange_and_add (&set->control_pending, 1); G_ATOMIC_INT_ADD (&set->control_pending, 1);
} }
} }
return old; return old;

View file

@ -44,6 +44,7 @@
#include "gstenumtypes.h" #include "gstenumtypes.h"
#include "gstpoll.h" #include "gstpoll.h"
#include "gstutils.h" #include "gstutils.h"
#include "glib-compat-private.h"
#include <errno.h> #include <errno.h>
@ -56,8 +57,8 @@
#define GET_ENTRY_STATUS(e) (g_atomic_int_get(&GST_CLOCK_ENTRY_STATUS(e))) #define GET_ENTRY_STATUS(e) (g_atomic_int_get(&GST_CLOCK_ENTRY_STATUS(e)))
#define SET_ENTRY_STATUS(e,val) (g_atomic_int_set(&GST_CLOCK_ENTRY_STATUS(e),(val))) #define SET_ENTRY_STATUS(e,val) (g_atomic_int_set(&GST_CLOCK_ENTRY_STATUS(e),(val)))
#define CAS_ENTRY_STATUS(e,old,val) (g_atomic_int_compare_and_exchange(\ #define CAS_ENTRY_STATUS(e,old,val) (G_ATOMIC_INT_COMPARE_AND_EXCHANGE(\
((volatile gint *)&GST_CLOCK_ENTRY_STATUS(e)), (old), (val))) (&GST_CLOCK_ENTRY_STATUS(e)), (old), (val)))
/* Define this to get some extra debug about jitter from each clock_wait */ /* Define this to get some extra debug about jitter from each clock_wait */
#undef WAIT_DEBUGGING #undef WAIT_DEBUGGING

View file

@ -39,6 +39,7 @@
#include "gstparse.h" #include "gstparse.h"
#include "gstvalue.h" #include "gstvalue.h"
#include "gst-i18n-lib.h" #include "gst-i18n-lib.h"
#include "glib-compat-private.h"
#include <math.h> #include <math.h>
/** /**
@ -704,7 +705,7 @@ guint32
gst_util_seqnum_next (void) gst_util_seqnum_next (void)
{ {
static gint counter = 0; static gint counter = 0;
return g_atomic_int_exchange_and_add (&counter, 1); return G_ATOMIC_INT_ADD (&counter, 1);
} }
/** /**

View file

@ -45,6 +45,8 @@ lex._gst_parse_yy.c: parse.l grammar.tab.h
echo '#ifdef HAVE_CONFIG_H' > lex._gst_parse_yy_tmp2.c && \ echo '#ifdef HAVE_CONFIG_H' > lex._gst_parse_yy_tmp2.c && \
echo '#include <config.h>' >> lex._gst_parse_yy_tmp2.c && \ echo '#include <config.h>' >> lex._gst_parse_yy_tmp2.c && \
echo '#endif' >> lex._gst_parse_yy_tmp2.c && \ echo '#endif' >> lex._gst_parse_yy_tmp2.c && \
echo 'static inline int _gst_parse_yyget_column (void * yyscanner);' >> lex._gst_parse_yy_tmp2.c && \
echo 'static inline void _gst_parse_yyset_column (int column_no , void * yyscanner);' >> lex._gst_parse_yy_tmp2.c && \
cat lex._gst_parse_yy_tmp.c >> lex._gst_parse_yy_tmp2.c && \ cat lex._gst_parse_yy_tmp.c >> lex._gst_parse_yy_tmp2.c && \
rm lex._gst_parse_yy_tmp.c && \ rm lex._gst_parse_yy_tmp.c && \
mv lex._gst_parse_yy_tmp2.c lex._gst_parse_yy.c mv lex._gst_parse_yy_tmp2.c lex._gst_parse_yy.c

View file

@ -112,6 +112,7 @@
#include <gst/gst.h> #include <gst/gst.h>
#include <stdio.h> #include <stdio.h>
#include "gstmultiqueue.h" #include "gstmultiqueue.h"
#include <gst/glib-compat-private.h>
/** /**
* GstSingleQueue: * GstSingleQueue:
@ -1360,7 +1361,7 @@ gst_multi_queue_chain (GstPad * pad, GstBuffer * buffer)
goto was_eos; goto was_eos;
/* Get a unique incrementing id */ /* Get a unique incrementing id */
curid = g_atomic_int_exchange_and_add ((gint *) & mq->counter, 1); curid = G_ATOMIC_INT_ADD ((gint *) & mq->counter, 1);
GST_LOG_OBJECT (mq, "SingleQueue %d : about to enqueue buffer %p with id %d", GST_LOG_OBJECT (mq, "SingleQueue %d : about to enqueue buffer %p with id %d",
sq->id, buffer, curid); sq->id, buffer, curid);
@ -1466,7 +1467,7 @@ gst_multi_queue_sink_event (GstPad * pad, GstEvent * event)
goto was_eos; goto was_eos;
/* Get an unique incrementing id. */ /* Get an unique incrementing id. */
curid = g_atomic_int_exchange_and_add ((gint *) & mq->counter, 1); curid = G_ATOMIC_INT_ADD ((gint *) & mq->counter, 1);
item = gst_multi_queue_event_item_new ((GstMiniObject *) event, curid); item = gst_multi_queue_event_item_new ((GstMiniObject *) event, curid);

View file

@ -20,6 +20,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <gst/gst.h> #include <gst/gst.h>
#include <gst/glib-compat-private.h>
#define MAX_THREADS 100 #define MAX_THREADS 100
@ -34,7 +35,7 @@ run_test (void *user_data)
while (running) { while (running) {
gst_clock_get_time (sysclock); gst_clock_get_time (sysclock);
prev = g_atomic_int_exchange_and_add (&count, 1); prev = G_ATOMIC_INT_ADD (&count, 1);
if (prev == G_MAXINT) if (prev == G_MAXINT)
g_warning ("overflow"); g_warning ("overflow");
} }