static gboolean gst_wasapi_sink_start (GstBaseSink * sink) { GstWasapiSink *self = GST_WASAPI_SINK (sink); gboolean res = FALSE; IAudioClient *client = NULL; HRESULT hr; IAudioRenderClient *render_client = NULL; if (!gst_wasapi_util_get_default_device_client (GST_ELEMENT (self), FALSE, self->rate, self->buffer_time, self->period_time, AUDCLNT_STREAMFLAGS_EVENTCALLBACK, &client, &self->latency)) goto beach; hr = IAudioClient_SetEventHandle (client, self->event_handle); if (hr != S_OK) { GST_ERROR_OBJECT (self, "IAudioClient::SetEventHandle () failed"); goto beach; } hr = IAudioClient_GetService (client, &IID_IAudioRenderClient, &render_client); if (hr != S_OK) { GST_ERROR_OBJECT (self, "IAudioClient::GetService " "(IID_IAudioRenderClient) failed"); goto beach; } hr = IAudioClient_Start (client); if (hr != S_OK) { GST_ERROR_OBJECT (self, "IAudioClient::Start failed"); goto beach; } self->client = client; self->render_client = render_client; res = TRUE; beach: if (!res) { if (render_client != NULL) IUnknown_Release (render_client); if (client != NULL) IUnknown_Release (client); } return res; }
static gboolean gst_wasapi_sink_open (GstAudioSink * asink) { GstWasapiSink *self = GST_WASAPI_SINK (asink); gboolean res = FALSE; IAudioClient *client = NULL; if (!gst_wasapi_util_get_default_device_client (GST_ELEMENT (self), FALSE, &client)) { GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ, (NULL), ("Failed to get default device")); goto beach; } self->client = client; res = TRUE; beach: return res; }
static gboolean gst_wasapi_src_start (GstBaseSrc * src) { GstWasapiSrc *self = GST_WASAPI_SRC (src); gboolean res = FALSE; IAudioClient *client = NULL; IAudioClock *client_clock = NULL; guint64 client_clock_freq = 0; IAudioCaptureClient *capture_client = NULL; HRESULT hr; if (!gst_wasapi_util_get_default_device_client (GST_ELEMENT (self), TRUE, self->rate, self->buffer_time, self->period_time, 0, &client, &self->latency)) goto beach; hr = IAudioClient_GetService (client, &IID_IAudioClock, &client_clock); if (hr != S_OK) { GST_ERROR_OBJECT (self, "IAudioClient::GetService (IID_IAudioClock) " "failed"); goto beach; } hr = IAudioClock_GetFrequency (client_clock, &client_clock_freq); if (hr != S_OK) { GST_ERROR_OBJECT (self, "IAudioClock::GetFrequency () failed"); goto beach; } hr = IAudioClient_GetService (client, &IID_IAudioCaptureClient, &capture_client); if (hr != S_OK) { GST_ERROR_OBJECT (self, "IAudioClient::GetService " "(IID_IAudioCaptureClient) failed"); goto beach; } hr = IAudioClient_Start (client); if (hr != S_OK) { GST_ERROR_OBJECT (self, "IAudioClient::Start failed"); goto beach; } self->client = client; self->client_clock = client_clock; self->client_clock_freq = client_clock_freq; self->capture_client = capture_client; res = TRUE; beach: if (!res) { if (capture_client != NULL) IUnknown_Release (capture_client); if (client_clock != NULL) IUnknown_Release (client_clock); if (client != NULL) IUnknown_Release (client); } return res; }