1 /* GStreamer 2 * Copyright (C) 2005 Sebastien Moutte <sebastien@moutte.net> 3 * Copyright (C) 2007 Pioneers of the Inevitable <songbird@songbirdnest.com> 4 * Copyright (C) 2010 Fluendo S.A. <support@fluendo.com> 5 * 6 * gstdirectsoundsink.h: 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Library General Public 10 * License as published by the Free Software Foundation; either 11 * version 2 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Library General Public License for more details. 17 * 18 * You should have received a copy of the GNU Library General Public 19 * License along with this library; if not, write to the 20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 21 * Boston, MA 02110-1301, USA. 22 * 23 * The development of this code was made possible due to the involvement 24 * of Pioneers of the Inevitable, the creators of the Songbird Music player 25 * 26 * 27 */ 28 29 #ifndef __GST_DIRECTSOUNDSINK_H__ 30 #define __GST_DIRECTSOUNDSINK_H__ 31 32 #include <gst/gst.h> 33 #include <gst/audio/audio.h> 34 #include <gst/audio/gstaudiosink.h> 35 36 #include <windows.h> 37 #include <dsound.h> 38 #include <mmreg.h> 39 #include <ks.h> 40 #include <ksmedia.h> 41 42 G_BEGIN_DECLS 43 #define GST_TYPE_DIRECTSOUND_SINK (gst_directsound_sink_get_type()) 44 #define GST_DIRECTSOUND_SINK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DIRECTSOUND_SINK,GstDirectSoundSink)) 45 #define GST_DIRECTSOUND_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DIRECTSOUND_SINK,GstDirectSoundSinkClass)) 46 #define GST_IS_DIRECTSOUND_SINK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DIRECTSOUND_SINK)) 47 #define GST_IS_DIRECTSOUND_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DIRECTSOUND_SINK)) 48 typedef struct _GstDirectSoundSink GstDirectSoundSink; 49 typedef struct _GstDirectSoundSinkClass GstDirectSoundSinkClass; 50 51 #define GST_DSOUND_LOCK(obj) (g_mutex_lock (&obj->dsound_lock)) 52 #define GST_DSOUND_UNLOCK(obj) (g_mutex_unlock (&obj->dsound_lock)) 53 54 struct _GstDirectSoundSink 55 { 56 GstAudioSink sink; 57 58 59 /* directsound object interface pointer */ 60 LPDIRECTSOUND pDS; 61 62 /* directsound sound object interface pointer */ 63 LPDIRECTSOUNDBUFFER pDSBSecondary; 64 65 /* directSound buffer size */ 66 guint buffer_size; 67 68 /* offset of the circular buffer where we must write next */ 69 guint current_circular_offset; 70 71 guint bytes_per_sample; 72 73 /* current volume setup by mixer interface */ 74 glong volume; 75 gboolean mute; 76 77 /* current directsound device ID */ 78 gchar * device_id; 79 80 GstCaps *cached_caps; 81 /* lock used to protect writes and resets */ 82 GMutex dsound_lock; 83 84 GstClock *system_clock; 85 GstClockID write_wait_clock_id; 86 gboolean reset_while_sleeping; 87 88 gboolean first_buffer_after_reset; 89 90 GstAudioRingBufferFormatType type; 91 }; 92 93 struct _GstDirectSoundSinkClass 94 { 95 GstAudioSinkClass parent_class; 96 }; 97 98 GType gst_directsound_sink_get_type (void); 99 100 #define GST_DIRECTSOUND_SINK_CAPS "audio/x-raw, " \ 101 "format = (string) S16LE, " \ 102 "layout = (string) interleaved, " \ 103 "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]; " \ 104 "audio/x-raw, " \ 105 "format = (string) U8, " \ 106 "layout = (string) interleaved, " \ 107 "rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ];" \ 108 "audio/x-ac3, framed = (boolean) true;" \ 109 "audio/x-dts, framed = (boolean) true;" 110 111 G_END_DECLS 112 #endif /* __GST_DIRECTSOUNDSINK_H__ */ 113