implemented wait_async and unschedule ossclock, and support it in osssink -- really should make this a general clock,...

Original commit message from CVS:
implemented wait_async and unschedule ossclock, and support it in osssink -- really should make this a general clock, ill need it in gstsf
This commit is contained in:
Andy Wingo 2003-07-03 14:35:50 +00:00
parent b69213925f
commit 82c42cb6fd
3 changed files with 72 additions and 11 deletions

View file

@ -25,7 +25,11 @@
static void gst_oss_clock_class_init (GstOssClockClass *klass);
static void gst_oss_clock_init (GstOssClock *clock);
static GstClockTime gst_oss_clock_get_internal_time (GstClock *clock);
static GstClockTime gst_oss_clock_get_internal_time (GstClock *clock);
static GstClockReturn gst_oss_clock_id_wait_async (GstClock *clock,
GstClockEntry *entry);
static void gst_oss_clock_id_unschedule (GstClock *clock,
GstClockEntry *entry);
static GstSystemClockClass *parent_class = NULL;
/* static guint gst_oss_clock_signals[LAST_SIGNAL] = { 0 }; */
@ -68,7 +72,9 @@ gst_oss_clock_class_init (GstOssClockClass *klass)
parent_class = g_type_class_ref (GST_TYPE_SYSTEM_CLOCK);
gstclock_class->get_internal_time = gst_oss_clock_get_internal_time;
gstclock_class->get_internal_time = gst_oss_clock_get_internal_time;
gstclock_class->wait_async = gst_oss_clock_id_wait_async;
gstclock_class->unschedule = gst_oss_clock_id_unschedule;
}
static void
@ -137,3 +143,49 @@ gst_oss_clock_get_internal_time (GstClock *clock)
}
}
void
gst_oss_clock_update_time (GstClock *clock, GstClockTime time)
{
GstOssClock *oss_clock = (GstOssClock*)clock;
while (oss_clock->async_entries) {
GstClockEntry *entry = (GstClockEntry*)oss_clock->async_entries->data;
if (entry->time > time)
break;
entry->func (clock, time, entry, entry->user_data);
oss_clock->async_entries = g_slist_delete_link (oss_clock->async_entries,
oss_clock->async_entries);
/* do I need to free the entry? */
}
}
static gint
compare_clock_entries (GstClockEntry *entry1, GstClockEntry *entry2)
{
return entry1->time - entry2->time;
}
static GstClockReturn
gst_oss_clock_id_wait_async (GstClock *clock, GstClockEntry *entry)
{
GstOssClock *oss_clock = (GstOssClock*)clock;
oss_clock->async_entries = g_slist_insert_sorted (oss_clock->async_entries,
entry,
(GCompareFunc)compare_clock_entries);
/* is this the proper return val? */
return GST_CLOCK_EARLY;
}
static void
gst_oss_clock_id_unschedule (GstClock *clock, GstClockEntry *entry)
{
GstOssClock *oss_clock = (GstOssClock*)clock;
oss_clock->async_entries = g_slist_remove (oss_clock->async_entries,
entry);
}

View file

@ -57,6 +57,8 @@ struct _GstOssClock {
GstClockTime prev1, prev2;
GstClockTimeDiff adjust;
GSList *async_entries;
gboolean active;
};
@ -64,11 +66,13 @@ struct _GstOssClockClass {
GstSystemClockClass parent_class;
};
GType gst_oss_clock_get_type (void);
GstOssClock* gst_oss_clock_new (gchar *name, GstOssClockGetTimeFunc func,
gpointer user_data);
void gst_oss_clock_set_active (GstClock *clock, gboolean active);
void gst_oss_clock_set_time (GstClock *clock, GstClockTime time);
GType gst_oss_clock_get_type (void);
GstOssClock* gst_oss_clock_new (gchar *name, GstOssClockGetTimeFunc func,
gpointer user_data);
void gst_oss_clock_set_active (GstClock *clock, gboolean active);
void gst_oss_clock_set_time (GstClock *clock, GstClockTime time);
void gst_oss_clock_update_time (GstClock *clock, GstClockTime time);
#ifdef __cplusplus
}

View file

@ -61,7 +61,7 @@ static gboolean gst_osssink_query (GstElement *element, GstQueryType type,
static gboolean gst_osssink_sink_query (GstPad *pad, GstQueryType type,
GstFormat *format, gint64 *value);
static GstPadLinkReturn gst_osssink_sinkconnect (GstPad *pad, GstCaps *caps);
static GstPadLinkReturn gst_osssink_sinkconnect (GstPad *pad, GstCaps *caps);
static void gst_osssink_set_property (GObject *object, guint prop_id, const GValue *value,
GParamSpec *pspec);
@ -187,10 +187,10 @@ gst_osssink_class_init (GstOssSinkClass *klass)
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_DEVICE,
g_param_spec_string ("device", "Device", "The device to use for output",
"/dev/dsp", G_PARAM_READWRITE)); /* CHECKME! */
"/dev/dsp", G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_MUTE,
g_param_spec_boolean ("mute", "Mute", "Mute the audio",
TRUE, G_PARAM_READWRITE));
FALSE, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_SYNC,
g_param_spec_boolean ("sync", "Sync", "If syncing on timestamps should be enabled",
TRUE, G_PARAM_READWRITE));
@ -199,7 +199,7 @@ gst_osssink_class_init (GstOssSinkClass *klass)
"The fragment as 0xMMMMSSSS (MMMM = total fragments, 2^SSSS = fragment size)",
0, G_MAXINT, 6, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_BUFFER_SIZE,
g_param_spec_uint ("buffer_size", "Buffer size", "The buffer size",
g_param_spec_uint ("buffer_size", "Buffer size", "Size of buffers in osssink's bufferpool (bytes)",
0, G_MAXINT, 4096, G_PARAM_READWRITE));
g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_CHUNK_SIZE,
g_param_spec_uint ("chunk_size", "Chunk size", "Write data in chunk sized buffers",
@ -242,6 +242,7 @@ gst_osssink_init (GstOssSink *osssink)
osssink->bufsize = 4096;
osssink->chunk_size = 4096;
osssink->resync = FALSE;
osssink->mute = FALSE;
osssink->sync = TRUE;
osssink->sinkpool = NULL;
osssink->provided_clock = GST_CLOCK (gst_oss_clock_new ("ossclock", gst_osssink_get_time, osssink));
@ -439,6 +440,10 @@ gst_osssink_chain (GstPad *pad, GstBuffer *buf)
}
}
}
if (osssink->clock)
gst_oss_clock_update_time (osssink->clock, buftime);
gst_buffer_unref (buf);
}