X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fhildon2%2Fmodest-platform.c;h=77cc6102d9afdeb207a0cd761f019daf8fdce933;hb=3657a0c4fbad8e7a2f27f92a053182968f24a8a1;hp=f8554c1c4851c3ce6d1d3f37960dc37d82f16347;hpb=22edd9fadf7c6fcec2b7917a2dc54433d5e8b248;p=modest diff --git a/src/hildon2/modest-platform.c b/src/hildon2/modest-platform.c index f8554c1..77cc610 100644 --- a/src/hildon2/modest-platform.c +++ b/src/hildon2/modest-platform.c @@ -79,6 +79,7 @@ #include #include #include +#include #ifdef MODEST_HAVE_MCE #include @@ -2624,6 +2625,19 @@ modest_platform_get_osso_context (void) return modest_maemo_utils_get_osso_context (); } +static gfloat +convert_volume_to_db (int linear_volume) +{ + gfloat linear_converted = linear_volume / 100.0; + gfloat db_vol = 0.0; + + db_vol = 20 * log10 (linear_converted); + if (isinf (db_vol) != 0) + return -60.0; + + return db_vol; +} + static void modest_platform_play_email_tone (void) { @@ -2631,6 +2645,7 @@ modest_platform_play_email_tone (void) gint mail_volume_int; int ret; ca_proplist *pl = NULL; + gfloat db_volume; #ifdef MODEST_USE_PROFILE gchar *active_profile; @@ -2660,6 +2675,12 @@ modest_platform_play_email_tone (void) if (ca_con == NULL) { if ((ret = ca_context_create (&ca_con)) != CA_SUCCESS) { g_warning("ca_context_create: %s\n", ca_strerror(ret)); + ca_con = NULL; + return; + } + if ((ret = ca_context_set_driver (ca_con, "gstreamer")) != CA_SUCCESS) { + g_warning ("ca_context_set_driver: %s\n", ca_strerror (ret)); + ca_con = NULL; return; } } @@ -2675,7 +2696,8 @@ modest_platform_play_email_tone (void) ca_proplist_create(&pl); ca_proplist_sets(pl, CA_PROP_MEDIA_FILENAME, mail_tone); - ca_proplist_setf(pl, CA_PROP_CANBERRA_VOLUME, "%f", (gfloat) mail_volume_int); + db_volume = convert_volume_to_db (mail_volume_int); + ca_proplist_setf(pl, CA_PROP_CANBERRA_VOLUME, "%f", db_volume); ret = ca_context_play_full(ca_con, 0, pl, NULL, NULL); g_debug("ca_context_play_full (vol %f): %s\n", (gfloat) mail_volume_int, ca_strerror(ret));