View | Details | Raw Unified | Return to bug 224402
Collapse All | Expand All

(-)audio/volumeicon/Makefile (-1 / +2 lines)
Lines 2-7 Link Here
2
2
3
PORTNAME=	volumeicon
3
PORTNAME=	volumeicon
4
PORTVERSION=	0.5.1
4
PORTVERSION=	0.5.1
5
PORTREVISION=	1
5
CATEGORIES=	audio
6
CATEGORIES=	audio
6
7
7
MAINTAINER=	lme@FreeBSD.org
8
MAINTAINER=	lme@FreeBSD.org
Lines 10-16 Link Here
10
LICENSE=	GPLv3
11
LICENSE=	GPLv3
11
12
12
GNU_CONFIGURE=	yes
13
GNU_CONFIGURE=	yes
13
CONFIGURE_ARGS=	--enable-oss \
14
CONFIGURE_ARGS=	--enable-oss=v3 \
14
		--with-oss-include-path=/usr/include/sys
15
		--with-oss-include-path=/usr/include/sys
15
CPPFLAGS+=	-I${LOCALBASE}/include
16
CPPFLAGS+=	-I${LOCALBASE}/include
16
LIBS+=		-L${LOCALBASE}/lib
17
LIBS+=		-L${LOCALBASE}/lib
(-)audio/volumeicon/files/patch-configure.ac (+20 lines)
Line 0 Link Here
1
--- configure.ac.orig	2015-03-02 22:54:36 UTC
2
+++ configure.ac
3
@@ -86,14 +86,15 @@ fi
4
 if test "x${notify}" = xyes; then
5
 # Check for libnotify
6
 PKG_CHECK_MODULES([NOTIFY], [libnotify >= 0.5.0])
7
-NOTIFY_CFLAGS+="-DCOMPILEWITH_NOTIFY"
8
+NOTIFY_CFLAGS="-DCOMPILEWITH_NOTIFY"
9
 AC_SUBST(NOTIFY_CFLAGS)
10
 AC_SUBST(NOTIFY_LIBS)
11
 fi
12
 
13
 AC_SUBST(OSS_CFLAGS)
14
 
15
-AM_CONDITIONAL(ENABLE_OSS, test "$oss" = "yes")
16
+AM_CONDITIONAL(ENABLE_OSS4, test "x${oss}" = xyes -o "x${oss}" = xv4)
17
+AM_CONDITIONAL(ENABLE_OSS3, test "x${oss}" = xv3)
18
 
19
 DEFAULT_MIXERAPP="xterm -e 'alsamixer'"
20
 AC_ARG_WITH(default-mixerapp,
(-)audio/volumeicon/files/patch-data_gui_preferences.ui (-1 / +1 lines)
Lines 1-4 Link Here
1
--- data/gui/preferences.ui.orig	2017-12-12 18:43:30 UTC
1
--- data/gui/preferences.ui.orig	2015-03-02 22:54:36 UTC
2
+++ data/gui/preferences.ui
2
+++ data/gui/preferences.ui
3
@@ -197,7 +197,7 @@
3
@@ -197,7 +197,7 @@
4
                               <object class="GtkLabel" id="label5">
4
                               <object class="GtkLabel" id="label5">
(-)audio/volumeicon/files/patch-src_Makefile.am (+19 lines)
Line 0 Link Here
1
--- src/Makefile.am.orig	2015-03-02 22:54:36 UTC
2
+++ src/Makefile.am
3
@@ -5,11 +5,15 @@ LIBS = @GTK_LIBS@ @ALSA_LIBS@ @X11_LIBS@
4
 
5
 bin_PROGRAMS = volumeicon
6
 
7
-if ENABLE_OSS
8
+if ENABLE_OSS4
9
 BACKEND = oss_backend.c oss_backend.h
10
 else
11
+if ENABLE_OSS3
12
+BACKEND = oss3_backend.c oss_backend.h
13
+else
14
 BACKEND = alsa_backend.c alsa_backend.h alsa_volume_mapping.h alsa_volume_mapping.c
15
 endif
16
+endif
17
 
18
 volumeicon_SOURCES = \
19
 	volumeicon.c \
(-)audio/volumeicon/files/patch-src_oss3__backend.c (+189 lines)
Line 0 Link Here
1
--- src/oss3_backend.c.orig	2017-12-17 03:57:12 UTC
2
+++ src/oss3_backend.c
3
@@ -0,0 +1,186 @@
4
+//
5
+// Copyright (c) 2011 Maato <maato@softwarebakery.com>
6
+// Copyright (c) 2015-2017 Lars Engels <lme@FreeBSD.org>
7
+// Copyright (c) 2017 Dmitri Goutnik <dg@syrec.org>
8
+// All rights reserved.
9
+//
10
+// Redistribution and use in source and binary forms, with or without
11
+// modification, are permitted provided that the following conditions
12
+// are met:
13
+// 1. Redistributions of source code must retain the above copyright
14
+//    notice, this list of conditions and the following disclaimer
15
+//    in this position and unchanged.
16
+// 2. Redistributions in binary form must reproduce the above copyright
17
+//    notice, this list of conditions and the following disclaimer in the
18
+//    documentation and/or other materials provided with the distribution.
19
+//
20
+// THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
21
+// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22
+// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23
+// IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
24
+// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25
+// NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29
+// THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+//
31
+
32
+#include OSS_HEADER
33
+#include <sys/soundcard.h>
34
+#include <fcntl.h>
35
+#include <assert.h>
36
+#include <stdlib.h>
37
+#include <stdio.h>
38
+#include <glib.h>
39
+
40
+#include "oss_backend.h"
41
+
42
+static const char *channel_labels[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES;
43
+static int m_mixer_fd = -1;
44
+static GList *m_channel_names = NULL;
45
+static char *m_channel;
46
+static int m_channel_dev = 0;
47
+static char *m_device = NULL;
48
+static GList *m_device_names = NULL;
49
+
50
+void
51
+oss_setup(const gchar *card, const gchar *channel, void (*volume_changed) (int, gboolean))
52
+{
53
+	// Make sure (for now) that the setup function only gets called once
54
+	static int oss_setup_called = 0;
55
+	assert(oss_setup_called == 0);
56
+	oss_setup_called++;
57
+
58
+	g_list_free_full(m_channel_names, g_free);
59
+	m_channel_names = NULL;
60
+	g_list_free_full(m_device_names, g_free);
61
+	m_device_names = NULL;
62
+
63
+	g_free(m_device);
64
+	m_device = g_strdup(card);
65
+	m_device_names = g_list_append(m_device_names, g_strdup(m_device));
66
+
67
+	// Get ahold of the mixer device
68
+	char *devmixer;
69
+	if ((devmixer = getenv("OSS_MIXERDEV")) == NULL)
70
+		devmixer = "/dev/mixer";
71
+	if ((m_mixer_fd = open(devmixer, O_RDWR)) == -1) {
72
+		perror("Cannot open mixer");
73
+		exit(EXIT_FAILURE);
74
+	}
75
+
76
+	// Query mixer devices
77
+	int devmask = 0;
78
+	if (ioctl(m_mixer_fd, SOUND_MIXER_READ_DEVMASK, &devmask) == -1) {
79
+		perror("Cannot query devices");
80
+		exit(EXIT_FAILURE);
81
+	}
82
+
83
+	// Pupulate channel list
84
+	for (int i = 0; i < SOUND_MIXER_NRDEVICES; i++) {
85
+		if (!((1 << i) & devmask))
86
+			continue;
87
+		m_channel_names = g_list_append(m_channel_names, g_strdup(channel_labels[i]));
88
+	}
89
+
90
+	// Setup channel using the provided channel name
91
+	if (channel != NULL)
92
+		oss_set_channel(channel);
93
+	else if (channel == NULL && m_channel_names != NULL)
94
+		oss_set_channel((const gchar *)m_channel_names->data);
95
+}
96
+
97
+const gchar *
98
+oss_get_channel()
99
+{
100
+	return m_channel;
101
+}
102
+
103
+void
104
+oss_set_channel(const gchar *channel)
105
+{
106
+	assert(channel != NULL);
107
+	assert(m_mixer_fd != -1);
108
+
109
+	if (g_strcmp0(channel, m_channel) == 0)
110
+		return;
111
+
112
+	// Find channel dev index
113
+	int i;
114
+	for (i = 0; i < SOUND_MIXER_NRDEVICES; i++)
115
+		if (g_strcmp0(channel, channel_labels[i]) == 0)
116
+			break;
117
+
118
+	if (i < SOUND_MIXER_NRDEVICES) {
119
+		g_free(m_channel);
120
+		m_channel = g_strdup(channel);
121
+		m_channel_dev = i;
122
+	}
123
+}
124
+
125
+const gchar *
126
+oss_get_device()
127
+{
128
+	return m_device;
129
+}
130
+
131
+const GList *
132
+oss_get_channel_names()
133
+{
134
+	return m_channel_names;
135
+}
136
+
137
+const GList *
138
+oss_get_device_names()
139
+{
140
+	return m_device_names;
141
+}
142
+
143
+int
144
+oss_get_volume()
145
+{
146
+	assert(m_mixer_fd != -1);
147
+
148
+	int current_volume;
149
+	if (ioctl(m_mixer_fd, MIXER_READ(m_channel_dev), &current_volume) == -1) {
150
+		perror("Cannot read volume");
151
+		exit(EXIT_FAILURE);
152
+	}
153
+
154
+	// Only the left channel is returned
155
+	return current_volume & 0x7f;
156
+}
157
+
158
+void
159
+oss_set_volume(int volume)
160
+{
161
+	assert(m_mixer_fd != -1);
162
+	volume = (volume < 0 ? 0 : (volume > 100 ? 100 : volume));
163
+
164
+	volume = (volume << 8) | volume;
165
+	if (ioctl(m_mixer_fd, MIXER_WRITE(m_channel_dev), &volume) == -1) {
166
+		perror("Cannot write volume");
167
+		exit(EXIT_FAILURE);
168
+	}
169
+}
170
+
171
+gboolean
172
+oss_get_mute()
173
+{
174
+	assert(m_mixer_fd != -1);
175
+
176
+	// TODO: see if there's a way to return real mute state
177
+	return oss_get_volume() == 0;
178
+}
179
+
180
+void
181
+oss_set_mute(gboolean mute)
182
+{
183
+	assert(m_mixer_fd != -1);
184
+
185
+	// TODO: see if there's a way to toggle real mute
186
+	if (mute) {
187
+		oss_set_volume(0);
188
+	}
189
+}
(-)audio/volumeicon/files/patch-src_oss__backend.c (-177 / +3 lines)
Lines 1-183 Link Here
1
--- src/oss_backend.c.orig	2015-03-02 22:54:36 UTC
1
--- src/oss_backend.c.orig	2015-03-02 22:54:36 UTC
2
+++ src/oss_backend.c
2
+++ src/oss_backend.c
3
@@ -22,7 +22,7 @@
3
@@ -292,3 +292,13 @@ void oss_set_volume(int volume)
4
 //##############################################################################
5
 
6
 #include OSS_HEADER
7
-#include <stropts.h>
8
+#include <sys/soundcard.h>
9
 #include <fcntl.h>
10
 #include <assert.h>
11
 #include <stdlib.h>
12
@@ -30,12 +30,16 @@
13
 
14
 #include "oss_backend.h"
15
 
16
+#define	MIXT_MONOSLIDER16	19
17
+#define	MIXT_STEREOSLIDER16	20
18
+#define	MIXT_MUTE		21
19
+
20
 //##############################################################################
21
 // Static variables
22
 //##############################################################################
23
 static char * m_channel = NULL;
24
 static GList * m_channel_names = NULL;
25
-static int m_actual_maxvalue = 0;
26
+//static int m_actual_maxvalue = 0;
27
 static int m_mixer_fd = -1;
28
 static oss_mixext m_ext;
29
 
30
@@ -44,6 +48,7 @@ static oss_mixext m_ext;
31
 //##############################################################################
32
 static int get_raw_value()
33
 {
34
+#if 0
35
 	assert(m_mixer_fd != -1);
36
 
37
 	oss_mixer_value vr;
38
@@ -51,7 +56,7 @@ static int get_raw_value()
39
 	vr.ctrl = m_ext.ctrl;
40
 	vr.timestamp = m_ext.timestamp;
41
 
42
-	int result = ioctl(m_mixer_fd, SNDCTL_MIX_READ, &vr);
43
+	int result = ioctl(m_mixer_fd, SOUND_MIXER_READ_VOLUME, &vr);
44
 	if(result == -1)
45
 		return 0;
46
 
47
@@ -78,6 +83,7 @@ static int get_raw_value()
48
 			return short_value->lower;
49
 	}
50
 
51
+#endif
52
 	return 0;
53
 }
54
 
55
@@ -97,9 +103,20 @@ const GList * oss_get_channel_names()
56
 int oss_get_volume()
57
 {
58
 	assert(m_mixer_fd != -1);
59
+#if 0
60
 	if(m_actual_maxvalue == 0)
61
 		return 0;
62
 	return 100 * get_raw_value() / m_actual_maxvalue;
63
+#endif
64
+
65
+	int current_volume;
66
+	if (ioctl(m_mixer_fd, SOUND_MIXER_READ_VOLUME, &current_volume) == -1) {
67
+                perror("Cannot read volume!");
68
+                exit(EXIT_FAILURE);
69
+        }
70
+
71
+        /* Only the left channel is returned */
72
+        return current_volume & 0x7f;
73
 }
74
 
75
 gboolean oss_get_mute()
76
@@ -108,6 +125,7 @@ gboolean oss_get_mute()
77
 
78
 	gboolean mute = FALSE;
79
 
80
+#if 0
81
 	// Save current control;
82
 	int parent = m_ext.parent;
83
 	int control = m_ext.ctrl;
84
@@ -132,6 +150,7 @@ gboolean oss_get_mute()
85
 	// Restore to previous control
86
 	m_ext.ctrl = control;
87
 	ioctl(m_mixer_fd, SNDCTL_MIX_EXTINFO, &m_ext);
88
+#endif
89
 
90
 	return mute;
91
 }
92
@@ -148,12 +167,13 @@ void oss_setup(const gchar * card, const
93
 	char * devmixer;
94
 	if((devmixer=getenv("OSS_MIXERDEV")) == NULL)
95
 		devmixer = "/dev/mixer";
96
-	if((m_mixer_fd = open(devmixer, O_RDWR, 0)) == -1)
97
+	if((m_mixer_fd = open(devmixer, O_RDWR)) == -1)
98
 	{
99
 		perror(devmixer);
100
 		exit(1);
101
 	}
102
 
103
+#if 0
104
 	// Check that there is at least one mixer
105
 	int nmix;
106
 	ioctl(m_mixer_fd, SNDCTL_MIX_NRMIX, &nmix);
107
@@ -163,6 +183,7 @@ void oss_setup(const gchar * card, const
108
 		exit(EXIT_FAILURE);
109
 	}
110
 
111
+
112
 	m_ext.dev=0;
113
 	m_ext.ctrl = 0;
114
 	while(ioctl(m_mixer_fd, SNDCTL_MIX_EXTINFO, &m_ext) >= 0)
115
@@ -175,6 +196,7 @@ void oss_setup(const gchar * card, const
116
 		}
117
 		m_ext.ctrl++;
118
 	}
119
+#endif
120
 
121
 	// Setup channel using the provided channelname
