1
0
Fork 0
Commit graph

8 commits

Author SHA1 Message Date
Bilal Elmoussaoui
74bb480753 sound player: Don't unref undefined fields
If the sound player feature is disabled, none of those fields are
instantiated which causes the crash reported in #2451

Also switch to using g_clear_pointer while we are at it

Fixes https://gitlab.gnome.org/GNOME/mutter/-/issues/2451

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2706>
2022-11-23 10:37:19 +01:00
Bilal Elmoussaoui
7902fa3f9f core: Make sound player feature optional
Mutter can play sounds in some contexts and also provides an API
for libmutter users to do so using libcanberra internally.

In some specific use cases of Mutter, we would like to not depend
on libcanberra and not have any sound playing feature by default.

The changes keeps the sound player API but make it no-op if the
sound_player feature is disabled to not make it possible to break
a gnome-shell build.

See https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2270
for relevant discussion

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2375>
2022-09-02 08:04:31 +00:00
Olivier Fourdan
17417a82a5 cleanup: remove controversial naming
Replace "whitelist" and "blacklist" with "allow_list" and "deny_list"
which better represent the purpose of those variables.

There is no functional change.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1396
2020-08-04 10:04:16 +02:00
Sebastian Keller
aedcfcd010 sound-player: Fix invalid write after playback is cancelled early
The cancellable of a request might already be cancelled by the time
the cancelled_cb is connected resulting in finish_cb being called via
ca_context_cancel before g_cancellable_connect returns. In this case
the request that is written to has already been freed.

Fixes https://gitlab.gnome.org/GNOME/mutter/issues/1060
2020-02-21 16:06:18 +00:00
Robert Mader
92375c75f8 cleanup: Use g_clear_signal_handler() where possible
This is inspired by 98892391d7 where the usage of
`g_signal_handler_disconnect()` without resetting the corresponding
handler id later resulted in a bug. Using `g_clear_signal_handler()`
makes sure we avoid similar bugs and is almost always the better
alternative. We use it for new code, let's clean up the old code to
also use it.

A further benefit is that it can get called even if the passed id is
0, allowing us to remove a lot of now unnessecary checks, and the fact
that `g_clear_signal_handler()` checks for the right type size, forcing us
to clean up all places where we used `guint` instead of `gulong`.

No functional changes intended here and all changes should be trivial,
thus bundled in one big commit.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/940
2019-11-21 15:02:27 +00:00
Andrea Azzarone
8856a396fd sound-player: Don't deadlock in finish_cb
The function finish_cb can be called as a result of a call to ca_context_cancel
in cancelled_cb. This will result in a deadlock because, as per documentation,
g_cancellable_disconnect cannot be called inside the cancellable handler.

It is possible to detect if the call to finish_cb is caused by ca_context_cancel
checking if error_code == CA_ERROR_CANCELED. To avoid the deadlock we should
call g_signal_handler_disconnect instead g_cancellable_disconnect if this is the
case.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/474
2019-03-05 12:07:41 +00:00
Robert Mader
f740e8ed79 core: Fix compiler warning in MetaSoundPlayer 2019-01-09 03:42:43 +00:00
Carlos Garnacho
12f8325cbc 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.
2019-01-08 16:14:17 +01:00