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
#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 */
/* adaptations */

View file

@ -26,6 +26,7 @@
#include <gst/gst.h>
#include "gstatomicqueue.h"
#include "glib-compat-private.h"
/**
* SECTION:gstatomicqueue
@ -112,8 +113,8 @@ add_to_free_list (GstAtomicQueue * queue, GstAQueueMem * mem)
{
do {
mem->free = g_atomic_pointer_get (&queue->free_list);
} while (!g_atomic_pointer_compare_and_exchange ((gpointer *) &
queue->free_list, mem->free, mem));
} while (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->free_list,
mem->free, mem));
}
static void
@ -126,8 +127,8 @@ clear_free_list (GstAtomicQueue * queue)
free_list = g_atomic_pointer_get (&queue->free_list);
if (free_list == NULL)
return;
} while (!g_atomic_pointer_compare_and_exchange ((gpointer *) &
queue->free_list, free_list, NULL));
} while (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->free_list, free_list,
NULL));
while (free_list) {
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,
* some other reader managed to do it first and we retry */
if (!g_atomic_pointer_compare_and_exchange ((gpointer *) &
queue->head_mem, head_mem, next))
if (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->head_mem, head_mem,
next))
continue;
/* 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,
* some other reader managed to do it first and we retry */
if (!g_atomic_pointer_compare_and_exchange ((gpointer *) &
queue->head_mem, head_mem, next))
if (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->head_mem, head_mem,
next))
continue;
/* 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);
/* try to make our new array visible to other writers */
if (!g_atomic_pointer_compare_and_exchange ((gpointer *) &
queue->tail_mem, tail_mem, mem)) {
if (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->tail_mem, tail_mem,
mem)) {
/* 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
* again */

View file

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

View file

@ -57,6 +57,7 @@
#endif
#include "gst_private.h"
#include "glib-compat-private.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 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 DEC_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_ADD(&(s)->waiting, -1))
#define GET_WAITING(s) (g_atomic_int_get(&(s)->waiting))
#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;
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 */
result = WAKE_EVENT (set);
}
@ -214,7 +215,7 @@ release_all_wakeup (GstPoll * set)
break;
else
/* 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;

View file

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

View file

@ -39,6 +39,7 @@
#include "gstparse.h"
#include "gstvalue.h"
#include "gst-i18n-lib.h"
#include "glib-compat-private.h"
#include <math.h>
/**
@ -704,7 +705,7 @@ guint32
gst_util_seqnum_next (void)
{
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 '#include <config.h>' >> 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 && \
rm lex._gst_parse_yy_tmp.c && \
mv lex._gst_parse_yy_tmp2.c lex._gst_parse_yy.c

View file

@ -112,6 +112,7 @@
#include <gst/gst.h>
#include <stdio.h>
#include "gstmultiqueue.h"
#include <gst/glib-compat-private.h>
/**
* GstSingleQueue:
@ -1360,7 +1361,7 @@ gst_multi_queue_chain (GstPad * pad, GstBuffer * buffer)
goto was_eos;
/* 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",
sq->id, buffer, curid);
@ -1466,7 +1467,7 @@ gst_multi_queue_sink_event (GstPad * pad, GstEvent * event)
goto was_eos;
/* 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);

View file

@ -20,6 +20,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
#include <gst/glib-compat-private.h>
#define MAX_THREADS 100
@ -34,7 +35,7 @@ run_test (void *user_data)
while (running) {
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)
g_warning ("overflow");
}