mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
wasapi: Initial port to 1.0
This should really use GstAudioSink and GstAudioSrc.
This commit is contained in:
parent
d5d37fafa7
commit
e7a69bb8de
9 changed files with 83 additions and 93 deletions
|
@ -328,7 +328,7 @@ GST_PLUGINS_NONPORTED=" aiff \
|
||||||
gsettings ladspa \
|
gsettings ladspa \
|
||||||
musepack musicbrainz nas neon ofa openal rsvg sdl sndfile timidity \
|
musepack musicbrainz nas neon ofa openal rsvg sdl sndfile timidity \
|
||||||
directdraw direct3d9 acm wininet \
|
directdraw direct3d9 acm wininet \
|
||||||
xvid lv2 teletextdec sndio wasapi"
|
xvid lv2 teletextdec sndio"
|
||||||
AC_SUBST(GST_PLUGINS_NONPORTED)
|
AC_SUBST(GST_PLUGINS_NONPORTED)
|
||||||
|
|
||||||
dnl these are all the gst plug-ins, compilable without additional libs
|
dnl these are all the gst plug-ins, compilable without additional libs
|
||||||
|
|
|
@ -7,7 +7,7 @@ libgstwasapi_la_SOURCES = gstwasapi.c \
|
||||||
|
|
||||||
libgstwasapi_la_CFLAGS = $(GST_BASE_CFLAGS) $(GST_CFLAGS) -DCOBJMACROS=1
|
libgstwasapi_la_CFLAGS = $(GST_BASE_CFLAGS) $(GST_CFLAGS) -DCOBJMACROS=1
|
||||||
libgstwasapi_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS) \
|
libgstwasapi_la_LIBADD = $(GST_LIBS) $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS) \
|
||||||
-lgstaudio-$(GST_MAJORMINOR) -lgstinterfaces-$(GST_MAJORMINOR) \
|
-lgstaudio-$(GST_API_VERSION) \
|
||||||
$(WASAPI_LIBS)
|
$(WASAPI_LIBS)
|
||||||
libgstwasapi_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
libgstwasapi_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||||
libgstwasapi_la_LIBTOOLFLAGS = --tag=disable-static
|
libgstwasapi_la_LIBTOOLFLAGS = --tag=disable-static
|
||||||
|
|
|
@ -42,4 +42,4 @@ GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
||||||
GST_VERSION_MINOR,
|
GST_VERSION_MINOR,
|
||||||
wasapi,
|
wasapi,
|
||||||
"Windows audio session API plugin",
|
"Windows audio session API plugin",
|
||||||
plugin_init, VERSION, "LGPL", "GStreamer", "http://gstreamer.net/")
|
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
* <refsect2>
|
* <refsect2>
|
||||||
* <title>Example pipelines</title>
|
* <title>Example pipelines</title>
|
||||||
* |[
|
* |[
|
||||||
* gst-launch-0.10 -v audiotestsrc samplesperbuffer=160 ! wasapisink
|
* gst-launch-1.0 -v audiotestsrc samplesperbuffer=160 ! wasapisink
|
||||||
* ]| Generate 20 ms buffers and render to the default audio device.
|
* ]| Generate 20 ms buffers and render to the default audio device.
|
||||||
* </refsect2>
|
* </refsect2>
|
||||||
*/
|
*/
|
||||||
|
@ -42,13 +42,10 @@ GST_DEBUG_CATEGORY_STATIC (gst_wasapi_sink_debug);
|
||||||
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||||
GST_PAD_SINK,
|
GST_PAD_SINK,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"width = (int) 16, "
|
"format = (string) S16LE, "
|
||||||
"depth = (int) 16, "
|
"layout = (string) interleaved, "
|
||||||
"rate = (int) 8000, "
|
"rate = (int) 8000, " "channels = (int) 1"));
|
||||||
"channels = (int) 1, "
|
|
||||||
"signed = (boolean) TRUE, "
|
|
||||||
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER)));
|
|
||||||
|
|
||||||
static void gst_wasapi_sink_dispose (GObject * object);
|
static void gst_wasapi_sink_dispose (GObject * object);
|
||||||
static void gst_wasapi_sink_finalize (GObject * object);
|
static void gst_wasapi_sink_finalize (GObject * object);
|
||||||
|
@ -60,31 +57,25 @@ static gboolean gst_wasapi_sink_stop (GstBaseSink * sink);
|
||||||
static GstFlowReturn gst_wasapi_sink_render (GstBaseSink * sink,
|
static GstFlowReturn gst_wasapi_sink_render (GstBaseSink * sink,
|
||||||
GstBuffer * buffer);
|
GstBuffer * buffer);
|
||||||
|
|
||||||
GST_BOILERPLATE (GstWasapiSink, gst_wasapi_sink, GstBaseSink,
|
G_DEFINE_TYPE (GstWasapiSink, gst_wasapi_sink, GST_TYPE_BASE_SINK);
|
||||||
GST_TYPE_BASE_SINK);
|
|
||||||
|
|
||||||
static void
|
|
||||||
gst_wasapi_sink_base_init (gpointer gclass)
|
|
||||||
{
|
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
|
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&sink_template));
|
|
||||||
gst_element_class_set_static_metadata (element_class, "WasapiSrc",
|
|
||||||
"Sink/Audio",
|
|
||||||
"Stream audio to an audio capture device through WASAPI",
|
|
||||||
"Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_wasapi_sink_class_init (GstWasapiSinkClass * klass)
|
gst_wasapi_sink_class_init (GstWasapiSinkClass * klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
||||||
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
||||||
GstBaseSinkClass *gstbasesink_class = GST_BASE_SINK_CLASS (klass);
|
GstBaseSinkClass *gstbasesink_class = GST_BASE_SINK_CLASS (klass);
|
||||||
|
|
||||||
gobject_class->dispose = gst_wasapi_sink_dispose;
|
gobject_class->dispose = gst_wasapi_sink_dispose;
|
||||||
gobject_class->finalize = gst_wasapi_sink_finalize;
|
gobject_class->finalize = gst_wasapi_sink_finalize;
|
||||||
|
|
||||||
|
gst_element_class_add_pad_template (gstelement_class,
|
||||||
|
gst_static_pad_template_get (&sink_template));
|
||||||
|
gst_element_class_set_static_metadata (gstelement_class, "WasapiSrc",
|
||||||
|
"Sink/Audio",
|
||||||
|
"Stream audio to an audio capture device through WASAPI",
|
||||||
|
"Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>");
|
||||||
|
|
||||||
gstbasesink_class->get_times = gst_wasapi_sink_get_times;
|
gstbasesink_class->get_times = gst_wasapi_sink_get_times;
|
||||||
gstbasesink_class->start = gst_wasapi_sink_start;
|
gstbasesink_class->start = gst_wasapi_sink_start;
|
||||||
gstbasesink_class->stop = gst_wasapi_sink_stop;
|
gstbasesink_class->stop = gst_wasapi_sink_stop;
|
||||||
|
@ -95,7 +86,7 @@ gst_wasapi_sink_class_init (GstWasapiSinkClass * klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_wasapi_sink_init (GstWasapiSink * self, GstWasapiSinkClass * gclass)
|
gst_wasapi_sink_init (GstWasapiSink * self)
|
||||||
{
|
{
|
||||||
self->rate = 8000;
|
self->rate = 8000;
|
||||||
self->buffer_time = 20 * GST_MSECOND;
|
self->buffer_time = 20 * GST_MSECOND;
|
||||||
|
@ -117,17 +108,15 @@ gst_wasapi_sink_dispose (GObject * object)
|
||||||
self->event_handle = NULL;
|
self->event_handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (gst_wasapi_sink_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_wasapi_sink_finalize (GObject * object)
|
gst_wasapi_sink_finalize (GObject * object)
|
||||||
{
|
{
|
||||||
GstWasapiSink *self = GST_WASAPI_SINK (object);
|
|
||||||
|
|
||||||
CoUninitialize ();
|
CoUninitialize ();
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (gst_wasapi_sink_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -171,7 +160,7 @@ gst_wasapi_sink_start (GstBaseSink * sink)
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = IAudioClient_GetService (client, &IID_IAudioRenderClient,
|
hr = IAudioClient_GetService (client, &IID_IAudioRenderClient,
|
||||||
&render_client);
|
(void **) &render_client);
|
||||||
if (hr != S_OK) {
|
if (hr != S_OK) {
|
||||||
GST_ERROR_OBJECT (self, "IAudioClient::GetService "
|
GST_ERROR_OBJECT (self, "IAudioClient::GetService "
|
||||||
"(IID_IAudioRenderClient) failed");
|
"(IID_IAudioRenderClient) failed");
|
||||||
|
@ -229,11 +218,23 @@ gst_wasapi_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
||||||
GstWasapiSink *self = GST_WASAPI_SINK (sink);
|
GstWasapiSink *self = GST_WASAPI_SINK (sink);
|
||||||
GstFlowReturn ret = GST_FLOW_OK;
|
GstFlowReturn ret = GST_FLOW_OK;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
gint16 *src = (gint16 *) GST_BUFFER_DATA (buffer);
|
GstMapInfo minfo;
|
||||||
|
const gint16 *src;
|
||||||
gint16 *dst = NULL;
|
gint16 *dst = NULL;
|
||||||
guint nsamples = GST_BUFFER_SIZE (buffer) / sizeof (gint16);
|
guint nsamples;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
|
memset (&minfo, 0, sizeof (minfo));
|
||||||
|
|
||||||
|
if (!gst_buffer_map (buffer, &minfo, GST_MAP_READ)) {
|
||||||
|
GST_ELEMENT_ERROR (self, RESOURCE, WRITE, (NULL),
|
||||||
|
("Failed to map input buffer"));
|
||||||
|
ret = GST_FLOW_ERROR;
|
||||||
|
goto beach;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsamples = minfo.size / sizeof (gint16);
|
||||||
|
|
||||||
WaitForSingleObject (self->event_handle, INFINITE);
|
WaitForSingleObject (self->event_handle, INFINITE);
|
||||||
|
|
||||||
hr = IAudioRenderClient_GetBuffer (self->render_client, nsamples,
|
hr = IAudioRenderClient_GetBuffer (self->render_client, nsamples,
|
||||||
|
@ -246,6 +247,7 @@ gst_wasapi_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
||||||
goto beach;
|
goto beach;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
src = (const gint16 *) minfo.data;
|
||||||
for (i = 0; i < nsamples; i++) {
|
for (i = 0; i < nsamples; i++) {
|
||||||
dst[0] = *src;
|
dst[0] = *src;
|
||||||
dst[1] = *src;
|
dst[1] = *src;
|
||||||
|
@ -263,5 +265,8 @@ gst_wasapi_sink_render (GstBaseSink * sink, GstBuffer * buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
beach:
|
beach:
|
||||||
|
if (minfo.data)
|
||||||
|
gst_buffer_unmap (buffer, &minfo);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
|
|
||||||
#include "gstwasapiutil.h"
|
#include "gstwasapiutil.h"
|
||||||
|
|
||||||
#include <gst/base/gstbasesink.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_TYPE_WASAPI_SINK \
|
#define GST_TYPE_WASAPI_SINK \
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
* <refsect2>
|
* <refsect2>
|
||||||
* <title>Example pipelines</title>
|
* <title>Example pipelines</title>
|
||||||
* |[
|
* |[
|
||||||
* gst-launch-0.10 -v wasapisrc ! fakesink
|
* gst-launch-1.0 -v wasapisrc ! fakesink
|
||||||
* ]| Capture from the default audio device and render to fakesink.
|
* ]| Capture from the default audio device and render to fakesink.
|
||||||
* </refsect2>
|
* </refsect2>
|
||||||
*/
|
*/
|
||||||
|
@ -43,13 +43,10 @@ GST_DEBUG_CATEGORY_STATIC (gst_wasapi_src_debug);
|
||||||
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
GST_PAD_ALWAYS,
|
GST_PAD_ALWAYS,
|
||||||
GST_STATIC_CAPS ("audio/x-raw-int, "
|
GST_STATIC_CAPS ("audio/x-raw, "
|
||||||
"width = (int) 16, "
|
"format = (string) S16LE, "
|
||||||
"depth = (int) 16, "
|
"layout = (string) interleaved, "
|
||||||
"rate = (int) 8000, "
|
"rate = (int) 8000, " "channels = (int) 1"));
|
||||||
"channels = (int) 1, "
|
|
||||||
"signed = (boolean) TRUE, "
|
|
||||||
"endianness = (int) " G_STRINGIFY (G_BYTE_ORDER)));
|
|
||||||
|
|
||||||
static void gst_wasapi_src_dispose (GObject * object);
|
static void gst_wasapi_src_dispose (GObject * object);
|
||||||
static void gst_wasapi_src_finalize (GObject * object);
|
static void gst_wasapi_src_finalize (GObject * object);
|
||||||
|
@ -65,20 +62,7 @@ static GstFlowReturn gst_wasapi_src_create (GstPushSrc * src, GstBuffer ** buf);
|
||||||
static GstClockTime gst_wasapi_src_get_time (GstClock * clock,
|
static GstClockTime gst_wasapi_src_get_time (GstClock * clock,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
GST_BOILERPLATE (GstWasapiSrc, gst_wasapi_src, GstPushSrc, GST_TYPE_PUSH_SRC);
|
G_DEFINE_TYPE (GstWasapiSrc, gst_wasapi_src, GST_TYPE_PUSH_SRC);
|
||||||
|
|
||||||
static void
|
|
||||||
gst_wasapi_src_base_init (gpointer gclass)
|
|
||||||
{
|
|
||||||
GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);
|
|
||||||
|
|
||||||
gst_element_class_add_pad_template (element_class,
|
|
||||||
gst_static_pad_template_get (&src_template));
|
|
||||||
gst_element_class_set_static_metadata (element_class, "WasapiSrc",
|
|
||||||
"Source/Audio",
|
|
||||||
"Stream audio from an audio capture device through WASAPI",
|
|
||||||
"Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_wasapi_src_class_init (GstWasapiSrcClass * klass)
|
gst_wasapi_src_class_init (GstWasapiSrcClass * klass)
|
||||||
|
@ -93,6 +77,13 @@ gst_wasapi_src_class_init (GstWasapiSrcClass * klass)
|
||||||
|
|
||||||
gstelement_class->provide_clock = gst_wasapi_src_provide_clock;
|
gstelement_class->provide_clock = gst_wasapi_src_provide_clock;
|
||||||
|
|
||||||
|
gst_element_class_add_pad_template (gstelement_class,
|
||||||
|
gst_static_pad_template_get (&src_template));
|
||||||
|
gst_element_class_set_static_metadata (gstelement_class, "WasapiSrc",
|
||||||
|
"Source/Audio",
|
||||||
|
"Stream audio from an audio capture device through WASAPI",
|
||||||
|
"Ole André Vadla Ravnås <ole.andre.ravnas@tandberg.com>");
|
||||||
|
|
||||||
gstbasesrc_class->start = gst_wasapi_src_start;
|
gstbasesrc_class->start = gst_wasapi_src_start;
|
||||||
gstbasesrc_class->stop = gst_wasapi_src_stop;
|
gstbasesrc_class->stop = gst_wasapi_src_stop;
|
||||||
gstbasesrc_class->query = gst_wasapi_src_query;
|
gstbasesrc_class->query = gst_wasapi_src_query;
|
||||||
|
@ -104,7 +95,7 @@ gst_wasapi_src_class_init (GstWasapiSrcClass * klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_wasapi_src_init (GstWasapiSrc * self, GstWasapiSrcClass * gclass)
|
gst_wasapi_src_init (GstWasapiSrc * self)
|
||||||
{
|
{
|
||||||
GstBaseSrc *basesrc = GST_BASE_SRC (self);
|
GstBaseSrc *basesrc = GST_BASE_SRC (self);
|
||||||
|
|
||||||
|
@ -120,14 +111,9 @@ gst_wasapi_src_init (GstWasapiSrc * self, GstWasapiSrcClass * gclass)
|
||||||
self->start_time = GST_CLOCK_TIME_NONE;
|
self->start_time = GST_CLOCK_TIME_NONE;
|
||||||
self->next_time = GST_CLOCK_TIME_NONE;
|
self->next_time = GST_CLOCK_TIME_NONE;
|
||||||
|
|
||||||
#if GST_CHECK_VERSION(0, 10, 31) || (GST_CHECK_VERSION(0, 10, 30) && GST_VERSION_NANO > 0)
|
self->clock = gst_audio_clock_new ("GstWasapiSrcClock",
|
||||||
self->clock = gst_audio_clock_new_full ("GstWasapiSrcClock",
|
|
||||||
gst_wasapi_src_get_time, gst_object_ref (self),
|
gst_wasapi_src_get_time, gst_object_ref (self),
|
||||||
(GDestroyNotify) gst_object_unref);
|
(GDestroyNotify) gst_object_unref);
|
||||||
#else
|
|
||||||
self->clock = gst_audio_clock_new ("GstWasapiSrcClock",
|
|
||||||
gst_wasapi_src_get_time, self);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
CoInitialize (NULL);
|
CoInitialize (NULL);
|
||||||
}
|
}
|
||||||
|
@ -142,17 +128,15 @@ gst_wasapi_src_dispose (GObject * object)
|
||||||
self->clock = NULL;
|
self->clock = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (gst_wasapi_src_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_wasapi_src_finalize (GObject * object)
|
gst_wasapi_src_finalize (GObject * object)
|
||||||
{
|
{
|
||||||
GstWasapiSrc *self = GST_WASAPI_SRC (object);
|
|
||||||
|
|
||||||
CoUninitialize ();
|
CoUninitialize ();
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
G_OBJECT_CLASS (gst_wasapi_src_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstClock *
|
static GstClock *
|
||||||
|
@ -196,7 +180,7 @@ gst_wasapi_src_start (GstBaseSrc * src)
|
||||||
&self->latency))
|
&self->latency))
|
||||||
goto beach;
|
goto beach;
|
||||||
|
|
||||||
hr = IAudioClient_GetService (client, &IID_IAudioClock, &client_clock);
|
hr = IAudioClient_GetService (client, &IID_IAudioClock, (void**) &client_clock);
|
||||||
if (hr != S_OK) {
|
if (hr != S_OK) {
|
||||||
GST_ERROR_OBJECT (self, "IAudioClient::GetService (IID_IAudioClock) "
|
GST_ERROR_OBJECT (self, "IAudioClient::GetService (IID_IAudioClock) "
|
||||||
"failed");
|
"failed");
|
||||||
|
@ -210,7 +194,7 @@ gst_wasapi_src_start (GstBaseSrc * src)
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = IAudioClient_GetService (client, &IID_IAudioCaptureClient,
|
hr = IAudioClient_GetService (client, &IID_IAudioCaptureClient,
|
||||||
&capture_client);
|
(void**) &capture_client);
|
||||||
if (hr != S_OK) {
|
if (hr != S_OK) {
|
||||||
GST_ERROR_OBJECT (self, "IAudioClient::GetService "
|
GST_ERROR_OBJECT (self, "IAudioClient::GetService "
|
||||||
"(IID_IAudioCaptureClient) failed");
|
"(IID_IAudioCaptureClient) failed");
|
||||||
|
@ -298,7 +282,8 @@ gst_wasapi_src_query (GstBaseSrc * src, GstQuery * query)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ret = GST_BASE_SRC_CLASS (parent_class)->query (src, query);
|
ret =
|
||||||
|
GST_BASE_SRC_CLASS (gst_wasapi_src_parent_class)->query (src, query);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,6 +302,9 @@ gst_wasapi_src_create (GstPushSrc * src, GstBuffer ** buf)
|
||||||
guint32 nsamples_read = 0, nsamples;
|
guint32 nsamples_read = 0, nsamples;
|
||||||
DWORD flags = 0;
|
DWORD flags = 0;
|
||||||
guint64 devpos;
|
guint64 devpos;
|
||||||
|
guint i;
|
||||||
|
GstMapInfo minfo;
|
||||||
|
gint16 *dst;
|
||||||
|
|
||||||
GST_OBJECT_LOCK (self);
|
GST_OBJECT_LOCK (self);
|
||||||
clock = GST_ELEMENT_CLOCK (self);
|
clock = GST_ELEMENT_CLOCK (self);
|
||||||
|
@ -347,7 +335,7 @@ gst_wasapi_src_create (GstPushSrc * src, GstBuffer ** buf)
|
||||||
|
|
||||||
if (flags != 0) {
|
if (flags != 0) {
|
||||||
GST_WARNING_OBJECT (self, "devpos %" G_GUINT64_FORMAT ": flags=0x%08x",
|
GST_WARNING_OBJECT (self, "devpos %" G_GUINT64_FORMAT ": flags=0x%08x",
|
||||||
devpos, flags);
|
devpos, (guint) flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Why do we get 1024 sometimes and not a multiple of
|
/* FIXME: Why do we get 1024 sometimes and not a multiple of
|
||||||
|
@ -384,26 +372,21 @@ gst_wasapi_src_create (GstPushSrc * src, GstBuffer ** buf)
|
||||||
timestamp = 0;
|
timestamp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = gst_pad_alloc_buffer_and_set_caps (GST_BASE_SRC_PAD (self),
|
*buf = gst_buffer_new_and_alloc (nsamples * sizeof (gint16));
|
||||||
devpos,
|
|
||||||
nsamples * sizeof (gint16), GST_PAD_CAPS (GST_BASE_SRC_PAD (self)), buf);
|
|
||||||
|
|
||||||
if (ret == GST_FLOW_OK) {
|
GST_BUFFER_OFFSET_END (*buf) = devpos + self->samples_per_buffer;
|
||||||
guint i;
|
GST_BUFFER_TIMESTAMP (*buf) = timestamp;
|
||||||
gint16 *dst;
|
GST_BUFFER_DURATION (*buf) = duration;
|
||||||
|
|
||||||
GST_BUFFER_OFFSET_END (*buf) = devpos + self->samples_per_buffer;
|
gst_buffer_map (*buf, &minfo, GST_MAP_WRITE);
|
||||||
GST_BUFFER_TIMESTAMP (*buf) = timestamp;
|
dst = (gint16 *) minfo.data;
|
||||||
GST_BUFFER_DURATION (*buf) = duration;
|
for (i = 0; i < nsamples; i++) {
|
||||||
|
*dst = *samples;
|
||||||
|
|
||||||
dst = (gint16 *) GST_BUFFER_DATA (*buf);
|
samples += 2;
|
||||||
for (i = 0; i < nsamples; i++) {
|
dst++;
|
||||||
*dst = *samples;
|
|
||||||
|
|
||||||
samples += 2;
|
|
||||||
dst++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
gst_buffer_unmap (*buf, &minfo);
|
||||||
|
|
||||||
hr = IAudioCaptureClient_ReleaseBuffer (self->capture_client, nsamples_read);
|
hr = IAudioCaptureClient_ReleaseBuffer (self->capture_client, nsamples_read);
|
||||||
if (hr != S_OK) {
|
if (hr != S_OK) {
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
|
|
||||||
#include "gstwasapiutil.h"
|
#include "gstwasapiutil.h"
|
||||||
|
|
||||||
#include <gst/base/gstpushsrc.h>
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define GST_TYPE_WASAPI_SRC \
|
#define GST_TYPE_WASAPI_SRC \
|
||||||
|
|
|
@ -28,18 +28,23 @@
|
||||||
const CLSID CLSID_MMDeviceEnumerator = { 0xbcde0395, 0xe52f, 0x467c,
|
const CLSID CLSID_MMDeviceEnumerator = { 0xbcde0395, 0xe52f, 0x467c,
|
||||||
{0x8e, 0x3d, 0xc4, 0x57, 0x92, 0x91, 0x69, 0x2e}
|
{0x8e, 0x3d, 0xc4, 0x57, 0x92, 0x91, 0x69, 0x2e}
|
||||||
};
|
};
|
||||||
|
|
||||||
const IID IID_IMMDeviceEnumerator = { 0xa95664d2, 0x9614, 0x4f35,
|
const IID IID_IMMDeviceEnumerator = { 0xa95664d2, 0x9614, 0x4f35,
|
||||||
{0xa7, 0x46, 0xde, 0x8d, 0xb6, 0x36, 0x17, 0xe6}
|
{0xa7, 0x46, 0xde, 0x8d, 0xb6, 0x36, 0x17, 0xe6}
|
||||||
};
|
};
|
||||||
|
|
||||||
const IID IID_IAudioClient = { 0x1cb9ad4c, 0xdbfa, 0x4c32,
|
const IID IID_IAudioClient = { 0x1cb9ad4c, 0xdbfa, 0x4c32,
|
||||||
{0xb1, 0x78, 0xc2, 0xf5, 0x68, 0xa7, 0x03, 0xb2}
|
{0xb1, 0x78, 0xc2, 0xf5, 0x68, 0xa7, 0x03, 0xb2}
|
||||||
};
|
};
|
||||||
|
|
||||||
const IID IID_IAudioClock = { 0xcd63314f, 0x3fba, 0x4a1b,
|
const IID IID_IAudioClock = { 0xcd63314f, 0x3fba, 0x4a1b,
|
||||||
{0x81, 0x2c, 0xef, 0x96, 0x35, 0x87, 0x28, 0xe7}
|
{0x81, 0x2c, 0xef, 0x96, 0x35, 0x87, 0x28, 0xe7}
|
||||||
};
|
};
|
||||||
|
|
||||||
const IID IID_IAudioCaptureClient = { 0xc8adbd64, 0xe71e, 0x48a0,
|
const IID IID_IAudioCaptureClient = { 0xc8adbd64, 0xe71e, 0x48a0,
|
||||||
{0xa4, 0xde, 0x18, 0x5c, 0x39, 0x5c, 0xd3, 0x17}
|
{0xa4, 0xde, 0x18, 0x5c, 0x39, 0x5c, 0xd3, 0x17}
|
||||||
};
|
};
|
||||||
|
|
||||||
const IID IID_IAudioRenderClient = { 0xf294acfc, 0x3146, 0x4483,
|
const IID IID_IAudioRenderClient = { 0xf294acfc, 0x3146, 0x4483,
|
||||||
{0xa7, 0xbf, 0xad, 0xdc, 0xa7, 0xc2, 0x60, 0xe2}
|
{0xa7, 0xbf, 0xad, 0xdc, 0xa7, 0xc2, 0x60, 0xe2}
|
||||||
};
|
};
|
||||||
|
@ -147,7 +152,7 @@ gst_wasapi_util_get_default_device_client (GstElement * element,
|
||||||
WAVEFORMATEXTENSIBLE format;
|
WAVEFORMATEXTENSIBLE format;
|
||||||
|
|
||||||
hr = CoCreateInstance (&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
|
hr = CoCreateInstance (&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
|
||||||
&IID_IMMDeviceEnumerator, &enumerator);
|
&IID_IMMDeviceEnumerator, (void **) &enumerator);
|
||||||
if (hr != S_OK) {
|
if (hr != S_OK) {
|
||||||
GST_ERROR_OBJECT (element, "CoCreateInstance (MMDeviceEnumerator) failed");
|
GST_ERROR_OBJECT (element, "CoCreateInstance (MMDeviceEnumerator) failed");
|
||||||
goto beach;
|
goto beach;
|
||||||
|
@ -162,7 +167,7 @@ gst_wasapi_util_get_default_device_client (GstElement * element,
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = IMMDevice_Activate (device, &IID_IAudioClient, CLSCTX_ALL, NULL,
|
hr = IMMDevice_Activate (device, &IID_IAudioClient, CLSCTX_ALL, NULL,
|
||||||
&client);
|
(void **) &client);
|
||||||
if (hr != S_OK) {
|
if (hr != S_OK) {
|
||||||
GST_ERROR_OBJECT (element, "IMMDevice::Activate (IID_IAudioClient) failed");
|
GST_ERROR_OBJECT (element, "IMMDevice::Activate (IID_IAudioClient) failed");
|
||||||
goto beach;
|
goto beach;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#define __GST_WASAPI_UTIL_H__
|
#define __GST_WASAPI_UTIL_H__
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
|
#include <gst/audio/audio.h>
|
||||||
|
|
||||||
#include <audioclient.h>
|
#include <audioclient.h>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue