Support mixer_idx with OSS
make mixer_idx load the default mixer
This commit is contained in:
parent
7f83d0a197
commit
f30ec89b79
@ -312,9 +312,10 @@ details on the format string.
|
||||
Outputs the volume of the specified mixer on the specified device. Works only
|
||||
on Linux because it uses ALSA.
|
||||
A simplified configuration can be used on FreeBSD and OpenBSD due to
|
||||
the lack of ALSA, the +device+, +mixer+ and +mixder_idx+ options can be
|
||||
the lack of ALSA, the +device+ and +mixer+ options can be
|
||||
ignored on these systems. On these systems the OSS API is used instead to
|
||||
query +/dev/mixer+ directly.
|
||||
query +/dev/mixer+ directly if +mixer_dix+ is -1, otherwise
|
||||
+/dev/mixer++mixer_idx+.
|
||||
|
||||
*Example order*: +volume master+
|
||||
|
||||
|
@ -175,12 +175,22 @@ void print_volume(yajl_gen json_gen, char *buffer, const char *fmt, const char *
|
||||
}
|
||||
#endif
|
||||
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
|
||||
char mixerpath[] = "/dev/mixer";
|
||||
char *mixerpath;
|
||||
char defaultmixer[] = "/dev/mixer";
|
||||
int mixfd, vol, devmask = 0;
|
||||
pbval = 1;
|
||||
|
||||
if (mixer_idx > 0)
|
||||
asprintf(&mixerpath, "/dev/mixer%d", mixer_idx);
|
||||
else
|
||||
mixerpath = defaultmixer;
|
||||
|
||||
if ((mixfd = open(mixerpath, O_RDWR)) < 0)
|
||||
return;
|
||||
|
||||
if (mixer_idx > 0)
|
||||
free(mixerpath);
|
||||
|
||||
if (ioctl(mixfd, SOUND_MIXER_READ_DEVMASK, &devmask) == -1)
|
||||
return;
|
||||
if (ioctl(mixfd, MIXER_READ(0),&vol) == -1)
|
||||
|
Loading…
Reference in New Issue
Block a user