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) 2009-2010 Chris Robinson <chris.kcat@gmail.com> 7 * Copyright (C) 2013 Juan Manuel Borges Caño <juanmabcmail@gmail.com> 8 * 9 * This library is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU Library General Public 11 * License as published by the Free Software Foundation; either 12 * version 2 of the License, or (at your option) any later version. 13 * 14 * This library is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 * Library General Public License for more details. 18 * 19 * You should have received a copy of the GNU Library General Public 20 * License along with this library; if not, write to the 21 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 22 * Boston, MA 02110-1301, USA. 23 */ 24 25 #ifndef __GST_OPENALSINK_H__ 26 #define __GST_OPENALSINK_H__ 27 28 #include <gst/gst.h> 29 #include <gst/audio/audio.h> 30 31 #ifdef _WIN32 32 #include <al.h> 33 #include <alc.h> 34 #include <alext.h> 35 #else 36 #include <AL/al.h> 37 #include <AL/alc.h> 38 #include <AL/alext.h> 39 #endif 40 41 G_BEGIN_DECLS 42 43 #define GST_TYPE_OPENAL_SINK \ 44 (gst_openal_sink_get_type()) 45 #define GST_OPENAL_SINK(obj) \ 46 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OPENAL_SINK,GstOpenALSink)) 47 #define GST_OPENAL_SINK_CLASS(klass) \ 48 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OPENAL_SINK,GstOpenALSinkClass)) 49 #define GST_IS_OPENAL_SINK(obj) \ 50 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OPENAL_SINK)) 51 #define GST_IS_OPENAL_SINK_CLASS(klass) \ 52 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OPENAL_SINK)) 53 #define GST_OPENAL_SINK_CAST(obj) \ 54 ((GstOpenALSink*)obj) 55 56 #if 1 57 #define GST_ALC_ERROR(Device) ("ALC error: %s", alcGetString((Device), alcGetError((Device)))) 58 #else 59 #define GST_ALC_ERROR(Device) ("ALC error: 0x%x", alcGetError((Device))) 60 #endif 61 62 typedef struct _GstOpenALSink GstOpenALSink; 63 typedef struct _GstOpenALSinkClass GstOpenALSinkClass; 64 65 #define GST_OPENAL_SINK_GET_LOCK(obj) (&GST_OPENAL_SINK_CAST(obj)->openal_lock) 66 #define GST_OPENAL_SINK_LOCK(obj) (g_mutex_lock(GST_OPENAL_SINK_GET_LOCK(obj))) 67 #define GST_OPENAL_SINK_UNLOCK(obj) (g_mutex_unlock(GST_OPENAL_SINK_GET_LOCK(obj))) 68 69 struct _GstOpenALSink 70 { 71 GstAudioSink sink; 72 73 gchar *device_name; 74 75 ALCdevice *default_device; 76 /* When set, device is not owned */ 77 ALCdevice *user_device; 78 79 ALCcontext *default_context; 80 /* When set, device or context is not owned */ 81 ALCcontext *user_context; 82 83 ALuint default_source; 84 /* When set, source is not owned */ 85 ALuint user_source; 86 87 ALuint buffer_idx; 88 ALuint buffer_count; 89 ALuint *buffers; 90 ALuint buffer_length; 91 92 ALenum format; 93 ALuint rate; 94 ALuint channels; 95 ALuint bytes_per_sample; 96 97 ALboolean write_reset; 98 99 GstCaps *probed_caps; 100 101 GMutex openal_lock; 102 }; 103 104 struct _GstOpenALSinkClass 105 { 106 GstAudioSinkClass parent_class; 107 }; 108 109 GType gst_openal_sink_get_type (void); 110 111 G_END_DECLS 112 113 #endif /* __GST_OPENALSINK_H__ */ 114