|
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, ¤t_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 |
+} |