changeset 26425:722527dc050f

Implement create_default_audio_* functions in gtkmedia.c.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Sun, 22 Mar 2009 23:00:16 +0000
parents 0c96ac2ea5f8
children 8457de1211f2
files pidgin/gtkmedia.c
diffstat 1 files changed, 46 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/pidgin/gtkmedia.c	Sun Mar 22 22:49:10 2009 +0000
+++ b/pidgin/gtkmedia.c	Sun Mar 22 23:00:16 2009 +0000
@@ -884,17 +884,57 @@
 static GstElement *
 create_default_audio_src(void)
 {
-	GstElement *ret = NULL, *level = NULL;
-	purple_media_audio_init_src(&ret, &level);
-	return ret;
+	GstElement *bin, *src, *volume, *level;
+	GstPad *pad, *ghost;
+	const gchar *audio_device = purple_prefs_get_string(
+			"/purple/media/audio/device");
+	double input_volume = purple_prefs_get_int(
+			"/purple/media/audio/volume/input")/10.0;
+
+	bin = gst_bin_new("purplesendaudiobin");
+	src = gst_element_factory_make("alsasrc", "asrc");
+	volume = gst_element_factory_make("volume", "purpleaudioinputvolume");
+	g_object_set(volume, "volume", input_volume, NULL);
+	level = gst_element_factory_make("level", "sendlevel");
+	gst_bin_add_many(GST_BIN(bin), src, volume, level, NULL);
+	gst_element_link(src, volume);
+	gst_element_link(volume, level);
+	pad = gst_element_get_pad(level, "src");
+	ghost = gst_ghost_pad_new("ghostsrc", pad);
+	gst_element_add_pad(bin, ghost);
+	g_object_set(G_OBJECT(level), "message", TRUE, NULL);
+
+	if (audio_device != NULL && strcmp(audio_device, ""))
+		g_object_set(G_OBJECT(src), "device", audio_device, NULL);
+
+	return bin;
 }
 
 static GstElement *
 create_default_audio_sink(void)
 {
-	GstElement *ret = NULL, *level = NULL;
-	purple_media_audio_init_recv(&ret, &level);
-	return ret;
+	GstElement *bin, *sink, *volume, *level, *queue;
+	GstPad *pad, *ghost;
+	double output_volume = purple_prefs_get_int(
+			"/purple/media/audio/volume/output")/10.0;
+
+	bin = gst_bin_new("pidginrecvaudiobin");
+	sink = gst_element_factory_make("alsasink", "asink");
+	g_object_set(G_OBJECT(sink), "async", FALSE, "sync", FALSE, NULL);
+	volume = gst_element_factory_make("volume", "purpleaudiooutputvolume");
+	g_object_set(volume, "volume", output_volume, NULL);
+	level = gst_element_factory_make("level", "recvlevel");
+	queue = gst_element_factory_make("queue", NULL);
+	gst_bin_add_many(GST_BIN(bin), sink, volume, level, queue, NULL);
+	gst_element_link(level, sink);
+	gst_element_link(volume, level);
+	gst_element_link(queue, volume);
+	pad = gst_element_get_pad(queue, "sink");
+	ghost = gst_ghost_pad_new("ghostsink", pad);
+	gst_element_add_pad(bin, ghost);
+	g_object_set(G_OBJECT(level), "message", TRUE, NULL);
+
+	return bin;
 }
 
 static PurpleMediaElementInfo default_video_src =