2 * This file is part of hildon-libs
4 * Copyright (C) 2005 Nokia Corporation.
6 * Contact: Luc Pionchon <luc.pionchon@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; either 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
25 #include <gconf/gconf-client.h>
27 #include "hildon-system-sound.h"
29 #define ALARM_GCONF_PATH "/apps/osso/sound/system_alert_volume"
32 * hildon_play_system_sound:
33 * @sample: Sound file to play
35 * Plays the given sample using esd sound daemon.
36 * Volume level is received from gconf.
38 void hildon_play_system_sound(const gchar *sample)
42 gint volume, scale, sock, sample_id;
44 client = gconf_client_get_default();
45 value = gconf_client_get(client, ALARM_GCONF_PATH, NULL);
47 /* We want error cases to match full volume, not silence, so
48 we do not want to use gconf_client_get_int */
49 if (!value || value->type != GCONF_VALUE_INT) {
50 g_message("Failed to get volume level. Using default");
54 volume = gconf_value_get_int(value);
57 gconf_value_free(value);
58 g_object_unref(client);
63 g_message("System sounds are off");
74 sock = esd_open_sound(NULL);
76 g_warning("Failed to setup ESD");
80 sample_id = esd_file_cache(sock, g_get_prgname(), sample);
83 g_warning("error while caching sample.");
87 g_message("Playing sample %s at volume %d", sample, scale);
88 esd_set_default_sample_pan(sock, sample_id, scale, scale);
89 esd_sample_play(sock, sample_id);
90 esd_sample_free(sock, sample_id);