* even if the old device was unplugged. We need to handle this somehow.
* For example, perhaps we should automatically switch to the new device if
* the default device is changed and a device isn't explicitly selected. */
- if (!gst_wasapi_util_get_device_client (GST_ELEMENT (self), eRender,
- self->role, self->device_strid, &device, &client)) {
+ if (!gst_wasapi_util_get_device (GST_ELEMENT (self), eRender,
+ self->role, self->device_strid, &device)
+ || !gst_wasapi_util_get_audio_client (GST_ELEMENT (self),
+ device, &client)) {
if (!self->device_strid)
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_WRITE, (NULL),
("Failed to get default device"));
* even if the old device was unplugged. We need to handle this somehow.
* For example, perhaps we should automatically switch to the new device if
* the default device is changed and a device isn't explicitly selected. */
- if (!gst_wasapi_util_get_device_client (GST_ELEMENT (self),
+ if (!gst_wasapi_util_get_device (GST_ELEMENT (self),
self->loopback ? eRender : eCapture, self->role, self->device_strid,
- &device, &client)) {
+ &device)
+ || !gst_wasapi_util_get_audio_client (GST_ELEMENT (self),
+ device, &client)) {
if (!self->device_strid)
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ, (NULL),
("Failed to get default device"));
* we will keep pusing silence data to into wasapi client so that make audio
* client report audio data in any case
*/
- if (!gst_wasapi_util_get_device_client (GST_ELEMENT (self),
- eRender, self->role, self->device_strid,
- &loopback_device, &self->loopback_client)) {
+ if (!gst_wasapi_util_get_device (GST_ELEMENT (self),
+ eRender, self->role, self->device_strid, &loopback_device)
+ || !gst_wasapi_util_get_audio_client (GST_ELEMENT (self),
+ loopback_device, &self->loopback_client)) {
if (!self->device_strid)
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ, (NULL),
("Failed to get default device for loopback"));
}
gboolean
-gst_wasapi_util_get_device_client (GstElement * self,
+gst_wasapi_util_get_device (GstElement * self,
gint data_flow, gint role, const wchar_t * device_strid,
- IMMDevice ** ret_device, IAudioClient ** ret_client)
+ IMMDevice ** ret_device)
{
gboolean res = FALSE;
HRESULT hr;
IMMDeviceEnumerator *enumerator = NULL;
IMMDevice *device = NULL;
- IAudioClient *client = NULL;
if (!(enumerator = gst_wasapi_util_get_device_enumerator (GST_OBJECT (self))))
goto beach;
}
}
+ IUnknown_AddRef (device);
+ *ret_device = device;
+
+ res = TRUE;
+
+beach:
+ if (device != NULL)
+ IUnknown_Release (device);
+
+ if (enumerator != NULL)
+ IUnknown_Release (enumerator);
+
+ return res;
+}
+
+gboolean
+gst_wasapi_util_get_audio_client (GstElement * self,
+ IMMDevice * device, IAudioClient ** ret_client)
+{
+ IAudioClient *client = NULL;
+ gboolean res = FALSE;
+ HRESULT hr;
+
if (gst_wasapi_util_have_audioclient3 ())
hr = IMMDevice_Activate (device, &IID_IAudioClient3, CLSCTX_ALL, NULL,
(void **) &client);
HR_FAILED_GOTO (hr, IMMDevice::Activate (IID_IAudioClient), beach);
IUnknown_AddRef (client);
- IUnknown_AddRef (device);
*ret_client = client;
- *ret_device = device;
res = TRUE;
if (client != NULL)
IUnknown_Release (client);
- if (device != NULL)
- IUnknown_Release (device);
-
- if (enumerator != NULL)
- IUnknown_Release (enumerator);
-
return res;
}
gboolean gst_wasapi_util_get_devices (GstObject * element, gboolean active,
GList ** devices);
-gboolean gst_wasapi_util_get_device_client (GstElement * element,
+gboolean gst_wasapi_util_get_device (GstElement * self,
gint data_flow, gint role, const wchar_t * device_strid,
- IMMDevice ** ret_device, IAudioClient ** ret_client);
+ IMMDevice ** ret_device);
+
+gboolean gst_wasapi_util_get_audio_client (GstElement * self,
+ IMMDevice * device, IAudioClient ** ret_client);
gboolean gst_wasapi_util_get_device_format (GstElement * element,
gint device_mode, IMMDevice * device, IAudioClient * client,