mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
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:
parent
b69213925f
commit
82c42cb6fd
3 changed files with 72 additions and 11 deletions
|
@ -26,6 +26,10 @@ 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 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 }; */
|
||||
|
@ -69,6 +73,8 @@ 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->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);
|
||||
}
|
||||
|
|
|
@ -57,6 +57,8 @@ struct _GstOssClock {
|
|||
GstClockTime prev1, prev2;
|
||||
GstClockTimeDiff adjust;
|
||||
|
||||
GSList *async_entries;
|
||||
|
||||
gboolean active;
|
||||
};
|
||||
|
||||
|
@ -70,6 +72,8 @@ GstOssClock* gst_oss_clock_new (gchar *name, GstOssClockGetTimeFunc func,
|
|||
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
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue