compatibility fix for new GST_DEBUG stuff.
[platform/upstream/gstreamer.git] / ext / arts / gst_arts.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 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23 #include <string.h>
24 #include <math.h>
25 #include <sys/soundcard.h>
26
27 /*#define DEBUG_ENABLED */
28 #include "gst_arts.h"
29 #include "gst_artsio_impl.h"
30
31 /* elementfactory information */
32 static GstElementDetails gst_arts_details = {
33   "aRts plugin",
34   "Filter/Audio",
35   "LGPL",
36   "aRts wrapper filter",
37   VERSION,
38   "Erik Walthinsen <omega@temple-baptist.com,\n"
39   "Stefan Westerfeld <stefan@space.twc.de>",
40   "(C) 2000",
41 };
42
43
44 GST_PAD_TEMPLATE_FACTORY ( sink_temp,
45   "sink",
46   GST_PAD_SINK,
47   GST_PAD_ALWAYS,
48   GST_CAPS_NEW (
49     "arts_sample",
50     "audio/raw",
51     "format",   GST_PROPS_STRING ("int"),
52     "law",      GST_PROPS_INT (0),
53     "depth",    GST_PROPS_INT (16),
54     "width",    GST_PROPS_INT (16),
55     "signed",   GST_PROPS_BOOLEAN (TRUE),
56     "channels", GST_PROPS_INT (2),
57     "endianness", GST_PROPS_INT (G_BYTE_ORDER)
58   )
59 )
60
61 GST_PAD_TEMPLATE_FACTORY ( src_temp,
62   "src",
63   GST_PAD_SRC,
64   GST_PAD_ALWAYS,
65   GST_CAPS_NEW (
66     "arts_sample",
67     "audio/raw",
68     "format",   GST_PROPS_STRING ("int"),
69     "law",      GST_PROPS_INT (0),
70     "depth",    GST_PROPS_INT (16),
71     "width",    GST_PROPS_INT (16),
72     "signed",   GST_PROPS_BOOLEAN (TRUE),
73     "channels", GST_PROPS_INT (2),
74     "rate",     GST_PROPS_INT (44100),
75     "endianness", GST_PROPS_INT (G_BYTE_ORDER)
76   )
77 )
78
79 enum {
80   ARG_0,
81   ARG_LAST,
82 };
83
84 static void                     gst_arts_class_init             (GstARTSClass *klass);
85 static void                     gst_arts_init                   (GstARTS *arts);
86
87 static void                     gst_arts_loop                   (GstElement *element);
88
89
90 static GstElementClass *parent_class = NULL;
91 /*static guint gst_arts_signals[LAST_SIGNAL] = { 0 }; */
92
93 GType
94 gst_arts_get_type (void)
95 {
96   static GType gst_arts_type = 0;
97
98   if (!gst_arts_type) {
99     static const GTypeInfo gst_arts_info = {
100       sizeof(GstARTSClass),      NULL,
101       NULL,
102       (GClassInitFunc)gst_arts_class_init,
103       NULL,
104       NULL,
105       sizeof(GstARTS),
106       0,
107       (GInstanceInitFunc)gst_arts_init,
108     };
109     gst_arts_type = g_type_register_static(GST_TYPE_ELEMENT, "GstArts", &gst_arts_info, 0);
110   }
111   return gst_arts_type;
112
113
114 static void
115 gst_arts_class_init (GstARTSClass *klass)
116 {
117   GObjectClass *gobject_class;
118   GstElementClass *gstelement_class;
119
120   parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
121
122   gobject_class = (GObjectClass*)klass;
123   gstelement_class = (GstElementClass*)klass;
124 }
125
126 static void
127 gst_arts_init (GstARTS *arts)
128 {
129   arts->sinkpad = gst_pad_new_from_template(GST_PAD_TEMPLATE_GET(sink_temp),"sink");
130   gst_element_add_pad(GST_ELEMENT(arts),arts->sinkpad);
131
132   arts->srcpad = gst_pad_new_from_template(GST_PAD_TEMPLATE_GET(src_temp),"src");
133   gst_element_add_pad(GST_ELEMENT(arts),arts->srcpad);
134
135   gst_element_set_loop_function (GST_ELEMENT (arts), gst_arts_loop);
136
137   arts->wrapper = gst_arts_wrapper_new(arts->sinkpad,arts->srcpad);
138 }
139
140 static void
141 gst_arts_loop   (GstElement *element)
142 {
143   GstARTS *arts = (GstARTS*)element;
144
145   g_return_if_fail (arts != NULL);
146
147   gst_arts_wrapper_do(arts->wrapper);
148 }
149
150 static gboolean
151 plugin_init (GModule *module, GstPlugin *plugin)
152 {
153   GstElementFactory *gstarts;
154
155   gstarts = gst_element_factory_new("gstarts",GST_TYPE_ARTS,&gst_arts_details);
156   g_return_val_if_fail(gstarts != NULL, FALSE);
157
158   gst_element_factory_add_pad_template(gstarts, GST_PAD_TEMPLATE_GET(sink_temp));
159   gst_element_factory_add_pad_template(gstarts, GST_PAD_TEMPLATE_GET(src_temp));
160
161   gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (gstarts));
162
163   return TRUE;
164 }
165
166 GstPluginDesc plugin_desc = {
167   GST_VERSION_MAJOR,
168   GST_VERSION_MINOR,
169   "gst_arts",
170   plugin_init
171 };