#ifdef DAC
dolog ("Driver `%s' does not support " NAME "\n", drv->name);
#endif
- }
- else {
+ } else {
dolog ("Driver `%s' does not support %d " NAME " voices, max %d\n",
drv->name,
glue (s->nb_hw_voices_, TYPE),
static void glue (audio_pcm_hw_free_resources_, TYPE) (HW *hw)
{
+ g_free(hw->buf_emul);
g_free (HWBUF);
HWBUF = NULL;
}
-static bool glue(audio_pcm_hw_alloc_resources_, TYPE)(HW *hw)
+static void glue(audio_pcm_hw_alloc_resources_, TYPE)(HW *hw)
{
- HWBUF = audio_calloc(__func__, hw->samples, sizeof(struct st_sample));
- if (!HWBUF) {
- dolog("Could not allocate " NAME " buffer (%zu samples)\n",
- hw->samples);
- return false;
- }
+ if (glue(audio_get_pdo_, TYPE)(hw->s->dev)->mixing_engine) {
+ size_t samples = hw->samples;
+ if (audio_bug(__func__, samples == 0)) {
+ dolog("Attempted to allocate empty buffer\n");
+ }
- return true;
+ HWBUF = g_malloc0(sizeof(STSampleBuffer) + sizeof(st_sample) * samples);
+ HWBUF->size = samples;
+ } else {
+ HWBUF = NULL;
+ }
}
static void glue (audio_pcm_sw_free_resources_, TYPE) (SW *sw)
{
int samples;
- samples = ((int64_t) sw->hw->samples << 32) / sw->ratio;
+ if (!glue(audio_get_pdo_, TYPE)(sw->s->dev)->mixing_engine) {
+ return 0;
+ }
+
+ samples = ((int64_t) sw->HWBUF->size << 32) / sw->ratio;
sw->buf = audio_calloc(__func__, samples, sizeof(struct st_sample));
if (!sw->buf) {
sw->ratio = ((int64_t) sw->info.freq << 32) / sw->hw->info.freq;
#endif
+ if (sw->info.is_float) {
+#ifdef DAC
+ sw->conv = mixeng_conv_float[sw->info.nchannels == 2];
+#else
+ sw->clip = mixeng_clip_float[sw->info.nchannels == 2];
+#endif
+ } else {
#ifdef DAC
- sw->conv = mixeng_conv
+ sw->conv = mixeng_conv
#else
- sw->clip = mixeng_clip
+ sw->clip = mixeng_clip
#endif
- [sw->info.nchannels == 2]
- [sw->info.sign]
- [sw->info.swap_endianness]
- [audio_bits_to_index (sw->info.bits)];
+ [sw->info.nchannels == 2]
+ [sw->info.is_signed]
+ [sw->info.swap_endianness]
+ [audio_bits_to_index(sw->info.bits)];
+ }
sw->name = g_strdup (name);
err = glue (audio_pcm_sw_alloc_resources_, TYPE) (sw);
if (!hw->sw_head.lh_first) {
#ifdef DAC
- audio_detach_capture (hw);
+ audio_detach_capture(hw);
#endif
- QLIST_REMOVE (hw, entries);
- glue (hw->pcm_ops->fini_, TYPE) (hw);
- glue (s->nb_hw_voices_, TYPE) += 1;
- glue (audio_pcm_hw_free_resources_ ,TYPE) (hw);
- g_free (hw);
+ QLIST_REMOVE(hw, entries);
+ glue(hw->pcm_ops->fini_, TYPE) (hw);
+ glue(s->nb_hw_voices_, TYPE) += 1;
+ glue(audio_pcm_hw_free_resources_ , TYPE) (hw);
+ g_free(hw);
*hwp = NULL;
}
}
hw->s = s;
hw->pcm_ops = drv->pcm_ops;
- hw->ctl_caps = drv->ctl_caps;
QLIST_INIT (&hw->sw_head);
#ifdef DAC
goto err1;
}
+ if (hw->info.is_float) {
#ifdef DAC
- hw->clip = mixeng_clip
+ hw->clip = mixeng_clip_float[hw->info.nchannels == 2];
#else
- hw->conv = mixeng_conv
+ hw->conv = mixeng_conv_float[hw->info.nchannels == 2];
#endif
- [hw->info.nchannels == 2]
- [hw->info.sign]
- [hw->info.swap_endianness]
- [audio_bits_to_index (hw->info.bits)];
-
- if (!glue(audio_pcm_hw_alloc_resources_, TYPE)(hw)) {
- goto err1;
+ } else {
+#ifdef DAC
+ hw->clip = mixeng_clip
+#else
+ hw->conv = mixeng_conv
+#endif
+ [hw->info.nchannels == 2]
+ [hw->info.is_signed]
+ [hw->info.swap_endianness]
+ [audio_bits_to_index(hw->info.bits)];
}
+ glue(audio_pcm_hw_alloc_resources_, TYPE)(hw);
+
QLIST_INSERT_HEAD (&s->glue (hw_head_, TYPE), hw, entries);
glue (s->nb_hw_voices_, TYPE) -= 1;
#ifdef DAC
case AUDIODEV_DRIVER_COREAUDIO:
return qapi_AudiodevCoreaudioPerDirectionOptions_base(
dev->u.coreaudio.TYPE);
+ case AUDIODEV_DRIVER_DBUS:
+ return dev->u.dbus.TYPE;
case AUDIODEV_DRIVER_DSOUND:
return dev->u.dsound.TYPE;
+ case AUDIODEV_DRIVER_JACK:
+ return qapi_AudiodevJackPerDirectionOptions_base(dev->u.jack.TYPE);
case AUDIODEV_DRIVER_OSS:
return qapi_AudiodevOssPerDirectionOptions_base(dev->u.oss.TYPE);
case AUDIODEV_DRIVER_PA:
return qapi_AudiodevPaPerDirectionOptions_base(dev->u.pa.TYPE);
case AUDIODEV_DRIVER_SDL:
- return dev->u.sdl.TYPE;
+ return qapi_AudiodevSdlPerDirectionOptions_base(dev->u.sdl.TYPE);
+ case AUDIODEV_DRIVER_SNDIO:
+ return dev->u.sndio.TYPE;
case AUDIODEV_DRIVER_SPICE:
return dev->u.spice.TYPE;
case AUDIODEV_DRIVER_WAV:
HW *hw;
AudiodevPerDirectionOptions *pdo = glue(audio_get_pdo_, TYPE)(s->dev);
- if (pdo->fixed_settings) {
+ if (!pdo->mixing_engine || pdo->fixed_settings) {
hw = glue(audio_pcm_hw_add_new_, TYPE)(s, as);
- if (hw) {
+ if (!pdo->mixing_engine || hw) {
return hw;
}
}
if (pdo->fixed_settings) {
hw_as = audiodev_to_audsettings(pdo);
- }
- else {
+ } else {
hw_as = *as;
}
struct audsettings *as
)
{
- AudioState *s = card->state;
- AudiodevPerDirectionOptions *pdo = glue(audio_get_pdo_, TYPE)(s->dev);
+ AudioState *s;
+ AudiodevPerDirectionOptions *pdo;
if (audio_bug(__func__, !card || !name || !callback_fn || !as)) {
dolog ("card=%p name=%p callback_fn=%p as=%p\n",
goto fail;
}
+ s = card->state;
+ pdo = glue(audio_get_pdo_, TYPE)(s->dev);
+
ldebug ("open %s, freq %d, nchannels %d, fmt %d\n",
name, as->freq, as->nchannels, as->fmt);
if (glue (audio_pcm_sw_init_, TYPE) (sw, hw, name, as)) {
goto fail;
}
- }
- else {
+ } else {
sw = glue(audio_pcm_create_voice_pair_, TYPE)(s, name, as);
if (!sw) {
dolog ("Failed to create voice `%s'\n", name);
if (cur_ts >= old_ts) {
delta = cur_ts - old_ts;
- }
- else {
+ } else {
delta = UINT64_MAX - old_ts + cur_ts;
}