122
 	if(channel != NULL)
123
@@ -195,6 +217,7 @@ void oss_set_channel(const gchar * chann
124
 	g_free(m_channel);
125
 	m_channel = g_strdup(channel);
126
 
127
+#if 0
128
 	// Find channel and then return
129
 	m_ext.dev=0;
130
 	m_ext.ctrl = 0;
131
@@ -207,6 +230,7 @@ void oss_set_channel(const gchar * chann
132
 		}
133
 		m_ext.ctrl++;
134
 	}
135
+#endif
136
 }
137
 
138
 void oss_set_mute(gboolean mute)
139
@@ -219,6 +243,7 @@ void oss_set_mute(gboolean mute)
140
 
141
 	// Check for mute in this group
142
 	m_ext.ctrl = 0;
143
+#if 0
144
 	while(ioctl(m_mixer_fd, SNDCTL_MIX_EXTINFO, &m_ext) >= 0)
145
 	{
146
 		if(m_ext.parent == parent && m_ext.type == MIXT_MUTE)
147
@@ -239,6 +264,7 @@ void oss_set_mute(gboolean mute)
148
 	m_ext.ctrl = control;
149
 	ioctl(m_mixer_fd, SNDCTL_MIX_EXTINFO, &m_ext);
150
 
151
+#endif
152
 	// If no mute control was found, revert to setting the volume to zero
153
 	if(!mute_found && mute)
154
 	{
155
@@ -251,6 +277,7 @@ void oss_set_volume(int volume)
156
 	assert(m_mixer_fd != -1);
157
 	volume = (volume < 0 ? 0 : (volume > 100 ? 100 : volume));
158
 
159
+#if 0
160
 	oss_mixer_value vr;
161
 	vr.dev = m_ext.dev;
162
 	vr.ctrl = m_ext.ctrl;
163
@@ -286,9 +313,24 @@ void oss_set_volume(int volume)
164
 		default:
165
 			return;
166
 	}
167
-
168
-	ioctl(m_mixer_fd, SNDCTL_MIX_WRITE, &vr);
169
-
170
+#endif
171
+	volume = (volume << 8) | volume;
172
+	if(ioctl(m_mixer_fd, SOUND_MIXER_WRITE_VOLUME, &volume) == -1) {
173
+		perror("Mixer write failed");
174
+		exit(EXIT_FAILURE);
175
+	}
176
+#if 0
177
 	if(volume == 100)
4
 	if(volume == 100)
178
 		m_actual_maxvalue = get_raw_value();
5
 		m_actual_maxvalue = get_raw_value();
179
+#endif
6
 }
180
+}
181
+
7
+
182
+const gchar * oss_get_device()
8
+const gchar * oss_get_device()
183
+{
9
+{
Lines 187-190 Link Here
187
+const GList * oss_get_device_names()
13
+const GList * oss_get_device_names()
188
+{
14
+{
189
+	return NULL;
15
+	return NULL;
190
 }
16
+}

Return to bug 224402