1295
1296
HWVoiceOut *hw = NULL;
1296
1297
SWVoiceOut *sw;
1298
while ((hw = audio_pcm_hw_find_any_enabled_out (s, hw))) {
1299
while ((hw = audio_pcm_hw_find_any_enabled_out (hw))) {
1300
1301
int live, free, nb_live, cleanup_required, prev_rpos;
1610
1611
s->drv_opaque = drv->init ();
1612
1613
if (s->drv_opaque) {
1613
audio_init_nb_voices_out (s, drv);
1614
audio_init_nb_voices_in (s, drv);
1614
audio_init_nb_voices_out (drv);
1615
audio_init_nb_voices_in (drv);
1630
1631
int op = running ? VOICE_ENABLE : VOICE_DISABLE;
1632
1633
s->vm_running = running;
1633
while ((hwo = audio_pcm_hw_find_any_enabled_out (s, hwo))) {
1634
while ((hwo = audio_pcm_hw_find_any_enabled_out (hwo))) {
1634
1635
hwo->pcm_ops->ctl_out (hwo, op);
1637
while ((hwi = audio_pcm_hw_find_any_enabled_in (s, hwi))) {
1638
while ((hwi = audio_pcm_hw_find_any_enabled_in (hwi))) {
1638
1639
hwi->pcm_ops->ctl_in (hwi, op);
1692
void AUD_register_card (AudioState *s, const char *name, QEMUSoundCard *card)
1695
card->name = qemu_strdup (name);
1696
memset (&card->entries, 0, sizeof (card->entries));
1697
LIST_INSERT_HEAD (&s->card_head, card, entries);
1700
void AUD_remove_card (QEMUSoundCard *card)
1702
LIST_REMOVE (card, entries);
1704
qemu_free (card->name);
1707
AudioState *AUD_init (void)
1693
static void audio_init (void)
1711
1697
const char *drvname;
1712
1698
AudioState *s = &glob_audio_state;
1714
1704
LIST_INIT (&s->hw_head_out);
1715
1705
LIST_INIT (&s->hw_head_in);
1716
1706
LIST_INIT (&s->cap_head);
1719
1709
s->ts = qemu_new_timer (vm_clock, audio_timer, s);
1721
dolog ("Could not create audio timer\n");
1711
hw_error("Could not create audio timer\n");
1725
1714
audio_process_options ("AUDIO", audio_options);
1773
1762
done = !audio_driver_init (s, &no_audio_driver);
1775
dolog ("Could not initialize audio subsystem\n");
1764
hw_error("Could not initialize audio subsystem\n");
1778
1767
dolog ("warning: Using timer based audio emulation\n");
1783
VMChangeStateEntry *e;
1785
if (conf.period.hertz <= 0) {
1786
if (conf.period.hertz < 0) {
1787
dolog ("warning: Timer period is negative - %d "
1788
"treating as zero\n",
1791
conf.period.ticks = 1;
1794
conf.period.ticks = ticks_per_sec / conf.period.hertz;
1797
e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);
1799
dolog ("warning: Could not register change state handler\n"
1800
"(Audio can continue looping even after stopping the VM)\n");
1771
VMChangeStateEntry *e;
1773
if (conf.period.hertz <= 0) {
1774
if (conf.period.hertz < 0) {
1775
dolog ("warning: Timer period is negative - %d "
1776
"treating as zero\n",
1779
conf.period.ticks = 1;
1781
conf.period.ticks = ticks_per_sec / conf.period.hertz;
1804
qemu_del_timer (s->ts);
1784
e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);
1786
dolog ("warning: Could not register change state handler\n"
1787
"(Audio can continue looping even after stopping the VM)\n");
1808
1790
LIST_INIT (&s->card_head);
1809
1791
register_savevm ("audio", 0, 1, audio_save, audio_load, s);
1810
1792
qemu_mod_timer (s->ts, qemu_get_clock (vm_clock) + conf.period.ticks);
1795
void AUD_register_card (const char *name, QEMUSoundCard *card)
1798
card->name = qemu_strdup (name);
1799
memset (&card->entries, 0, sizeof (card->entries));
1800
LIST_INSERT_HEAD (&glob_audio_state.card_head, card, entries);
1803
void AUD_remove_card (QEMUSoundCard *card)
1805
LIST_REMOVE (card, entries);
1806
qemu_free (card->name);
1814
1810
CaptureVoiceOut *AUD_add_capture (
1816
1811
struct audsettings *as,
1817
1812
struct audio_capture_ops *ops,
1818
1813
void *cb_opaque
1816
AudioState *s = &glob_audio_state;
1821
1817
CaptureVoiceOut *cap;
1822
1818
struct capture_callback *cb;
1826
s = &glob_audio_state;
1829
1820
if (audio_validate_settings (as)) {
1830
1821
dolog ("Invalid settings were passed when trying to add capture\n");
1831
1822
audio_print_settings (as);
1891
1882
LIST_INSERT_HEAD (&cap->cb_head, cb, entries);
1894
while ((hw = audio_pcm_hw_find_any_out (s, hw))) {
1895
audio_attach_capture (s, hw);
1885
while ((hw = audio_pcm_hw_find_any_out (hw))) {
1886
audio_attach_capture (hw);