svn commit: r456640 - in head/audio/volumeicon: . files
Lars Engels
lme at FreeBSD.org
Mon Dec 18 16:25:34 UTC 2017
Author: lme
Date: Mon Dec 18 16:25:32 2017
New Revision: 456640
URL: https://svnweb.freebsd.org/changeset/ports/456640
Log:
audio/volumeicon:
- Add OSS v3 backend [1]
- Fix mixer channel selection in Preferences/Channels
- Bump PORTREVISION
[1] Upstream PR: https://github.com/Maato/volumeicon/pull/70
Submitted by: Dmitri Goutnik
Added:
head/audio/volumeicon/files/patch-configure.ac (contents, props changed)
head/audio/volumeicon/files/patch-src_Makefile.am (contents, props changed)
head/audio/volumeicon/files/patch-src_oss3__backend.c (contents, props changed)
Modified:
head/audio/volumeicon/Makefile
head/audio/volumeicon/files/patch-data_gui_preferences.ui
head/audio/volumeicon/files/patch-src_oss__backend.c
head/audio/volumeicon/files/patch-src_oss__backend.h
head/audio/volumeicon/files/patch-src_volumeicon.c
Modified: head/audio/volumeicon/Makefile
==============================================================================
--- head/audio/volumeicon/Makefile Mon Dec 18 15:44:57 2017 (r456639)
+++ head/audio/volumeicon/Makefile Mon Dec 18 16:25:32 2017 (r456640)
@@ -2,6 +2,7 @@
PORTNAME= volumeicon
PORTVERSION= 0.5.1
+PORTREVISION= 1
CATEGORIES= audio
MAINTAINER= lme at FreeBSD.org
@@ -10,7 +11,7 @@ COMMENT= Lightweight volume control for the systray
LICENSE= GPLv3
GNU_CONFIGURE= yes
-CONFIGURE_ARGS= --enable-oss \
+CONFIGURE_ARGS= --enable-oss=v3 \
--with-oss-include-path=/usr/include/sys
CPPFLAGS+= -I${LOCALBASE}/include
LIBS+= -L${LOCALBASE}/lib
Added: head/audio/volumeicon/files/patch-configure.ac
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/audio/volumeicon/files/patch-configure.ac Mon Dec 18 16:25:32 2017 (r456640)
@@ -0,0 +1,20 @@
+--- configure.ac.orig 2015-03-02 23:54:36.000000000 +0100
++++ configure.ac 2017-12-18 17:23:45.215876000 +0100
+@@ -86,14 +86,15 @@ fi
+ if test "x${notify}" = xyes; then
+ # Check for libnotify
+ PKG_CHECK_MODULES([NOTIFY], [libnotify >= 0.5.0])
+-NOTIFY_CFLAGS+="-DCOMPILEWITH_NOTIFY"
++NOTIFY_CFLAGS="-DCOMPILEWITH_NOTIFY"
+ AC_SUBST(NOTIFY_CFLAGS)
+ AC_SUBST(NOTIFY_LIBS)
+ fi
+
+ AC_SUBST(OSS_CFLAGS)
+
+-AM_CONDITIONAL(ENABLE_OSS, test "$oss" = "yes")
++AM_CONDITIONAL(ENABLE_OSS4, test "x${oss}" = xyes -o "x${oss}" = xv4)
++AM_CONDITIONAL(ENABLE_OSS3, test "x${oss}" = xv3)
+
+ DEFAULT_MIXERAPP="xterm -e 'alsamixer'"
+ AC_ARG_WITH(default-mixerapp,
Modified: head/audio/volumeicon/files/patch-data_gui_preferences.ui
==============================================================================
--- head/audio/volumeicon/files/patch-data_gui_preferences.ui Mon Dec 18 15:44:57 2017 (r456639)
+++ head/audio/volumeicon/files/patch-data_gui_preferences.ui Mon Dec 18 16:25:32 2017 (r456640)
@@ -1,5 +1,5 @@
---- data/gui/preferences.ui.orig 2017-12-12 18:43:30 UTC
-+++ data/gui/preferences.ui
+--- data/gui/preferences.ui.orig 2015-03-02 23:54:36.000000000 +0100
++++ data/gui/preferences.ui 2017-12-18 17:23:45.219716000 +0100
@@ -197,7 +197,7 @@
<object class="GtkLabel" id="label5">
<property name="visible">True</property>
Added: head/audio/volumeicon/files/patch-src_Makefile.am
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/audio/volumeicon/files/patch-src_Makefile.am Mon Dec 18 16:25:32 2017 (r456640)
@@ -0,0 +1,19 @@
+--- src/Makefile.am.orig 2015-03-02 23:54:36.000000000 +0100
++++ src/Makefile.am 2017-12-18 17:23:45.222731000 +0100
+@@ -5,11 +5,15 @@ LIBS = @GTK_LIBS@ @ALSA_LIBS@ @X11_LIBS@
+
+ bin_PROGRAMS = volumeicon
+
+-if ENABLE_OSS
++if ENABLE_OSS4
+ BACKEND = oss_backend.c oss_backend.h
+ else
++if ENABLE_OSS3
++BACKEND = oss3_backend.c oss_backend.h
++else
+ BACKEND = alsa_backend.c alsa_backend.h alsa_volume_mapping.h alsa_volume_mapping.c
+ endif
++endif
+
+ volumeicon_SOURCES = \
+ volumeicon.c \
Added: head/audio/volumeicon/files/patch-src_oss3__backend.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/audio/volumeicon/files/patch-src_oss3__backend.c Mon Dec 18 16:25:32 2017 (r456640)
@@ -0,0 +1,188 @@
+--- src/oss3_backend.c.orig 2017-12-18 17:23:45.225185000 +0100
++++ src/oss3_backend.c 2017-12-18 17:23:57.906175000 +0100
+@@ -0,0 +1,185 @@
++//
++// Copyright (c) 2011 Maato <maato at softwarebakery.com>
++// Copyright (c) 2017 Dmitri Goutnik <dg at syrec.org>
++// All rights reserved.
++//
++// Redistribution and use in source and binary forms, with or without
++// modification, are permitted provided that the following conditions
++// are met:
++// 1. Redistributions of source code must retain the above copyright
++// notice, this list of conditions and the following disclaimer
++// in this position and unchanged.
++// 2. Redistributions in binary form must reproduce the above copyright
++// notice, this list of conditions and the following disclaimer in the
++// documentation and/or other materials provided with the distribution.
++//
++// THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
++// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
++// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
++// IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
++// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
++// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
++// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++//
++
++#include OSS_HEADER
++#include <sys/soundcard.h>
++#include <fcntl.h>
++#include <assert.h>
++#include <stdlib.h>
++#include <stdio.h>
++#include <glib.h>
++
++#include "oss_backend.h"
++
++static const char *channel_labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES;
++static int m_mixer_fd = -1;
++static GList *m_channel_names = NULL;
++static char *m_channel;
++static int m_channel_dev = 0;
++static char *m_device = NULL;
++static GList *m_device_names = NULL;
++
++void
++oss_setup(const gchar *card, const gchar *channel, void (*volume_changed) (int, gboolean))
++{
++ // Make sure (for now) that the setup function only gets called once
++ static int oss_setup_called = 0;
++ assert(oss_setup_called == 0);
++ oss_setup_called++;
++
++ g_list_free_full(m_channel_names, g_free);
++ m_channel_names = NULL;
++ g_list_free_full(m_device_names, g_free);
++ m_device_names = NULL;
++
++ g_free(m_device);
++ m_device = g_strdup(card);
++ m_device_names = g_list_append(m_device_names, g_strdup(m_device));
++
++ // Get ahold of the mixer device
++ char *devmixer;
++ if ((devmixer = getenv("OSS_MIXERDEV")) == NULL)
++ devmixer = "/dev/mixer";
++ if ((m_mixer_fd = open(devmixer, O_RDWR)) == -1) {
++ perror("Cannot open mixer");
++ exit(EXIT_FAILURE);
++ }
++
++ // Query mixer devices
++ int devmask = 0;
++ if (ioctl(m_mixer_fd, SOUND_MIXER_READ_DEVMASK, &devmask) == -1) {
++ perror("Cannot query devices");
++ exit(EXIT_FAILURE);
++ }
++
++ // Pupulate channel list
++ for (int i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
++ if (!((1 << i) & devmask))
++ continue;
++ m_channel_names = g_list_append(m_channel_names, g_strdup(channel_labels[i]));
++ }
++
++ // Setup channel using the provided channel name
++ if (channel != NULL)
++ oss_set_channel(channel);
++ else if (channel == NULL && m_channel_names != NULL)
++ oss_set_channel((const gchar *)m_channel_names->data);
++}
++
++const gchar *
++oss_get_channel()
++{
++ return m_channel;
++}
++
++void
++oss_set_channel(const gchar *channel)
++{
++ assert(channel != NULL);
++ assert(m_mixer_fd != -1);
++
++ if (g_strcmp0(channel, m_channel) == 0)
++ return;
++
++ // Find channel dev index
++ int i;
++ for (i = 0; i < SOUND_MIXER_NRDEVICES; i++)
++ if (g_strcmp0(channel, channel_labels[i]) == 0)
++ break;
++
++ if (i < SOUND_MIXER_NRDEVICES) {
++ g_free(m_channel);
++ m_channel = g_strdup(channel);
++ m_channel_dev = i;
++ }
++}
++
++const gchar *
++oss_get_device()
++{
++ return m_device;
++}
++
++const GList *
++oss_get_channel_names()
++{
++ return m_channel_names;
++}
++
++const GList *
++oss_get_device_names()
++{
++ return m_device_names;
++}
++
++int
++oss_get_volume()
++{
++ assert(m_mixer_fd != -1);
++
++ int current_volume;
++ if (ioctl(m_mixer_fd, MIXER_READ(m_channel_dev), ¤t_volume) == -1) {
++ perror("Cannot read volume");
++ exit(EXIT_FAILURE);
++ }
++
++ // Only the left channel is returned
++ return current_volume & 0x7f;
++}
++
++void
++oss_set_volume(int volume)
++{
++ assert(m_mixer_fd != -1);
++ volume = (volume < 0 ? 0 : (volume > 100 ? 100 : volume));
++
++ volume = (volume << 8) | volume;
++ if (ioctl(m_mixer_fd, MIXER_WRITE(m_channel_dev), &volume) == -1) {
++ perror("Cannot write volume");
++ exit(EXIT_FAILURE);
++ }
++}
++
++gboolean
++oss_get_mute()
++{
++ assert(m_mixer_fd != -1);
++
++ // TODO: see if there's a way to return real mute state
++ return oss_get_volume() == 0;
++}
++
++void
++oss_set_mute(gboolean mute)
++{
++ assert(m_mixer_fd != -1);
++
++ // TODO: see if there's a way to toggle real mute
++ if (mute) {
++ oss_set_volume(0);
++ }
++}
Modified: head/audio/volumeicon/files/patch-src_oss__backend.c
==============================================================================
--- head/audio/volumeicon/files/patch-src_oss__backend.c Mon Dec 18 15:44:57 2017 (r456639)
+++ head/audio/volumeicon/files/patch-src_oss__backend.c Mon Dec 18 16:25:32 2017 (r456640)
@@ -1,183 +1,9 @@
---- src/oss_backend.c.orig 2015-03-02 22:54:36 UTC
-+++ src/oss_backend.c
-@@ -22,7 +22,7 @@
- //##############################################################################
-
- #include OSS_HEADER
--#include <stropts.h>
-+#include <sys/soundcard.h>
- #include <fcntl.h>
- #include <assert.h>
- #include <stdlib.h>
-@@ -30,12 +30,16 @@
-
- #include "oss_backend.h"
-
-+#define MIXT_MONOSLIDER16 19
-+#define MIXT_STEREOSLIDER16 20
-+#define MIXT_MUTE 21
-+
- //##############################################################################
- // Static variables
- //##############################################################################
- static char * m_channel = NULL;
- static GList * m_channel_names = NULL;
--static int m_actual_maxvalue = 0;
-+//static int m_actual_maxvalue = 0;
- static int m_mixer_fd = -1;
- static oss_mixext m_ext;
-
-@@ -44,6 +48,7 @@ static oss_mixext m_ext;
- //##############################################################################
- static int get_raw_value()
- {
-+#if 0
- assert(m_mixer_fd != -1);
-
- oss_mixer_value vr;
-@@ -51,7 +56,7 @@ static int get_raw_value()
- vr.ctrl = m_ext.ctrl;
- vr.timestamp = m_ext.timestamp;
-
-- int result = ioctl(m_mixer_fd, SNDCTL_MIX_READ, &vr);
-+ int result = ioctl(m_mixer_fd, SOUND_MIXER_READ_VOLUME, &vr);
- if(result == -1)
- return 0;
-
-@@ -78,6 +83,7 @@ static int get_raw_value()
- return short_value->lower;
- }
-
-+#endif
- return 0;
- }
-
-@@ -97,9 +103,20 @@ const GList * oss_get_channel_names()
- int oss_get_volume()
- {
- assert(m_mixer_fd != -1);
-+#if 0
- if(m_actual_maxvalue == 0)
- return 0;
- return 100 * get_raw_value() / m_actual_maxvalue;
-+#endif
-+
-+ int current_volume;
-+ if (ioctl(m_mixer_fd, SOUND_MIXER_READ_VOLUME, ¤t_volume) == -1) {
-+ perror("Cannot read volume!");
-+ exit(EXIT_FAILURE);
-+ }
-+
-+ /* Only the left channel is returned */
-+ return current_volume & 0x7f;
- }
-
- gboolean oss_get_mute()
-@@ -108,6 +125,7 @@ gboolean oss_get_mute()
-
- gboolean mute = FALSE;
-
-+#if 0
- // Save current control;
- int parent = m_ext.parent;
- int control = m_ext.ctrl;
-@@ -132,6 +150,7 @@ gboolean oss_get_mute()
- // Restore to previous control
- m_ext.ctrl = control;
- ioctl(m_mixer_fd, SNDCTL_MIX_EXTINFO, &m_ext);
-+#endif
-
- return mute;
- }
-@@ -148,12 +167,13 @@ void oss_setup(const gchar * card, const
- char * devmixer;
- if((devmixer=getenv("OSS_MIXERDEV")) == NULL)
- devmixer = "/dev/mixer";
-- if((m_mixer_fd = open(devmixer, O_RDWR, 0)) == -1)
-+ if((m_mixer_fd = open(devmixer, O_RDWR)) == -1)
- {
- perror(devmixer);
- exit(1);
- }
-
-+#if 0
- // Check that there is at least one mixer
- int nmix;
- ioctl(m_mixer_fd, SNDCTL_MIX_NRMIX, &nmix);
-@@ -163,6 +183,7 @@ void oss_setup(const gchar * card, const
- exit(EXIT_FAILURE);
- }
-
-+
- m_ext.dev=0;
- m_ext.ctrl = 0;
- while(ioctl(m_mixer_fd, SNDCTL_MIX_EXTINFO, &m_ext) >= 0)
-@@ -175,6 +196,7 @@ void oss_setup(const gchar * card, const
- }
- m_ext.ctrl++;
- }
-+#endif
-
- // Setup channel using the provided channelname
- if(channel != NULL)
-@@ -195,6 +217,7 @@ void oss_set_channel(const gchar * chann
- g_free(m_channel);
- m_channel = g_strdup(channel);
-
-+#if 0
- // Find channel and then return
- m_ext.dev=0;
- m_ext.ctrl = 0;
-@@ -207,6 +230,7 @@ void oss_set_channel(const gchar * chann
- }
- m_ext.ctrl++;
- }
-+#endif
- }
-
- void oss_set_mute(gboolean mute)
-@@ -219,6 +243,7 @@ void oss_set_mute(gboolean mute)
-
- // Check for mute in this group
- m_ext.ctrl = 0;
-+#if 0
- while(ioctl(m_mixer_fd, SNDCTL_MIX_EXTINFO, &m_ext) >= 0)
- {
- if(m_ext.parent == parent && m_ext.type == MIXT_MUTE)
-@@ -239,6 +264,7 @@ void oss_set_mute(gboolean mute)
- m_ext.ctrl = control;
- ioctl(m_mixer_fd, SNDCTL_MIX_EXTINFO, &m_ext);
-
-+#endif
- // If no mute control was found, revert to setting the volume to zero
- if(!mute_found && mute)
- {
-@@ -251,6 +277,7 @@ void oss_set_volume(int volume)
- assert(m_mixer_fd != -1);
- volume = (volume < 0 ? 0 : (volume > 100 ? 100 : volume));
-
-+#if 0
- oss_mixer_value vr;
- vr.dev = m_ext.dev;
- vr.ctrl = m_ext.ctrl;
-@@ -286,9 +313,24 @@ void oss_set_volume(int volume)
- default:
- return;
- }
--
-- ioctl(m_mixer_fd, SNDCTL_MIX_WRITE, &vr);
--
-+#endif
-+ volume = (volume << 8) | volume;
-+ if(ioctl(m_mixer_fd, SOUND_MIXER_WRITE_VOLUME, &volume) == -1) {
-+ perror("Mixer write failed");
-+ exit(EXIT_FAILURE);
-+ }
-+#if 0
+--- src/oss_backend.c.orig 2015-03-02 23:54:36.000000000 +0100
++++ src/oss_backend.c 2017-12-18 17:23:45.230183000 +0100
+@@ -292,3 +292,13 @@ void oss_set_volume(int volume)
if(volume == 100)
m_actual_maxvalue = get_raw_value();
-+#endif
-+}
+ }
+
+const gchar * oss_get_device()
+{
@@ -187,4 +13,4 @@
+const GList * oss_get_device_names()
+{
+ return NULL;
- }
++}
Modified: head/audio/volumeicon/files/patch-src_oss__backend.h
==============================================================================
--- head/audio/volumeicon/files/patch-src_oss__backend.h Mon Dec 18 15:44:57 2017 (r456639)
+++ head/audio/volumeicon/files/patch-src_oss__backend.h Mon Dec 18 16:25:32 2017 (r456640)
@@ -1,5 +1,5 @@
---- src/oss_backend.h.orig 2015-03-02 22:54:36 UTC
-+++ src/oss_backend.h
+--- src/oss_backend.h.orig 2015-03-02 23:54:36.000000000 +0100
++++ src/oss_backend.h 2017-12-18 17:23:45.233327000 +0100
@@ -35,5 +35,7 @@ int oss_get_volume();
gboolean oss_get_mute();
const gchar * oss_get_channel();
Modified: head/audio/volumeicon/files/patch-src_volumeicon.c
==============================================================================
--- head/audio/volumeicon/files/patch-src_volumeicon.c Mon Dec 18 15:44:57 2017 (r456639)
+++ head/audio/volumeicon/files/patch-src_volumeicon.c Mon Dec 18 16:25:32 2017 (r456640)
@@ -1,5 +1,5 @@
---- src/volumeicon.c.orig 2015-03-02 22:54:36 UTC
-+++ src/volumeicon.c
+--- src/volumeicon.c.orig 2015-03-02 23:54:36.000000000 +0100
++++ src/volumeicon.c 2017-12-18 17:23:45.237664000 +0100
@@ -1295,6 +1295,8 @@ int main(int argc, char * argv[])
backend_get_mute = &oss_get_mute;
backend_get_channel = &oss_get_channel;
More information about the svn-ports-all
mailing list