From: Philip Chimento Date: Wed, 5 Jan 2011 21:55:52 +0000 (-0500) Subject: Implement glk_schannel_set_volume() X-Git-Tag: v0.9~152^2~14 X-Git-Url: https://git.stderr.nl/gitweb?a=commitdiff_plain;h=24f606be7ff02b0267401f1eb6373d3a8a6d11e0;p=projects%2Fchimara%2Fchimara.git Implement glk_schannel_set_volume() Implement setting volume on sound channels using the GStreamer "volume" element. --- 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 } /**