wasapi: Rename struct element for device name

We will use ->device for storing a pointer to the IMMDevice structure
which is needed for fetching the caps supported by devices in
exclusive mode.

https://bugzilla.gnome.org/show_bug.cgi?id=793289
This commit is contained in:
Nirbheek Chauhan 2018-02-06 23:37:19 +05:30
parent 3f1e039007
commit 4b388814af
4 changed files with 24 additions and 20 deletions

View file

@ -182,7 +182,7 @@ gst_wasapi_sink_finalize (GObject * object)
}
g_clear_pointer (&self->positions, g_free);
g_clear_pointer (&self->device, g_free);
g_clear_pointer (&self->device_strid, g_free);
self->mute = FALSE;
G_OBJECT_CLASS (gst_wasapi_sink_parent_class)->finalize (object);
@ -204,8 +204,8 @@ gst_wasapi_sink_set_property (GObject * object, guint prop_id,
case PROP_DEVICE:
{
const gchar *device = g_value_get_string (value);
g_free (self->device);
self->device =
g_free (self->device_strid);
self->device_strid =
device ? g_utf8_to_utf16 (device, -1, NULL, NULL, NULL) : NULL;
break;
}
@ -229,8 +229,8 @@ gst_wasapi_sink_get_property (GObject * object, guint prop_id,
g_value_set_boolean (value, self->mute);
break;
case PROP_DEVICE:
g_value_take_string (value, self->device ?
g_utf16_to_utf8 (self->device, -1, NULL, NULL, NULL) : NULL);
g_value_take_string (value, self->device_strid ?
g_utf16_to_utf8 (self->device_strid, -1, NULL, NULL, NULL) : NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -309,14 +309,18 @@ gst_wasapi_sink_open (GstAudioSink * asink)
if (self->client)
return TRUE;
/* FIXME: Switching the default device does not switch the stream to it,
* 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), FALSE,
self->role, self->device, &client)) {
if (!self->device)
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ, (NULL),
self->role, self->device_strid, &client)) {
if (!self->device_strid)
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_WRITE, (NULL),
("Failed to get default device"));
else
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ, (NULL),
("Failed to open device %S", self->device));
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_WRITE, (NULL),
("Failed to open device %S", self->device_strid));
goto beach;
}

View file

@ -58,7 +58,7 @@ struct _GstWasapiSink
/* properties */
gint role;
gboolean mute;
wchar_t *device;
wchar_t *device_strid;
};
struct _GstWasapiSinkClass

View file

@ -183,7 +183,7 @@ gst_wasapi_src_finalize (GObject * object)
g_clear_pointer (&self->cached_caps, gst_caps_unref);
g_clear_pointer (&self->positions, g_free);
g_clear_pointer (&self->device, g_free);
g_clear_pointer (&self->device_strid, g_free);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -201,8 +201,8 @@ gst_wasapi_src_set_property (GObject * object, guint prop_id,
case PROP_DEVICE:
{
const gchar *device = g_value_get_string (value);
g_free (self->device);
self->device =
g_free (self->device_strid);
self->device_strid =
device ? g_utf8_to_utf16 (device, -1, NULL, NULL, NULL) : NULL;
break;
}
@ -223,8 +223,8 @@ gst_wasapi_src_get_property (GObject * object, guint prop_id,
g_value_set_enum (value, gst_wasapi_erole_to_device_role (self->role));
break;
case PROP_DEVICE:
g_value_take_string (value, self->device ?
g_utf16_to_utf8 (self->device, -1, NULL, NULL, NULL) : NULL);
g_value_take_string (value, self->device_strid ?
g_utf16_to_utf8 (self->device_strid, -1, NULL, NULL, NULL) : NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -306,13 +306,13 @@ gst_wasapi_src_open (GstAudioSrc * asrc)
* 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), TRUE,
self->role, self->device, &client)) {
if (!self->device)
self->role, self->device_strid, &client)) {
if (!self->device_strid)
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ, (NULL),
("Failed to get default device"));
else
GST_ELEMENT_ERROR (self, RESOURCE, OPEN_READ, (NULL),
("Failed to open device %S", self->device));
("Failed to open device %S", self->device_strid));
goto beach;
}

View file

@ -59,7 +59,7 @@ struct _GstWasapiSrc
/* properties */
gint role;
wchar_t *device;
wchar_t *device_strid;
};
struct _GstWasapiSrcClass