+PUBLIC void _alsa_play (unsigned int num) {
+
+ if (!dev_ctx_a || !dev_ctx_a[num] || dev_ctx_a[num]->thr_should_run ||
+ access (AUDIO_BUFFER, F_OK) == -1)
+ return;
+
+ dev_ctx_a[num]->thr_should_run = 1;
+ dev_ctx_a[num]->thr_finished = 0;
+ pthread_create (&dev_ctx_a[num]->thr, NULL, _alsa_play_thread_fn, (void*)dev_ctx_a[num]);
+}
+
+PUBLIC void _alsa_stop (unsigned int num) {
+
+ if (!dev_ctx_a || !dev_ctx_a[num] || !dev_ctx_a[num]->thr_should_run)
+ return;
+
+ /* stop the "while" loop in thread */
+ dev_ctx_a[num]->thr_should_run = 0;
+
+ while (!dev_ctx_a[num]->thr_finished)
+ usleep(100000);
+
+ pthread_join (dev_ctx_a[num]->thr, NULL);
+}
+
+PUBLIC int _alsa_get_volume (unsigned int num, unsigned int channel) {
+
+ if (!dev_ctx_a || !dev_ctx_a[num] || !dev_ctx_a[num]->mixer_elm)
+ return;
+
+ snd_mixer_selem_get_playback_volume (dev_ctx_a[num]->mixer_elm, SCHANNELS[channel], &dev_ctx_a[num]->vol);
+
+ return (int)(dev_ctx_a[num]->vol*100)/dev_ctx_a[num]->vol_max;
+}
+
+PUBLIC void _alsa_set_volume (unsigned int num, unsigned int channel, int vol) {
+
+ if (!dev_ctx_a || !dev_ctx_a[num] || !dev_ctx_a[num]->mixer_elm ||
+ 0 > vol > 100)
+ return;
+
+ snd_mixer_selem_set_playback_volume (dev_ctx_a[num]->mixer_elm, SCHANNELS[channel], (vol*dev_ctx_a[num]->vol_max)/100);
+
+}
+
+PUBLIC void _alsa_set_volume_all (unsigned int num, int vol) {
+
+ if (!dev_ctx_a || !dev_ctx_a[num] || !dev_ctx_a[num]->mixer_elm ||
+ 0 > vol > 100)
+
+ snd_mixer_selem_set_playback_volume_all (dev_ctx_a[num]->mixer_elm, (vol*dev_ctx_a[num]->vol_max)/100);
+}
+
+PUBLIC unsigned char _alsa_get_mute (unsigned int num) {
+
+ int mute = 0;
+ snd_mixer_elem_t *elm_m;
+
+ if (!dev_ctx_a || !dev_ctx_a[num] || !dev_ctx_a[num]->mixer_elm)
+ return;
+
+ dev_ctx_a[num]->mixer_elm_m ? (elm_m = dev_ctx_a[num]->mixer_elm_m) :
+ (elm_m = dev_ctx_a[num]->mixer_elm);
+
+ if (snd_mixer_selem_has_playback_switch (elm_m)) {
+ snd_mixer_selem_get_playback_switch (elm_m, SND_MIXER_SCHN_FRONT_LEFT, &mute);
+ snd_mixer_selem_get_playback_switch (elm_m, SND_MIXER_SCHN_FRONT_RIGHT, &mute);
+ }
+
+ if (dev_ctx_a[num]->mixer_elm_m)
+ return (unsigned char)mute;
+ else
+ return (unsigned char)!mute;
+}
+
+PUBLIC void _alsa_set_mute (unsigned int num, unsigned char tomute) {
+
+ snd_mixer_elem_t *elm_m;
+ int mute;