core: Add MetaSoundPlayer abstraction

This is a simple libcanberra abstraction object, so we are able
to play file/theme sounds without poking into GTK+/X11. Play
requests are delegated to a separate thread, so we don't block
UI on cards that are slow to wake up from power saving.
This commit is contained in:
Carlos Garnacho
2018-12-09 12:44:20 +01:00
parent 956ab4bd58
commit 12f8325cbc
8 changed files with 354 additions and 0 deletions

View File

@ -66,6 +66,7 @@
#include "meta/main.h"
#include "meta/meta-backend.h"
#include "meta/meta-enum-types.h"
#include "meta/meta-sound-player.h"
#include "meta/meta-x11-errors.h"
#include "meta/prefs.h"
#include "x11/meta-startup-notification-x11.h"
@ -777,6 +778,8 @@ meta_display_open (void)
meta_idle_monitor_init_dbus ();
display->sound_player = g_object_new (META_TYPE_SOUND_PLAYER, NULL);
/* Done opening new display */
display->display_opening = FALSE;
@ -954,6 +957,7 @@ meta_display_close (MetaDisplay *display,
g_clear_object (&display->bell);
g_clear_object (&display->startup_notification);
g_clear_object (&display->workspace_manager);
g_clear_object (&display->sound_player);
g_object_unref (display);
the_display = NULL;
@ -3629,3 +3633,15 @@ meta_display_generate_window_id (MetaDisplay *display)
/* We can overflow here, that's fine */
return (base_window_id + last_window_id++);
}
/**
* meta_display_get_sound_player:
* @display: a #MetaDisplay
*
* Returns: (transfer none): The sound player of the display
*/
MetaSoundPlayer *
meta_display_get_sound_player (MetaDisplay *display)
{
return display->sound_player;
}