2 * This file is a part of hildon
4 * Copyright (C) 2005, 2006 Nokia Corporation, all rights reserved.
6 * Contact: Michael Dominic Kostrzewa <michael.kostrzewa@nokia.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public License
10 * as published by the Free Software Foundation; version 2.1 of
11 * the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
26 * SECTION:hildon-sound
27 * @short_description: An esd-based utility function for playing a sound.
31 #include "hildon-sound.h"
32 #include <gconf/gconf-client.h>
36 #define ALARM_GCONF_PATH \
37 "/apps/osso/sound/system_alert_volume"
40 * hildon_play_system_sound:
41 * @sample: sound file to play
43 * Plays the given sample using esd sound daemon.
44 * Volume level is received from gconf.
47 hildon_play_system_sound (const gchar *sample)
51 gint volume, scale, sock, sample_id;
53 client = gconf_client_get_default ();
54 value = gconf_client_get (client, ALARM_GCONF_PATH, NULL);
56 /* We want error cases to match full volume, not silence, so
57 we do not want to use gconf_client_get_int */
58 if (!value || value->type != GCONF_VALUE_INT)
61 volume = gconf_value_get_int(value);
64 gconf_value_free(value);
65 g_object_unref (client);
80 sock = esd_open_sound (NULL);
84 sample_id = esd_file_cache (sock, g_get_prgname(), sample);
90 esd_set_default_sample_pan (sock, sample_id, scale, scale);
91 esd_sample_play(sock, sample_id);
92 esd_sample_free(sock, sample_id);