Play sounds with "module-stream-restore.id" set to "x-maemo-system-sound"
[hildon] / hildon / hildon-sound.c
index 1bbc264..5d611cc 100644 (file)
@@ -25,6 +25,9 @@
 /**
  * SECTION:hildon-sound
  * @short_description: libcanberra-based utility function for playing a sound.
+ *
+ * Please note that this method is only provided for backwards compatibility,
+ * but we highly recommend you to use canberra-gtk directly instead.
  * 
  */
 
@@ -81,49 +84,28 @@ hildon_ca_context_get (void)
  * @sample: sound file to play
  * 
  * Plays the given sample using libcanberra.
- * Volume level is received from gconf. 
+ * Volume level is received from gconf.
+ *
+ * This method sets the "dialog-information" role for the sound played,
+ * so you need to keep this into account when using it. For any purpose, it
+ * is highly recommended that you use canberra-gtk instead of this method.
  */
 void 
 hildon_play_system_sound(const gchar *sample)
 {
-    float volume = 0;
     int ret;
     ca_context *ca_con = NULL;
     ca_proplist *pl = NULL;
 
-#if 0 /* FIXME: Check volume handling. Would be great not to use Gconf... */
-    GConfClient *client;
-    GConfValue *value;
-    gint gconf_vol;
-
-    /*
-     * The volume is from -0dB to -6dB,
-       The full volume is marked as 2 in gconf */
-    client = gconf_client_get_default ();
-    value = gconf_client_get (client, ALARM_GCONF_PATH, NULL);
-
-    /* We want error cases to match full volume, not silence, so
-       we do not want to use gconf_client_get_int */
-    if (!value || value->type != GCONF_VALUE_INT)
-        gconf_vol = 2;
-    else
-        gconf_vol = gconf_value_get_int(value);
-
-    if (value)
-        gconf_value_free(value);
-    g_object_unref (client);
-
-    volume = ((1.0 - (float)gconf_vol / 2.0)) * (-6.0);
-#endif
-
     ca_con = hildon_ca_context_get ();
 
     ca_proplist_create(&pl);
     ca_proplist_sets(pl, CA_PROP_MEDIA_FILENAME, sample);
-    ca_proplist_setf(pl, CA_PROP_CANBERRA_VOLUME, "%f", volume);
+    ca_proplist_sets(pl, CA_PROP_MEDIA_ROLE, "dialog-information");
+    ca_proplist_sets(pl, "module-stream-restore.id", "x-maemo-system-sound");
 
     ret = ca_context_play_full(ca_con, 0, pl, NULL, NULL);
-    g_debug("ca_context_play_full (vol %f): %s\n", volume, ca_strerror(ret));
+    g_debug("ca_context_play_full %s\n", ca_strerror(ret));
 
     ca_proplist_destroy(pl);
 }