From 8481ebdc843ec212e59f98c8ff5f718485f864c0 Mon Sep 17 00:00:00 2001 From: Michal Ratajsky Date: Thu, 3 Jul 2014 19:06:24 +0200 Subject: Remove GStreamer parts and use libmatemixer --- AUTHORS | 1 + NEWS | 7 +- configure.ac | 107 ++++---- plugins/media-keys/Makefile.am | 17 +- plugins/media-keys/msd-media-keys-manager.c | 370 +++++++++++----------------- plugins/media-keys/msd-media-keys-plugin.c | 20 +- 6 files changed, 222 insertions(+), 300 deletions(-) diff --git a/AUTHORS b/AUTHORS index 53aea91..d281e75 100644 --- a/AUTHORS +++ b/AUTHORS @@ -2,6 +2,7 @@ MATE: Perberos Steve Zesch Stefano Karapetsas +Michal Ratajsky GNOME: Jonathan Blandford diff --git a/NEWS b/NEWS index 829f3bc..8b0967e 100644 --- a/NEWS +++ b/NEWS @@ -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 #include +#ifdef HAVE_LIBMATEMIXER +#include +#endif + +#ifdef HAVE_LIBCANBERRA +#include +#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 -#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 #include -#include +#include + +#ifdef HAVE_LIBMATEMIXER +#include +#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) { } - -- cgit v1.2.1 From 1eadf051aed2cbf103e2e9653107339be01a5740 Mon Sep 17 00:00:00 2001 From: Michal Ratajsky Date: Sat, 5 Jul 2014 02:16:45 +0200 Subject: Clean things up a bit, update copyright, remove unused code, fix NEWS and compiler warnings --- NEWS | 4 +- plugins/media-keys/msd-media-keys-manager.c | 123 ++++------------------------ plugins/media-keys/msd-media-keys-manager.h | 22 ++--- plugins/media-keys/msd-media-keys-plugin.c | 21 ++--- plugins/media-keys/msd-media-keys-plugin.h | 29 ++++--- plugins/media-keys/msd-media-keys-window.c | 4 - plugins/media-keys/test-media-keys.c | 6 +- 7 files changed, 51 insertions(+), 158 deletions(-) diff --git a/NEWS b/NEWS index 8b0967e..a1ca7d9 100644 --- a/NEWS +++ b/NEWS @@ -1,7 +1,7 @@ 1.9.x * Port media-keys plugin to libmatemixer - * Remove GStreamer and PulseAudio dependencies, add optional dependency - on libmatemixer + * Remove GStreamer bits, make libmatemixer, libcanberra and PulseAudio + optional dependencies 1.8.0 * Add GTK3 support diff --git a/plugins/media-keys/msd-media-keys-manager.c b/plugins/media-keys/msd-media-keys-manager.c index 6c12274..a0e3ace 100644 --- a/plugins/media-keys/msd-media-keys-manager.c +++ b/plugins/media-keys/msd-media-keys-manager.c @@ -2,6 +2,7 @@ * * Copyright (C) 2001-2003 Bastien Nocera * Copyright (C) 2006-2007 William Jon McCann + * Copyright (C) 2014 Michal Ratajsky * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,16 +22,6 @@ #include "config.h" -#include -#include -#include -#include -#include -#include -#include - -#include - #include #include #include @@ -75,7 +66,7 @@ typedef struct { guint32 time; } MediaPlayer; -struct MsdMediaKeysManagerPrivate +struct _MsdMediaKeysManagerPrivate { #ifdef HAVE_LIBMATEMIXER /* Volume bits */ @@ -105,7 +96,6 @@ static guint signals[LAST_SIGNAL] = { 0 }; static void msd_media_keys_manager_class_init (MsdMediaKeysManagerClass *klass); static void msd_media_keys_manager_init (MsdMediaKeysManager *media_keys_manager); -static void msd_media_keys_manager_finalize (GObject *object); G_DEFINE_TYPE (MsdMediaKeysManager, msd_media_keys_manager, G_TYPE_OBJECT) @@ -1180,90 +1170,21 @@ msd_media_keys_manager_stop (MsdMediaKeysManager *manager) priv->media_players = NULL; } -static void -msd_media_keys_manager_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - MsdMediaKeysManager *self; - - self = MSD_MEDIA_KEYS_MANAGER (object); - - switch (prop_id) { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -msd_media_keys_manager_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - MsdMediaKeysManager *self; - - self = MSD_MEDIA_KEYS_MANAGER (object); - - switch (prop_id) { - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static GObject * -msd_media_keys_manager_constructor (GType type, - guint n_construct_properties, - GObjectConstructParam *construct_properties) -{ - MsdMediaKeysManager *media_keys_manager; - MsdMediaKeysManagerClass *klass; - - klass = MSD_MEDIA_KEYS_MANAGER_CLASS (g_type_class_peek (MSD_TYPE_MEDIA_KEYS_MANAGER)); - - media_keys_manager = MSD_MEDIA_KEYS_MANAGER (G_OBJECT_CLASS (msd_media_keys_manager_parent_class)->constructor (type, - n_construct_properties, - construct_properties)); - - return G_OBJECT (media_keys_manager); -} - -static void -msd_media_keys_manager_dispose (GObject *object) -{ - MsdMediaKeysManager *media_keys_manager; - - media_keys_manager = MSD_MEDIA_KEYS_MANAGER (object); - - G_OBJECT_CLASS (msd_media_keys_manager_parent_class)->dispose (object); -} - static void msd_media_keys_manager_class_init (MsdMediaKeysManagerClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); - - object_class->get_property = msd_media_keys_manager_get_property; - object_class->set_property = msd_media_keys_manager_set_property; - object_class->constructor = msd_media_keys_manager_constructor; - object_class->dispose = msd_media_keys_manager_dispose; - object_class->finalize = msd_media_keys_manager_finalize; - - signals[MEDIA_PLAYER_KEY_PRESSED] = - g_signal_new ("media-player-key-pressed", - G_OBJECT_CLASS_TYPE (klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (MsdMediaKeysManagerClass, media_player_key_pressed), - NULL, - NULL, - msd_marshal_VOID__STRING_STRING, - G_TYPE_NONE, - 2, - G_TYPE_STRING, - G_TYPE_STRING); + signals[MEDIA_PLAYER_KEY_PRESSED] = + g_signal_new ("media-player-key-pressed", + G_OBJECT_CLASS_TYPE (klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (MsdMediaKeysManagerClass, media_player_key_pressed), + NULL, + NULL, + msd_marshal_VOID__STRING_STRING, + G_TYPE_NONE, + 2, + G_TYPE_STRING, + G_TYPE_STRING); dbus_g_object_type_install_info (MSD_TYPE_MEDIA_KEYS_MANAGER, &dbus_glib_msd_media_keys_manager_object_info); @@ -1274,22 +1195,6 @@ static void msd_media_keys_manager_init (MsdMediaKeysManager *manager) { manager->priv = MSD_MEDIA_KEYS_MANAGER_GET_PRIVATE (manager); - -} - -static void -msd_media_keys_manager_finalize (GObject *object) -{ - MsdMediaKeysManager *media_keys_manager; - - g_return_if_fail (object != NULL); - g_return_if_fail (MSD_IS_MEDIA_KEYS_MANAGER (object)); - - media_keys_manager = MSD_MEDIA_KEYS_MANAGER (object); - - g_return_if_fail (media_keys_manager->priv != NULL); - - G_OBJECT_CLASS (msd_media_keys_manager_parent_class)->finalize (object); } static gboolean diff --git a/plugins/media-keys/msd-media-keys-manager.h b/plugins/media-keys/msd-media-keys-manager.h index 1bcabf2..2afb5bc 100644 --- a/plugins/media-keys/msd-media-keys-manager.h +++ b/plugins/media-keys/msd-media-keys-manager.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann + * Copyright (C) 2014 Michal Ratajsky * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,11 +22,10 @@ #ifndef __MSD_MEDIA_KEYS_MANAGER_H #define __MSD_MEDIA_KEYS_MANAGER_H +#include #include -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define MSD_TYPE_MEDIA_KEYS_MANAGER (msd_media_keys_manager_get_type ()) #define MSD_MEDIA_KEYS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MSD_TYPE_MEDIA_KEYS_MANAGER, MsdMediaKeysManager)) @@ -34,21 +34,23 @@ extern "C" { #define MSD_IS_MEDIA_KEYS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MSD_TYPE_MEDIA_KEYS_MANAGER)) #define MSD_MEDIA_KEYS_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MSD_TYPE_MEDIA_KEYS_MANAGER, MsdMediaKeysManagerClass)) -typedef struct MsdMediaKeysManagerPrivate MsdMediaKeysManagerPrivate; +typedef struct _MsdMediaKeysManager MsdMediaKeysManager; +typedef struct _MsdMediaKeysManagerClass MsdMediaKeysManagerClass; +typedef struct _MsdMediaKeysManagerPrivate MsdMediaKeysManagerPrivate; -typedef struct +struct _MsdMediaKeysManager { GObject parent; MsdMediaKeysManagerPrivate *priv; -} MsdMediaKeysManager; +}; -typedef struct +struct _MsdMediaKeysManagerClass { GObjectClass parent_class; void (* media_player_key_pressed) (MsdMediaKeysManager *manager, const char *application, const char *key); -} MsdMediaKeysManagerClass; +}; GType msd_media_keys_manager_get_type (void); @@ -65,8 +67,6 @@ gboolean msd_media_keys_manager_release_media_player_keys (MsdMedia const char *application, GError **error); -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __MSD_MEDIA_KEYS_MANAGER_H */ diff --git a/plugins/media-keys/msd-media-keys-plugin.c b/plugins/media-keys/msd-media-keys-plugin.c index 0b40418..28134b2 100644 --- a/plugins/media-keys/msd-media-keys-plugin.c +++ b/plugins/media-keys/msd-media-keys-plugin.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann + * Copyright (C) 2014 Michal Ratajsky * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -32,7 +33,8 @@ #include "msd-media-keys-plugin.h" #include "msd-media-keys-manager.h" -struct MsdMediaKeysPluginPrivate { +struct _MsdMediaKeysPluginPrivate +{ MsdMediaKeysManager *manager; }; @@ -51,24 +53,17 @@ msd_media_keys_plugin_init (MsdMediaKeysPlugin *plugin) } static void -msd_media_keys_plugin_finalize (GObject *object) +msd_media_keys_plugin_dispose (GObject *object) { MsdMediaKeysPlugin *plugin; - g_return_if_fail (object != NULL); - g_return_if_fail (MSD_IS_MEDIA_KEYS_PLUGIN (object)); - - g_debug ("MsdMediaKeysPlugin finalizing"); + g_debug ("MsdMediaKeysPlugin disposing"); plugin = MSD_MEDIA_KEYS_PLUGIN (object); - g_return_if_fail (plugin->priv != NULL); - - if (plugin->priv->manager != NULL) { - g_object_unref (plugin->priv->manager); - } + g_clear_object (&plugin->priv->manager); - G_OBJECT_CLASS (msd_media_keys_plugin_parent_class)->finalize (object); + G_OBJECT_CLASS (msd_media_keys_plugin_parent_class)->dispose (object); } static void @@ -106,7 +101,7 @@ msd_media_keys_plugin_class_init (MsdMediaKeysPluginClass *klass) GObjectClass *object_class = G_OBJECT_CLASS (klass); MateSettingsPluginClass *plugin_class = MATE_SETTINGS_PLUGIN_CLASS (klass); - object_class->finalize = msd_media_keys_plugin_finalize; + object_class->dispose = msd_media_keys_plugin_dispose; plugin_class->activate = impl_activate; plugin_class->deactivate = impl_deactivate; diff --git a/plugins/media-keys/msd-media-keys-plugin.h b/plugins/media-keys/msd-media-keys-plugin.h index dee322f..0662009 100644 --- a/plugins/media-keys/msd-media-keys-plugin.h +++ b/plugins/media-keys/msd-media-keys-plugin.h @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * * Copyright (C) 2007 William Jon McCann + * Copyright (C) 2014 Michal Ratajsky * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,9 +28,7 @@ #include "mate-settings-plugin.h" -#ifdef __cplusplus -extern "C" { -#endif +G_BEGIN_DECLS #define MSD_TYPE_MEDIA_KEYS_PLUGIN (msd_media_keys_plugin_get_type ()) #define MSD_MEDIA_KEYS_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MSD_TYPE_MEDIA_KEYS_PLUGIN, MsdMediaKeysPlugin)) @@ -38,26 +37,26 @@ extern "C" { #define MSD_IS_MEDIA_KEYS_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), MSD_TYPE_MEDIA_KEYS_PLUGIN)) #define MSD_MEDIA_KEYS_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), MSD_TYPE_MEDIA_KEYS_PLUGIN, MsdMediaKeysPluginClass)) -typedef struct MsdMediaKeysPluginPrivate MsdMediaKeysPluginPrivate; +typedef struct _MsdMediaKeysPlugin MsdMediaKeysPlugin; +typedef struct _MsdMediaKeysPluginClass MsdMediaKeysPluginClass; +typedef struct _MsdMediaKeysPluginPrivate MsdMediaKeysPluginPrivate; -typedef struct +struct _MsdMediaKeysPlugin { - MateSettingsPlugin parent; - MsdMediaKeysPluginPrivate *priv; -} MsdMediaKeysPlugin; + MateSettingsPlugin parent; + MsdMediaKeysPluginPrivate *priv; +}; -typedef struct +struct _MsdMediaKeysPluginClass { - MateSettingsPluginClass parent_class; -} MsdMediaKeysPluginClass; + MateSettingsPluginClass parent_class; +}; -GType msd_media_keys_plugin_get_type (void) G_GNUC_CONST; +GType msd_media_keys_plugin_get_type (void) G_GNUC_CONST; /* All the plugins must implement this function */ G_MODULE_EXPORT GType register_mate_settings_plugin (GTypeModule *module); -#ifdef __cplusplus -} -#endif +G_END_DECLS #endif /* __MSD_MEDIA_KEYS_PLUGIN_H__ */ diff --git a/plugins/media-keys/msd-media-keys-window.c b/plugins/media-keys/msd-media-keys-window.c index 9281a9e..7dde696 100644 --- a/plugins/media-keys/msd-media-keys-window.c +++ b/plugins/media-keys/msd-media-keys-window.c @@ -683,12 +683,8 @@ msd_media_keys_window_class_init (MsdMediaKeysWindowClass *klass) static void msd_media_keys_window_init (MsdMediaKeysWindow *window) { - GdkScreen *screen; - window->priv = MSD_MEDIA_KEYS_WINDOW_GET_PRIVATE (window); - screen = gtk_widget_get_screen (GTK_WIDGET (window)); - if (!msd_osd_window_is_composited (MSD_OSD_WINDOW (window))) { GtkBuilder *builder; const gchar *objects[] = {"acme_box", NULL}; diff --git a/plugins/media-keys/test-media-keys.c b/plugins/media-keys/test-media-keys.c index ce1e18a..51ea1e3 100644 --- a/plugins/media-keys/test-media-keys.c +++ b/plugins/media-keys/test-media-keys.c @@ -35,8 +35,7 @@ int main (int argc, char **argv) { - GError *error; - gboolean res; + GError *error = NULL; #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, MATE_SETTINGS_LOCALEDIR); @@ -46,7 +45,6 @@ main (int argc, textdomain (GETTEXT_PACKAGE); #endif - error = NULL; if (! gtk_init_with_args (&argc, &argv, NULL, NULL, NULL, &error)) { fprintf (stderr, "%s", error->message); g_error_free (error); @@ -56,7 +54,7 @@ main (int argc, manager = msd_media_keys_manager_new (); error = NULL; - res = msd_media_keys_manager_start (manager, &error); + msd_media_keys_manager_start (manager, &error); gtk_main (); -- cgit v1.2.1 From 3b519db084df2ad290cd897b1317daf7f53c05e4 Mon Sep 17 00:00:00 2001 From: Michal Ratajsky Date: Mon, 18 Aug 2014 21:17:09 +0200 Subject: Update to libmatemixer changes --- plugins/media-keys/msd-media-keys-manager.c | 80 +++++++++++++++++------------ plugins/media-keys/msd-media-keys-plugin.c | 4 -- 2 files changed, 46 insertions(+), 38 deletions(-) diff --git a/plugins/media-keys/msd-media-keys-manager.c b/plugins/media-keys/msd-media-keys-manager.c index a0e3ace..87f67d1 100644 --- a/plugins/media-keys/msd-media-keys-manager.c +++ b/plugins/media-keys/msd-media-keys-manager.c @@ -70,8 +70,9 @@ struct _MsdMediaKeysManagerPrivate { #ifdef HAVE_LIBMATEMIXER /* Volume bits */ - MateMixerControl *control; - MateMixerStream *stream; + MateMixerContext *context; + MateMixerStream *stream; + MateMixerStreamControl *control; #endif GtkWidget *dialog; GSettings *settings; @@ -639,13 +640,13 @@ do_sound_action (MsdMediaKeysManager *manager, int type) guint volume_step; guint volume_last; - if (manager->priv->stream == NULL) + if (manager->priv->control == NULL) return; /* 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); + volume_min = mate_mixer_stream_control_get_min_volume (manager->priv->control); + volume_max = mate_mixer_stream_control_get_normal_volume (manager->priv->control); volume_step = g_settings_get_int (manager->priv->settings, "volume-step"); if (volume_step <= 0 || @@ -656,9 +657,9 @@ do_sound_action (MsdMediaKeysManager *manager, int type) volume_step = (volume_max - volume_min) * volume_step / 100; volume = volume_last = - mate_mixer_stream_get_volume (manager->priv->stream); + mate_mixer_stream_control_get_volume (manager->priv->control); muted = muted_last = - mate_mixer_stream_get_mute (manager->priv->stream); + mate_mixer_stream_control_get_mute (manager->priv->control); switch (type) { case MUTE_KEY: @@ -685,14 +686,16 @@ do_sound_action (MsdMediaKeysManager *manager, int type) break; } + g_print ("muted=%d muted_last=%d\n", muted,muted_last); + if (muted != muted_last) { - if (mate_mixer_stream_set_mute (manager->priv->stream, muted)) + if (mate_mixer_stream_control_set_mute (manager->priv->control, 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)) + if (volume != mate_mixer_stream_control_get_volume (manager->priv->control)) { + if (mate_mixer_stream_control_set_volume (manager->priv->control, volume)) sound_changed = TRUE; else volume = volume_last; @@ -707,32 +710,38 @@ do_sound_action (MsdMediaKeysManager *manager, int type) static void update_default_output (MsdMediaKeysManager *manager) { - MateMixerStream *stream; + MateMixerStream *stream; + MateMixerStreamControl *control = NULL; + + stream = mate_mixer_context_get_default_output_stream (manager->priv->context); + if (stream != NULL) + control = mate_mixer_stream_get_default_control (stream); - stream = mate_mixer_control_get_default_output_stream (manager->priv->control); if (stream == manager->priv->stream) return; g_clear_object (&manager->priv->stream); + g_clear_object (&manager->priv->control); - if (stream != NULL) { - MateMixerStreamFlags flags = mate_mixer_stream_get_flags (stream); + if (control != NULL) { + MateMixerStreamControlFlags flags = mate_mixer_stream_control_get_flags (control); /* 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)) + if (!(flags & MATE_MIXER_STREAM_CONTROL_MUTE_WRITABLE) && + !(flags & MATE_MIXER_STREAM_CONTROL_VOLUME_WRITABLE)) return; - manager->priv->stream = g_object_ref (stream); + manager->priv->stream = g_object_ref (stream); + manager->priv->control = g_object_ref (control); g_debug ("Default output stream updated to %s", - mate_mixer_stream_get_name (manager->priv->stream)); + mate_mixer_stream_get_name (stream)); } else g_debug ("Default output stream unset"); } static void -on_control_state_notify (MateMixerControl *control, +on_context_state_notify (MateMixerContext *context, GParamSpec *pspec, MsdMediaKeysManager *manager) { @@ -740,7 +749,7 @@ on_control_state_notify (MateMixerControl *control, } static void -on_control_default_output_notify (MateMixerControl *control, +on_context_default_output_notify (MateMixerContext *context, GParamSpec *pspec, MsdMediaKeysManager *manager) { @@ -748,16 +757,18 @@ on_control_default_output_notify (MateMixerControl *control, } static void -on_control_stream_removed (MateMixerControl *control, +on_context_stream_removed (MateMixerContext *context, const gchar *name, MsdMediaKeysManager *manager) { if (manager->priv->stream != NULL) { MateMixerStream *stream = - mate_mixer_control_get_stream (manager->priv->control, name); + mate_mixer_context_get_stream (manager->priv->context, name); - if (stream == manager->priv->stream) + if (stream == manager->priv->stream) { g_clear_object (&manager->priv->stream); + g_clear_object (&manager->priv->control); + } } } #endif /* HAVE_LIBMATEMIXER */ @@ -1069,26 +1080,26 @@ msd_media_keys_manager_start (MsdMediaKeysManager *manager, GError **error) #ifdef HAVE_LIBMATEMIXER if (G_LIKELY (mate_mixer_is_initialized ())) { - mate_settings_profile_start ("mate_mixer_control_new"); + mate_settings_profile_start ("mate_mixer_context_new"); - manager->priv->control = mate_mixer_control_new (); + manager->priv->context = mate_mixer_context_new (); - g_signal_connect (manager->priv->control, + g_signal_connect (manager->priv->context, "notify::state", - G_CALLBACK (on_control_state_notify), + G_CALLBACK (on_context_state_notify), manager); - g_signal_connect (manager->priv->control, - "notify::default-output", - G_CALLBACK (on_control_default_output_notify), + g_signal_connect (manager->priv->context, + "notify::default-output-stream", + G_CALLBACK (on_context_default_output_notify), manager); - g_signal_connect (manager->priv->control, + g_signal_connect (manager->priv->context, "stream-removed", - G_CALLBACK (on_control_stream_removed), + G_CALLBACK (on_context_stream_removed), manager); - mate_mixer_control_open (manager->priv->control); + mate_mixer_context_open (manager->priv->context); - mate_settings_profile_end ("mate_mixer_control_new"); + mate_settings_profile_end ("mate_mixer_context_new"); } #endif g_idle_add ((GSourceFunc) start_media_keys_idle_cb, manager); @@ -1154,6 +1165,7 @@ msd_media_keys_manager_stop (MsdMediaKeysManager *manager) #ifdef HAVE_LIBMATEMIXER g_clear_object (&priv->stream); g_clear_object (&priv->control); + g_clear_object (&priv->context); #endif if (priv->dialog != NULL) { diff --git a/plugins/media-keys/msd-media-keys-plugin.c b/plugins/media-keys/msd-media-keys-plugin.c index 28134b2..3cce9d2 100644 --- a/plugins/media-keys/msd-media-keys-plugin.c +++ b/plugins/media-keys/msd-media-keys-plugin.c @@ -89,10 +89,6 @@ 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 -- cgit v1.2.1 From eb996b39801092f4548497aba20e88400f4a9ae0 Mon Sep 17 00:00:00 2001 From: Michal Ratajsky Date: Wed, 20 Aug 2014 21:42:50 +0200 Subject: Remove debugging message --- plugins/media-keys/msd-media-keys-manager.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/media-keys/msd-media-keys-manager.c b/plugins/media-keys/msd-media-keys-manager.c index 87f67d1..d7033ff 100644 --- a/plugins/media-keys/msd-media-keys-manager.c +++ b/plugins/media-keys/msd-media-keys-manager.c @@ -686,8 +686,6 @@ do_sound_action (MsdMediaKeysManager *manager, int type) break; } - g_print ("muted=%d muted_last=%d\n", muted,muted_last); - if (muted != muted_last) { if (mate_mixer_stream_control_set_mute (manager->priv->control, muted)) sound_changed = TRUE; -- cgit v1.2.1 From be56b0f8f8ef77296fe12c73985785874dc896c2 Mon Sep 17 00:00:00 2001 From: Michal Ratajsky Date: Thu, 21 Aug 2014 01:28:05 +0200 Subject: Unmute when lowering volume and the target volume is higher than minimal --- plugins/media-keys/msd-media-keys-manager.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/media-keys/msd-media-keys-manager.c b/plugins/media-keys/msd-media-keys-manager.c index d7033ff..1ff0291 100644 --- a/plugins/media-keys/msd-media-keys-manager.c +++ b/plugins/media-keys/msd-media-keys-manager.c @@ -653,7 +653,7 @@ do_sound_action (MsdMediaKeysManager *manager, int type) volume_step > 100) volume_step = VOLUME_STEP; - /* Scale the volume step size accordingly to the range used by the stream */ + /* Scale the volume step size accordingly to the range used by the control */ volume_step = (volume_max - volume_min) * volume_step / 100; volume = volume_last = @@ -666,12 +666,12 @@ do_sound_action (MsdMediaKeysManager *manager, int type) muted = !muted; break; case VOLUME_DOWN_KEY: - if (!muted) { - if (volume <= (volume_min + volume_step)) { - volume = volume_min; - muted = TRUE; - } else - volume -= volume_step; + if (volume <= (volume_min + volume_step)) { + volume = volume_min; + muted = TRUE; + } else { + volume -= volume_step; + muted = FALSE; } break; case VOLUME_UP_KEY: -- cgit v1.2.1