mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
Convert everything from GstAtomicInt to g_atomic_int_*, and remove gstatomic.
Original commit message from CVS: Convert everything from GstAtomicInt to g_atomic_int_*, and remove gstatomic. * gst/Makefile.am: * gst/gstatomic.c: * gst/gstatomic.h: * gst/gstatomic_impl.h: * gst/gstbuffer.c: * gst/gstcaps.c: * gst/gstcaps.h: * gst/gstclock.c: * gst/gstclock.h: * gst/gstdata.c: * gst/gstdata.h: * gst/gstdata_private.h: * gst/gstevent.c: * gst/gstinfo.c: * gst/gstinfo.h: * gst/gstmessage.c: * gst/gstobject.c: * gst/gstobject.h: * gst/gststructure.c: * gst/gststructure.h: * gst/gstutils.c: Add gst_atomic_int_set() compaitibility function. * gst/gstutils.h:
This commit is contained in:
parent
01c25dc75f
commit
46e13eb5e2
23 changed files with 98 additions and 656 deletions
27
ChangeLog
27
ChangeLog
|
@ -1,3 +1,30 @@
|
|||
2005-04-24 David Schleef <ds@schleef.org>
|
||||
|
||||
Convert everything from GstAtomicInt to g_atomic_int_*, and
|
||||
remove gstatomic.
|
||||
* gst/Makefile.am:
|
||||
* gst/gstatomic.c:
|
||||
* gst/gstatomic.h:
|
||||
* gst/gstatomic_impl.h:
|
||||
* gst/gstbuffer.c:
|
||||
* gst/gstcaps.c:
|
||||
* gst/gstcaps.h:
|
||||
* gst/gstclock.c:
|
||||
* gst/gstclock.h:
|
||||
* gst/gstdata.c:
|
||||
* gst/gstdata.h:
|
||||
* gst/gstdata_private.h:
|
||||
* gst/gstevent.c:
|
||||
* gst/gstinfo.c:
|
||||
* gst/gstinfo.h:
|
||||
* gst/gstmessage.c:
|
||||
* gst/gstobject.c:
|
||||
* gst/gstobject.h:
|
||||
* gst/gststructure.c:
|
||||
* gst/gststructure.h:
|
||||
* gst/gstutils.c: Add gst_atomic_int_set() compaitibility function.
|
||||
* gst/gstutils.h:
|
||||
|
||||
2005-04-24 David Schleef <ds@schleef.org>
|
||||
|
||||
* check/gst/gstpad.c: (START_TEST): Oh yeah, it's always nice to
|
||||
|
|
|
@ -77,7 +77,6 @@ EXTRA_libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \
|
|||
libgstreamer_@GST_MAJORMINOR@_la_SOURCES = \
|
||||
gst.c \
|
||||
gstobject.c \
|
||||
gstatomic.c \
|
||||
gstbin.c \
|
||||
gstbuffer.c \
|
||||
gstbus.c \
|
||||
|
@ -150,7 +149,6 @@ libgstreamer_@GST_MAJORMINOR@includedir = $(includedir)/gstreamer-@GST_MAJORMINO
|
|||
|
||||
gst_headers = \
|
||||
gst.h \
|
||||
gstatomic.h \
|
||||
gstobject.h \
|
||||
gstbin.h \
|
||||
gstbuffer.h \
|
||||
|
@ -206,7 +204,6 @@ noinst_HEADERS = \
|
|||
gst-i18n-lib.h \
|
||||
gst-i18n-app.h \
|
||||
gst_private.h \
|
||||
gstatomic_impl.h \
|
||||
gstdata_private.h \
|
||||
gstarch.h \
|
||||
cothreads.h
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#define GST_IMPLEMENT_INLINES 1
|
||||
#define __GST_ATOMIC_C__
|
||||
|
||||
#include "gst_private.h"
|
||||
#include "gstatomic.h"
|
||||
#include "gstatomic_impl.h"
|
|
@ -1,48 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GST_ATOMIC_H__
|
||||
#define __GST_ATOMIC_H__
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef volatile gint gst_vgint; /* gtk-doc volatile workaround */
|
||||
|
||||
typedef struct _GstAtomicInt GstAtomicInt;
|
||||
|
||||
struct _GstAtomicInt {
|
||||
gst_vgint counter;
|
||||
GMutex *lock; /* for C fallback */
|
||||
};
|
||||
|
||||
|
||||
void gst_atomic_int_init (GstAtomicInt *aint, gint val);
|
||||
void gst_atomic_int_destroy (GstAtomicInt *aint);
|
||||
void gst_atomic_int_set (GstAtomicInt *aint, gint val);
|
||||
gint gst_atomic_int_read (GstAtomicInt *aint);
|
||||
void gst_atomic_int_add (GstAtomicInt *aint, gint val);
|
||||
void gst_atomic_int_inc (GstAtomicInt *aint);
|
||||
gboolean gst_atomic_int_dec_and_test (GstAtomicInt *aint);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_ATOMIC_H__ */
|
|
@ -1,523 +0,0 @@
|
|||
/* GStreamer
|
||||
* Copyright (C) 1999, 2003 Erik Walthinsen <omega@cse.ogi.edu>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*
|
||||
*
|
||||
* Much of the code in this file is taken from the Linux kernel.
|
||||
* The code is relicensed under the LGPL with the kind permission of
|
||||
* Linus Torvalds,Ralf Baechle and Alan Cox
|
||||
*/
|
||||
|
||||
#ifndef __GST_ATOMIC_IMPL_H__
|
||||
#define __GST_ATOMIC_IMPL_H__
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <glib.h>
|
||||
#include "gstatomic.h"
|
||||
#include "gstmacros.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#if defined (GST_CAN_INLINE) || defined (__GST_ATOMIC_C__)
|
||||
|
||||
/***** Intel x86 *****/
|
||||
#if (defined (HAVE_CPU_I386) || defined (HAVE_CPU_X86_64)) && defined(__GNUC__)
|
||||
|
||||
#ifdef GST_CONFIG_NO_SMP
|
||||
#define SMP_LOCK ""
|
||||
#else
|
||||
#define SMP_LOCK "lock ; "
|
||||
#endif
|
||||
|
||||
GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; }
|
||||
GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
|
||||
GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; }
|
||||
GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; }
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_add (GstAtomicInt *aint, gint val)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
SMP_LOCK "addl %1,%0"
|
||||
:"=m" (aint->counter)
|
||||
:"ir" (val), "m" (aint->counter));
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_inc (GstAtomicInt *aint)
|
||||
{
|
||||
__asm__ __volatile__(
|
||||
SMP_LOCK "incl %0"
|
||||
:"=m" (aint->counter)
|
||||
:"m" (aint->counter));
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC gboolean
|
||||
gst_atomic_int_dec_and_test (GstAtomicInt *aint)
|
||||
{
|
||||
guchar res;
|
||||
|
||||
__asm__ __volatile__(
|
||||
SMP_LOCK "decl %0; sete %1"
|
||||
:"=m" (aint->counter), "=qm" (res)
|
||||
:"m" (aint->counter) : "memory");
|
||||
|
||||
return res != 0;
|
||||
}
|
||||
|
||||
/***** PowerPC *****/
|
||||
#elif defined (HAVE_CPU_PPC) && defined(__GNUC__)
|
||||
|
||||
#ifdef GST_CONFIG_NO_SMP
|
||||
#define SMP_SYNC ""
|
||||
#define SMP_ISYNC
|
||||
#else
|
||||
#define SMP_SYNC "\tsync\n"
|
||||
#define SMP_ISYNC "\tisync\n"
|
||||
#endif
|
||||
|
||||
/* Erratum #77 on the 405 means we need a sync or dcbt before every stwcx.
|
||||
* The old ATOMIC_SYNC_FIX covered some but not all of this.
|
||||
*/
|
||||
#ifdef GST_CONFIG_IBM405_ERR77
|
||||
#define PPC405_ERR77(ra,rb) "\tdcbt " #ra "," #rb "\n"
|
||||
#else
|
||||
#define PPC405_ERR77(ra,rb)
|
||||
#endif
|
||||
|
||||
GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; }
|
||||
GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
|
||||
GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; }
|
||||
GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; }
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_add (GstAtomicInt *aint, gint val)
|
||||
{
|
||||
int t;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"1: lwarx %0,0,%3\n"
|
||||
" add %0,%2,%0\n"
|
||||
PPC405_ERR77(0,%3)
|
||||
" stwcx. %0,0,%3 \n"
|
||||
" bne- 1b\n"
|
||||
: "=&r" (t), "=m" (aint->counter)
|
||||
: "r" (val), "r" (&aint->counter), "m" (aint->counter)
|
||||
: "cc");
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_inc (GstAtomicInt *aint)
|
||||
{
|
||||
int t;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"1: lwarx %0,0,%2\n"
|
||||
" addic %0,%0,1\n"
|
||||
PPC405_ERR77(0,%2)
|
||||
" stwcx. %0,0,%2\n"
|
||||
" bne- 1b\n"
|
||||
: "=&r" (t), "=m" (aint->counter)
|
||||
: "r" (&aint->counter), "m" (aint->counter)
|
||||
: "cc");
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC gboolean
|
||||
gst_atomic_int_dec_and_test (GstAtomicInt *aint)
|
||||
{
|
||||
int t;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"1: lwarx %0,0,%1\n"
|
||||
" addic %0,%0,-1\n"
|
||||
PPC405_ERR77(0,%1)
|
||||
" stwcx. %0,0,%1\n"
|
||||
" bne- 1b\n"
|
||||
SMP_ISYNC
|
||||
: "=&r" (t)
|
||||
: "r" (&aint->counter)
|
||||
: "cc", "memory");
|
||||
|
||||
return t == 0;
|
||||
}
|
||||
|
||||
/***** DEC[/Compaq/HP?/Intel?] Alpha *****/
|
||||
#elif defined(HAVE_CPU_ALPHA) && defined(__GNUC__)
|
||||
|
||||
GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; }
|
||||
GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
|
||||
GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; }
|
||||
GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; }
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_add (GstAtomicInt *aint, gint val)
|
||||
{
|
||||
unsigned long temp;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"1: ldl_l %0,%1\n"
|
||||
" addl %0,%2,%0\n"
|
||||
" stl_c %0,%1\n"
|
||||
" beq %0,2f\n"
|
||||
".subsection 2\n"
|
||||
"2: br 1b\n"
|
||||
".previous"
|
||||
:"=&r" (temp), "=m" (aint->counter)
|
||||
:"Ir" (val), "m" (aint->counter));
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_inc (GstAtomicInt *aint)
|
||||
{
|
||||
gst_atomic_int_add (aint, 1);
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC gboolean
|
||||
gst_atomic_int_dec_and_test (GstAtomicInt *aint)
|
||||
{
|
||||
long temp, result;
|
||||
int val = 1;
|
||||
__asm__ __volatile__(
|
||||
"1: ldl_l %0,%1\n"
|
||||
" subl %0,%3,%2\n"
|
||||
" subl %0,%3,%0\n"
|
||||
" stl_c %0,%1\n"
|
||||
" beq %0,2f\n"
|
||||
" mb\n"
|
||||
".subsection 2\n"
|
||||
"2: br 1b\n"
|
||||
".previous"
|
||||
:"=&r" (temp), "=m" (aint->counter), "=&r" (result)
|
||||
:"Ir" (val), "m" (aint->counter) : "memory");
|
||||
|
||||
return result == 0;
|
||||
}
|
||||
|
||||
/***** Sun SPARC *****/
|
||||
#elif 0 && defined(HAVE_CPU_SPARC) && defined(__GNUC__)
|
||||
/* allegedly broken again */
|
||||
|
||||
GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
|
||||
|
||||
#ifdef GST_CONFIG_NO_SMP
|
||||
GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; }
|
||||
GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; }
|
||||
GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; }
|
||||
#else
|
||||
GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = (val<<8); }
|
||||
GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = (val<<8); }
|
||||
|
||||
/*
|
||||
* For SMP the trick is you embed the spin lock byte within
|
||||
* the word, use the low byte so signedness is easily retained
|
||||
* via a quick arithmetic shift. It looks like this:
|
||||
*
|
||||
* ----------------------------------------
|
||||
* | signed 24-bit counter value | lock | atomic_t
|
||||
* ----------------------------------------
|
||||
* 31 8 7 0
|
||||
*/
|
||||
GST_INLINE_FUNC gint
|
||||
gst_atomic_int_read (GstAtomicInt *aint)
|
||||
{
|
||||
int ret = aint->counter;
|
||||
|
||||
while (ret & 0xff)
|
||||
ret = aint->counter;
|
||||
|
||||
return ret >> 8;
|
||||
}
|
||||
#endif /* GST_CONFIG_NO_SMP */
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_add (GstAtomicInt *aint, gint val)
|
||||
{
|
||||
volatile int increment, *ptr;
|
||||
int lock = 1;
|
||||
int ignore = 0;
|
||||
|
||||
ptr = &(aint->counter);
|
||||
|
||||
#if __GNUC__ > 3 || (__GNUC__ >=3 && __GNUC_MINOR__ >= 2)
|
||||
__asm__ __volatile__("1: ldstub [%[ptr] + 3], %[lock]\n"
|
||||
"\torcc %[lock], 0, %[ignore]\n"
|
||||
"\tbne 1b\n" /* go back until we have the lock */
|
||||
"\tld [%[ptr]], %[inc]\n"
|
||||
"\tsra %[inc], 8, %[inc]\n"
|
||||
"\tadd %[inc], %[val], %[inc]\n"
|
||||
"\tsll %[inc], 8, %[lock]\n"
|
||||
"\tst %[lock],[%[ptr]]\n" /* Release the lock */
|
||||
: [inc] "=&r" (increment), [lock] "=r" (lock),
|
||||
[ignore] "=&r" (ignore)
|
||||
: "0" (increment), [ptr] "r" (ptr), [val] "r" (val)
|
||||
);
|
||||
#else
|
||||
__asm__ __volatile__("1: ldstub [%4 + 3], %1\n"
|
||||
"\torcc %1, 0, %2\n"
|
||||
"\tbne 1b\n" /* go back until we have the lock */
|
||||
"\tld [%4], %0\n"
|
||||
"\tsra %0, 8, %0\n"
|
||||
"\tadd %0, %5, %0\n"
|
||||
"\tsll %0, 8, %1\n"
|
||||
"\tst %1,[%4]\n" /* Release the lock */
|
||||
: "=&r" (increment), "=r" (lock), "=&r" (ignore)
|
||||
: "0" (increment), "r" (ptr), "r" (val)
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_inc (GstAtomicInt *aint)
|
||||
{
|
||||
gst_atomic_int_add (aint, 1);
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC gboolean
|
||||
gst_atomic_int_dec_and_test (GstAtomicInt *aint)
|
||||
{
|
||||
volatile int increment, *ptr;
|
||||
int lock = 1;
|
||||
int ignore = 0;
|
||||
|
||||
ptr = &aint->counter;
|
||||
|
||||
#if __GNUC__ > 3 || (__GNUC__ >=3 && __GNUC_MINOR__ >= 2)
|
||||
__asm__ __volatile__("1: ldstub [%[ptr] + 3], %[lock]\n"
|
||||
"\torcc %[lock], 0, %[ignore]\n"
|
||||
"\tbne 1b\n" /* go back until we have the lock */
|
||||
"\tld [%[ptr]], %[inc]\n"
|
||||
"\tsra %[inc], 8, %[inc]\n"
|
||||
"\tsub %[inc], 1, %[inc]\n"
|
||||
"\tsll %[inc], 8, %[lock]\n"
|
||||
"\tst %[lock],[%[ptr]]\n" /* Release the lock */
|
||||
: [inc] "=&r" (increment), [lock] "=r" (lock),
|
||||
[ignore] "=&r" (ignore)
|
||||
: "0" (increment), [ptr] "r" (ptr)
|
||||
);
|
||||
#else
|
||||
__asm__ __volatile__("1: ldstub [%4 + 3], %1\n"
|
||||
"\torcc %1, 0, %2\n"
|
||||
"\tbne 1b\n" /* go back until we have the lock */
|
||||
"\tld [%4], %0\n"
|
||||
"\tsra %0, 8, %0\n"
|
||||
"\tsub %0, 1, %0\n"
|
||||
"\tsll %0, 8, %1\n"
|
||||
"\tst %1,[%4]\n" /* Release the lock */
|
||||
: "=&r" (increment), "=r" (lock), "=&r" (ignore)
|
||||
: "0" (increment), "r" (ptr)
|
||||
);
|
||||
#endif
|
||||
|
||||
return increment == 0;
|
||||
}
|
||||
|
||||
/***** MIPS *****/
|
||||
/* This is disabled because the asm code is broken on most MIPS
|
||||
* processors and doesn't generally compile. */
|
||||
#elif defined(HAVE_CPU_MIPS) && defined(__GNUC__) && 0
|
||||
|
||||
GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; }
|
||||
GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
|
||||
GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; }
|
||||
GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; }
|
||||
|
||||
/* this only works on MIPS II and better */
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_add (GstAtomicInt *aint, gint val)
|
||||
{
|
||||
unsigned long temp;
|
||||
|
||||
__asm__ __volatile__(
|
||||
"1: ll %0, %1 # atomic_add\n"
|
||||
" addu %0, %2 \n"
|
||||
" sc %0, %1 \n"
|
||||
" beqz %0, 1b \n"
|
||||
: "=&r" (temp), "=m" (aint->counter)
|
||||
: "Ir" (val), "m" (aint->counter));
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_inc (GstAtomicInt *aint)
|
||||
{
|
||||
gst_atomic_int_add (aint, 1);
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC gboolean
|
||||
gst_atomic_int_dec_and_test (GstAtomicInt *aint)
|
||||
{
|
||||
unsigned long temp, result;
|
||||
int val = 1;
|
||||
|
||||
__asm__ __volatile__(
|
||||
".set push \n"
|
||||
".set noreorder # atomic_sub_return\n"
|
||||
"1: ll %1, %2 \n"
|
||||
" subu %0, %1, %3 \n"
|
||||
" sc %0, %2 \n"
|
||||
" beqz %0, 1b \n"
|
||||
" subu %0, %1, %3 \n"
|
||||
".set pop \n"
|
||||
: "=&r" (result), "=&r" (temp), "=m" (aint->counter)
|
||||
: "Ir" (val), "m" (aint->counter)
|
||||
: "memory");
|
||||
|
||||
return result == 0;
|
||||
}
|
||||
|
||||
/***** S/390 *****/
|
||||
#elif defined(HAVE_CPU_S390) && defined(__GNUC__)
|
||||
typedef struct { volatile int counter; } atomic_t __attribute__ ((aligned (4)));
|
||||
|
||||
GST_INLINE_FUNC void gst_atomic_int_init (GstAtomicInt *aint, gint val) { aint->counter = val; }
|
||||
GST_INLINE_FUNC void gst_atomic_int_destroy (GstAtomicInt *aint) { }
|
||||
GST_INLINE_FUNC void gst_atomic_int_set (GstAtomicInt *aint, gint val) { aint->counter = val; }
|
||||
GST_INLINE_FUNC gint gst_atomic_int_read (GstAtomicInt *aint) { return aint->counter; }
|
||||
|
||||
#define __CS_LOOP(old_val, new_val, ptr, op_val, op_string) \
|
||||
__asm__ __volatile__(" l %0,0(%3)\n" \
|
||||
"0: lr %1,%0\n" \
|
||||
op_string " %1,%4\n" \
|
||||
" cs %0,%1,0(%3)\n" \
|
||||
" jl 0b" \
|
||||
: "=&d" (old_val), "=&d" (new_val), \
|
||||
"+m" (((atomic_t *)(ptr))->counter) \
|
||||
: "a" (ptr), "d" (op_val) : "cc" );
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_add (GstAtomicInt *aint, gint val)
|
||||
{
|
||||
int old_val, new_val;
|
||||
__CS_LOOP(old_val, new_val, aint, val, "ar");
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_inc (GstAtomicInt *aint)
|
||||
{
|
||||
int old_val, new_val;
|
||||
__CS_LOOP(old_val, new_val, aint, 1, "ar");
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC gboolean
|
||||
gst_atomic_int_dec_and_test (GstAtomicInt *aint)
|
||||
{
|
||||
int old_val, new_val;
|
||||
__CS_LOOP(old_val, new_val, aint, 1, "sr");
|
||||
return new_val == 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
/* no need warning about this if we can't do inline assembly */
|
||||
#ifdef __GNUC__
|
||||
#warning consider putting your architecture specific atomic implementations here
|
||||
#endif
|
||||
|
||||
/*
|
||||
* generic implementation
|
||||
*/
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_init (GstAtomicInt *aint, gint val)
|
||||
{
|
||||
aint->counter = val;
|
||||
aint->lock = g_mutex_new ();
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_destroy (GstAtomicInt *aint)
|
||||
{
|
||||
g_mutex_free (aint->lock);
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_set (GstAtomicInt *aint, gint val)
|
||||
{
|
||||
g_mutex_lock (aint->lock);
|
||||
aint->counter = val;
|
||||
g_mutex_unlock (aint->lock);
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC gint
|
||||
gst_atomic_int_read (GstAtomicInt *aint)
|
||||
{
|
||||
gint res;
|
||||
|
||||
g_mutex_lock (aint->lock);
|
||||
res = aint->counter;
|
||||
g_mutex_unlock (aint->lock);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_add (GstAtomicInt *aint, gint val)
|
||||
{
|
||||
g_mutex_lock (aint->lock);
|
||||
aint->counter += val;
|
||||
g_mutex_unlock (aint->lock);
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_inc (GstAtomicInt *aint)
|
||||
{
|
||||
g_mutex_lock (aint->lock);
|
||||
aint->counter++;
|
||||
g_mutex_unlock (aint->lock);
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC gboolean
|
||||
gst_atomic_int_dec_and_test (GstAtomicInt *aint)
|
||||
{
|
||||
gboolean res;
|
||||
|
||||
g_mutex_lock (aint->lock);
|
||||
aint->counter--;
|
||||
res = (aint->counter == 0);
|
||||
g_mutex_unlock (aint->lock);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
/*
|
||||
* common functions
|
||||
*/
|
||||
GST_INLINE_FUNC GstAtomicInt*
|
||||
gst_atomic_int_new (gint val)
|
||||
{
|
||||
GstAtomicInt *aint;
|
||||
|
||||
aint = g_new0 (GstAtomicInt, 1);
|
||||
gst_atomic_int_init (aint, val);
|
||||
|
||||
return aint;
|
||||
}
|
||||
|
||||
GST_INLINE_FUNC void
|
||||
gst_atomic_int_free (GstAtomicInt *aint)
|
||||
{
|
||||
gst_atomic_int_destroy (aint);
|
||||
g_free (aint);
|
||||
}
|
||||
|
||||
#endif /* defined (GST_CAN_INLINE) || defined (__GST_TRASH_STACK_C__)*/
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GST_ATOMIC_IMPL_H__ */
|
|
@ -22,11 +22,11 @@
|
|||
|
||||
#include "gst_private.h"
|
||||
|
||||
#include "gstatomic_impl.h"
|
||||
#include "gstdata_private.h"
|
||||
#include "gstbuffer.h"
|
||||
#include "gstmemchunk.h"
|
||||
#include "gstinfo.h"
|
||||
#include "gstutils.h"
|
||||
|
||||
GType _gst_buffer_type = 0;
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
#include <signal.h>
|
||||
|
||||
#include "gst_private.h"
|
||||
#include "gstatomic_impl.h"
|
||||
#include <gst/gst.h>
|
||||
|
||||
/* #define DEBUG_REFCOUNT */
|
||||
|
@ -44,7 +43,7 @@
|
|||
} \
|
||||
} G_STMT_END
|
||||
#define IS_WRITABLE(caps) \
|
||||
(gst_atomic_int_read(&(caps)->refcount) == 1)
|
||||
(g_atomic_int_get (&(caps)->refcount) == 1)
|
||||
|
||||
|
||||
static void gst_caps_transform_to_string (const GValue * src_value,
|
||||
|
@ -85,7 +84,7 @@ gst_caps_new_empty (void)
|
|||
{
|
||||
GstCaps *caps = g_new0 (GstCaps, 1);
|
||||
|
||||
gst_atomic_int_init (&(caps)->refcount, 1);
|
||||
g_atomic_int_inc (&caps->refcount);
|
||||
caps->type = GST_TYPE_CAPS;
|
||||
caps->structs = g_ptr_array_new ();
|
||||
|
||||
|
@ -247,7 +246,6 @@ _gst_caps_free (GstCaps * caps)
|
|||
#ifdef USE_POISONING
|
||||
memset (caps, 0xff, sizeof (GstCaps));
|
||||
#endif
|
||||
gst_atomic_int_destroy (&(caps)->refcount);
|
||||
g_free (caps);
|
||||
}
|
||||
|
||||
|
@ -277,7 +275,7 @@ gst_caps_make_writable (GstCaps * caps)
|
|||
g_return_val_if_fail (caps != NULL, NULL);
|
||||
|
||||
/* we are the only instance reffing this caps */
|
||||
if (gst_atomic_int_read (&caps->refcount) == 1)
|
||||
if (g_atomic_int_get (&caps->refcount) == 1)
|
||||
return caps;
|
||||
|
||||
/* else copy */
|
||||
|
@ -313,7 +311,7 @@ gst_caps_ref (GstCaps * caps)
|
|||
#endif
|
||||
g_return_val_if_fail (GST_CAPS_REFCOUNT_VALUE (caps) > 0, NULL);
|
||||
|
||||
gst_atomic_int_inc (&caps->refcount);
|
||||
g_atomic_int_inc (&caps->refcount);
|
||||
|
||||
return caps;
|
||||
}
|
||||
|
@ -338,7 +336,7 @@ gst_caps_unref (GstCaps * caps)
|
|||
g_return_if_fail (GST_CAPS_REFCOUNT_VALUE (caps) > 0);
|
||||
|
||||
/* if we ended up with the refcount at zero, free the caps */
|
||||
if (gst_atomic_int_dec_and_test (&caps->refcount)) {
|
||||
if (g_atomic_int_dec_and_test (&caps->refcount)) {
|
||||
_gst_caps_free (caps);
|
||||
}
|
||||
}
|
||||
|
@ -358,9 +356,14 @@ gst_static_caps_get (GstStaticCaps * static_caps)
|
|||
gboolean ret;
|
||||
|
||||
if (caps->type == 0) {
|
||||
if (static_caps->string == NULL) {
|
||||
g_warning ("static caps is NULL");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
caps->type = GST_TYPE_CAPS;
|
||||
/* initialize the caps to a refcount of 1 so the caps can be writable... */
|
||||
gst_atomic_int_init (&(caps)->refcount, 1);
|
||||
gst_atomic_int_set (&caps->refcount, 1);
|
||||
caps->structs = g_ptr_array_new ();
|
||||
ret = gst_caps_from_string_inplace (caps, static_caps->string);
|
||||
|
||||
|
|
|
@ -56,14 +56,14 @@ typedef struct _GstStaticCaps GstStaticCaps;
|
|||
|
||||
/* refcount */
|
||||
#define GST_CAPS_REFCOUNT(caps) ((GST_CAPS(caps))->refcount)
|
||||
#define GST_CAPS_REFCOUNT_VALUE(caps) (gst_atomic_int_read (&(GST_CAPS(caps))->refcount))
|
||||
#define GST_CAPS_REFCOUNT_VALUE(caps) (g_atomic_int_get (&(GST_CAPS(caps))->refcount))
|
||||
|
||||
struct _GstCaps {
|
||||
GType type;
|
||||
|
||||
/*< public >*/ /* with COW */
|
||||
/* refcounting */
|
||||
GstAtomicInt refcount;
|
||||
gint refcount;
|
||||
|
||||
guint16 flags;
|
||||
GPtrArray *structs;
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#include "gstclock.h"
|
||||
#include "gstinfo.h"
|
||||
#include "gstmemchunk.h"
|
||||
#include "gstatomic_impl.h"
|
||||
#include "gstutils.h"
|
||||
|
||||
#ifndef GST_DISABLE_TRACE
|
||||
/* #define GST_WITH_ALLOC_TRACE */
|
||||
|
@ -76,7 +76,7 @@ gst_clock_entry_new (GstClock * clock, GstClockTime time,
|
|||
#endif
|
||||
GST_CAT_DEBUG (GST_CAT_CLOCK, "created entry %p", entry);
|
||||
|
||||
gst_atomic_int_init (&entry->refcount, 1);
|
||||
gst_atomic_int_set (&entry->refcount, 1);
|
||||
entry->clock = clock;
|
||||
entry->time = time;
|
||||
entry->interval = interval;
|
||||
|
@ -101,7 +101,7 @@ gst_clock_id_ref (GstClockID id)
|
|||
{
|
||||
g_return_val_if_fail (id != NULL, NULL);
|
||||
|
||||
gst_atomic_int_inc (&((GstClockEntry *) id)->refcount);
|
||||
g_atomic_int_inc (&((GstClockEntry *) id)->refcount);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ gst_clock_id_unref (GstClockID id)
|
|||
|
||||
g_return_if_fail (id != NULL);
|
||||
|
||||
zero = gst_atomic_int_dec_and_test (&((GstClockEntry *) id)->refcount);
|
||||
zero = g_atomic_int_dec_and_test (&((GstClockEntry *) id)->refcount);
|
||||
/* if we ended up with the refcount at zero, free the id */
|
||||
if (zero) {
|
||||
_gst_clock_id_free (id);
|
||||
|
|
|
@ -105,7 +105,7 @@ typedef enum {
|
|||
#define GST_CLOCK_ENTRY_STATUS(entry) ((entry)->status)
|
||||
|
||||
struct _GstClockEntry {
|
||||
GstAtomicInt refcount;
|
||||
gint refcount;
|
||||
/*< protected >*/
|
||||
GstClock *clock;
|
||||
GstClockEntryType type;
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
|
||||
#include "gst_private.h"
|
||||
|
||||
#include "gstatomic_impl.h"
|
||||
#include "gstdata.h"
|
||||
#include "gstdata_private.h"
|
||||
#include "gstinfo.h"
|
||||
#include "gstutils.h"
|
||||
|
||||
GType
|
||||
gst_data_get_type (void)
|
||||
|
@ -131,7 +131,7 @@ gst_data_is_writable (GstData * data)
|
|||
|
||||
g_return_val_if_fail (data != NULL, FALSE);
|
||||
|
||||
refcount = gst_atomic_int_read (&data->refcount);
|
||||
refcount = g_atomic_int_get (&data->refcount);
|
||||
|
||||
/* if we have the only ref and the data is not readonly, we can
|
||||
* safely write */
|
||||
|
@ -164,7 +164,7 @@ gst_data_copy_on_write (GstData * data)
|
|||
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
|
||||
refcount = gst_atomic_int_read (&data->refcount);
|
||||
refcount = g_atomic_int_get (&data->refcount);
|
||||
|
||||
/* if we have the only ref and the data is not readonly, we can
|
||||
* safely write, so we return the input data */
|
||||
|
@ -200,7 +200,7 @@ gst_data_ref (GstData * data)
|
|||
GST_CAT_LOG (GST_CAT_BUFFER, "%p %d->%d", data,
|
||||
GST_DATA_REFCOUNT_VALUE (data), GST_DATA_REFCOUNT_VALUE (data) + 1);
|
||||
|
||||
gst_atomic_int_inc (&data->refcount);
|
||||
g_atomic_int_inc (&data->refcount);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ gst_data_ref_by_count (GstData * data, gint count)
|
|||
GST_CAT_LOG (GST_CAT_BUFFER, "%p %d->%d", data,
|
||||
GST_DATA_REFCOUNT_VALUE (data), GST_DATA_REFCOUNT_VALUE (data) + count);
|
||||
|
||||
gst_atomic_int_add (&data->refcount, count);
|
||||
g_atomic_int_add (&data->refcount, count);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ gst_data_unref (GstData * data)
|
|||
GST_DATA_REFCOUNT_VALUE (data), GST_DATA_REFCOUNT_VALUE (data) - 1);
|
||||
g_return_if_fail (GST_DATA_REFCOUNT_VALUE (data) > 0);
|
||||
|
||||
zero = gst_atomic_int_dec_and_test (&data->refcount);
|
||||
zero = g_atomic_int_dec_and_test (&data->refcount);
|
||||
|
||||
/* if we ended up with the refcount at zero, free the data */
|
||||
if (zero) {
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#define __GST_DATA_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <gst/gstatomic.h>
|
||||
#include <gst/gsttypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@ -59,7 +58,7 @@ typedef enum
|
|||
|
||||
/* refcount */
|
||||
#define GST_DATA_REFCOUNT(data) ((GST_DATA(data))->refcount)
|
||||
#define GST_DATA_REFCOUNT_VALUE(data) (gst_atomic_int_read (&(GST_DATA(data))->refcount))
|
||||
#define GST_DATA_REFCOUNT_VALUE(data) (g_atomic_int_get (&(GST_DATA(data))->refcount))
|
||||
|
||||
/* copy/free functions */
|
||||
#define GST_DATA_COPY_FUNC(data) (GST_DATA(data)->copy)
|
||||
|
@ -71,7 +70,7 @@ struct _GstData {
|
|||
|
||||
/*< public >*/ /* with COW */
|
||||
/* refcounting */
|
||||
GstAtomicInt refcount;
|
||||
gint refcount;
|
||||
|
||||
guint16 flags;
|
||||
|
||||
|
|
|
@ -20,11 +20,9 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "gstatomic_impl.h"
|
||||
|
||||
#define _GST_DATA_INIT(data, ptype, pflags, pfree, pcopy) \
|
||||
G_STMT_START { \
|
||||
gst_atomic_int_init (&(data)->refcount, 1); \
|
||||
gst_atomic_int_set (&(data)->refcount, 1); \
|
||||
(data)->type = ptype; \
|
||||
(data)->flags = pflags; \
|
||||
(data)->free = pfree; \
|
||||
|
@ -33,6 +31,5 @@ G_STMT_START { \
|
|||
|
||||
#define _GST_DATA_DISPOSE(data) \
|
||||
G_STMT_START { \
|
||||
gst_atomic_int_destroy (&(data)->refcount); \
|
||||
} G_STMT_END;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "gstmemchunk.h"
|
||||
#include "gstevent.h"
|
||||
#include "gsttag.h"
|
||||
#include "gstutils.h"
|
||||
|
||||
#ifndef GST_DISABLE_TRACE
|
||||
/* #define GST_WITH_ALLOC_TRACE */
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
#include "gstpad.h"
|
||||
#include "gstscheduler.h"
|
||||
#include "gst_private.h"
|
||||
#include "gstatomic_impl.h"
|
||||
#include "gstutils.h"
|
||||
#ifdef HAVE_VALGRIND
|
||||
#include <valgrind/valgrind.h>
|
||||
#endif
|
||||
|
@ -121,8 +121,8 @@ LogFuncEntry;
|
|||
static GStaticMutex __log_func_mutex = G_STATIC_MUTEX_INIT;
|
||||
static GSList *__log_functions = NULL;
|
||||
|
||||
static GstAtomicInt __default_level;
|
||||
static GstAtomicInt __use_color;
|
||||
static gint __default_level;
|
||||
static gint __use_color;
|
||||
gboolean __gst_debug_enabled = TRUE;
|
||||
|
||||
|
||||
|
@ -209,8 +209,8 @@ _gst_debug_init (void)
|
|||
{
|
||||
GTimeVal current;
|
||||
|
||||
gst_atomic_int_init (&__default_level, GST_LEVEL_DEFAULT);
|
||||
gst_atomic_int_init (&__use_color, 1);
|
||||
gst_atomic_int_set (&__default_level, GST_LEVEL_DEFAULT);
|
||||
gst_atomic_int_set (&__use_color, 1);
|
||||
|
||||
/* get time we started for debugging messages */
|
||||
g_get_current_time (¤t);
|
||||
|
@ -716,7 +716,7 @@ gst_debug_set_colored (gboolean colored)
|
|||
gboolean
|
||||
gst_debug_is_colored (void)
|
||||
{
|
||||
return gst_atomic_int_read (&__use_color) == 0 ? FALSE : TRUE;
|
||||
return g_atomic_int_get (&__use_color) == 0 ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -772,7 +772,7 @@ gst_debug_set_default_threshold (GstDebugLevel level)
|
|||
GstDebugLevel
|
||||
gst_debug_get_default_threshold (void)
|
||||
{
|
||||
return (GstDebugLevel) gst_atomic_int_read (&__default_level);
|
||||
return (GstDebugLevel) g_atomic_int_get (&__default_level);
|
||||
}
|
||||
static void
|
||||
gst_debug_reset_threshold (gpointer category, gpointer unused)
|
||||
|
@ -895,8 +895,7 @@ _gst_debug_category_new (gchar * name, guint color, gchar * description)
|
|||
} else {
|
||||
cat->description = g_strdup ("no description");
|
||||
}
|
||||
cat->threshold = g_new (GstAtomicInt, 1);
|
||||
gst_atomic_int_init (cat->threshold, 0);
|
||||
gst_atomic_int_set (&cat->threshold, 0);
|
||||
gst_debug_reset_threshold (cat, NULL);
|
||||
|
||||
/* add to category list */
|
||||
|
@ -926,8 +925,6 @@ gst_debug_category_free (GstDebugCategory * category)
|
|||
|
||||
g_free ((gpointer) category->name);
|
||||
g_free ((gpointer) category->description);
|
||||
gst_atomic_int_destroy (category->threshold);
|
||||
g_free (category->threshold);
|
||||
g_free (category);
|
||||
}
|
||||
|
||||
|
@ -951,7 +948,7 @@ gst_debug_category_set_threshold (GstDebugCategory * category,
|
|||
{
|
||||
g_return_if_fail (category != NULL);
|
||||
|
||||
gst_atomic_int_set (category->threshold, level);
|
||||
gst_atomic_int_set (&category->threshold, level);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -981,7 +978,7 @@ gst_debug_category_reset_threshold (GstDebugCategory * category)
|
|||
GstDebugLevel
|
||||
gst_debug_category_get_threshold (GstDebugCategory * category)
|
||||
{
|
||||
return gst_atomic_int_read (category->threshold);
|
||||
return g_atomic_int_get (&category->threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
#include <gst/gstatomic.h>
|
||||
#include <gst/gstconfig.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@ -96,7 +95,7 @@ typedef enum {
|
|||
typedef struct _GstDebugCategory GstDebugCategory;
|
||||
struct _GstDebugCategory {
|
||||
/*< private >*/
|
||||
GstAtomicInt * threshold;
|
||||
gint threshold;
|
||||
guint color; /* see defines above */
|
||||
|
||||
const gchar * name;
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "gstmemchunk.h"
|
||||
#include "gstmessage.h"
|
||||
#include "gsttag.h"
|
||||
#include "gstutils.h"
|
||||
|
||||
#ifndef GST_DISABLE_TRACE
|
||||
/* #define GST_WITH_ALLOC_TRACE */
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include "gstobject.h"
|
||||
#include "gstmarshal.h"
|
||||
#include "gstinfo.h"
|
||||
#include "gstatomic_impl.h"
|
||||
#include "gstutils.h"
|
||||
|
||||
#ifndef GST_DISABLE_TRACE
|
||||
#include "gsttrace.h"
|
||||
|
@ -210,7 +210,7 @@ gst_object_init (GTypeInstance * instance, gpointer g_class)
|
|||
object->lock = g_mutex_new ();
|
||||
object->parent = NULL;
|
||||
object->name = NULL;
|
||||
gst_atomic_int_init (&(object)->refcount, 1);
|
||||
gst_atomic_int_set (&object->refcount, 1);
|
||||
PATCH_REFCOUNT (object);
|
||||
gst_object_set_name_default (object, G_OBJECT_CLASS_NAME (g_class));
|
||||
|
||||
|
@ -271,7 +271,7 @@ gst_object_ref (GstObject * object)
|
|||
#endif
|
||||
|
||||
#ifdef REFCOUNT_HACK
|
||||
gst_atomic_int_inc (&object->refcount);
|
||||
g_atomic_int_inc (&object->refcount);
|
||||
PATCH_REFCOUNT (object);
|
||||
#else
|
||||
/* FIXME, not MT safe because glib is not MT safe */
|
||||
|
@ -321,7 +321,7 @@ gst_object_unref (GstObject * object)
|
|||
#endif
|
||||
|
||||
#ifdef REFCOUNT_HACK
|
||||
if (G_UNLIKELY (gst_atomic_int_dec_and_test (&object->refcount))) {
|
||||
if (G_UNLIKELY (g_atomic_int_dec_and_test (&object->refcount))) {
|
||||
PATCH_REFCOUNT1 (object);
|
||||
g_object_unref (object);
|
||||
} else {
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include <glib-object.h> /* note that this gets wrapped in __GST_OBJECT_H__ */
|
||||
|
||||
#include <gst/gstatomic.h>
|
||||
#include <gst/gsttypes.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@ -60,7 +59,7 @@ typedef enum
|
|||
} GstObjectFlags;
|
||||
|
||||
#define GST_OBJECT_REFCOUNT(caps) ((GST_OBJECT_CAST(caps))->refcount)
|
||||
#define GST_OBJECT_REFCOUNT_VALUE(caps) (gst_atomic_int_read (&(GST_OBJECT_CAST(caps))->refcount))
|
||||
#define GST_OBJECT_REFCOUNT_VALUE(caps) (g_atomic_int_get (&(GST_OBJECT_CAST(caps))->refcount))
|
||||
|
||||
/* we do a GST_OBJECT_CAST to avoid type checking, better call these
|
||||
* function with a valid object! */
|
||||
|
@ -86,7 +85,7 @@ struct _GstObject {
|
|||
GObject object;
|
||||
|
||||
/*< public >*/
|
||||
GstAtomicInt refcount;
|
||||
gint refcount;
|
||||
|
||||
/*< public >*/ /* with LOCK */
|
||||
GMutex *lock; /* object LOCK */
|
||||
|
|
|
@ -42,7 +42,7 @@ struct _GstStructureField
|
|||
|
||||
#define IS_MUTABLE(structure) \
|
||||
(!(structure)->parent_refcount || \
|
||||
gst_atomic_int_read ((structure)->parent_refcount) == 1)
|
||||
g_atomic_int_get ((structure)->parent_refcount) == 1)
|
||||
|
||||
static void gst_structure_set_field (GstStructure * structure,
|
||||
GstStructureField * field);
|
||||
|
@ -180,7 +180,7 @@ gst_structure_new_valist (const gchar * name,
|
|||
/**
|
||||
* gst_structure_set_parent_refcount:
|
||||
* @structure: a #GstStructure
|
||||
* @refcount: a pointer to the parent's #GstAtomicInt refcount
|
||||
* @refcount: a pointer to the parent's refcount
|
||||
*
|
||||
* Sets the parent_refcount field of #GstStructure. This field is used to
|
||||
* determine whether a structure is mutable or not. This function should only be
|
||||
|
@ -190,8 +190,7 @@ gst_structure_new_valist (const gchar * name,
|
|||
* Returns: a new #GstStructure.
|
||||
*/
|
||||
void
|
||||
gst_structure_set_parent_refcount (GstStructure * structure,
|
||||
GstAtomicInt * refcount)
|
||||
gst_structure_set_parent_refcount (GstStructure * structure, int *refcount)
|
||||
{
|
||||
g_return_if_fail (structure != NULL);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ struct _GstStructure {
|
|||
GQuark name;
|
||||
|
||||
/* owned by parent structure, NULL if no parent */
|
||||
GstAtomicInt *parent_refcount;
|
||||
gint *parent_refcount;
|
||||
|
||||
GArray *fields;
|
||||
|
||||
|
@ -66,7 +66,7 @@ GstStructure * gst_structure_new_valist (const gchar *
|
|||
va_list varargs);
|
||||
GstStructure * gst_structure_copy (const GstStructure *structure);
|
||||
void gst_structure_set_parent_refcount (GstStructure *structure,
|
||||
GstAtomicInt *refcount);
|
||||
gint *refcount);
|
||||
void gst_structure_free (GstStructure *structure);
|
||||
|
||||
G_CONST_RETURN gchar * gst_structure_get_name (const GstStructure *structure);
|
||||
|
|
|
@ -1662,3 +1662,20 @@ gst_pad_proxy_setcaps (GstPad * pad, GstCaps * caps)
|
|||
/* ok not to unset the gvalue */
|
||||
return g_value_get_boolean (&ret);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gst_atomic_int_set:
|
||||
* @atomic_int: pointer to an atomic integer
|
||||
* @value: value to set
|
||||
*
|
||||
* Unconditionally sets the atomic integer to @value.
|
||||
*/
|
||||
void
|
||||
gst_atomic_int_set (gint * atomic_int, gint value)
|
||||
{
|
||||
int ignore;
|
||||
|
||||
*atomic_int = value;
|
||||
ignore = g_atomic_int_get (atomic_int);
|
||||
}
|
||||
|
|
|
@ -272,6 +272,8 @@ void gst_bin_remove_many (GstBin *bin, GstElement *eleme
|
|||
GstBuffer * gst_buffer_merge (GstBuffer * buf1, GstBuffer * buf2);
|
||||
void gst_buffer_stamp (GstBuffer * dest, const GstBuffer * src);
|
||||
|
||||
/* atomic functions */
|
||||
void gst_atomic_int_set (gint * atomic_int, gint value);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in a new issue