Mercurial > pidgin.yaz
changeset 25737:4b8c64deac5e
Simplify device API. Use gchar* instead of GValue.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Wed, 27 Aug 2008 05:52:14 +0000 |
parents | 9ff63ec7d869 |
children | 441492fb6b61 |
files | libpurple/media.c libpurple/media.h pidgin/gtkprefs.c |
diffstat | 3 files changed, 17 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/media.c Wed Aug 27 00:12:57 2008 +0000 +++ b/libpurple/media.c Wed Aug 27 05:52:14 2008 +0000 @@ -751,15 +751,15 @@ } gchar* -purple_media_get_device_name(GstElement *element, GValue *device) +purple_media_get_device_name(GstElement *element, const gchar *device) { gchar *name; GstElementFactory *factory = gst_element_get_factory(element); GstElement *temp = gst_element_factory_create(factory, "tmp_src"); - g_object_set_property (G_OBJECT (temp), "device", device); - g_object_get (G_OBJECT (temp), "device-name", &name, NULL); + g_object_set(G_OBJECT (temp), "device", device, NULL); + g_object_get(G_OBJECT (temp), "device-name", &name, NULL); gst_object_unref(temp); return name; @@ -807,14 +807,12 @@ if (array != NULL) { for (n = 0 ; n < array->n_values ; n++) { GValue *device = g_value_array_get_nth (array, n); - GValue *location = g_new0(GValue, 1); gst_element_set_state (element, GST_STATE_NULL); - location = g_value_init(location, G_TYPE_STRING); + + ret = g_list_append(ret, g_value_dup_string(device)); - g_value_copy(device, location); - ret = g_list_append(ret, location); - - name = purple_media_get_device_name(GST_ELEMENT(element), device); + name = purple_media_get_device_name(GST_ELEMENT(element), + g_value_get_string(device)); purple_debug_info("media", "Found source '%s' (%s) - device '%s' (%s)\n", longname, GST_PLUGIN_FEATURE (factory)->name, name, g_value_get_string(device)); @@ -836,15 +834,15 @@ } void -purple_media_element_set_device(GstElement *element, GValue *device) +purple_media_element_set_device(GstElement *element, const gchar *device) { - g_object_set_property(G_OBJECT(element), "device", device); + g_object_set(G_OBJECT(element), "device", device, NULL); } -GValue * +gchar * purple_media_element_get_device(GstElement *element) { - GValue *device; + gchar *device; g_object_get(G_OBJECT(element), "device", &device, NULL); return device; } @@ -895,7 +893,7 @@ purple_debug_info("media", "Setting device of GstElement src to %s\n", audio_device); for (; dev ; dev = dev->next) { - GValue *device = (GValue *) dev->data; + gchar *device = (gchar *) dev->data; char *name = purple_media_get_device_name(src, device); if (strcmp(name, audio_device) == 0) { purple_media_element_set_device(src, device); @@ -954,7 +952,7 @@ purple_debug_info("media", "Setting device of GstElement src to %s\n", video_device); for (; dev ; dev = dev->next) { - GValue *device = (GValue *) dev->data; + gchar *device = (gchar *) dev->data; char *name = purple_media_get_device_name(src, device); if (strcmp(name, video_device) == 0) { purple_media_element_set_device(src, device);
--- a/libpurple/media.h Wed Aug 27 00:12:57 2008 +0000 +++ b/libpurple/media.h Wed Aug 27 05:52:14 2008 +0000 @@ -293,7 +293,7 @@ * @return The name of the device. */ gchar *purple_media_get_device_name(GstElement *element, - GValue *device); + const gchar *device); /** * Enumerates a list of devices. @@ -310,7 +310,7 @@ * @param element The plugin to set the device on. * @param device The device to set the plugin to. */ -void purple_media_element_set_device(GstElement *element, GValue *device); +void purple_media_element_set_device(GstElement *element, const gchar *device); /** * Sets the device from the given name. @@ -328,7 +328,7 @@ * * @return The device retrieved. */ -GValue *purple_media_element_get_device(GstElement *element); +gchar *purple_media_element_get_device(GstElement *element); /** * Creates an element from a factory name.
--- a/pidgin/gtkprefs.c Wed Aug 27 00:12:57 2008 +0000 +++ b/pidgin/gtkprefs.c Wed Aug 27 05:52:14 2008 +0000 @@ -2032,7 +2032,7 @@ for(; devices ; devices = devices->next) { gchar *name = purple_media_get_device_name(GST_ELEMENT(element), devices->data); ret = g_list_append(ret, name); - ret = g_list_append(ret, g_value_dup_string(devices->data)); + ret = g_list_append(ret, g_strdup(devices->data)); } return ret; @@ -2123,7 +2123,6 @@ video_items = get_device_items(video, video_devices); for(; video_devices; video_devices = g_list_delete_link( video_devices, video_devices)) { - g_value_unset(video_devices->data); g_free(video_devices->data); } } @@ -2233,7 +2232,6 @@ video_items = get_device_items(video, video_devices); for(; video_devices; video_devices = g_list_delete_link( video_devices, video_devices)) { - g_value_unset(video_devices->data); g_free(video_devices->data); } } @@ -2243,7 +2241,6 @@ audio_items = get_device_items(audio, audio_devices); for(; audio_devices; audio_devices = g_list_delete_link( audio_devices, audio_devices)) { - g_value_unset(audio_devices->data); g_free(audio_devices->data); } }