(void) samples;
}
-static CaptureVoiceOut *audio_pcm_capture_find_specific (
- struct audsettings *as
- )
+static CaptureVoiceOut *audio_pcm_capture_find_specific(AudioState *s,
+ struct audsettings *as)
{
CaptureVoiceOut *cap;
- AudioState *s = &glob_audio_state;
for (cap = s->cap_head.lh_first; cap; cap = cap->entries.le_next) {
if (audio_pcm_info_eq (&cap->hw.info, as)) {
static int audio_attach_capture (HWVoiceOut *hw)
{
- AudioState *s = &glob_audio_state;
+ AudioState *s = hw->s;
CaptureVoiceOut *cap;
audio_detach_capture (hw);
/*
* Timer
*/
-
-static bool audio_timer_running;
-static uint64_t audio_timer_last;
-
-static int audio_is_timer_needed (void)
+static int audio_is_timer_needed(AudioState *s)
{
HWVoiceIn *hwi = NULL;
HWVoiceOut *hwo = NULL;
- while ((hwo = audio_pcm_hw_find_any_enabled_out (hwo))) {
+ while ((hwo = audio_pcm_hw_find_any_enabled_out(s, hwo))) {
if (!hwo->poll_mode) return 1;
}
- while ((hwi = audio_pcm_hw_find_any_enabled_in (hwi))) {
+ while ((hwi = audio_pcm_hw_find_any_enabled_in(s, hwi))) {
if (!hwi->poll_mode) return 1;
}
return 0;
static void audio_reset_timer (AudioState *s)
{
- if (audio_is_timer_needed ()) {
+ if (audio_is_timer_needed(s)) {
timer_mod_anticipate_ns(s->ts,
qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + s->period_ticks);
- if (!audio_timer_running) {
- audio_timer_running = true;
- audio_timer_last = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
+ if (!s->timer_running) {
+ s->timer_running = true;
+ s->timer_last = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
trace_audio_timer_start(s->period_ticks / SCALE_MS);
}
} else {
timer_del(s->ts);
- if (audio_timer_running) {
- audio_timer_running = false;
+ if (s->timer_running) {
+ s->timer_running = false;
trace_audio_timer_stop();
}
}
AudioState *s = opaque;
now = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
- diff = now - audio_timer_last;
+ diff = now - s->timer_last;
if (diff > s->period_ticks * 3 / 2) {
trace_audio_timer_delayed(diff / SCALE_MS);
}
- audio_timer_last = now;
+ s->timer_last = now;
audio_run("timer");
audio_reset_timer(s);
hw = sw->hw;
if (sw->active != on) {
- AudioState *s = &glob_audio_state;
+ AudioState *s = sw->s;
SWVoiceOut *temp_sw;
SWVoiceCap *sc;
hw = sw->hw;
if (sw->active != on) {
- AudioState *s = &glob_audio_state;
+ AudioState *s = sw->s;
SWVoiceIn *temp_sw;
if (on) {
HWVoiceOut *hw = NULL;
SWVoiceOut *sw;
- while ((hw = audio_pcm_hw_find_any_enabled_out (hw))) {
+ while ((hw = audio_pcm_hw_find_any_enabled_out(s, hw))) {
int played;
int live, free, nb_live, cleanup_required, prev_rpos;
{
HWVoiceIn *hw = NULL;
- while ((hw = audio_pcm_hw_find_any_enabled_in (hw))) {
+ while ((hw = audio_pcm_hw_find_any_enabled_in(s, hw))) {
SWVoiceIn *sw;
int captured = 0, min;
s->drv_opaque = drv->init(dev);
if (s->drv_opaque) {
- audio_init_nb_voices_out (drv);
- audio_init_nb_voices_in (drv);
+ audio_init_nb_voices_out(s, drv);
+ audio_init_nb_voices_in(s, drv);
s->drv = drv;
return 0;
}
int op = running ? VOICE_ENABLE : VOICE_DISABLE;
s->vm_running = running;
- while ((hwo = audio_pcm_hw_find_any_enabled_out (hwo))) {
+ while ((hwo = audio_pcm_hw_find_any_enabled_out(s, hwo))) {
hwo->pcm_ops->ctl_out(hwo, op);
}
- while ((hwi = audio_pcm_hw_find_any_enabled_in (hwi))) {
+ while ((hwi = audio_pcm_hw_find_any_enabled_in(s, hwi))) {
hwi->pcm_ops->ctl_in(hwi, op);
}
audio_reset_timer (s);
HWVoiceIn *hwi, *hwin;
is_cleaning_up = true;
- QLIST_FOREACH_SAFE(hwo, &glob_audio_state.hw_head_out, entries, hwon) {
+ QLIST_FOREACH_SAFE(hwo, &s->hw_head_out, entries, hwon) {
SWVoiceCap *sc;
if (hwo->enabled) {
QLIST_REMOVE(hwo, entries);
}
- QLIST_FOREACH_SAFE(hwi, &glob_audio_state.hw_head_in, entries, hwin) {
+ QLIST_FOREACH_SAFE(hwi, &s->hw_head_in, entries, hwin) {
if (hwi->enabled) {
hwi->pcm_ops->ctl_in (hwi, VOICE_DISABLE);
}
cb->ops = *ops;
cb->opaque = cb_opaque;
- cap = audio_pcm_capture_find_specific (as);
+ cap = audio_pcm_capture_find_specific(s, as);
if (cap) {
QLIST_INSERT_HEAD (&cap->cb_head, cb, entries);
return cap;
cap = g_malloc0(sizeof(*cap));
hw = &cap->hw;
+ hw->s = s;
QLIST_INIT (&hw->sw_head);
QLIST_INIT (&cap->cb_head);
QLIST_INSERT_HEAD (&s->cap_head, cap, entries);
QLIST_INSERT_HEAD (&cap->cb_head, cb, entries);
- QLIST_FOREACH(hw, &glob_audio_state.hw_head_out, entries) {
+ QLIST_FOREACH(hw, &s->hw_head_out, entries) {
audio_attach_capture (hw);
}
return cap;
#define HWBUF hw->conv_buf
#endif
-static void glue (audio_init_nb_voices_, TYPE) (struct audio_driver *drv)
+static void glue(audio_init_nb_voices_, TYPE)(AudioState *s,
+ struct audio_driver *drv)
{
- AudioState *s = &glob_audio_state;
int max_voices = glue (drv->max_voices_, TYPE);
int voice_size = glue (drv->voice_size_, TYPE);
static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp)
{
- AudioState *s = &glob_audio_state;
HW *hw = *hwp;
+ AudioState *s = hw->s;
if (!hw->sw_head.lh_first) {
#ifdef DAC
}
}
-static HW *glue (audio_pcm_hw_find_any_, TYPE) (HW *hw)
+static HW *glue(audio_pcm_hw_find_any_, TYPE)(AudioState *s, HW *hw)
{
- AudioState *s = &glob_audio_state;
return hw ? hw->entries.le_next : glue (s->hw_head_, TYPE).lh_first;
}
-static HW *glue (audio_pcm_hw_find_any_enabled_, TYPE) (HW *hw)
+static HW *glue(audio_pcm_hw_find_any_enabled_, TYPE)(AudioState *s, HW *hw)
{
- while ((hw = glue (audio_pcm_hw_find_any_, TYPE) (hw))) {
+ while ((hw = glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) {
if (hw->enabled) {
return hw;
}
return NULL;
}
-static HW *glue (audio_pcm_hw_find_specific_, TYPE) (
- HW *hw,
- struct audsettings *as
- )
+static HW *glue(audio_pcm_hw_find_specific_, TYPE)(AudioState *s, HW *hw,
+ struct audsettings *as)
{
- while ((hw = glue (audio_pcm_hw_find_any_, TYPE) (hw))) {
+ while ((hw = glue(audio_pcm_hw_find_any_, TYPE)(s, hw))) {
if (audio_pcm_info_eq (&hw->info, as)) {
return hw;
}
return NULL;
}
-static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct audsettings *as)
+static HW *glue(audio_pcm_hw_add_new_, TYPE)(AudioState *s,
+ struct audsettings *as)
{
HW *hw;
- AudioState *s = &glob_audio_state;
struct audio_driver *drv = s->drv;
if (!glue (s->nb_hw_voices_, TYPE)) {
return NULL;
}
+ hw->s = s;
hw->pcm_ops = drv->pcm_ops;
hw->ctl_caps = drv->ctl_caps;
abort();
}
-static HW *glue (audio_pcm_hw_add_, TYPE) (struct audsettings *as)
+static HW *glue(audio_pcm_hw_add_, TYPE)(AudioState *s, struct audsettings *as)
{
HW *hw;
- AudioState *s = &glob_audio_state;
AudiodevPerDirectionOptions *pdo = glue(audio_get_pdo_, TYPE)(s->dev);
if (pdo->fixed_settings) {
- hw = glue (audio_pcm_hw_add_new_, TYPE) (as);
+ hw = glue(audio_pcm_hw_add_new_, TYPE)(s, as);
if (hw) {
return hw;
}
}
- hw = glue (audio_pcm_hw_find_specific_, TYPE) (NULL, as);
+ hw = glue(audio_pcm_hw_find_specific_, TYPE)(s, NULL, as);
if (hw) {
return hw;
}
- hw = glue (audio_pcm_hw_add_new_, TYPE) (as);
+ hw = glue(audio_pcm_hw_add_new_, TYPE)(s, as);
if (hw) {
return hw;
}
- return glue (audio_pcm_hw_find_any_, TYPE) (NULL);
+ return glue(audio_pcm_hw_find_any_, TYPE)(s, NULL);
}
-static SW *glue (audio_pcm_create_voice_pair_, TYPE) (
+static SW *glue(audio_pcm_create_voice_pair_, TYPE)(
+ AudioState *s,
const char *sw_name,
struct audsettings *as
)
SW *sw;
HW *hw;
struct audsettings hw_as;
- AudioState *s = &glob_audio_state;
AudiodevPerDirectionOptions *pdo = glue(audio_get_pdo_, TYPE)(s->dev);
if (pdo->fixed_settings) {
sw_name ? sw_name : "unknown", sizeof (*sw));
goto err1;
}
+ sw->s = s;
- hw = glue (audio_pcm_hw_add_, TYPE) (&hw_as);
+ hw = glue(audio_pcm_hw_add_, TYPE)(s, &hw_as);
if (!hw) {
goto err2;
}
}
}
else {
- sw = glue (audio_pcm_create_voice_pair_, TYPE) (name, as);
+ sw = glue(audio_pcm_create_voice_pair_, TYPE)(s, name, as);
if (!sw) {
dolog ("Failed to create voice `%s'\n", name);
return NULL;