2004-12-08 18:05:14 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
2005-01-06 18:17:12 +00:00
|
|
|
* 2005 Wim Taymans <wim@fluendo.com>
|
2004-12-08 18:05:14 +00:00
|
|
|
*
|
|
|
|
* gsttask.c: Streaming tasks
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gst_private.h"
|
|
|
|
|
|
|
|
#include "gstinfo.h"
|
|
|
|
#include "gsttask.h"
|
|
|
|
|
|
|
|
static void gst_task_class_init (GstTaskClass * klass);
|
2005-01-06 18:17:12 +00:00
|
|
|
static void gst_task_init (GstTask * task);
|
2004-12-08 18:05:14 +00:00
|
|
|
static void gst_task_dispose (GObject * object);
|
|
|
|
|
|
|
|
static GstObjectClass *parent_class = NULL;
|
|
|
|
|
|
|
|
GType
|
|
|
|
gst_task_get_type (void)
|
|
|
|
{
|
|
|
|
static GType _gst_task_type = 0;
|
|
|
|
|
|
|
|
if (!_gst_task_type) {
|
|
|
|
static const GTypeInfo task_info = {
|
|
|
|
sizeof (GstTaskClass),
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc) gst_task_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof (GstTask),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc) gst_task_init,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
_gst_task_type =
|
|
|
|
g_type_register_static (GST_TYPE_OBJECT, "GstTask",
|
|
|
|
&task_info, G_TYPE_FLAG_ABSTRACT);
|
|
|
|
}
|
|
|
|
return _gst_task_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_task_class_init (GstTaskClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
|
|
|
|
parent_class = g_type_class_ref (GST_TYPE_OBJECT);
|
|
|
|
|
|
|
|
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_task_dispose);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-01-06 18:17:12 +00:00
|
|
|
gst_task_init (GstTask * task)
|
2004-12-08 18:05:14 +00:00
|
|
|
{
|
2005-01-06 18:17:12 +00:00
|
|
|
task->cond = g_cond_new ();
|
|
|
|
task->state = GST_TASK_STOPPED;
|
2004-12-08 18:05:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_task_dispose (GObject * object)
|
|
|
|
{
|
|
|
|
GstTask *task = GST_TASK (object);
|
|
|
|
|
|
|
|
GST_DEBUG ("task %p dispose", task);
|
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
g_cond_free (task->cond);
|
|
|
|
|
2004-12-08 18:05:14 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
/**
|
|
|
|
* gst_task_create:
|
|
|
|
* @func: The #GstTaskFunction to use
|
|
|
|
* @data: User data to pass to @func
|
|
|
|
*
|
|
|
|
* Create a new Task that will repeadedly call the provided @func
|
|
|
|
* with @data as a parameter. Typically the task will run in
|
|
|
|
* a new thread.
|
|
|
|
*
|
|
|
|
* Returns: A new #GstTask.
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
GstTask *
|
|
|
|
gst_task_create (GstTaskFunction func, gpointer data)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_task_get_state:
|
|
|
|
* @task: The #GstTask to query
|
|
|
|
*
|
|
|
|
* Get the current state of the task.
|
|
|
|
*
|
|
|
|
* Returns: The #GstTaskState of the task
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
|
|
|
GstTaskState
|
|
|
|
gst_task_get_state (GstTask * task)
|
|
|
|
{
|
|
|
|
GstTaskState result;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_TASK (task), GST_TASK_STOPPED);
|
|
|
|
|
|
|
|
GST_LOCK (task);
|
|
|
|
result = task->state;
|
|
|
|
GST_UNLOCK (task);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_task_start:
|
|
|
|
* @task: The #GstTask to start
|
|
|
|
*
|
|
|
|
* Starts @task.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the task could be started.
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
2004-12-08 18:05:14 +00:00
|
|
|
gboolean
|
|
|
|
gst_task_start (GstTask * task)
|
|
|
|
{
|
|
|
|
GstTaskClass *tclass;
|
|
|
|
gboolean result = FALSE;
|
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
g_return_val_if_fail (GST_IS_TASK (task), FALSE);
|
2004-12-08 18:05:14 +00:00
|
|
|
|
|
|
|
tclass = GST_TASK_GET_CLASS (task);
|
|
|
|
|
|
|
|
if (tclass->start)
|
|
|
|
result = tclass->start (task);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
/**
|
|
|
|
* gst_task_stop:
|
|
|
|
* @task: The #GstTask to stop
|
|
|
|
*
|
|
|
|
* Stops @task.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the task could be stopped.
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
2004-12-08 18:05:14 +00:00
|
|
|
gboolean
|
|
|
|
gst_task_stop (GstTask * task)
|
|
|
|
{
|
|
|
|
GstTaskClass *tclass;
|
|
|
|
gboolean result = FALSE;
|
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
g_return_val_if_fail (GST_IS_TASK (task), FALSE);
|
2004-12-08 18:05:14 +00:00
|
|
|
|
|
|
|
tclass = GST_TASK_GET_CLASS (task);
|
|
|
|
|
|
|
|
if (tclass->stop)
|
|
|
|
result = tclass->stop (task);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
gst/: Work on flushing.
Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_getrange),
(gst_filesrc_get), (gst_filesrc_activate):
* gst/gstclock.c: (gst_clock_init), (gst_clock_dispose):
* gst/gstclock.h:
* gst/gstevent.c: (gst_event_new_discontinuous_valist),
(gst_event_new_discontinuous), (gst_event_discont_get_value),
(gst_event_new_flush):
* gst/gstevent.h:
* gst/gstpad.c: (gst_pad_set_active), (gst_pad_set_blocked_async),
(gst_pad_set_acceptcaps_function),
(gst_pad_set_fixatecaps_function), (gst_pad_unlink),
(gst_pad_link_prepare_filtered), (gst_pad_link_filtered),
(gst_pad_relink_filtered), (gst_real_pad_get_caps_unlocked),
(gst_pad_peer_get_caps), (gst_pad_fixate_caps),
(gst_pad_accept_caps), (gst_pad_peer_accept_caps),
(gst_pad_set_caps), (gst_pad_configure_sink),
(gst_pad_configure_src), (gst_pad_realize), (gst_pad_alloc_buffer),
(gst_pad_push), (gst_pad_push_event), (gst_pad_send_event):
* gst/gstpad.h:
* gst/gsttask.c: (gst_task_pause):
* gst/gsttask.h:
* gst/schedulers/threadscheduler.c:
(gst_thread_scheduler_task_class_init),
(gst_thread_scheduler_task_init),
(gst_thread_scheduler_task_start),
(gst_thread_scheduler_task_stop),
(gst_thread_scheduler_task_pause), (gst_thread_scheduler_func):
Work on flushing.
Allow tasks to be paused.
Remove some old code in GstClock
2005-01-04 12:06:57 +00:00
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
/**
|
|
|
|
* gst_task_pause:
|
|
|
|
* @task: The #GstTask to pause
|
|
|
|
*
|
|
|
|
* Pauses @task.
|
|
|
|
*
|
|
|
|
* Returns: TRUE if the task could be paused.
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
gst/: Work on flushing.
Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_getrange),
(gst_filesrc_get), (gst_filesrc_activate):
* gst/gstclock.c: (gst_clock_init), (gst_clock_dispose):
* gst/gstclock.h:
* gst/gstevent.c: (gst_event_new_discontinuous_valist),
(gst_event_new_discontinuous), (gst_event_discont_get_value),
(gst_event_new_flush):
* gst/gstevent.h:
* gst/gstpad.c: (gst_pad_set_active), (gst_pad_set_blocked_async),
(gst_pad_set_acceptcaps_function),
(gst_pad_set_fixatecaps_function), (gst_pad_unlink),
(gst_pad_link_prepare_filtered), (gst_pad_link_filtered),
(gst_pad_relink_filtered), (gst_real_pad_get_caps_unlocked),
(gst_pad_peer_get_caps), (gst_pad_fixate_caps),
(gst_pad_accept_caps), (gst_pad_peer_accept_caps),
(gst_pad_set_caps), (gst_pad_configure_sink),
(gst_pad_configure_src), (gst_pad_realize), (gst_pad_alloc_buffer),
(gst_pad_push), (gst_pad_push_event), (gst_pad_send_event):
* gst/gstpad.h:
* gst/gsttask.c: (gst_task_pause):
* gst/gsttask.h:
* gst/schedulers/threadscheduler.c:
(gst_thread_scheduler_task_class_init),
(gst_thread_scheduler_task_init),
(gst_thread_scheduler_task_start),
(gst_thread_scheduler_task_stop),
(gst_thread_scheduler_task_pause), (gst_thread_scheduler_func):
Work on flushing.
Allow tasks to be paused.
Remove some old code in GstClock
2005-01-04 12:06:57 +00:00
|
|
|
gboolean
|
|
|
|
gst_task_pause (GstTask * task)
|
|
|
|
{
|
|
|
|
GstTaskClass *tclass;
|
|
|
|
gboolean result = FALSE;
|
|
|
|
|
2005-01-06 18:17:12 +00:00
|
|
|
g_return_val_if_fail (GST_IS_TASK (task), FALSE);
|
gst/: Work on flushing.
Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_getrange),
(gst_filesrc_get), (gst_filesrc_activate):
* gst/gstclock.c: (gst_clock_init), (gst_clock_dispose):
* gst/gstclock.h:
* gst/gstevent.c: (gst_event_new_discontinuous_valist),
(gst_event_new_discontinuous), (gst_event_discont_get_value),
(gst_event_new_flush):
* gst/gstevent.h:
* gst/gstpad.c: (gst_pad_set_active), (gst_pad_set_blocked_async),
(gst_pad_set_acceptcaps_function),
(gst_pad_set_fixatecaps_function), (gst_pad_unlink),
(gst_pad_link_prepare_filtered), (gst_pad_link_filtered),
(gst_pad_relink_filtered), (gst_real_pad_get_caps_unlocked),
(gst_pad_peer_get_caps), (gst_pad_fixate_caps),
(gst_pad_accept_caps), (gst_pad_peer_accept_caps),
(gst_pad_set_caps), (gst_pad_configure_sink),
(gst_pad_configure_src), (gst_pad_realize), (gst_pad_alloc_buffer),
(gst_pad_push), (gst_pad_push_event), (gst_pad_send_event):
* gst/gstpad.h:
* gst/gsttask.c: (gst_task_pause):
* gst/gsttask.h:
* gst/schedulers/threadscheduler.c:
(gst_thread_scheduler_task_class_init),
(gst_thread_scheduler_task_init),
(gst_thread_scheduler_task_start),
(gst_thread_scheduler_task_stop),
(gst_thread_scheduler_task_pause), (gst_thread_scheduler_func):
Work on flushing.
Allow tasks to be paused.
Remove some old code in GstClock
2005-01-04 12:06:57 +00:00
|
|
|
|
|
|
|
tclass = GST_TASK_GET_CLASS (task);
|
|
|
|
|
|
|
|
if (tclass->pause)
|
|
|
|
result = tclass->pause (task);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|