1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
|
/* GStreamer
* Copyright (C) 2005 Sebastien Moutte <sebastien@moutte.net>
*
* gstwaveformsink.c:
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:element-waveformsink
* @short_description: output sound using WaveForm API
*
* <refsect2>
* <para>
* This element lets you output sound using the WaveForm API.
* </para>
* <para>
* Note that you should almost always use generic audio conversion elements
* like audioconvert and audioresample in front of an audiosink to make sure
* your pipeline works under all circumstances (those conversion elements will
* act in passthrough-mode if no conversion is necessary).
* </para>
* <title>Example pipelines</title>
* <para>
* <programlisting>
* gst-launch-0.10 -v audiotestsrc ! audioconvert ! volume volume=0.1 ! waveformsink
* </programlisting>
* will output a sine wave (continuous beep sound) to your sound card (with
* a very low volume as precaution).
* </para>
* <para>
* <programlisting>
* gst-launch-0.10 -v filesrc location=music.ogg ! decodebin ! audioconvert ! audioresample ! waveformsink
* </programlisting>
* will play an Ogg/Vorbis audio file and output it.
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstwaveformsink.h"
GST_DEBUG_CATEGORY_STATIC (waveformsink_debug);
/* elementfactory information */
static const GstElementDetails gst_waveform_sink_details =
GST_ELEMENT_DETAILS ("WaveForm Audio Sink",
"Sink/Audio",
"Output to a sound card via WaveForm API",
"Sebastien Moutte <sebastien@moutte.net>");
static void gst_waveform_sink_base_init (gpointer g_class);
static void gst_waveform_sink_class_init (GstWaveFormSinkClass * klass);
static void gst_waveform_sink_init (GstWaveFormSink * wfsink,
GstWaveFormSinkClass * g_class);
static void gst_waveform_sink_finalise (GObject * object);
static void gst_waveform_sink_set_property (GObject * object,
guint prop_id, const GValue * value, GParamSpec * pspec);
static void gst_waveform_sink_get_property (GObject * object,
guint prop_id, GValue * value, GParamSpec * pspec);
static GstCaps *gst_waveform_sink_getcaps (GstBaseSink * bsink);
/************************************************************************/
/* GstAudioSink functions */
/************************************************************************/
static gboolean gst_waveform_sink_prepare (GstAudioSink * asink,
GstRingBufferSpec * spec);
static gboolean gst_waveform_sink_unprepare (GstAudioSink * asink);
static gboolean gst_waveform_sink_open (GstAudioSink * asink);
static gboolean gst_waveform_sink_close (GstAudioSink * asink);
static guint gst_waveform_sink_write (GstAudioSink * asink, gpointer data,
guint length);
static guint gst_waveform_sink_delay (GstAudioSink * asink);
static void gst_waveform_sink_reset (GstAudioSink * asink);
/************************************************************************/
/* Utils */
/************************************************************************/
GstCaps *gst_waveform_sink_create_caps (gint rate, gint channels,
gint bits_per_sample);
WAVEHDR *bufferpool_get_buffer (GstWaveFormSink * wfsink, gpointer data,
guint length);
void CALLBACK waveOutProc (HWAVEOUT hwo, UINT uMsg, unsigned long dwInstance,
DWORD dwParam1, DWORD dwParam2);
static GstStaticPadTemplate waveformsink_sink_factory =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-raw-int, "
"signed = (boolean) { TRUE, FALSE }, "
"width = (int) 16, "
"depth = (int) 16, "
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]; "
"audio/x-raw-int, "
"signed = (boolean) { TRUE, FALSE }, "
"width = (int) 8, "
"depth = (int) 8, "
"rate = (int) [ 1, MAX ], " "channels = (int) [ 1, 2 ]"));
GST_BOILERPLATE (GstWaveFormSink, gst_waveform_sink, GstAudioSink,
GST_TYPE_AUDIO_SINK);
static void
gst_waveform_sink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (element_class, &gst_waveform_sink_details);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&waveformsink_sink_factory));
}
static void
gst_waveform_sink_class_init (GstWaveFormSinkClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *gstelement_class;
GstBaseSinkClass *gstbasesink_class;
GstBaseAudioSinkClass *gstbaseaudiosink_class;
GstAudioSinkClass *gstaudiosink_class;
gobject_class = (GObjectClass *) klass;
gstelement_class = (GstElementClass *) klass;
gstbasesink_class = (GstBaseSinkClass *) klass;
gstbaseaudiosink_class = (GstBaseAudioSinkClass *) klass;
gstaudiosink_class = (GstAudioSinkClass *) klass;
parent_class = g_type_class_peek_parent (klass);
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_waveform_sink_finalise);
gobject_class->get_property =
GST_DEBUG_FUNCPTR (gst_waveform_sink_get_property);
gobject_class->set_property =
GST_DEBUG_FUNCPTR (gst_waveform_sink_set_property);
gstbasesink_class->get_caps = GST_DEBUG_FUNCPTR (gst_waveform_sink_getcaps);
gstaudiosink_class->prepare = GST_DEBUG_FUNCPTR (gst_waveform_sink_prepare);
gstaudiosink_class->unprepare =
GST_DEBUG_FUNCPTR (gst_waveform_sink_unprepare);
gstaudiosink_class->open = GST_DEBUG_FUNCPTR (gst_waveform_sink_open);
gstaudiosink_class->close = GST_DEBUG_FUNCPTR (gst_waveform_sink_close);
gstaudiosink_class->write = GST_DEBUG_FUNCPTR (gst_waveform_sink_write);
gstaudiosink_class->delay = GST_DEBUG_FUNCPTR (gst_waveform_sink_delay);
gstaudiosink_class->reset = GST_DEBUG_FUNCPTR (gst_waveform_sink_reset);
GST_DEBUG_CATEGORY_INIT (waveformsink_debug, "waveformsink", 0,
"Waveform sink");
}
static void
gst_waveform_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstWaveFormSink *wfsink = GST_WAVEFORM_SINK (object);
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_waveform_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstWaveFormSink *wfsink = GST_WAVEFORM_SINK (object);
switch (prop_id) {
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_waveform_sink_init (GstWaveFormSink * wfsink,
GstWaveFormSinkClass * g_class)
{
/* initialize members */
wfsink->hwaveout = NULL;
wfsink->cached_caps = NULL;
wfsink->wave_buffers = NULL;
wfsink->write_buffer = 0;
wfsink->buffer_count = BUFFER_COUNT;
wfsink->buffer_size = BUFFER_SIZE;
wfsink->free_buffers_count = wfsink->buffer_count;
wfsink->bytes_in_queue = 0;
InitializeCriticalSection (&wfsink->critic_wave);
}
static void
gst_waveform_sink_finalise (GObject * object)
{
GstWaveFormSink *wfsink = GST_WAVEFORM_SINK (object);
if (wfsink->cached_caps) {
gst_caps_unref (wfsink->cached_caps);
wfsink->cached_caps = NULL;
}
DeleteCriticalSection (&wfsink->critic_wave);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
static GstCaps *
gst_waveform_sink_getcaps (GstBaseSink * bsink)
{
GstWaveFormSink *wfsink = GST_WAVEFORM_SINK (bsink);
MMRESULT mmresult;
WAVEOUTCAPS wocaps;
GstCaps *caps, *caps_temp;
/* return the cached caps if already defined */
if (wfsink->cached_caps) {
return gst_caps_ref (wfsink->cached_caps);
}
/* get the default device caps */
mmresult = waveOutGetDevCaps (WAVE_MAPPER, &wocaps, sizeof (wocaps));
if (mmresult != MMSYSERR_NOERROR) {
waveOutGetErrorText (mmresult, wfsink->error_string, ERROR_LENGTH - 1);
GST_ELEMENT_ERROR (wfsink, RESOURCE, SETTINGS,
("gst_waveform_sink_getcaps: waveOutGetDevCaps failed error=>%s",
wfsink->error_string), (NULL));
return NULL;
}
caps = gst_caps_new_empty ();
/* create a caps for all wave formats supported by the device
starting by the best quality format */
if (wocaps.dwFormats & WAVE_FORMAT_96S16) {
caps_temp = gst_waveform_sink_create_caps (96000, 2, 16);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (wocaps.dwFormats & WAVE_FORMAT_96S08) {
caps_temp = gst_waveform_sink_create_caps (96000, 2, 8);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (wocaps.dwFormats & WAVE_FORMAT_96M16) {
caps_temp = gst_waveform_sink_create_caps (96000, 1, 16);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (wocaps.dwFormats & WAVE_FORMAT_96M08) {
caps_temp = gst_waveform_sink_create_caps (96000, 1, 8);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (wocaps.dwFormats & WAVE_FORMAT_4S16) {
caps_temp = gst_waveform_sink_create_caps (44100, 2, 16);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (wocaps.dwFormats & WAVE_FORMAT_4S08) {
caps_temp = gst_waveform_sink_create_caps (44100, 2, 8);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (wocaps.dwFormats & WAVE_FORMAT_4M16) {
caps_temp = gst_waveform_sink_create_caps (44100, 1, 16);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (wocaps.dwFormats & WAVE_FORMAT_4M08) {
caps_temp = gst_waveform_sink_create_caps (44100, 1, 8);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (wocaps.dwFormats & WAVE_FORMAT_2S16) {
caps_temp = gst_waveform_sink_create_caps (22050, 2, 16);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (wocaps.dwFormats & WAVE_FORMAT_2S08) {
caps_temp = gst_waveform_sink_create_caps (22050, 2, 8);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (wocaps.dwFormats & WAVE_FORMAT_2M16) {
caps_temp = gst_waveform_sink_create_caps (22050, 1, 16);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (wocaps.dwFormats & WAVE_FORMAT_2M08) {
caps_temp = gst_waveform_sink_create_caps (22050, 1, 8);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (wocaps.dwFormats & WAVE_FORMAT_1S16) {
caps_temp = gst_waveform_sink_create_caps (11025, 2, 16);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (wocaps.dwFormats & WAVE_FORMAT_1S08) {
caps_temp = gst_waveform_sink_create_caps (11025, 2, 8);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (wocaps.dwFormats & WAVE_FORMAT_1M16) {
caps_temp = gst_waveform_sink_create_caps (11025, 1, 16);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (wocaps.dwFormats & WAVE_FORMAT_1M08) {
caps_temp = gst_waveform_sink_create_caps (11025, 1, 8);
if (caps_temp) {
gst_caps_append (caps, caps_temp);
}
}
if (gst_caps_is_empty (caps)) {
gst_caps_unref (caps);
caps = NULL;
} else {
wfsink->cached_caps = gst_caps_ref (caps);
}
GST_CAT_LOG_OBJECT (waveformsink_debug, wfsink, "Returning caps %s",
gst_caps_to_string (caps));
return caps;
}
static gboolean
gst_waveform_sink_open (GstAudioSink * asink)
{
GstWaveFormSink *wfsink = GST_WAVEFORM_SINK (asink);
/* nothing to do here as the device needs to be opened with the format we will use */
return TRUE;
}
static gboolean
gst_waveform_sink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec)
{
GstWaveFormSink *wfsink = GST_WAVEFORM_SINK (asink);
WAVEFORMATEX wfx;
MMRESULT mmresult;
guint index;
/* setup waveformex struture with the input ringbuffer specs */
memset (&wfx, 0, sizeof (wfx));
wfx.cbSize = 0;
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nChannels = spec->channels;
wfx.nSamplesPerSec = spec->rate;
wfx.wBitsPerSample = (spec->bytes_per_sample * 8) / wfx.nChannels;
wfx.nBlockAlign = spec->bytes_per_sample;
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
/* save bytes per sample to use it in delay */
wfsink->bytes_per_sample = spec->bytes_per_sample;
/* open the default audio device with the given caps */
mmresult = waveOutOpen (&wfsink->hwaveout, WAVE_MAPPER,
&wfx, (DWORD) waveOutProc, (DWORD) wfsink, CALLBACK_FUNCTION);
if (mmresult != MMSYSERR_NOERROR) {
waveOutGetErrorText (mmresult, wfsink->error_string, ERROR_LENGTH - 1);
GST_ELEMENT_ERROR (wfsink, RESOURCE, OPEN_WRITE,
("gst_waveform_sink_prepare: waveOutOpen failed error=>%s",
wfsink->error_string), (NULL));
return FALSE;
}
/* evaluate the buffer size and the number of buffers needed */
wfsink->free_buffers_count = wfsink->buffer_count;
/* allocate wave buffers */
wfsink->wave_buffers = (WAVEHDR *) g_new0 (WAVEHDR, wfsink->buffer_count);
if (!wfsink->wave_buffers) {
GST_ELEMENT_ERROR (wfsink, RESOURCE, OPEN_WRITE,
("gst_waveform_sink_prepare: Failed to allocate wave buffer headers (buffer count=%d)",
wfsink->buffer_count), (NULL));
return FALSE;
}
memset (wfsink->wave_buffers, 0, sizeof (WAVEHDR) * wfsink->buffer_count);
/* setup headers */
for (index = 0; index < wfsink->buffer_count; index++) {
wfsink->wave_buffers[index].dwBufferLength = wfsink->buffer_size;
wfsink->wave_buffers[index].lpData = g_new0 (gchar, wfsink->buffer_size);
}
return TRUE;
}
static gboolean
gst_waveform_sink_unprepare (GstAudioSink * asink)
{
GstWaveFormSink *wfsink = GST_WAVEFORM_SINK (asink);
/* free wave buffers */
if (wfsink->wave_buffers) {
guint index;
for (index = 0; index < wfsink->buffer_count; index++) {
if (wfsink->wave_buffers[index].dwFlags & WHDR_PREPARED) {
MMRESULT mmresult =
waveOutUnprepareHeader (wfsink->hwaveout,
&wfsink->wave_buffers[index], sizeof (WAVEHDR));
if (mmresult != MMSYSERR_NOERROR) {
waveOutGetErrorText (mmresult, wfsink->error_string,
ERROR_LENGTH - 1);
GST_CAT_WARNING_OBJECT (waveformsink_debug, wfsink,
"gst_waveform_sink_unprepare: Error unpreparing buffer => %s",
wfsink->error_string);
}
}
g_free (wfsink->wave_buffers[index].lpData);
}
g_free (wfsink->wave_buffers);
wfsink->wave_buffers = NULL;
}
/* close waveform-audio output device */
if (wfsink->hwaveout) {
waveOutClose (wfsink->hwaveout);
wfsink->hwaveout = NULL;
}
return TRUE;
}
static gboolean
gst_waveform_sink_close (GstAudioSink * asink)
{
GstWaveFormSink *wfsink = GST_WAVEFORM_SINK (asink);
return TRUE;
}
static guint
gst_waveform_sink_write (GstAudioSink * asink, gpointer data, guint length)
{
GstWaveFormSink *wfsink = GST_WAVEFORM_SINK (asink);
WAVEHDR *waveheader;
MMRESULT mmresult;
guint bytes_to_write = length;
guint remaining_length = length;
wfsink->bytes_in_queue += length;
while (remaining_length > 0) {
if (wfsink->free_buffers_count == 0) {
/* no free buffer available, wait for one */
Sleep (10);
continue;
}
/* get the current write buffer header */
waveheader = &wfsink->wave_buffers[wfsink->write_buffer];
/* unprepare the header if needed */
if (waveheader->dwFlags & WHDR_PREPARED) {
mmresult =
waveOutUnprepareHeader (wfsink->hwaveout, waveheader,
sizeof (WAVEHDR));
if (mmresult != MMSYSERR_NOERROR) {
waveOutGetErrorText (mmresult, wfsink->error_string, ERROR_LENGTH - 1);
GST_CAT_WARNING_OBJECT (waveformsink_debug, wfsink,
"Error unpreparing buffer => %s", wfsink->error_string);
}
}
if (wfsink->buffer_size - waveheader->dwUser >= remaining_length)
bytes_to_write = remaining_length;
else
bytes_to_write = wfsink->buffer_size - waveheader->dwUser;
memcpy (waveheader->lpData + waveheader->dwUser, data, bytes_to_write);
waveheader->dwUser += bytes_to_write;
remaining_length -= bytes_to_write;
data = (byte *) data + bytes_to_write;
if (waveheader->dwUser == wfsink->buffer_size) {
/* we have filled a buffer, let's prepare it and next write it to the device */
mmresult =
waveOutPrepareHeader (wfsink->hwaveout, waveheader, sizeof (WAVEHDR));
if (mmresult != MMSYSERR_NOERROR) {
waveOutGetErrorText (mmresult, wfsink->error_string, ERROR_LENGTH - 1);
GST_CAT_WARNING_OBJECT (waveformsink_debug, wfsink,
"gst_waveform_sink_write: Error preparing header => %s",
wfsink->error_string);
}
mmresult = waveOutWrite (wfsink->hwaveout, waveheader, sizeof (WAVEHDR));
if (mmresult != MMSYSERR_NOERROR) {
waveOutGetErrorText (mmresult, wfsink->error_string, ERROR_LENGTH - 1);
GST_CAT_WARNING_OBJECT (waveformsink_debug, wfsink,
"gst_waveform_sink_write: Error writting buffer to the device => %s",
wfsink->error_string);
}
EnterCriticalSection (&wfsink->critic_wave);
wfsink->free_buffers_count--;
LeaveCriticalSection (&wfsink->critic_wave);
wfsink->write_buffer++;
wfsink->write_buffer %= wfsink->buffer_count;
waveheader->dwUser = 0;
wfsink->bytes_in_queue = 0;
GST_CAT_LOG_OBJECT (waveformsink_debug, wfsink,
"gst_waveform_sink_write: Writting a buffer to the device (free buffers remaining=%d, write buffer=%d)",
wfsink->free_buffers_count, wfsink->write_buffer);
}
}
return length;
}
static guint
gst_waveform_sink_delay (GstAudioSink * asink)
{
/* return the number of samples in queue (device+internal queue) */
GstWaveFormSink *wfsink = GST_WAVEFORM_SINK (asink);
guint bytes_in_device =
(wfsink->buffer_count - wfsink->free_buffers_count) * wfsink->buffer_size;
guint delay =
(bytes_in_device + wfsink->bytes_in_queue) / wfsink->bytes_per_sample;
return delay;
}
static void
gst_waveform_sink_reset (GstAudioSink * asink)
{
GstWaveFormSink *wfsink = GST_WAVEFORM_SINK (asink);
MMRESULT mmresult = waveOutReset (wfsink->hwaveout);
if (mmresult != MMSYSERR_NOERROR) {
waveOutGetErrorText (mmresult, wfsink->error_string, ERROR_LENGTH - 1);
GST_CAT_WARNING_OBJECT (waveformsink_debug, wfsink,
"gst_waveform_sink_reset: Error reseting waveform-audio device => %s",
wfsink->error_string);
}
}
GstCaps *
gst_waveform_sink_create_caps (gint rate, gint channels, gint bits_per_sample)
{
GstCaps *caps = NULL;
caps = gst_caps_new_simple ("audio/x-raw-int",
"width", G_TYPE_INT, bits_per_sample,
"depth", G_TYPE_INT, bits_per_sample,
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, TRUE,
"channels", G_TYPE_INT, channels, "rate", G_TYPE_INT, rate, NULL);
return caps;
}
void CALLBACK
waveOutProc (HWAVEOUT hwo,
UINT uMsg, unsigned long dwInstance, DWORD dwParam1, DWORD dwParam2)
{
GstWaveFormSink *wfsink = (GstWaveFormSink *) dwInstance;
if (uMsg == WOM_DONE) {
EnterCriticalSection (&wfsink->critic_wave);
wfsink->free_buffers_count++;
LeaveCriticalSection (&wfsink->critic_wave);
}
}
|