#include <esd.h>
#include "qemu-common.h"
#include "audio.h"
-#include <signal.h>
#define AUDIO_CAP "esd"
#include "audio_int.h"
int wsamples = written >> hw->info.shift;
int wbytes = wsamples << hw->info.shift;
if (wbytes != written) {
- dolog ("warning: Misaligned write %d (requested %d), "
+ dolog ("warning: Misaligned write %d (requested %zd), "
"alignment %d\n",
wbytes, written, hw->info.align + 1);
}
return NULL;
}
-static int qesd_run_out (HWVoiceOut *hw)
+static int qesd_run_out (HWVoiceOut *hw, int live)
{
- int live, decr;
+ int decr;
ESDVoiceOut *esd = (ESDVoiceOut *) hw;
if (audio_pt_lock (&esd->pt, AUDIO_FUNC)) {
return 0;
}
- live = audio_pcm_hw_get_live_out (hw);
decr = audio_MIN (live, esd->decr);
esd->decr -= decr;
esd->live = live - decr;
ESDVoiceOut *esd = (ESDVoiceOut *) hw;
struct audsettings obt_as = *as;
int esdfmt = ESD_STREAM | ESD_PLAY;
- int err;
- sigset_t set, old_set;
-
- sigfillset (&set);
esdfmt |= (as->nchannels == 2) ? ESD_STEREO : ESD_MONO;
switch (as->fmt) {
return -1;
}
- esd->fd = -1;
- err = pthread_sigmask (SIG_BLOCK, &set, &old_set);
- if (err) {
- qesd_logerr (err, "pthread_sigmask failed\n");
- goto fail1;
- }
-
esd->fd = esd_play_stream (esdfmt, as->freq, conf.dac_host, NULL);
if (esd->fd < 0) {
qesd_logerr (errno, "esd_play_stream failed\n");
- goto fail2;
+ goto fail1;
}
if (audio_pt_init (&esd->pt, qesd_thread_out, esd, AUDIO_CAP, AUDIO_FUNC)) {
- goto fail3;
- }
-
- err = pthread_sigmask (SIG_SETMASK, &old_set, NULL);
- if (err) {
- qesd_logerr (err, "pthread_sigmask(restore) failed\n");
+ goto fail2;
}
return 0;
- fail3:
+ fail2:
if (close (esd->fd)) {
qesd_logerr (errno, "%s: close on esd socket(%d) failed\n",
AUDIO_FUNC, esd->fd);
}
esd->fd = -1;
- fail2:
- err = pthread_sigmask (SIG_SETMASK, &old_set, NULL);
- if (err) {
- qesd_logerr (err, "pthread_sigmask(restore) failed\n");
- }
-
fail1:
qemu_free (esd->pcm_buf);
esd->pcm_buf = NULL;
int rsamples = nread >> hw->info.shift;
int rbytes = rsamples << hw->info.shift;
if (rbytes != nread) {
- dolog ("warning: Misaligned write %d (requested %d), "
+ dolog ("warning: Misaligned write %d (requested %zd), "
"alignment %d\n",
rbytes, nread, hw->info.align + 1);
}
break;
}
- hw->conv (hw->conv_buf + wpos, buf, nread >> hw->info.shift,
- &nominal_volume);
+ hw->conv (hw->conv_buf + wpos, buf, nread >> hw->info.shift);
wpos = (wpos + chunk) % hw->samples;
to_grab -= chunk;
}
ESDVoiceIn *esd = (ESDVoiceIn *) hw;
struct audsettings obt_as = *as;
int esdfmt = ESD_STREAM | ESD_RECORD;
- int err;
- sigset_t set, old_set;
-
- sigfillset (&set);
esdfmt |= (as->nchannels == 2) ? ESD_STEREO : ESD_MONO;
switch (as->fmt) {
return -1;
}
- esd->fd = -1;
-
- err = pthread_sigmask (SIG_BLOCK, &set, &old_set);
- if (err) {
- qesd_logerr (err, "pthread_sigmask failed\n");
- goto fail1;
- }
-
esd->fd = esd_record_stream (esdfmt, as->freq, conf.adc_host, NULL);
if (esd->fd < 0) {
qesd_logerr (errno, "esd_record_stream failed\n");
- goto fail2;
+ goto fail1;
}
if (audio_pt_init (&esd->pt, qesd_thread_in, esd, AUDIO_CAP, AUDIO_FUNC)) {
- goto fail3;
- }
-
- err = pthread_sigmask (SIG_SETMASK, &old_set, NULL);
- if (err) {
- qesd_logerr (err, "pthread_sigmask(restore) failed\n");
+ goto fail2;
}
return 0;
- fail3:
+ fail2:
if (close (esd->fd)) {
qesd_logerr (errno, "%s: close on esd socket(%d) failed\n",
AUDIO_FUNC, esd->fd);
}
esd->fd = -1;
- fail2:
- err = pthread_sigmask (SIG_SETMASK, &old_set, NULL);
- if (err) {
- qesd_logerr (err, "pthread_sigmask(restore) failed\n");
- }
-
fail1:
qemu_free (esd->pcm_buf);
esd->pcm_buf = NULL;
}
struct audio_option qesd_options[] = {
- {.name = "SAMPLES",
- .tag = AUD_OPT_INT,
- .valp = &conf.samples,
- .descr = "buffer size in samples"},
- {.name = "DIVISOR",
- .tag = AUD_OPT_INT,
- .valp = &conf.divisor,
- .descr = "threshold divisor"},
- {.name = "DAC_HOST",
- .tag = AUD_OPT_STR,
- .valp = &conf.dac_host,
- .descr = "playback host"},
- {.name = "ADC_HOST",
- .tag = AUD_OPT_STR,
- .valp = &conf.adc_host,
- .descr = "capture host"},
+ {
+ .name = "SAMPLES",
+ .tag = AUD_OPT_INT,
+ .valp = &conf.samples,
+ .descr = "buffer size in samples"
+ },
+ {
+ .name = "DIVISOR",
+ .tag = AUD_OPT_INT,
+ .valp = &conf.divisor,
+ .descr = "threshold divisor"
+ },
+ {
+ .name = "DAC_HOST",
+ .tag = AUD_OPT_STR,
+ .valp = &conf.dac_host,
+ .descr = "playback host"
+ },
+ {
+ .name = "ADC_HOST",
+ .tag = AUD_OPT_STR,
+ .valp = &conf.adc_host,
+ .descr = "capture host"
+ },
{ /* End of list */ }
};