maiku.vv: 86774cdb: Simplify device API. Use gchar* instead ...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Wed Aug 27 04:00:39 EDT 2008


-----------------------------------------------------------------
Revision: 86774cdbc6fcdccad43c893f30f3f3398d75dc7b
Ancestor: cbb06fda6f01f91df733ab56b1efb1b1f3e826f3
Author: maiku at soc.pidgin.im
Date: 2008-08-27T05:52:14
Branch: im.pidgin.maiku.vv
URL: http://d.pidgin.im/viewmtn/revision/info/86774cdbc6fcdccad43c893f30f3f3398d75dc7b

Modified files:
        libpurple/media.c libpurple/media.h pidgin/gtkprefs.c

ChangeLog: 

Simplify device API. Use gchar* instead of GValue.

-------------- next part --------------
============================================================
--- libpurple/media.c	ba98eb8e2c6319c15fe66b391055f51e20ce12b0
+++ libpurple/media.c	6def34bd0fa125078c131715492b6bd8194d724d
@@ -751,15 +751,15 @@ gchar*
 }
 
 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 @@ purple_media_get_devices(GstElement *ele
 		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
 }
 
 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_media_audio_init_src(GstElement *
 		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_media_video_init_src(GstElement *
 		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);
============================================================
--- libpurple/media.h	39c1bbdb7c9009c38332e79a872f5942ac8716d9
+++ libpurple/media.h	ec07949cb9cf8449f33bcf16b475edcffa43d662
@@ -293,7 +293,7 @@ gchar *purple_media_get_device_name(GstE
  * @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 @@ GList *purple_media_get_devices(GstEleme
  * @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 @@ void purple_media_element_set_device_fro
  *
  * @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.
============================================================
--- pidgin/gtkprefs.c	02bab9853d658ed9f2ed59f63d765175fd6dc666
+++ pidgin/gtkprefs.c	970388c8a7288ff0623f768a9e53da66c66212c5
@@ -2032,7 +2032,7 @@ get_device_items(const GstElement *eleme
 	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 @@ media_plugin_changed_cb(const gchar *nam
 		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 @@ media_page()
 		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 @@ media_page()
 		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);
 		}
 	}


More information about the Commits mailing list