42 lines
955 B
C
42 lines
955 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <sys/ioctl.h>
|
|
#include <errno.h>
|
|
|
|
#define DEVICE_NAME "/dev/audio_mixer"
|
|
#define AUDIO_IOC_MAGIC 'A'
|
|
#define AUDIO_IOC_SET_VOLUME _IOW(AUDIO_IOC_MAGIC, 0, int)
|
|
#define AUDIO_IOC_MUTE _IOW(AUDIO_IOC_MAGIC, 1, int)
|
|
#define AUDIO_IOC_RESET _IO(AUDIO_IOC_MAGIC, 2)
|
|
|
|
int main() {
|
|
int fd = open(DEVICE_NAME, O_RDWR);
|
|
if (fd < 0) {
|
|
perror("Failed to open the device");
|
|
return errno;
|
|
}
|
|
|
|
int volume = 75;
|
|
if (ioctl(fd, AUDIO_IOC_SET_VOLUME, &volume) < 0) {
|
|
perror("Failed to set volume");
|
|
close(fd);
|
|
return errno;
|
|
}
|
|
|
|
if (ioctl(fd, AUDIO_IOC_MUTE) < 0) {
|
|
perror("Failed to mute channels");
|
|
close(fd);
|
|
return errno;
|
|
}
|
|
|
|
if (ioctl(fd, AUDIO_IOC_RESET) < 0) {
|
|
perror("Failed to reset channels");
|
|
close(fd);
|
|
return errno;
|
|
}
|
|
|
|
close(fd);
|
|
return 0;
|
|
} |