comparison gtk/gtksound.c @ 14253:dc0afefc19d8

[gaim-migrate @ 16935] If gstreamer fails, show an error message and continue to load. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Mon, 21 Aug 2006 03:04:12 +0000
parents 009db0b357b5
children 360c016459d0
comparison
equal deleted inserted replaced
14252:5d15efb9f440 14253:dc0afefc19d8
53 #define PLAY_SOUND_TIMEOUT 15000 53 #define PLAY_SOUND_TIMEOUT 15000
54 54
55 static guint mute_login_sounds_timeout = 0; 55 static guint mute_login_sounds_timeout = 0;
56 static gboolean mute_login_sounds = FALSE; 56 static gboolean mute_login_sounds = FALSE;
57 57
58 #ifdef USE_GSTREAMER
59 static gboolean gst_init_failed;
60 #endif /* USE_GSTREAMER */
61
58 static struct gaim_sound_event sounds[GAIM_NUM_SOUNDS] = { 62 static struct gaim_sound_event sounds[GAIM_NUM_SOUNDS] = {
59 {N_("Buddy logs in"), "login", "login.wav"}, 63 {N_("Buddy logs in"), "login", "login.wav"},
60 {N_("Buddy logs out"), "logout", "logout.wav"}, 64 {N_("Buddy logs out"), "logout", "logout.wav"},
61 {N_("Message received"), "im_recv", "receive.wav"}, 65 {N_("Message received"), "im_recv", "receive.wav"},
62 {N_("Message received begins conversation"), "first_im_recv", "receive.wav"}, 66 {N_("Message received begins conversation"), "first_im_recv", "receive.wav"},
259 gaim_gtk_sound_init(void) 263 gaim_gtk_sound_init(void)
260 { 264 {
261 void *gtk_sound_handle = gaim_gtk_sound_get_handle(); 265 void *gtk_sound_handle = gaim_gtk_sound_get_handle();
262 void *blist_handle = gaim_blist_get_handle(); 266 void *blist_handle = gaim_blist_get_handle();
263 void *conv_handle = gaim_conversations_get_handle(); 267 void *conv_handle = gaim_conversations_get_handle();
268 #ifdef USE_GSTREAMER
269 GError *error = NULL;
270 #endif
264 271
265 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", 272 gaim_signal_connect(gaim_connections_get_handle(), "signed-on",
266 gtk_sound_handle, GAIM_CALLBACK(account_signon_cb), 273 gtk_sound_handle, GAIM_CALLBACK(account_signon_cb),
267 NULL); 274 NULL);
268 275
297 gaim_prefs_add_string("/gaim/gtk/sound/method", "automatic"); 304 gaim_prefs_add_string("/gaim/gtk/sound/method", "automatic");
298 gaim_prefs_add_int("/gaim/gtk/sound/volume", 50); 305 gaim_prefs_add_int("/gaim/gtk/sound/volume", 50);
299 306
300 #ifdef USE_GSTREAMER 307 #ifdef USE_GSTREAMER
301 gaim_debug_info("sound", "Initializing sound output drivers.\n"); 308 gaim_debug_info("sound", "Initializing sound output drivers.\n");
302 gst_init(NULL, NULL); 309 if ((gst_init_failed = !gst_init_check(NULL, NULL, &error))) {
310 gaim_notify_error(NULL, _("GStreamer Failure"),
311 _("GStreamer failed to initialize."),
312 error ? error->message : "");
313 if (error) {
314 g_error_free(error);
315 error = NULL;
316 }
317 return;
318 }
303 #endif /* USE_GSTREAMER */ 319 #endif /* USE_GSTREAMER */
304 320
305 gaim_signal_connect(blist_handle, "buddy-signed-on", 321 gaim_signal_connect(blist_handle, "buddy-signed-on",
306 gtk_sound_handle, GAIM_CALLBACK(buddy_state_cb), 322 gtk_sound_handle, GAIM_CALLBACK(buddy_state_cb),
307 GINT_TO_POINTER(GAIM_SOUND_BUDDY_ARRIVE)); 323 GINT_TO_POINTER(GAIM_SOUND_BUDDY_ARRIVE));
330 346
331 static void 347 static void
332 gaim_gtk_sound_uninit(void) 348 gaim_gtk_sound_uninit(void)
333 { 349 {
334 #ifdef USE_GSTREAMER 350 #ifdef USE_GSTREAMER
335 gst_deinit(); 351 if (!gst_init_failed)
352 gst_deinit();
336 #endif 353 #endif
337 354
338 gaim_signals_disconnect_by_handle(gaim_gtk_sound_get_handle()); 355 gaim_signals_disconnect_by_handle(gaim_gtk_sound_get_handle());
339 } 356 }
340 357
426 443
427 g_free(command); 444 g_free(command);
428 return; 445 return;
429 } 446 }
430 #ifdef USE_GSTREAMER 447 #ifdef USE_GSTREAMER
448 if (gst_init_failed) /* Perhaps do gdk_beep instead? */
449 return;
431 volume = (float)(CLAMP(gaim_prefs_get_int("/gaim/gtk/sound/volume"),0,100)) / 50; 450 volume = (float)(CLAMP(gaim_prefs_get_int("/gaim/gtk/sound/volume"),0,100)) / 50;
432 if (!strcmp(method, "automatic")) { 451 if (!strcmp(method, "automatic")) {
433 if (gaim_running_gnome()) { 452 if (gaim_running_gnome()) {
434 sink = gst_element_factory_make("gconfaudiosink", "sink"); 453 sink = gst_element_factory_make("gconfaudiosink", "sink");
435 } 454 }