From 24f606be7ff02b0267401f1eb6373d3a8a6d11e0 Mon Sep 17 00:00:00 2001 From: Philip Chimento Date: Wed, 5 Jan 2011 16:55:52 -0500 Subject: [PATCH] Implement glk_schannel_set_volume() Implement setting volume on sound channels using the GStreamer "volume" element. --- libchimara/gestalt.c | 2 +- libchimara/schannel.c | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/libchimara/gestalt.c b/libchimara/gestalt.c index 749bc43..0615459 100644 --- a/libchimara/gestalt.c +++ b/libchimara/gestalt.c @@ -127,6 +127,7 @@ glk_gestalt_ext(glui32 sel, glui32 val, glui32 *arr, glui32 arrlen) return 1; case gestalt_Sound: + case gestalt_SoundVolume: #ifdef GSTREAMER_SOUND return 1; #else @@ -134,7 +135,6 @@ glk_gestalt_ext(glui32 sel, glui32 val, glui32 *arr, glui32 arrlen) #endif /* Unsupported capabilities */ - case gestalt_SoundVolume: case gestalt_SoundNotify: case gestalt_SoundMusic: /* Selector not supported */ diff --git a/libchimara/schannel.c b/libchimara/schannel.c index d93101f..730e033 100644 --- a/libchimara/schannel.c +++ b/libchimara/schannel.c @@ -45,7 +45,7 @@ glk_schannel_create(glui32 rock) /* Create GStreamer elements to put in the pipeline */ s->source = gst_element_factory_make("filesrc", NULL); - s->filter = gst_element_factory_make("identity", NULL); + s->filter = gst_element_factory_make("volume", NULL); s->sink = gst_element_factory_make("autoaudiosink", NULL); if(!s->source || !s->filter || !s->sink) { WARNING("Could not create one or more GStreamer elements"); @@ -266,12 +266,20 @@ glk_schannel_stop(schanid_t chan) * linkend="chimara-Testing-for-Sound-Capabilities">Testing for Sound * Capabilities. * - * This function is not implemented yet. + * Chimara + * Chimara supports volumes from 0 to 1000%, that is, values of + * @vol up to 0xA0000. + * */ void glk_schannel_set_volume(schanid_t chan, glui32 vol) { VALID_SCHANNEL(chan, return); +#ifdef GSTREAMER_SOUND + gdouble volume_gst = (gdouble)vol / 0x10000; + g_printerr("Volume set to: %f\n", volume_gst); + g_object_set(chan->filter, "volume", CLAMP(volume_gst, 0.0, 10.0), NULL); +#endif } /** -- 2.30.2