Steward
分享是一種喜悅、更是一種幸福
掌機 - Anbernic RG28XX - C/C++ - Volume
main.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <stdio.h> #include <stdlib.h> #include <alsa/asoundlib.h> int main ( int argc, char ** argv) { int vol = 10; snd_mixer_t *mixer = NULL ; snd_mixer_elem_t *elem = NULL ; snd_mixer_selem_id_t *sid = NULL ; snd_mixer_open (&mixer, 1); snd_mixer_attach (mixer, "default" ); snd_mixer_selem_register (mixer, NULL , NULL ); snd_mixer_load (mixer); snd_mixer_selem_id_alloca (&sid); snd_mixer_selem_id_set_index (sid, 0); snd_mixer_selem_id_set_name (sid, "lineout volume" ); elem = snd_mixer_find_selem (mixer, sid); snd_mixer_selem_set_playback_volume_all (elem, vol); snd_mixer_close (mixer); return 0; } |
編譯
$ arm-linux-gcc main.c -o main -lasound