diff options
author | Michal Ratajsky <[email protected]> | 2014-07-03 19:06:24 +0200 |
---|---|---|
committer | infirit <[email protected]> | 2014-10-09 16:51:28 +0200 |
commit | 8481ebdc843ec212e59f98c8ff5f718485f864c0 (patch) | |
tree | b583d25bde99c960956886a837f7434392480d7b | |
parent | 163f01a8b527c1ed801f68681fc7d82a54d42b1c (diff) | |
download | mate-settings-daemon-8481ebdc843ec212e59f98c8ff5f718485f864c0.tar.bz2 mate-settings-daemon-8481ebdc843ec212e59f98c8ff5f718485f864c0.tar.xz |
Remove GStreamer parts and use libmatemixer
-rw-r--r-- | AUTHORS | 1 | ||||
-rw-r--r-- | NEWS | 7 | ||||
-rw-r--r-- | configure.ac | 107 | ||||
-rw-r--r-- | plugins/media-keys/Makefile.am | 17 | ||||
-rw-r--r-- | plugins/media-keys/msd-media-keys-manager.c | 370 | ||||
-rw-r--r-- | plugins/media-keys/msd-media-keys-plugin.c | 20 |
6 files changed, 222 insertions, 300 deletions
@@ -2,6 +2,7 @@ MATE: Perberos <[email protected]> Steve Zesch <[email protected]> Stefano Karapetsas <[email protected]> +Michal Ratajsky <[email protected]> GNOME: Jonathan Blandford <[email protected]> @@ -1,10 +1,11 @@ -1.9.1 - * +1.9.x + * Port media-keys plugin to libmatemixer + * Remove GStreamer and PulseAudio dependencies, add optional dependency + on libmatemixer 1.8.0 * Add GTK3 support * Add Middle Click Emulation to mouse manager 1.6.0 - * Migration to gsettings diff --git a/configure.ac b/configure.ac index bab0855..6ca0136 100644 --- a/configure.ac +++ b/configure.ac @@ -55,6 +55,7 @@ GIO_REQUIRED_VERSION=2.26.0 MATE_DESKTOP_REQUIRED_VERSION=1.9.1 LIBMATEKBD_REQUIRED_VERSION=1.7.0 LIBNOTIFY_REQUIRED_VERSION=0.7.0 +LIBMATEMIXER_REQUIRED_VERSION=1.9.0 EXTRA_COMPILE_WARNINGS(yes) @@ -251,22 +252,12 @@ AC_SUBST(LIBMATEKBDUI_CFLAGS) AC_SUBST(LIBMATEKBDUI_LIBS) dnl --------------------------------------------------------------------------- -dnl - Housekeeping plugin stuff +dnl - Check for sound & mixer libraries dnl --------------------------------------------------------------------------- -PKG_CHECK_MODULES(GIOUNIX, [gio-unix-2.0]) -AC_SUBST(GIOUNIX_CFLAGS) -AC_SUBST(GIOUNIX_LIBS) - -dnl ============================================== -dnl PulseAudio section -dnl ============================================== - - have_pulse=false AC_ARG_ENABLE(pulse, - AC_HELP_STRING([--disable-pulse], - [turn off PulseAudio support]), + AC_HELP_STRING([--disable-pulse], [Disable PulseAudio support]), [case "${enableval}" in yes) WANT_PULSE=yes ;; no) WANT_PULSE=no ;; @@ -276,9 +267,9 @@ AC_ARG_ENABLE(pulse, if test x$WANT_PULSE = xyes ; then PA_REQUIRED_VERSION=0.9.16 - PKG_CHECK_MODULES(PULSE, glib-2.0 libpulse >= $PA_REQUIRED_VERSION libpulse-mainloop-glib >= $PA_REQUIRED_VERSION $LIBCANBERRA_PC, + PKG_CHECK_MODULES(PULSE, libpulse >= $PA_REQUIRED_VERSION, [have_pulse=true - AC_DEFINE(HAVE_PULSE, 1, [Define if PULSE sound server should be used])], + AC_DEFINE(HAVE_PULSE, 1, [Define if PulseAudio support is available])], [have_pulse=false]) fi AM_CONDITIONAL(HAVE_PULSE, test "x$have_pulse" = "xtrue") @@ -286,49 +277,45 @@ AM_CONDITIONAL(HAVE_PULSE, test "x$have_pulse" = "xtrue") AC_SUBST(PULSE_CFLAGS) AC_SUBST(PULSE_LIBS) - -dnl ============================================== -dnl GStreamer section -dnl ============================================== -GST_MAJORMINOR=auto - -AC_ARG_ENABLE(gstreamer, -AC_HELP_STRING([--enable-gstreamer],[use gstreamer if available (and optionally specify a version)]), -[case "${enableval}" in - yes) ENABLE_GSTREAMER=yes ;; - 0.10) ENABLE_GSTREAMER=yes && GST_MAJORMINOR=0.10 ;; - no) ENABLE_GSTREAMER=no ;; - *) AC_MSG_ERROR([ - *** Bad value ${enableval} for --enable-gstreamer - *** Please use one of the following: - *** --enable-gstreamer=0.10 - ]) ;; -esac], -[ENABLE_GSTREAMER=yes]) dnl Default value - -have_gstreamer=no -if test "x$ENABLE_GSTREAMER" = "xyes"; then - GST_REQS=0.10.1.2 - PKGS="gstreamer-0.10 >= $GST_REQS gstreamer-plugins-base-0.10 >= $GST_REQS" - - PKG_CHECK_MODULES(GST, $PKGS, have_gstreamer=yes, - AC_MSG_RESULT([no])) - - if test "x$have_pulse" = "xtrue"; then - AC_MSG_ERROR([*** GStreamer & Pulseaudio both are selected ***]) - fi - - if test "x$have_gstreamer" = "xyes"; then - GST_LIBS="$GST_LIBS -lgstinterfaces-0.10 -lgstaudio-0.10" - AC_DEFINE(HAVE_GSTREAMER,1,[enable gstreamer]) - fi -else - AC_MSG_NOTICE([*** GStreamer support disabled ***]) +have_libcanberra=no +AC_ARG_WITH(libcanberra, + AC_HELP_STRING([--without-libcanberra], [Disable sound events (default: auto)]), + with_libcanberra=$withval, with_libcanberra=auto) + +if test "x$with_libcanberra" != "xno"; then + PKG_CHECK_MODULES(LIBCANBERRA, $LIBCANBERRA_PC, + [AC_DEFINE(HAVE_LIBCANBERRA, 1, [Define if $LIBCANBERRA_PC is available]) + have_libcanberra=yes], have_libcanberra=no) + if test "x$have_libcanberra" = xno -a "x$with_libcanberra" = xyes; then + AC_MSG_ERROR([libcanberra support requested but library not found]) + fi +fi +AC_SUBST(LIBCANBERRA_CFLAGS) +AC_SUBST(LIBCANBERRA_LIBS) + +have_libmatemixer=no +AC_ARG_WITH(libmatemixer, + AC_HELP_STRING([--without-libmatemixer], [Disable volume event handling (default: auto)]), + with_libmatemixer=$withval, with_libmatemixer=auto) + +if test "x$with_libmatemixer" != "xno"; then + PKG_CHECK_MODULES(LIBMATEMIXER, libmatemixer >= $LIBMATEMIXER_REQUIRED_VERSION, + [AC_DEFINE(HAVE_LIBMATEMIXER, 1, [Define if libmatemixer is available]) + have_libmatemixer=yes], have_libmatemixer=no) + if test "x$have_libmatemixer" = xno -a "x$with_libmatemixer" = xyes; then + AC_MSG_ERROR([libmatemixer support requested but library not found]) + fi fi -AM_CONDITIONAL(HAVE_GSTREAMER, test "x$have_gstreamer" = "xyes") -AC_SUBST(GST_LIBS) -AC_SUBST(GST_CFLAGS) +AC_SUBST(LIBMATEMIXER_CFLAGS) +AC_SUBST(LIBMATEMIXER_LIBS) +dnl --------------------------------------------------------------------------- +dnl - Housekeeping plugin stuff +dnl --------------------------------------------------------------------------- + +PKG_CHECK_MODULES(GIOUNIX, [gio-unix-2.0]) +AC_SUBST(GIOUNIX_CFLAGS) +AC_SUBST(GIOUNIX_LIBS) dnl ============================================== dnl smartcard section @@ -375,7 +362,6 @@ fi AC_SUBST(NSS_DATABASE) - # --------------------------------------------------------------------------- # PolicyKit # --------------------------------------------------------------------------- @@ -411,8 +397,6 @@ AM_CONDITIONAL(HAVE_POLKIT, test "x$HAVE_POLKIT" = "xyes") AC_SUBST(POLKIT_CFLAGS) AC_SUBST(POLKIT_LIBS) - - # --------------------------------------------------------------------------- # Enable Profiling # --------------------------------------------------------------------------- @@ -424,7 +408,6 @@ if test "x$enable_profiling" = "xyes"; then AC_DEFINE(ENABLE_PROFILING,1,[enable profiling]) fi - # --------------------------------------------------------------------------- # Plugins # --------------------------------------------------------------------------- @@ -510,7 +493,6 @@ plugins/housekeeping/Makefile plugins/keybindings/Makefile plugins/keyboard/Makefile plugins/media-keys/Makefile -plugins/media-keys/cut-n-paste/Makefile plugins/mpris/Makefile plugins/mouse/Makefile plugins/smartcard/Makefile @@ -554,9 +536,10 @@ echo " PolicyKit support: ${HAVE_POLKIT} Gtk+ version: ${GTK_API_VERSION} - Libnotify support: ${have_libnotify} - GStreamer support: ${have_gstreamer} PulseAudio support: ${have_pulse} + Libnotify support: ${have_libnotify} + Libcanberra support: ${have_libcanberra} + Libmatemixer support: ${have_libmatemixer} Smartcard support: ${have_smartcard_support} ${NSS_DATABASE:+\ System nssdb: ${NSS_DATABASE} diff --git a/plugins/media-keys/Makefile.am b/plugins/media-keys/Makefile.am index d0a7b6a..8268b08 100644 --- a/plugins/media-keys/Makefile.am +++ b/plugins/media-keys/Makefile.am @@ -3,7 +3,6 @@ context = actions NULL = -SUBDIRS = cut-n-paste plugin_LTLIBRARIES = libmedia-keys.la BUILT_SOURCES = \ @@ -80,7 +79,6 @@ libmedia_keys_la_SOURCES = \ libmedia_keys_la_CPPFLAGS = \ -I$(top_srcdir)/mate-settings-daemon \ -I$(top_srcdir)/plugins/common \ - -I$(top_srcdir)/plugins/media-keys/cut-n-paste \ -DPIXMAPDIR=\""$(pkgdatadir)"\" \ -DGTKBUILDERDIR=\""$(pkgdatadir)"\" \ -DMATE_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \ @@ -88,6 +86,8 @@ libmedia_keys_la_CPPFLAGS = \ libmedia_keys_la_CFLAGS = \ $(SETTINGS_PLUGIN_CFLAGS) \ + $(LIBMATEMIXER_CFLAGS) \ + $(LIBCANBERRA_CFLAGS) \ $(AM_CFLAGS) libmedia_keys_la_LDFLAGS = \ @@ -95,8 +95,9 @@ libmedia_keys_la_LDFLAGS = \ libmedia_keys_la_LIBADD = \ $(top_builddir)/plugins/common/libcommon.la \ - $(top_builddir)/plugins/media-keys/cut-n-paste/libgvc.la \ $(SETTINGS_PLUGIN_LIBS) \ + $(LIBMATEMIXER_LIBS) \ + $(LIBCANBERRA_LIBS) \ $(XF86MISC_LIBS) \ -lm @@ -150,7 +151,6 @@ test_media_keys_SOURCES = \ test_media_keys_CPPFLAGS = \ -I$(top_srcdir)/mate-settings-daemon \ -I$(top_srcdir)/plugins/common \ - -I$(top_srcdir)/plugins/media-keys/cut-n-paste \ -DPIXMAPDIR=\""$(pkgdatadir)"\" \ -DGTKBUILDERDIR=\""$(pkgdatadir)"\" \ -DMATE_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \ @@ -158,6 +158,8 @@ test_media_keys_CPPFLAGS = \ test_media_keys_CFLAGS = \ $(SETTINGS_PLUGIN_CFLAGS) \ + $(LIBMATEMIXER_CFLAGS) \ + $(LIBCANBERRA_CFLAGS) \ $(AM_CFLAGS) test_media_keys_LDADD = \ @@ -165,19 +167,16 @@ test_media_keys_LDADD = \ $(top_builddir)/plugins/common/libcommon.la \ $(SETTINGS_DAEMON_LIBS) \ $(SETTINGS_PLUGIN_LIBS) \ + $(LIBMATEMIXER_LIBS) \ + $(LIBCANBERRA_LIBS) \ $(XF86MISC_LIBS) \ - $(GST_LIBS) \ -lm -test_media_keys_LDADD += $(top_builddir)/plugins/media-keys/cut-n-paste/libgvc.la - gtkbuilderdir = $(pkgdatadir) gtkbuilder_DATA = \ acme.ui \ $(NULL) -DIST_SUBDIRS = cut-n-paste - EXTRA_DIST = \ msd-media-keys-manager.xml \ msd-marshal.list \ diff --git a/plugins/media-keys/msd-media-keys-manager.c b/plugins/media-keys/msd-media-keys-manager.c index cc819c5..6c12274 100644 --- a/plugins/media-keys/msd-media-keys-manager.c +++ b/plugins/media-keys/msd-media-keys-manager.c @@ -41,6 +41,14 @@ #include <dbus/dbus-glib.h> #include <dbus/dbus-glib-lowlevel.h> +#ifdef HAVE_LIBMATEMIXER +#include <libmatemixer/matemixer.h> +#endif + +#ifdef HAVE_LIBCANBERRA +#include <canberra-gtk.h> +#endif + #include "mate-settings-profile.h" #include "msd-marshal.h" #include "msd-media-keys-manager.h" @@ -50,13 +58,6 @@ #include "acme.h" #include "msd-media-keys-window.h" -#ifdef HAVE_PULSE -#include <canberra-gtk.h> -#include "gvc-mixer-control.h" -#elif defined(HAVE_GSTREAMER) -#include "gvc-gstreamer-acme-vol.h" -#endif /* HAVE_PULSE */ - #define MSD_DBUS_PATH "/org/mate/SettingsDaemon" #define MSD_DBUS_NAME "org.mate.SettingsDaemon" #define MSD_MEDIA_KEYS_DBUS_PATH MSD_DBUS_PATH "/MediaKeys" @@ -65,8 +66,7 @@ #define TOUCHPAD_SCHEMA "org.mate.peripherals-touchpad" #define TOUCHPAD_ENABLED_KEY "touchpad-enabled" -#define VOLUME_STEP 6 /* percents for one volume button press */ -#define MAX_VOLUME 65536.0 +#define VOLUME_STEP 6 #define MSD_MEDIA_KEYS_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MSD_TYPE_MEDIA_KEYS_MANAGER, MsdMediaKeysManagerPrivate)) @@ -77,25 +77,23 @@ typedef struct { struct MsdMediaKeysManagerPrivate { -#ifdef HAVE_PULSE +#ifdef HAVE_LIBMATEMIXER /* Volume bits */ - GvcMixerControl *volume; - GvcMixerStream *stream; -#elif defined(HAVE_GSTREAMER) - AcmeVolume *volume; -#endif /* HAVE_PULSE */ - GtkWidget *dialog; - GSettings *settings; - GVolumeMonitor *volume_monitor; + MateMixerControl *control; + MateMixerStream *stream; +#endif + GtkWidget *dialog; + GSettings *settings; + GVolumeMonitor *volume_monitor; /* Multihead stuff */ - GdkScreen *current_screen; - GSList *screens; + GdkScreen *current_screen; + GSList *screens; - GList *media_players; + GList *media_players; - DBusGConnection *connection; - guint notify[HANDLED_KEYS]; + DBusGConnection *connection; + guint notify[HANDLED_KEYS]; }; enum { @@ -113,7 +111,6 @@ G_DEFINE_TYPE (MsdMediaKeysManager, msd_media_keys_manager, G_TYPE_OBJECT) static gpointer manager_object = NULL; - static void init_screens (MsdMediaKeysManager *manager) { @@ -134,7 +131,6 @@ init_screens (MsdMediaKeysManager *manager) manager->priv->current_screen = manager->priv->screens->data; } - static void acme_error (char * msg) { @@ -612,219 +608,169 @@ do_touchpad_action (MsdMediaKeysManager *manager) g_object_unref (settings); } -#ifdef HAVE_PULSE +#ifdef HAVE_LIBMATEMIXER static void update_dialog (MsdMediaKeysManager *manager, - guint vol, - gboolean muted, - gboolean sound_changed) + guint volume, + gboolean muted, + gboolean sound_changed) { - vol = (int) (100 * (double) vol / PA_VOLUME_NORM); - vol = CLAMP (vol, 0, 100); - dialog_init (manager); + msd_media_keys_window_set_volume_muted (MSD_MEDIA_KEYS_WINDOW (manager->priv->dialog), muted); - msd_media_keys_window_set_volume_level (MSD_MEDIA_KEYS_WINDOW (manager->priv->dialog), vol); + msd_media_keys_window_set_volume_level (MSD_MEDIA_KEYS_WINDOW (manager->priv->dialog), + volume); + msd_media_keys_window_set_action (MSD_MEDIA_KEYS_WINDOW (manager->priv->dialog), MSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME); dialog_show (manager); +#ifdef HAVE_LIBCANBERRA if (sound_changed != FALSE && muted == FALSE) ca_gtk_play_for_widget (manager->priv->dialog, 0, CA_PROP_EVENT_ID, "audio-volume-change", - CA_PROP_EVENT_DESCRIPTION, "volume changed through key press", - CA_PROP_APPLICATION_ID, "org.mate.VolumeControl", + CA_PROP_EVENT_DESCRIPTION, "Volume changed through key press", + CA_PROP_APPLICATION_NAME, PACKAGE_NAME, + CA_PROP_APPLICATION_VERSION, PACKAGE_VERSION, + CA_PROP_APPLICATION_ID, "org.mate.SettingsDaemon", NULL); +#endif } -#endif /* HAVE_PULSE */ - -#if defined(HAVE_PULSE) || defined(HAVE_GSTREAMER) + static void -do_sound_action (MsdMediaKeysManager *manager, - int type) +do_sound_action (MsdMediaKeysManager *manager, int type) { gboolean muted; - guint vol, norm_vol_step; - int vol_step; - gboolean sound_changed; + gboolean muted_last; + gboolean sound_changed = FALSE; + guint volume; + guint volume_min, volume_max; + guint volume_step; + guint volume_last; -#ifdef HAVE_PULSE if (manager->priv->stream == NULL) return; -#elif defined(HAVE_GSTREAMER) - if (manager->priv->volume == NULL) - return; -#endif - vol_step = g_settings_get_int (manager->priv->settings, "volume-step"); + /* Theoretically the volume limits might be different for different + * streams, also the minimum might not always start at 0 */ + volume_min = mate_mixer_stream_get_min_volume (manager->priv->stream); + volume_max = mate_mixer_stream_get_normal_volume (manager->priv->stream); - if (vol_step <= 0 || vol_step > 100) - vol_step = VOLUME_STEP; + volume_step = g_settings_get_int (manager->priv->settings, "volume-step"); + if (volume_step <= 0 || + volume_step > 100) + volume_step = VOLUME_STEP; -#ifdef HAVE_PULSE - norm_vol_step = PA_VOLUME_NORM * vol_step / 100; + /* Scale the volume step size accordingly to the range used by the stream */ + volume_step = (volume_max - volume_min) * volume_step / 100; - /* FIXME: this is racy */ - vol = gvc_mixer_stream_get_volume (manager->priv->stream); - muted = gvc_mixer_stream_get_is_muted (manager->priv->stream); -#else - if (vol_step > 0) { - gint threshold = acme_volume_get_threshold (manager->priv->volume); - if (vol_step < threshold) - vol_step = threshold; - g_debug ("Using volume step of %d", vol_step); - } - vol = acme_volume_get_volume (manager->priv->volume); - muted = acme_volume_get_mute (manager->priv->volume); -#endif - sound_changed = FALSE; + volume = volume_last = + mate_mixer_stream_get_volume (manager->priv->stream); + muted = muted_last = + mate_mixer_stream_get_mute (manager->priv->stream); switch (type) { case MUTE_KEY: -#ifdef HAVE_PULSE muted = !muted; - gvc_mixer_stream_change_is_muted (manager->priv->stream, muted); - sound_changed = TRUE; -#else - acme_volume_mute_toggle (manager->priv->volume); -#endif break; case VOLUME_DOWN_KEY: -#ifdef HAVE_PULSE - if (!muted && (vol <= norm_vol_step)) { - muted = !muted; - vol = 0; - gvc_mixer_stream_change_is_muted (manager->priv->stream, muted); - if (gvc_mixer_stream_set_volume (manager->priv->stream, vol) != FALSE) { - gvc_mixer_stream_push_volume (manager->priv->stream); - sound_changed = TRUE; - } - } else if (!muted) { - vol = vol - norm_vol_step; - if (gvc_mixer_stream_set_volume (manager->priv->stream, vol) != FALSE) { - gvc_mixer_stream_push_volume (manager->priv->stream); - sound_changed = TRUE; - } + if (!muted) { + if (volume <= (volume_min + volume_step)) { + volume = volume_min; + muted = TRUE; + } else + volume -= volume_step; } -#else - if (!muted && (vol <= vol_step)) - acme_volume_mute_toggle (manager->priv->volume); - acme_volume_set_volume (manager->priv->volume, vol - vol_step); -#endif break; case VOLUME_UP_KEY: if (muted) { - muted = !muted; - if (vol == 0) { -#ifdef HAVE_PULSE - vol = vol + norm_vol_step; - gvc_mixer_stream_change_is_muted (manager->priv->stream, muted); - if (gvc_mixer_stream_set_volume (manager->priv->stream, vol) != FALSE) { - gvc_mixer_stream_push_volume (manager->priv->stream); - sound_changed = TRUE; - } - } else { - gvc_mixer_stream_change_is_muted (manager->priv->stream, muted); - sound_changed = TRUE; - } -#else - /* We need to unmute otherwise vol is blocked (and muted) */ - acme_volume_set_mute (manager->priv->volume, FALSE); - } - acme_volume_set_volume (manager->priv->volume, vol + vol_step); -#endif - } else { -#ifdef HAVE_PULSE - if (vol < MAX_VOLUME) { - if (vol + norm_vol_step >= MAX_VOLUME) { - vol = MAX_VOLUME; - } else { - vol = vol + norm_vol_step; - } - if (gvc_mixer_stream_set_volume (manager->priv->stream, vol) != FALSE) { - gvc_mixer_stream_push_volume (manager->priv->stream); - sound_changed = TRUE; - } - } -#else - acme_volume_set_volume (manager->priv->volume, vol + vol_step); -#endif - } + muted = FALSE; + if (volume <= volume_min) + volume = volume_min + volume_step; + } else + volume = CLAMP (volume + volume_step, + volume_min, + volume_max); break; } -#ifdef HAVE_PULSE - update_dialog (manager, vol, muted, sound_changed); -#else - muted = acme_volume_get_mute (manager->priv->volume); - vol = acme_volume_get_volume (manager->priv->volume); + if (muted != muted_last) { + if (mate_mixer_stream_set_mute (manager->priv->stream, muted)) + sound_changed = TRUE; + else + muted = muted_last; + } + if (volume != mate_mixer_stream_get_volume (manager->priv->stream)) { + if (mate_mixer_stream_set_volume (manager->priv->stream, volume)) + sound_changed = TRUE; + else + volume = volume_last; + } - /* FIXME: AcmeVolume should probably emit signals - instead of doing it like this */ - dialog_init (manager); - msd_media_keys_window_set_volume_muted (MSD_MEDIA_KEYS_WINDOW (manager->priv->dialog), - muted); - msd_media_keys_window_set_volume_level (MSD_MEDIA_KEYS_WINDOW (manager->priv->dialog), - vol); - msd_media_keys_window_set_action (MSD_MEDIA_KEYS_WINDOW (manager->priv->dialog), - MSD_MEDIA_KEYS_WINDOW_ACTION_VOLUME); - dialog_show (manager); -#endif /* HAVE_PULSE */ + update_dialog (manager, + CLAMP (100 * volume / (volume_max - volume_min), 0, 100), + muted, + sound_changed); } -#endif /* defined(HAVE_PULSE) || defined(HAVE_GSTREAMER) */ -#ifdef HAVE_PULSE static void -update_default_sink (MsdMediaKeysManager *manager) +update_default_output (MsdMediaKeysManager *manager) { - GvcMixerStream *stream; + MateMixerStream *stream; - stream = gvc_mixer_control_get_default_sink (manager->priv->volume); + stream = mate_mixer_control_get_default_output_stream (manager->priv->control); if (stream == manager->priv->stream) return; - if (manager->priv->stream != NULL) { - g_object_unref (manager->priv->stream); - manager->priv->stream = NULL; - } + g_clear_object (&manager->priv->stream); if (stream != NULL) { + MateMixerStreamFlags flags = mate_mixer_stream_get_flags (stream); + + /* Do not use the stream if it is not possible to mute it or + * change the volume */ + if (!(flags & MATE_MIXER_STREAM_HAS_MUTE) && + !(flags & MATE_MIXER_STREAM_HAS_VOLUME)) + return; + manager->priv->stream = g_object_ref (stream); - } else { - g_warning ("Unable to get default sink"); - } + g_debug ("Default output stream updated to %s", + mate_mixer_stream_get_name (manager->priv->stream)); + } else + g_debug ("Default output stream unset"); } static void -on_control_ready (GvcMixerControl *control, - MsdMediaKeysManager *manager) +on_control_state_notify (MateMixerControl *control, + GParamSpec *pspec, + MsdMediaKeysManager *manager) { - update_default_sink (manager); + update_default_output (manager); } static void -on_control_default_sink_changed (GvcMixerControl *control, - guint id, - MsdMediaKeysManager *manager) +on_control_default_output_notify (MateMixerControl *control, + GParamSpec *pspec, + MsdMediaKeysManager *manager) { - update_default_sink (manager); + update_default_output (manager); } static void -on_control_stream_removed (GvcMixerControl *control, - guint id, +on_control_stream_removed (MateMixerControl *control, + const gchar *name, MsdMediaKeysManager *manager) { if (manager->priv->stream != NULL) { - if (gvc_mixer_stream_get_id (manager->priv->stream) == id) { - g_object_unref (manager->priv->stream); - manager->priv->stream = NULL; - } + MateMixerStream *stream = + mate_mixer_control_get_stream (manager->priv->control, name); + + if (stream == manager->priv->stream) + g_clear_object (&manager->priv->stream); } } - -#endif /* HAVE_PULSE */ +#endif /* HAVE_LIBMATEMIXER */ static gint find_by_application (gconstpointer a, @@ -949,9 +895,9 @@ do_action (MsdMediaKeysManager *manager, case MUTE_KEY: case VOLUME_DOWN_KEY: case VOLUME_UP_KEY: -#if defined(HAVE_PULSE) || defined(HAVE_GSTREAMER) +#ifdef HAVE_LIBMATEMIXER do_sound_action (manager, type); -#endif /* HAVE_PULSE || HAVE_GSTREAMER */ +#endif break; case POWER_KEY: do_exit_action (manager); @@ -1127,43 +1073,34 @@ start_media_keys_idle_cb (MsdMediaKeysManager *manager) } gboolean -msd_media_keys_manager_start (MsdMediaKeysManager *manager, - GError **error) +msd_media_keys_manager_start (MsdMediaKeysManager *manager, GError **error) { mate_settings_profile_start (NULL); -#ifdef HAVE_PULSE - /* initialise Volume handler - * - * We do this one here to force checking gstreamer cache, etc. - * The rest (grabbing and setting the keys) can happen in an - * idle. - */ - mate_settings_profile_start ("gvc_mixer_control_new"); - - manager->priv->volume = gvc_mixer_control_new ("MATE Volume Control Media Keys"); - - g_signal_connect (manager->priv->volume, - "ready", - G_CALLBACK (on_control_ready), - manager); - g_signal_connect (manager->priv->volume, - "default-sink-changed", - G_CALLBACK (on_control_default_sink_changed), - manager); - g_signal_connect (manager->priv->volume, - "stream-removed", - G_CALLBACK (on_control_stream_removed), - manager); - - gvc_mixer_control_open (manager->priv->volume); - - mate_settings_profile_end ("gvc_mixer_control_new"); -#elif defined(HAVE_GSTREAMER) - mate_settings_profile_start ("acme_volume_new"); - manager->priv->volume = acme_volume_new (); - mate_settings_profile_end ("acme_volume_new"); -#endif /* HAVE_PULSE */ +#ifdef HAVE_LIBMATEMIXER + if (G_LIKELY (mate_mixer_is_initialized ())) { + mate_settings_profile_start ("mate_mixer_control_new"); + + manager->priv->control = mate_mixer_control_new (); + + g_signal_connect (manager->priv->control, + "notify::state", + G_CALLBACK (on_control_state_notify), + manager); + g_signal_connect (manager->priv->control, + "notify::default-output", + G_CALLBACK (on_control_default_output_notify), + manager); + g_signal_connect (manager->priv->control, + "stream-removed", + G_CALLBACK (on_control_stream_removed), + manager); + + mate_mixer_control_open (manager->priv->control); + + mate_settings_profile_end ("mate_mixer_control_new"); + } +#endif g_idle_add ((GSourceFunc) start_media_keys_idle_cb, manager); mate_settings_profile_end (NULL); @@ -1224,19 +1161,10 @@ msd_media_keys_manager_stop (MsdMediaKeysManager *manager) g_slist_free (priv->screens); priv->screens = NULL; -#ifdef HAVE_PULSE - if (priv->stream) { - g_object_unref (priv->stream); - priv->stream = NULL; - } -#endif /* HAVE_PULSE */ - -#if defined(HAVE_PULSE) || defined(HAVE_GSTREAMER) - if (priv->volume) { - g_object_unref (priv->volume); - priv->volume = NULL; - } -#endif /* defined(HAVE_PULSE) || defined(HAVE_GSTREAMER) */ +#ifdef HAVE_LIBMATEMIXER + g_clear_object (&priv->stream); + g_clear_object (&priv->control); +#endif if (priv->dialog != NULL) { gtk_widget_destroy (priv->dialog); diff --git a/plugins/media-keys/msd-media-keys-plugin.c b/plugins/media-keys/msd-media-keys-plugin.c index 93a805f..0b40418 100644 --- a/plugins/media-keys/msd-media-keys-plugin.c +++ b/plugins/media-keys/msd-media-keys-plugin.c @@ -20,8 +20,13 @@ #include "config.h" +#include <glib.h> #include <glib/gi18n-lib.h> -#include <gmodule.h> +#include <glib-object.h> + +#ifdef HAVE_LIBMATEMIXER +#include <libmatemixer/matemixer.h> +#endif #include "mate-settings-plugin.h" #include "msd-media-keys-plugin.h" @@ -70,11 +75,13 @@ static void impl_activate (MateSettingsPlugin *plugin) { gboolean res; - GError *error; + GError *error = NULL; g_debug ("Activating media_keys plugin"); - error = NULL; +#ifdef HAVE_LIBMATEMIXER + mate_mixer_init (); +#endif res = msd_media_keys_manager_start (MSD_MEDIA_KEYS_PLUGIN (plugin)->priv->manager, &error); if (! res) { g_warning ("Unable to start media_keys manager: %s", error->message); @@ -87,12 +94,16 @@ impl_deactivate (MateSettingsPlugin *plugin) { g_debug ("Deactivating media_keys plugin"); msd_media_keys_manager_stop (MSD_MEDIA_KEYS_PLUGIN (plugin)->priv->manager); + +#ifdef HAVE_LIBMATEMIXER + mate_mixer_deinit (); +#endif } static void msd_media_keys_plugin_class_init (MsdMediaKeysPluginClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); MateSettingsPluginClass *plugin_class = MATE_SETTINGS_PLUGIN_CLASS (klass); object_class->finalize = msd_media_keys_plugin_finalize; @@ -107,4 +118,3 @@ static void msd_media_keys_plugin_class_finalize (MsdMediaKeysPluginClass *klass) { } - |