Commit 13d9e8d3 authored by Wim Taymans's avatar Wim Taymans

Changed to the new props API

Original commit message from CVS:
Changed to the new props API
Other small tuff.
parent c5e4b06f
......@@ -432,6 +432,14 @@ GST_CHECK_FEATURE(HTTP, [http plugins], gsthttpsrc, [
AC_SUBST(GST_HTTPSRC_GET_TYPE)
])
dnl *** Jack ***
translit(dnm, m, l) AM_CONDITIONAL(USE_LCS, true)
GST_CHECK_FEATURE(LCS, Lcs, lcs, [
PKG_CHECK_MODULES(LCS, lcs, HAVE_LCS="yes", HAVE_LCS="no")
AC_SUBST(LCS_CFLAGS)
AC_SUBST(LCS_LIBS)
])
dnl *** Jack ***
translit(dnm, m, l) AM_CONDITIONAL(USE_JACK, true)
GST_CHECK_FEATURE(JACK, Jack, jack, [
......@@ -796,6 +804,7 @@ ext/hermes/Makefile
ext/http/Makefile
ext/jack/Makefile
ext/jpeg/Makefile
ext/lcs/Makefile
ext/ladspa/Makefile
ext/lame/Makefile
ext/mad/Makefile
......
......@@ -242,8 +242,8 @@ gst_aasink_sinkconnect (GstPad *pad, GstCaps *caps)
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_CONNECT_DELAYED;
aasink->width = gst_caps_get_int (caps, "width");
aasink->height = gst_caps_get_int (caps, "height");
gst_caps_get_int (caps, "width", &aasink->width);
gst_caps_get_int (caps, "height", &aasink->height);
print_format = GULONG_FROM_LE (aasink->format);
......
......@@ -317,8 +317,12 @@ gst_dvdec_loop (GstElement *element)
/* try each format */
if (gst_pad_try_set_caps (dvdec->videosrcpad, to_try)) {
guint32 fourcc;
/* it worked, try to find what it was again */
if (gst_caps_get_fourcc_int (to_try, "format") == GST_STR_FOURCC ("RGB ")) {
gst_caps_get_fourcc_int (to_try, "format", &fourcc);
if (fourcc == GST_STR_FOURCC ("RGB ")) {
dvdec->space = e_dv_color_rgb;
dvdec->bpp = 3;
}
......
......@@ -227,9 +227,9 @@ gst_esdsink_sinkconnect (GstPad *pad, GstCaps *caps)
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_CONNECT_DELAYED;
esdsink->depth = gst_caps_get_int (caps, "depth");
esdsink->channels = gst_caps_get_int (caps, "channels");
esdsink->frequency = gst_caps_get_int (caps, "rate");
gst_caps_get_int (caps, "depth", &esdsink->depth);
gst_caps_get_int (caps, "channels", &esdsink->channels);
gst_caps_get_int (caps, "rate", &esdsink->frequency);
if (gst_esdsink_sync_parms (esdsink))
return GST_PAD_CONNECT_OK;
......
......@@ -110,9 +110,9 @@ gst_flacenc_sinkconnect (GstPad *pad, GstCaps *caps)
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_CONNECT_DELAYED;
flacenc->channels = gst_caps_get_int (caps, "channels");
flacenc->depth = gst_caps_get_int (caps, "depth");
flacenc->sample_rate = gst_caps_get_int (caps, "rate");
gst_caps_get_int (caps, "channels", &flacenc->channels);
gst_caps_get_int (caps, "depth", &flacenc->depth);
gst_caps_get_int (caps, "rate", &flacenc->sample_rate);
FLAC__stream_encoder_set_bits_per_sample (flacenc->encoder, flacenc->depth);
FLAC__stream_encoder_set_sample_rate (flacenc->encoder, flacenc->sample_rate);
......
......@@ -109,7 +109,7 @@ gst_ladspa_get_bufferpool (GstPad *pad)
{
gint i;
GstBufferPool *bp;
GstLADSPA *ladspa = gst_pad_get_parent (pad);
GstLADSPA *ladspa = (GstLADSPA *) gst_pad_get_parent (pad);
GstLADSPAClass *oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
if (oclass->numsrcpads > 0)
......@@ -394,7 +394,7 @@ gst_ladspa_init (GstLADSPA *ladspa)
}
ladspa->loopbased = TRUE;
gst_element_set_loop_function (ladspa, gst_ladspa_loop);
gst_element_set_loop_function (GST_ELEMENT (ladspa), gst_ladspa_loop);
}
gst_ladspa_instantiate(ladspa);
......@@ -406,13 +406,15 @@ gst_ladspa_connect (GstPad *pad, GstCaps *caps)
GstLADSPA *ladspa = (GstLADSPA *) GST_PAD_PARENT (pad);
GstLADSPAClass *oclass = (GstLADSPAClass *) (G_OBJECT_GET_CLASS (ladspa));
guint i;
gint rate;
g_return_val_if_fail (caps != NULL, GST_PAD_CONNECT_DELAYED);
g_return_val_if_fail (pad != NULL, GST_PAD_CONNECT_DELAYED);
gst_caps_get_int (caps, "rate", &rate);
/* have to instantiate ladspa plugin when samplerate changes (groan) */
if (ladspa->samplerate != gst_caps_get_int (caps, "rate")){
ladspa->samplerate = gst_caps_get_int (caps, "rate");
if (ladspa->samplerate != rate){
ladspa->samplerate = rate;
if (! gst_ladspa_instantiate(ladspa))
return GST_PAD_CONNECT_REFUSED;
}
......@@ -434,12 +436,15 @@ static GstPadConnectReturn
gst_ladspa_connect_get (GstPad *pad, GstCaps *caps)
{
GstLADSPA *ladspa = (GstLADSPA*)GST_OBJECT_PARENT (pad);
gint rate;
g_return_val_if_fail (caps != NULL, GST_PAD_CONNECT_DELAYED);
g_return_val_if_fail (pad != NULL, GST_PAD_CONNECT_DELAYED);
if (ladspa->samplerate != gst_caps_get_int (caps, "rate")) {
ladspa->samplerate = gst_caps_get_int (caps, "rate");
gst_caps_get_int (caps, "rate", &rate);
if (ladspa->samplerate != rate) {
ladspa->samplerate = rate;
if (! gst_ladspa_instantiate(ladspa))
return GST_PAD_CONNECT_REFUSED;
}
......@@ -674,7 +679,7 @@ gst_ladspa_deactivate(GstLADSPA *ladspa)
static void
gst_ladspa_loop (GstElement *element)
{
gint8 *raw_in, *zero_out, i, cur_buf;
gint8 *raw_in, *zero_out, i;
GstBuffer **buffers_out;
GstEvent *event = NULL;
guint32 waiting;
......@@ -703,7 +708,8 @@ gst_ladspa_loop (GstElement *element)
/* first get all the necessary data from the input ports */
for (i=0;i<oclass->numsinkpads;i++){
GST_DEBUG (0, "pulling %d bytes through channel %d's bytestream", i);
GST_DEBUG (0, "pulling %d bytes through channel %d'sbytestream\n",
ladspa->buffersize * sizeof (LADSPA_Data), i);
raw_in = gst_bytestream_peek_bytes (ladspa->bytestreams[i], ladspa->buffersize * sizeof (LADSPA_Data));
if (raw_in == NULL) {
......
......@@ -47,7 +47,7 @@ enum {
ARG_REVERB,
ARG_SNDFXVOLUME,
ARG_VOLUME,
ARG_FIXFREQ,
ARG_MIXFREQ,
ARG_INTERP,
ARG_REVERSE,
ARG_SURROUND,
......@@ -226,10 +226,10 @@ gst_mikmod_class_init (GstMikModClass *klass)
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_SONGNAME,
g_param_spec_string("songname","songname","songname",
"", G_PARAM_READABLE));
NULL, G_PARAM_READABLE));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MODTYPE,
g_param_spec_string("modtype", "modtype", "modtype",
"", G_PARAM_READABLE ));
NULL, G_PARAM_READABLE ));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MUSICVOLUME,
g_param_spec_int("musicvolume", "musivolume", "musicvolume",
0, 128, 128, G_PARAM_READWRITE ));
......@@ -245,7 +245,7 @@ gst_mikmod_class_init (GstMikModClass *klass)
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VOLUME,
g_param_spec_int("volume", "volume", "volume",
0, 128, 96, G_PARAM_READWRITE ));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_FIXFREQ,
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MIXFREQ,
g_param_spec_enum("mixfreq", "mixfreq", "mixfreq",
GST_TYPE_MIKMOD_MIXFREQ, 3,G_PARAM_READWRITE ));
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_INTERP,
......@@ -305,6 +305,8 @@ gst_mikmod_init (GstMikMod *filter)
filter->musicvolume = 128;
filter->volume = 96;
filter->sndfxvolume = 128;
filter->songname = NULL;
filter->modtype = NULL;
}
......@@ -314,7 +316,6 @@ gst_mikmod_loop (GstElement *element)
GstMikMod *mikmod;
GstBuffer *buffer_in;
gint mode16bits;
gint first = 0;
g_return_if_fail (element != NULL);
g_return_if_fail (GST_IS_MIKMOD (element));
......@@ -487,10 +488,12 @@ gst_mikmod_set_property (GObject *object, guint id, const GValue *value, GParamS
switch (id) {
case ARG_SONGNAME:
filter->songname = g_value_get_string (value);
g_free (filter->songname);
filter->songname = g_strdup (g_value_get_string (value));
break;
case ARG_MODTYPE:
filter->modtype = g_value_get_string (value);
g_free (filter->modtype);
filter->modtype = g_strdup (g_value_get_string (value));
break;
case ARG_MUSICVOLUME:
filter->musicvolume = g_value_get_int (value);
......@@ -507,7 +510,7 @@ gst_mikmod_set_property (GObject *object, guint id, const GValue *value, GParamS
case ARG_VOLUME:
filter->volume = g_value_get_int (value);
break;
case ARG_FIXFREQ:
case ARG_MIXFREQ:
filter->mixfreq = g_value_get_enum (value);
break;
case ARG_INTERP:
......@@ -565,8 +568,8 @@ gst_mikmod_get_property (GObject *object, guint id, GValue *value, GParamSpec *p
case ARG_VOLUME:
g_value_set_int (value, filter->volume);
break;
case ARG_FIXFREQ:
g_value_set_int (value, filter->mixfreq);
case ARG_MIXFREQ:
g_value_set_enum (value, filter->mixfreq);
break;
case ARG_INTERP:
g_value_set_boolean (value, filter->interp);
......
......@@ -583,12 +583,12 @@ gst_avidemux_parse_index (GstAviDemux *avi_demux,
if (GST_BUFFER_OFFSET (buf) != filepos + offset || GST_BUFFER_SIZE (buf) != 8) {
GST_INFO (GST_CAT_PLUGIN_INFO, "avidemux: could not get index");
return;
goto end;
}
if (gst_riff_fourcc_to_id (GST_BUFFER_DATA (buf)) != GST_RIFF_TAG_idx1) {
GST_INFO (GST_CAT_PLUGIN_INFO, "avidemux: no index found");
return;
goto end;
}
index_size = GUINT32_FROM_LE(*(guint32 *)(GST_BUFFER_DATA (buf) + 4));
......@@ -604,6 +604,7 @@ gst_avidemux_parse_index (GstAviDemux *avi_demux,
memcpy (avi_demux->index_entries, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
gst_buffer_unref (buf);
end:
if (!gst_bytestream_seek (avi_demux->bs, GST_SEEK_BYTEOFFSET_SET, filepos)) {
GST_INFO (GST_CAT_PLUGIN_INFO, "avidemux: could not seek back to movi");
return;
......
......@@ -292,57 +292,68 @@ gst_avimux_sinkconnect (GstPad *pad, GstCaps *vscaps)
if (!strcmp (mimetype, "video/avi"))
{
const gchar* format = gst_caps_get_string(caps, "format");
const gchar* format;
gst_caps_get_string (caps, "format", &format);
if (!strncmp (format, "strf_vids", 9)) {
avimux->vids.size = sizeof(gst_riff_strf_vids);
avimux->vids.width = gst_caps_get_int (caps, "width");
avimux->vids.height = gst_caps_get_int (caps, "height");
avimux->vids.planes = gst_caps_get_int (caps, "planes");
avimux->vids.bit_cnt = gst_caps_get_int (caps, "bit_cnt");
avimux->vids.compression = gst_caps_get_fourcc_int (caps, "compression");
avimux->vids.image_size = gst_caps_get_int (caps, "image_size");
avimux->vids.xpels_meter = gst_caps_get_int (caps, "xpels_meter");
avimux->vids.ypels_meter = gst_caps_get_int (caps, "ypels_meter");
avimux->vids.num_colors = gst_caps_get_int (caps, "num_colors");
avimux->vids.imp_colors = gst_caps_get_int (caps, "imp_colors");
gst_caps_get (caps,
"width", GST_PROPS_INT_TYPE, &avimux->vids.width,
"height", GST_PROPS_INT_TYPE, &avimux->vids.height,
"planes", GST_PROPS_INT_TYPE, &avimux->vids.planes,
"bit_cnt", GST_PROPS_INT_TYPE, &avimux->vids.bit_cnt,
"compression", GST_PROPS_FOURCC_TYPE, &avimux->vids.compression,
"image_size", GST_PROPS_INT_TYPE, &avimux->vids.image_size,
"xpels_meter", GST_PROPS_INT_TYPE, &avimux->vids.xpels_meter,
"ypels_meter", GST_PROPS_INT_TYPE, &avimux->vids.ypels_meter,
"num_colors", GST_PROPS_INT_TYPE, &avimux->vids.num_colors,
"imp_colors", GST_PROPS_INT_TYPE, &avimux->vids.imp_colors,
NULL);
}
else if (!strncmp (format, "strf_auds", 9)) {
avimux->auds.format = gst_caps_get_int (caps, "format");
avimux->auds.channels = gst_caps_get_int (caps, "channels");
avimux->auds.rate = gst_caps_get_int (caps, "rate");
avimux->auds.av_bps = gst_caps_get_int (caps, "av_bps");
avimux->auds.blockalign = gst_caps_get_int (caps, "blockalign");
avimux->auds.size = gst_caps_get_int (caps, "size");
gst_caps_get (caps,
"format", GST_PROPS_INT_TYPE, &avimux->auds.format,
"channels", GST_PROPS_INT_TYPE, &avimux->auds.channels,
"rate", GST_PROPS_INT_TYPE, &avimux->auds.rate,
"av_bps", GST_PROPS_INT_TYPE, &avimux->auds.av_bps,
"blockalign", GST_PROPS_INT_TYPE, &avimux->auds.blockalign,
"size", GST_PROPS_INT_TYPE, &avimux->auds.size,
NULL);
}
goto done;
}
else if (!strcmp (mimetype, "video/raw"))
{
switch (gst_caps_get_fourcc_int(caps, "format"))
guint32 format;
gst_caps_get_fourcc_int (caps, "format", &format);
switch (format)
{
case GST_MAKE_FOURCC('Y','U','Y','2'):
case GST_MAKE_FOURCC('I','4','2','0'):
case GST_MAKE_FOURCC('Y','4','1','P'):
case GST_MAKE_FOURCC('R','G','B',' '):
avimux->vids.size = sizeof(gst_riff_strf_vids);
avimux->vids.width = gst_caps_get_int (caps, "width");
avimux->vids.height = gst_caps_get_int (caps, "height");
gst_caps_get (caps,
"width", GST_PROPS_INT_TYPE, &avimux->vids.width,
"height", GST_PROPS_INT_TYPE, &avimux->vids.height,
NULL);
avimux->vids.planes = 1;
switch (gst_caps_get_fourcc_int(caps, "format"))
switch (format)
{
case GST_MAKE_FOURCC('Y','U','Y','2'):
avimux->vids.bit_cnt = 16; /* YUY2 */
break;
case GST_MAKE_FOURCC('R','G','B',' '):
avimux->vids.bit_cnt = gst_caps_get_fourcc_int(caps, "bpp"); /* RGB */
gst_caps_get_int (caps, "bpp", &avimux->vids.bit_cnt); /* RGB */
break;
case GST_MAKE_FOURCC('Y','4','1','P'):
case GST_MAKE_FOURCC('I','4','2','0'):
avimux->vids.bit_cnt = 12; /* Y41P or I420 */
break;
}
avimux->vids.compression = gst_caps_get_fourcc_int(caps, "format");
gst_caps_get_fourcc_int(caps, "format", &avimux->vids.compression);
avimux->vids.image_size = avimux->vids.height * avimux->vids.width;
goto done;
default:
......@@ -352,8 +363,10 @@ gst_avimux_sinkconnect (GstPad *pad, GstCaps *vscaps)
else if (!strcmp (mimetype, "video/jpeg"))
{
avimux->vids.size = sizeof(gst_riff_strf_vids);
avimux->vids.width = gst_caps_get_int (caps, "width");
avimux->vids.height = gst_caps_get_int (caps, "height");
gst_caps_get (caps,
"width", GST_PROPS_INT_TYPE, &avimux->vids.width,
"height", GST_PROPS_INT_TYPE, &avimux->vids.height,
NULL);
avimux->vids.planes = 1;
avimux->vids.bit_cnt = 24;
avimux->vids.compression = GST_MAKE_FOURCC('M','J','P','G');
......@@ -362,20 +375,29 @@ gst_avimux_sinkconnect (GstPad *pad, GstCaps *vscaps)
}
else if (!strcmp (mimetype, "audio/raw"))
{
gint width;
avimux->auds.format = GST_RIFF_WAVE_FORMAT_PCM;
avimux->auds.channels = gst_caps_get_int (caps, "channels");
avimux->auds.rate = gst_caps_get_int (caps, "rate");
avimux->auds.av_bps = gst_caps_get_int (caps, "width") * avimux->auds.rate *
avimux->auds.channels / 8;
avimux->auds.blockalign = gst_caps_get_int (caps, "width") * avimux->auds.channels/8;
avimux->auds.size = gst_caps_get_int (caps, "depth");
gst_caps_get (caps,
"channels", GST_PROPS_INT_TYPE, &avimux->auds.channels,
"rate", GST_PROPS_INT_TYPE, &avimux->auds.rate,
"width", GST_PROPS_INT_TYPE, &width,
"depth", GST_PROPS_INT_TYPE, &avimux->auds.size,
NULL);
avimux->auds.av_bps = width * avimux->auds.rate * avimux->auds.channels / 8;
avimux->auds.blockalign = width * avimux->auds.channels/8;
goto done;
}
else if (!strcmp (mimetype, "audio/mp3"))
{
gint layer;
gst_caps_get_int(caps, "layer", &layer);
/* we don't need to do anything here, compressed mp3 contains it all */
avimux->auds.format = gst_caps_get_int(caps, "layer")==3?
GST_RIFF_WAVE_FORMAT_MPEGL3:GST_RIFF_WAVE_FORMAT_MPEGL12;
avimux->auds.format = (layer == 3?
GST_RIFF_WAVE_FORMAT_MPEGL3 :
GST_RIFF_WAVE_FORMAT_MPEGL12);
goto done;
}
}
......
......@@ -235,13 +235,13 @@ gst_cutter_chain (GstPad *pad, GstBuffer *buf)
if (filter->silent)
{
/* g_print ("DEBUG: cutter: cut to here, turning off out\n"); */
gtk_signal_emit (G_OBJECT (filter), gst_cutter_signals[CUT_STOP]);
g_signal_emit (G_OBJECT (filter), gst_cutter_signals[CUT_STOP], 0);
}
else
{
/* g_print ("DEBUG: cutter: start from here, turning on out\n"); */
/* first of all, flush current buffer */
gtk_signal_emit (G_OBJECT (filter), gst_cutter_signals[CUT_START]);
g_signal_emit (G_OBJECT (filter), gst_cutter_signals[CUT_START], 0);
g_print ("DEBUG: cutter: flushing buffer ");
while (filter->pre_buffer)
{
......@@ -389,7 +389,7 @@ gst_cutter_get_caps (GstPad *pad, GstCutter* filter)
/* FIXME : Please change this to a better warning method ! */
if (caps == NULL)
printf ("WARNING: cutter: get_caps: Could not get caps of pad !\n");
filter->width = gst_caps_get_int (caps, "width");
gst_caps_get_int (caps, "width", &filter->width);
filter->max_sample = gst_audio_highest_sample_value (pad);
filter->have_caps = TRUE;
}
......@@ -114,7 +114,7 @@ GST_PADTEMPLATE_FACTORY (sink_template,
"width", GST_PROPS_INT (16),
"depth", GST_PROPS_INT (16),
"rate", GST_PROPS_INT_RANGE (8000, 96000),
"channels", GST_PROPS_INT (1)
"channels", GST_PROPS_INT (2)
)
)
......
......@@ -173,7 +173,7 @@ gst_level_chain (GstPad *pad,GstBuffer *buf)
printf ("WARNING : chain : Could not get caps of pad !\n");
}
width = gst_caps_get_int(caps, "width");
gst_caps_get_int(caps, "width", &width);
in_data = (gint16 *)GST_BUFFER_DATA(buf);
outbuf=gst_buffer_new();
......
......@@ -134,8 +134,8 @@ gst_median_sinkconnect (GstPad *pad, GstCaps *caps)
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_CONNECT_DELAYED;
filter->width = gst_caps_get_int (caps, "width");
filter->height = gst_caps_get_int (caps, "height");
gst_caps_get_int (caps, "width", &filter->width);
gst_caps_get_int (caps, "height", &filter->height);
return GST_PAD_CONNECT_OK;
}
......
......@@ -22,31 +22,10 @@
#include "gstossclock.h"
static GMemChunk *_gst_clock_entries_chunk;
static GMutex *_gst_clock_entries_chunk_lock;
static GList *_gst_clock_entries_pool;
typedef struct _GstClockEntry GstClockEntry;
typedef enum {
GST_ENTRY_OK,
GST_ENTRY_RESTART,
} GstEntryStatus;
struct _GstClockEntry {
GstClockTime time;
GstEntryStatus status;
GMutex *lock;
GCond *cond;
};
static void gst_oss_clock_class_init (GstOssClockClass *klass);
static void gst_oss_clock_init (GstOssClock *clock);
static void gst_oss_clock_reset (GstClock *clock);
static void gst_oss_clock_activate (GstClock *clock, gboolean activate);
static void gst_oss_clock_set_time (GstClock *clock, GstClockTime time);
static GstClockReturn gst_oss_clock_wait (GstClock *clock, GstClockTime time);
static GstClockTime gst_oss_clock_get_internal_time (GstClock *clock);
static GstSystemClockClass *parent_class = NULL;
/* static guint gst_oss_clock_signals[LAST_SIGNAL] = { 0 }; */
......@@ -89,241 +68,57 @@ gst_oss_clock_class_init (GstOssClockClass *klass)
parent_class = g_type_class_ref (GST_TYPE_SYSTEM_CLOCK);
gstclock_class->reset = gst_oss_clock_reset;
gstclock_class->activate = gst_oss_clock_activate;
gstclock_class->set_time = gst_oss_clock_set_time;
gstclock_class->wait = gst_oss_clock_wait;
gstclock_class->get_internal_time = gst_oss_clock_get_internal_time;
}
static void
gst_oss_clock_init (GstOssClock *clock)
{
gst_object_set_name (GST_OBJECT (clock), "GstOssClock");
clock->is_updated = FALSE;
}
#define GST_CLOCK_ENTRY(entry) ((GstClockEntry *)(entry))
#define GST_CLOCK_ENTRY_TIME(entry) (((GstClockEntry *)(entry))->time)
#define GST_CLOCK_ENTRY_LOCK(entry) (g_mutex_lock ((entry)->lock))
#define GST_CLOCK_ENTRY_UNLOCK(entry) (g_mutex_unlock ((entry)->lock))
#define GST_CLOCK_ENTRY_SIGNAL(entry) (g_cond_signal ((entry)->cond))
#define GST_CLOCK_ENTRY_WAIT(entry) (g_cond_wait (entry->cond, entry->lock))
#define GST_CLOCK_ENTRY_TIMED_WAIT(entry, time) (g_cond_timed_wait (entry->cond, entry->lock, (time)))
static GstClockEntry*
gst_clock_entry_new (GstClockTime time)
{
GstClockEntry *entry;
g_mutex_lock (_gst_clock_entries_chunk_lock);
if (_gst_clock_entries_pool) {
entry = GST_CLOCK_ENTRY (_gst_clock_entries_pool->data);
_gst_clock_entries_pool = g_list_remove (_gst_clock_entries_pool, entry);
g_mutex_unlock (_gst_clock_entries_chunk_lock);
}
else {
entry = g_mem_chunk_alloc (_gst_clock_entries_chunk);
g_mutex_unlock (_gst_clock_entries_chunk_lock);
entry->lock = g_mutex_new ();
entry->cond = g_cond_new ();
}
entry->time = time;
return entry;
}
static void
gst_clock_entry_free (GstClockEntry *entry)
{
g_mutex_lock (_gst_clock_entries_chunk_lock);
_gst_clock_entries_pool = g_list_prepend (_gst_clock_entries_pool, entry);
g_mutex_unlock (_gst_clock_entries_chunk_lock);
clock->prev1 = 0;
clock->prev2 = 0;
}
GstOssClock*
gst_oss_clock_new (gchar *name, GstElement *owner)
gst_oss_clock_new (gchar *name, GstOssClockGetTimeFunc func, gpointer user_data)
{
GstOssClock *oss_clock = GST_OSS_CLOCK (g_object_new (GST_TYPE_OSS_CLOCK, NULL));
oss_clock->entries = NULL;
oss_clock->current_time = 0;
oss_clock->next_time = 0;
_gst_clock_entries_chunk = g_mem_chunk_new ("GstClockEntries",
sizeof (GstClockEntry), sizeof (GstClockEntry) * 32,
G_ALLOC_AND_FREE);
_gst_clock_entries_chunk_lock = g_mutex_new ();
_gst_clock_entries_pool = NULL;
oss_clock->func = func;
oss_clock->user_data = user_data;
oss_clock->adjust = 0;
return oss_clock;
}
void
gst_oss_clock_set_update (GstOssClock *clock, gboolean update)
{
GST_LOCK (clock);
if (!update) {
GST_UNLOCK (clock);
GST_CLOCK_CLASS (parent_class)->set_time (GST_CLOCK (clock), clock->current_time);
GST_LOCK (clock);
clock->is_updated = FALSE;
/* FIXME, convert the entries to ones that wait for the system clock */
if (clock->entries) {
GList *entries = g_list_copy (clock->entries);
while (entries) {
GstClockEntry *entry = (GstClockEntry *)entries->data;
GST_CLOCK_ENTRY_LOCK (entry);
GST_CLOCK_ENTRY_SIGNAL (entry);
entry->status = GST_ENTRY_RESTART;
GST_CLOCK_ENTRY_UNLOCK (entry);
clock->entries = g_list_remove (clock->entries, entry);
entries = g_list_next (entries);
}
}
}
else {
clock->is_updated = TRUE;
}
GST_UNLOCK (clock);
}
void
gst_oss_clock_set_base (GstOssClock *clock, guint64 base)
{
GstOssClock *oss_clock = GST_OSS_CLOCK (clock);
oss_clock->base_time = base;
GST_CLOCK_CLASS (parent_class)->set_time (clock, base);
}
static void
gst_oss_clock_reset (GstClock *clock)
{
GstOssClock *oss_clock = GST_OSS_CLOCK (clock);
oss_clock->next_time = 0;
oss_clock->current_time = 0;
oss_clock->base_time = 0;
GST_CLOCK_CLASS (parent_class)->reset (clock);
}
static void
gst_oss_clock_activate (GstClock *clock, gboolean activate)
{
GstOssClock *oss_clock = GST_OSS_CLOCK (clock);
if (!activate) {
oss_clock->base_time = oss_clock->current_time;
}
GST_CLOCK_CLASS (parent_class)->activate (clock, activate);
}
static void
gst_oss_clock_set_time (GstClock *clock, GstClockTime time)
static GstClockTime
gst_oss_clock_get_internal_time (GstClock *clock)
{
GList *entries;
GTimeVal timeval;
GstClockTime time1;
GstClockTime time2;
GstClockTimeDiff diff1, diff2;
GstOssClock *oss_clock = GST_OSS_CLOCK (clock);
GST_LOCK (clock);
time += oss_clock->base_time;
/*g_print ("set time %llu\n", time); */
oss_clock->current_time = time;
if (oss_clock->next_time > time) {
GST_UNLOCK (clock);
return;
g_get_current_time (&timeval);
time1 = oss_clock->func (clock, oss_clock->user_data);
time2 = GST_TIMEVAL_TO_TIME (timeval);
if (!oss_clock->prev1) {
oss_clock->prev1 = time1;
}
diff1 = time1 - oss_clock->prev1;
diff2 = time2 - oss_clock->prev2;
entries = g_list_copy (oss_clock->entries);
while (entries) {
GstClockEntry *entry = (GstClockEntry *)entries->data;
if (GST_CLOCK_ENTRY_TIME (entry) <= oss_clock->current_time) {
GST_CLOCK_ENTRY_LOCK (entry);
GST_CLOCK_ENTRY_SIGNAL (entry);
entry->status = GST_ENTRY_OK;
GST_CLOCK_ENTRY_UNLOCK (entry);
oss_clock->prev1 = time1;
oss_clock->prev2 = time2;
oss_clock->entries = g_list_remove (oss_clock->entries, entry);
}
else {
break;
}
entries = g_list_next (entries);
if (diff1) {
oss_clock->adjust -= diff2 - diff1;
}
if (oss_clock->entries) {
oss_clock->next_time = GST_CLOCK_ENTRY_TIME (oss_clock->entries->data);
}
else {
oss_clock->next_time = 0;
}
GST_UNLOCK (oss_clock);
}
static gint
clock_compare_func (gconstpointer a,
gconstpointer b)
{