fix doc build fix autogen
[platform/upstream/gstreamer.git] / gst / gstthreaddummy.c
1 /* GStreamer
2  * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #include <unistd.h>
21 #include <sys/time.h>
22 #include <glib.h>
23 #include "gstlog.h"
24
25 static GMutex *mutex = NULL;
26 static GCond  *cond = NULL;
27
28 static GMutex*
29 gst_mutex_new_dummy_impl (void) 
30 {
31   if (!mutex)
32     mutex = g_malloc (8);
33
34   return mutex;
35 }
36
37 static void gst_mutex_dummy_impl (GMutex *mutex) { /* NOP */ }
38
39 static gboolean
40 gst_mutex_trylock_dummy_impl (GMutex *mutex)
41 {
42   return TRUE;
43 }
44
45 static GCond*
46 gst_cond_new_dummy_impl (void) 
47 {
48   if (!cond)
49     cond = g_malloc (8);
50
51   return cond;
52 }
53
54 static void
55 gst_cond_dummy_impl (GCond *cond) { /* NOP */ }
56
57 static gboolean
58 gst_cond_timed_wait_dummy_impl (GCond *cond, GMutex *mutex, GTimeVal *end_time)
59 {
60   struct timeval tvtarget;
61   GTimeVal tvnow;
62   guint64 now, target;
63   gint64 diff;
64   
65   target = end_time->tv_sec * 1000000 + end_time->tv_usec;
66
67   g_get_current_time (&tvnow);
68   now = tvnow.tv_sec * 1000000 + tvnow.tv_usec;
69
70   diff = target - now;
71   if (diff > 1000) {
72     tvtarget.tv_usec = diff % 1000000;
73     tvtarget.tv_sec = diff / 1000000;
74
75     select(0, NULL, NULL, NULL, &tvtarget);
76   }
77   
78   return TRUE;
79 }
80
81 static GPrivate*
82 gst_private_new_dummy_impl (GDestroyNotify destructor)
83 {
84   gpointer data;
85
86   data = g_new0 (gpointer, 1);
87
88   return (GPrivate *) data;
89 }
90
91 static gpointer
92 gst_private_get_dummy_impl (GPrivate *private_key)
93 {
94   gpointer *data = (gpointer) private_key;
95   
96   return *data;
97 }
98
99 static void
100 gst_private_set_dummy_impl (GPrivate *private_key, gpointer data)
101 {
102   *((gpointer*)private_key) = data;
103 }
104
105 static void
106 gst_thread_create_dummy_impl (GThreadFunc func, gpointer data, gulong stack_size,
107                               gboolean joinable, gboolean bound, GThreadPriority priority,
108                               gpointer thread, GError **error)
109 {
110   g_warning ("GStreamer configured to not use threads");
111 }
112
113 static void
114 gst_thread_dummy_impl (void) { /* NOP */ }
115
116 static void
117 gst_thread_dummy_impl_1 (gpointer thread) { /* NOP */ }
118
119 static void
120 gst_thread_set_priority_dummy_impl (gpointer thread, GThreadPriority priority) { /* NOP */ }
121
122 static gboolean
123 gst_thread_equal_dummy_impl (gpointer thread1, gpointer thread2)
124 {
125   return (thread1 == thread2);
126 }
127
128 GThreadFunctions 
129 gst_thread_dummy_functions =
130 {
131   gst_mutex_new_dummy_impl,
132   (void (*)(GMutex *)) gst_mutex_dummy_impl,
133   gst_mutex_trylock_dummy_impl,
134   (void (*)(GMutex *)) gst_mutex_dummy_impl,
135   gst_mutex_dummy_impl,
136   gst_cond_new_dummy_impl,
137   (void (*)(GCond *)) gst_cond_dummy_impl,
138   (void (*)(GCond *)) gst_cond_dummy_impl,
139   (void (*)(GCond *, GMutex *)) gst_cond_dummy_impl,
140   gst_cond_timed_wait_dummy_impl,
141   gst_cond_dummy_impl,
142   gst_private_new_dummy_impl,
143   gst_private_get_dummy_impl,
144   gst_private_set_dummy_impl,
145   gst_thread_create_dummy_impl,
146   gst_thread_dummy_impl,
147   gst_thread_dummy_impl_1,
148   gst_thread_dummy_impl,
149   gst_thread_set_priority_dummy_impl,
150   gst_thread_dummy_impl_1,
151   gst_thread_equal_dummy_impl
152 };
153