[mutter/bilelmoussaoui/make-canberra-a-plugin: 3/3] Core: Move sound playing feature to MetaPlugin
- From: Bilal Elmoussaoui <bilelmoussaoui src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/bilelmoussaoui/make-canberra-a-plugin: 3/3] Core: Move sound playing feature to MetaPlugin
- Date: Thu, 14 Apr 2022 10:37:45 +0000 (UTC)
commit c611424f2732f2876c62a6636a30fa03d60bc23b
Author: Bilal Elmoussaoui <belmouss redhat com>
Date: Tue Apr 12 15:27:19 2022 +0200
Core: Move sound playing feature to MetaPlugin
So that Mutter doesn't have to depend on libcanberra itself
and so on gstreamer.
meson.build | 2 -
src/compositor/meta-plugin-manager.c | 12 ++
src/compositor/meta-plugin-manager.h | 5 +
src/core/bell.c | 8 +-
src/core/display-private.h | 3 +-
src/core/display.c | 22 +--
src/core/meta-sound-player.c | 296 -----------------------------------
src/core/workspace.c | 4 +-
src/meson.build | 2 -
src/meta/display.h | 5 +-
src/meta/meson.build | 1 -
src/meta/meta-plugin.h | 12 ++
src/meta/meta-sound-player.h | 46 ------
13 files changed, 48 insertions(+), 370 deletions(-)
---
diff --git a/meson.build b/meson.build
index a10232bbb7..a2f35bf63d 100644
--- a/meson.build
+++ b/meson.build
@@ -31,7 +31,6 @@ xfixes_req = '>= 6'
xi_req = '>= 1.7.4'
xrandr_req = '>= 1.5.0'
libstartup_notification_req = '>= 0.7'
-libcanberra_req = '>= 0.26'
libwacom_req = '>= 0.13'
atk_req = '>= 2.5.3'
@@ -140,7 +139,6 @@ xinerama_dep = dependency('xinerama')
xau_dep = dependency('xau')
ice_dep = dependency('ice')
atk_dep = dependency('atk', version: atk_req)
-libcanberra_dep = dependency('libcanberra', version: libcanberra_req)
dbus_dep = dependency('dbus-1')
# For now always require X11 support
diff --git a/src/compositor/meta-plugin-manager.c b/src/compositor/meta-plugin-manager.c
index 94d62c2126..245916850e 100644
--- a/src/compositor/meta-plugin-manager.c
+++ b/src/compositor/meta-plugin-manager.c
@@ -421,3 +421,15 @@ meta_plugin_manager_locate_pointer (MetaPluginManager *plugin_mgr)
if (klass->locate_pointer)
klass->locate_pointer (plugin);
}
+
+void
+meta_plugin_manager_play_sound (MetaPluginManager *plugin_mgr,
+ const char *name,
+ const char *description)
+{
+ MetaPlugin *plugin = plugin_mgr->plugin;
+ MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin);
+
+ if (klass->play_sound)
+ klass->play_sound (plugin, name, description);
+}
diff --git a/src/compositor/meta-plugin-manager.h b/src/compositor/meta-plugin-manager.h
index a5fe0315ab..859d868624 100644
--- a/src/compositor/meta-plugin-manager.h
+++ b/src/compositor/meta-plugin-manager.h
@@ -104,4 +104,9 @@ MetaInhibitShortcutsDialog *
void meta_plugin_manager_locate_pointer (MetaPluginManager *mgr);
+void
+meta_plugin_manager_play_sound (MetaPluginManager *plugin_mgr,
+ const char *name,
+ const char *description);
+
#endif
diff --git a/src/core/bell.c b/src/core/bell.c
index f0c6f94631..4f2271c6a8 100644
--- a/src/core/bell.c
+++ b/src/core/bell.c
@@ -184,13 +184,7 @@ static gboolean
bell_audible_notify (MetaDisplay *display,
MetaWindow *window)
{
- MetaSoundPlayer *player;
-
- player = meta_display_get_sound_player (display);
- meta_sound_player_play_from_theme (player,
- "bell-window-system",
- _("Bell event"),
- NULL);
+ meta_display_play_sound (display, "bell-window-system", _("Bell event"));
return TRUE;
}
diff --git a/src/core/display-private.h b/src/core/display-private.h
index e91d730352..6c76464d82 100644
--- a/src/core/display-private.h
+++ b/src/core/display-private.h
@@ -32,6 +32,7 @@
#include <X11/Xlib.h>
#include "clutter/clutter.h"
+#include "compositor/meta-plugin-manager.h"
#include "core/keybindings-private.h"
#include "core/meta-gesture-tracker-private.h"
#include "core/meta-pad-action-mapper.h"
@@ -229,7 +230,7 @@ struct _MetaDisplay
MetaBell *bell;
MetaWorkspaceManager *workspace_manager;
- MetaSoundPlayer *sound_player;
+ MetaPluginManager *plugin_manager;
MetaSelectionSource *selection_source;
GBytes *saved_clipboard;
diff --git a/src/core/display.c b/src/core/display.c
index 5f99578a69..b6c118a0ae 100644
--- a/src/core/display.c
+++ b/src/core/display.c
@@ -70,7 +70,6 @@
#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"
@@ -907,6 +906,7 @@ meta_display_new (MetaContext *context,
G_CALLBACK (on_ui_scaling_factor_changed), display);
display->compositor = create_compositor (display);
+ display->plugin_manager = meta_plugin_manager_new (display->compositor);
meta_display_set_cursor (display, META_CURSOR_DEFAULT);
@@ -1001,8 +1001,6 @@ meta_display_new (MetaContext *context,
meta_display_unset_input_focus (display, timestamp);
}
- display->sound_player = g_object_new (META_TYPE_SOUND_PLAYER, NULL);
-
/* Done opening new display */
display->display_opening = FALSE;
@@ -1172,7 +1170,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_clear_object (&display->plugin_manager);
meta_clipboard_manager_shutdown (display);
g_clear_object (&display->selection);
@@ -3925,15 +3923,19 @@ meta_display_generate_window_id (MetaDisplay *display)
}
/**
- * meta_display_get_sound_player:
+ * meta_display_play_sound:
* @display: a #MetaDisplay
- *
- * Returns: (transfer none): The sound player of the display
+ * @name: sound theme name of the event
+ * @description: description of the event
*/
-MetaSoundPlayer *
-meta_display_get_sound_player (MetaDisplay *display)
+void
+meta_display_play_sound (MetaDisplay *display,
+ const char *name,
+ const char *description)
{
- return display->sound_player;
+ meta_plugin_manager_play_sound (display->plugin_manager,
+ name,
+ description);
}
/**
diff --git a/src/core/workspace.c b/src/core/workspace.c
index 357e37d894..49b001c96d 100644
--- a/src/core/workspace.c
+++ b/src/core/workspace.c
@@ -481,7 +481,6 @@ static void
workspace_switch_sound(MetaWorkspace *from,
MetaWorkspace *to)
{
- MetaSoundPlayer *player;
MetaWorkspaceLayout layout;
int i, nw, x, y, fi, ti;
const char *e;
@@ -529,8 +528,7 @@ workspace_switch_sound(MetaWorkspace *from,
goto finish;
}
- player = meta_display_get_sound_player (from->display);
- meta_sound_player_play_from_theme (player, e, "Desktop switched", NULL);
+ meta_display_play_sound (from->display, e, "Desktop switched");
finish:
meta_workspace_manager_free_workspace_layout (&layout);
diff --git a/src/meson.build b/src/meson.build
index 7b456f524f..52760b6914 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -25,7 +25,6 @@ mutter_pkg_private_deps = [
gmodule_no_export_dep,
gnome_settings_daemon_dep,
json_glib_dep,
- libcanberra_dep,
xkbcommon_dep,
]
@@ -401,7 +400,6 @@ mutter_sources = [
'core/meta-selection.c',
'core/meta-selection-source.c',
'core/meta-selection-source-memory.c',
- 'core/meta-sound-player.c',
'core/meta-workspace-manager.c',
'core/meta-workspace-manager-private.h',
'core/place.c',
diff --git a/src/meta/display.h b/src/meta/display.h
index e59bd03939..c163a4cdb2 100644
--- a/src/meta/display.h
+++ b/src/meta/display.h
@@ -27,7 +27,6 @@
#include <meta/prefs.h>
#include <meta/common.h>
#include <meta/workspace.h>
-#include <meta/meta-sound-player.h>
#include <meta/meta-startup-notification.h>
/**
@@ -301,7 +300,9 @@ META_EXPORT
MetaStartupNotification * meta_display_get_startup_notification (MetaDisplay *display);
META_EXPORT
-MetaSoundPlayer * meta_display_get_sound_player (MetaDisplay *display);
+void meta_display_play_sound (MetaDisplay *display,
+ const char *name,
+ const char *description);
META_EXPORT
MetaSelection * meta_display_get_selection (MetaDisplay *display);
diff --git a/src/meta/meson.build b/src/meta/meson.build
index 3076f75327..264a3f66c7 100644
--- a/src/meta/meson.build
+++ b/src/meta/meson.build
@@ -32,7 +32,6 @@ mutter_public_headers = [
'meta-settings.h',
'meta-shadow-factory.h',
'meta-shaped-texture.h',
- 'meta-sound-player.h',
'meta-stage.h',
'meta-startup-notification.h',
'meta-window-actor.h',
diff --git a/src/meta/meta-plugin.h b/src/meta/meta-plugin.h
index 663a75fa9d..b908f47e7b 100644
--- a/src/meta/meta-plugin.h
+++ b/src/meta/meta-plugin.h
@@ -247,6 +247,18 @@ struct _MetaPluginClass
* on screen to draw user attention on the pointer location.
*/
void (*locate_pointer) (MetaPlugin *plugin);
+
+ /**
+ * MetaPluginClass::play_sound:
+ * @plugin: a #MetaPlugin
+ * @name: sound theme name of the event
+ * @description: description of the event
+ *
+ * Virtual function called to play a sound theme.
+ */
+ void (* play_sound) (MetaPlugin *plugin,
+ const char *name,
+ const char *description);
};
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]