annotate Plugins/Output/esd/mixer.c @ 668:5f46230a24f8 trunk

[svn] ESD output plugin ported to objective make by Kyoshi Aman.
author chainsaw
date Thu, 23 Feb 2006 17:03:03 -0800
parents 025c253845a3
children f12d7e208b43
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
1 /* BMP - Cross-platform multimedia player
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
2 * Copyright (C) 2003-2004 BMP development team.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
3 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
4 * Based on XMMS:
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
5 * Copyright (C) 1998-2003 XMMS development team.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
6 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
10 * (at your option) any later version.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
11 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
15 * GNU General Public License for more details.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
16 *
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
20 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
21
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
22 #include <stdio.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
23 #include <stdlib.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
24 #include <string.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
25 #include <esd.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
26
490
025c253845a3 [svn] Whoops.
nenolod
parents: 488
diff changeset
27 #include <libaudacious/configdb.h>
488
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
28
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
29 #include <unistd.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
30 #include <fcntl.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
31 #include <sys/types.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
32 #include <sys/ioctl.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
33 #include <sys/stat.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
34
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
35 #include "esdout.h"
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
36
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
37 #ifdef HAVE_OSS
668
5f46230a24f8 [svn] ESD output plugin ported to objective make by Kyoshi Aman.
chainsaw
parents: 490
diff changeset
38 # include <OSS/soundcard.h>
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
39 # define OSS_AVAILABLE TRUE
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
40 #else
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
41 # define OSS_AVAILABLE FALSE
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
42 #endif
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
43
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
44 #include <libaudacious/util.h>
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
45
488
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
46 #define QUERY_PLAYER_ID_ATTEMPTS 5
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
47
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
48 static void esdout_get_oss_volume(int *l, int *r);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
49 static void esdout_set_oss_volume(int l, int r);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
50
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
51
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
52 static int player = -1;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
53 static int lp = 100, rp = 100;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
54
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
55 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
56 * Find the stream id, and set stream volume to 'persistent' value.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
57 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
58 void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
59 esdout_mixer_init(void)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
60 {
488
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
61 int i;
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
62
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
63 /* reset player id */
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
64 player = -1;
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
65
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
66 /* query n-time for player id */
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
67 for(i=0; (i<QUERY_PLAYER_ID_ATTEMPTS) && (player == (-1)) ; i++)
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
68 esdout_fetch_volume(NULL, NULL);
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
69
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
70 if (!(OSS_AVAILABLE && esd_cfg.use_oss_mixer && !esd_cfg.use_remote))
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
71 esdout_set_volume(lp, rp);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
72 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
73
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
74 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
75 * Grab the stream volume from the server. The problem here is that
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
76 * ESD does not have a built-in function for finding the player ID of
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
77 * a specific player - nor does it let us know what the player ID is
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
78 * when the player is created! So, we grab 'allinfo' and scan the
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
79 * returned player list for the string which we know is our player
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
80 * name (esd_cfg.playername) This function seems to take a long time
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
81 * to run... I'm not sure where to start optimizing, however...
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
82 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
83 void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
84 esdout_fetch_volume(int *l, int *r)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
85 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
86 int fd;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
87 esd_info_t *all_info = NULL;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
88 esd_player_info_t *info;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
89
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
90 fd = esd_open_sound(esd_cfg.hostname);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
91 all_info = esd_get_all_info(fd);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
92
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
93 /* scan linked list for our playername */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
94 for (info = all_info->player_list; info != NULL; info = info->next)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
95 if (!strcmp(esd_cfg.playername, info->name))
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
96 break;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
97
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
98 if (info) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
99 player = info->source_id;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
100 if (l && r) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
101 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
102 * Sometimes we call with NULL
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
103 * args to fetch the player num
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
104 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
105 *l = (info->left_vol_scale * 100) / 256;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
106 *r = (info->right_vol_scale * 100) / 256;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
107 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
108 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
109 else
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
110 g_warning("xmms: Couldn't find our player "
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
111 "(was looking for %s) at the server", esd_cfg.playername);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
112
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
113 if (all_info)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
114 esd_free_all_info(all_info);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
115 esd_close(fd);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
116 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
117
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
118 void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
119 esdout_get_volume(int *l, int *r)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
120 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
121 if (OSS_AVAILABLE && esd_cfg.use_oss_mixer && !esd_cfg.use_remote) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
122 esdout_get_oss_volume(l, r);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
123 lp = *l;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
124 rp = *r;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
125 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
126 else {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
127 /*
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
128 * We assume that the volume hasn't changed from the
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
129 * 'persistant' value. Constantly polling takes too
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
130 * much time/resources. Commenting this section out
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
131 * will consistently check the ESD server to see if
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
132 * someone else changed our stream volume.
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
133 */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
134 *l = lp;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
135 *r = rp;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
136 /* esdout_fetch_volume(l, r); */
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
137 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
138 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
139
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
140 void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
141 esdout_set_volume(int l, int r)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
142 {
488
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
143 ConfigDb *db;
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
144 lp = l;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
145 rp = r;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
146
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
147 if (OSS_AVAILABLE && esd_cfg.use_oss_mixer && !esd_cfg.use_remote) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
148 esdout_set_oss_volume(l, r);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
149 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
150 else if (player != -1 && esd_cfg.playername != NULL) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
151 int fd = esd_open_sound(esd_cfg.hostname);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
152 if (fd >= 0) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
153 esd_set_stream_pan(fd, player, (l * 256) / 100, (r * 256) / 100);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
154 esd_close(fd);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
155 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
156 }
488
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
157
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
158 /* save volume values in db */
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
159 db = bmp_cfg_db_open();
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
160 bmp_cfg_db_set_int(db, "ESD", "volume_left", lp);
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
161 bmp_cfg_db_set_int(db, "ESD", "volume_right", rp);
cb0f36590d98 [svn] ESD output plugin enhancements by max_verem -at- yahoo.com.
nenolod
parents: 61
diff changeset
162 bmp_cfg_db_close(db);
61
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
163 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
164
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
165 #ifdef HAVE_OSS
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
166
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
167 static void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
168 esdout_get_oss_volume(int *l, int *r)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
169 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
170 int fd, v, devs;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
171 long cmd;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
172
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
173 if (esd_cfg.use_remote)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
174 return;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
175
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
176 fd = open(DEV_MIXER, O_RDONLY);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
177 if (fd != -1) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
178 ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
179 if (devs & SOUND_MASK_PCM)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
180 cmd = SOUND_MIXER_READ_PCM;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
181 else if (devs & SOUND_MASK_VOLUME)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
182 cmd = SOUND_MIXER_READ_VOLUME;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
183 else {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
184 close(fd);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
185 return;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
186 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
187 ioctl(fd, cmd, &v);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
188 *r = (v & 0xFF00) >> 8;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
189 *l = (v & 0x00FF);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
190 close(fd);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
191 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
192 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
193
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
194 static void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
195 esdout_set_oss_volume(int l, int r)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
196 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
197 int fd, v, devs;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
198 long cmd;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
199
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
200 if (esd_cfg.use_remote)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
201 return;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
202
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
203 fd = open(DEV_MIXER, O_RDONLY);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
204
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
205 if (fd != -1) {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
206 ioctl(fd, SOUND_MIXER_READ_DEVMASK, &devs);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
207 if (devs & SOUND_MASK_PCM)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
208 cmd = SOUND_MIXER_WRITE_PCM;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
209 else if (devs & SOUND_MASK_VOLUME)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
210 cmd = SOUND_MIXER_WRITE_VOLUME;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
211 else {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
212 close(fd);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
213 return;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
214 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
215 v = (r << 8) | l;
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
216 ioctl(fd, cmd, &v);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
217 close(fd);
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
218 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
219 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
220
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
221 #else
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
222
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
223 static void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
224 esdout_get_oss_volume(int *l, int *r)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
225 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
226 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
227
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
228 static void
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
229 esdout_set_oss_volume(int l, int r)
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
230 {
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
231 }
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
232
fa848bd484d8 [svn] Move plugins to Plugins/
nenolod
parents:
diff changeset
233 #endif