1 /*
2  * GStreamer
3  *
4  * Copyright (C) 2005 Thomas Vander Stichele <thomas@apestaart.org>
5  * Copyright (C) 2005 Ronald S. Bultje <rbultje@ronald.bitfreak.net>
6  * Copyright (C) 2008 Victor Lin <bornstub@gmail.com>
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  *
26  * Alternatively, the contents of this file may be used under the
27  * GNU Lesser General Public License Version 2.1 (the "LGPL"), in
28  * which case the following provisions apply instead of the ones
29  * mentioned above:
30  *
31  * Copyright (C) 2013 Juan Manuel Borges Caño <juanmabcmail@gmail.com>
32  *
33  * This library is free software; you can redistribute it and/or
34  * modify it under the terms of the GNU Library General Public
35  * License as published by the Free Software Foundation; either
36  * version 2 of the License, or (at your option) any later version.
37  *
38  * This library is distributed in the hope that it will be useful,
39  * but WITHOUT ANY WARRANTY; without even the implied warranty of
40  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
41  * Library General Public License for more details.
42  *
43  * You should have received a copy of the GNU Library General Public
44  * License along with this library; if not, write to the
45  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
46  * Boston, MA 02110-1301, USA.
47  */
48 
49 #ifndef __GST_OPENAL_SRC_H__
50 #define __GST_OPENAL_SRC_H__
51 
52 #include <gst/gst.h>
53 #include <gst/audio/audio.h>
54 
55 #ifdef _WIN32
56 #include <al.h>
57 #include <alc.h>
58 #include <alext.h>
59 #else
60 #include <AL/al.h>
61 #include <AL/alc.h>
62 #include <AL/alext.h>
63 #endif
64 
65 G_BEGIN_DECLS
66 
67 #define GST_TYPE_OPENAL_SRC \
68     (gst_openal_src_get_type())
69 #define GST_OPENAL_SRC(obj) \
70     (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_OPENAL_SRC, GstOpenalSrc))
71 #define GST_OPENAL_SRC_CLASS(klass) \
72     (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_OPENAL_SRC, GstOpenalSrcClass))
73 #define GST_IS_OPENAL_SRC(obj) \
74     (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_OPENAL_SRC))
75 #define GST_IS_OPENAL_SRC_CLASS(klass) \
76     (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_OPENAL_SRC))
77 
78 #if 1
79 #define GST_ALC_ERROR(Device)  ("ALC error: %s", alcGetString((Device), alcGetError((Device))))
80 #else
81 #define GST_ALC_ERROR(Device)  ("ALC error: 0x%x", alcGetError((Device)))
82 #endif
83 
84 typedef struct _GstOpenalSrc GstOpenalSrc;
85 typedef struct _GstOpenalSrcClass GstOpenalSrcClass;
86 
87 struct _GstOpenalSrc
88 {
89   GstAudioSrc element;
90   GstPad *srcpad;
91   gboolean silent;
92 
93   /* readable name of device */
94   gchar *default_device_name;
95   /* name of device to open, default is a NULL pointer to get default device */
96   gchar *default_device;
97   /* OpenAL device handle */
98   ALCdevice *device;
99 
100   guint64 buffer_length;
101 
102   ALenum format;
103   ALuint rate;
104   ALuint bytes_per_sample;
105 
106   GstCaps *probed_caps;
107 };
108 
109 struct _GstOpenalSrcClass
110 {
111   GstAudioSrcClass parent_class;
112 };
113 
114 GType gst_openal_src_get_type (void);
115 
116 G_END_DECLS
117 
118 #endif /* __GST_OPENAL_SRC_H__ */
119