1 /* GStreamer
2  * Copyright (C)  2005 Sebastien Moutte <sebastien@moutte.net>
3  *
4  * gstwaveformsink.h:
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 
22 #ifndef __GST_WAVEFORMSINK_H__
23 #define __GST_WAVEFORMSINK_H__
24 
25 #include <gst/gst.h>
26 #include <gst/audio/audio.h>
27 #include <gst/audio/gstaudiosink.h>
28 
29 #include <windows.h>
30 #include <mmsystem.h>
31 
32 #ifndef WAVE_FORMAT_96M08
33 #define WAVE_FORMAT_96M08       0x00001000       /* 96   kHz, Mono,   8-bit  */
34 #endif
35 
36 #ifndef WAVE_FORMAT_96S08
37 #define WAVE_FORMAT_96S08       0x00002000       /* 96   kHz, Stereo, 8-bit  */
38 #endif
39 
40 #ifndef WAVE_FORMAT_96M16
41 #define WAVE_FORMAT_96M16       0x00004000       /* 96   kHz, Mono,   16-bit */
42 #endif
43 
44 #ifndef WAVE_FORMAT_96S16
45 #define WAVE_FORMAT_96S16       0x00008000       /* 96   kHz, Stereo, 16-bit */
46 #endif
47 
48 #define ERROR_LENGTH MAXERRORLENGTH+50
49 #define BUFFER_COUNT 20
50 #define BUFFER_SIZE 8192
51 
52 G_BEGIN_DECLS
53 #define GST_TYPE_WAVEFORM_SINK                (gst_waveform_sink_get_type())
54 #define GST_WAVEFORM_SINK(obj)                (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_WAVEFORM_SINK,GstWaveFormSink))
55 #define GST_WAVEFORM_SINK_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_WAVEFORM_SINK,GstWaveFormSinkClass))
56 #define GST_IS_WAVEFORM_SINK(obj)             (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_WAVEFORM_SINK))
57 #define GST_IS_WAVEFORM_SINK_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_WAVEFORM_SINK))
58 typedef struct _GstWaveFormSink GstWaveFormSink;
59 typedef struct _GstWaveFormSinkClass GstWaveFormSinkClass;
60 
61 struct _GstWaveFormSink
62 {
63   /* parent object */
64   GstAudioSink sink;
65 
66   /* supported caps */
67   GstCaps *cached_caps;
68 
69   /* handle to the waveform-audio output device */
70   HWAVEOUT hwaveout;
71 
72   /* table of buffer headers */
73   WAVEHDR *wave_buffers;
74 
75   /* critical section protecting access to the number of free buffers */
76   CRITICAL_SECTION critic_wave;
77 
78   /* number of free buffers available */
79   guint free_buffers_count;
80 
81   /* current free buffer where you have to write incoming data */
82   guint write_buffer;
83 
84   /* size of buffers streamed to the device */
85   guint buffer_size;
86 
87   /* number of buffers streamed to the device */
88   guint buffer_count;
89 
90   /* total of bytes in queue before they are written to the device */
91   guint bytes_in_queue;
92 
93   /* bytes per sample from setcaps used to evaluate the number samples returned by delay */
94   guint bytes_per_sample;
95 
96   /* wave form error string */
97   gchar error_string[ERROR_LENGTH];
98 };
99 
100 struct _GstWaveFormSinkClass
101 {
102   GstAudioSinkClass parent_class;
103 };
104 
105 GType gst_waveform_sink_get_type (void);
106 
107 G_END_DECLS
108 #endif /* __GST_WAVEFORMSINK_H__ */
109