- if ((res = snd_pcm_writei (dev_ctx[num]->dev, cbuf, frames)) != frames) {
- snd_pcm_recover (dev_ctx[num]->dev, res, 0);
- snd_pcm_prepare (dev_ctx[num]->dev);
+ if ((res = snd_pcm_writei (adev_ctx[num]->dev, cbuf, frames)) != frames) {
+ snd_pcm_recover (adev_ctx[num]->dev, res, 0);
+ snd_pcm_prepare (adev_ctx[num]->dev);
+ }
+ /* snd_pcm_drain (adev_ctx[num]->dev); */
+}
+
+PUBLIC unsigned int _alsa_get_volume (unsigned int num) {
+
+ if (!adev_ctx || !adev_ctx[num] || !adev_ctx[num]->mixer_elm)
+ return;
+
+ snd_mixer_selem_get_playback_volume (adev_ctx[num]->mixer_elm, SND_MIXER_SCHN_FRONT_LEFT, &adev_ctx[num]->vol);
+
+ return (unsigned int)(adev_ctx[num]->vol*100)/adev_ctx[num]->vol_max;
+}
+
+PUBLIC unsigned int _alsa_set_volume (unsigned int num, unsigned int vol) {
+
+ if (!adev_ctx || !adev_ctx[num] || !adev_ctx[num]->mixer_elm || vol > 100)
+ return;
+
+ snd_mixer_selem_set_playback_volume_all (adev_ctx[num]->mixer_elm, (vol*adev_ctx[num]->vol_max)/100);
+}
+
+PUBLIC unsigned char _alsa_get_mute (unsigned int num) {
+
+ int mute = 0;
+
+ if (!adev_ctx || !adev_ctx[num] || !adev_ctx[num]->mixer_elm)
+ return;
+
+ if (snd_mixer_selem_has_playback_switch (adev_ctx[num]->mixer_elm)) {
+ snd_mixer_selem_get_playback_switch (adev_ctx[num]->mixer_elm, SND_MIXER_SCHN_FRONT_LEFT, &mute);
+ snd_mixer_selem_get_playback_switch (adev_ctx[num]->mixer_elm, SND_MIXER_SCHN_FRONT_RIGHT, &mute);
+