38
38
#define SW_NAME(sw) (sw)->name ? (sw)->name : "unknown"
41
/* Order of CONFIG_AUDIO_DRIVERS is import.
42
The 1st one is the one used by default, that is the reason
43
that we generate the list.
40
45
static struct audio_driver *drvtab[] = {
61
66
int log_to_monitor;
63
{ /* DAC fixed settings */
70
AUD_FMT_S16, /* fmt */
75
{ /* ADC fixed settings */
82
AUD_FMT_S16, /* fmt */
89
0 /* log_to_monitor */
68
.fixed_out = { /* DAC fixed settings */
76
.endianness = AUDIO_HOST_ENDIANNESS,
80
.fixed_in = { /* ADC fixed settings */
88
.endianness = AUDIO_HOST_ENDIANNESS,
92
.period = { .hertz = 250 },
92
97
static AudioState glob_audio_state;
94
99
struct mixeng_volume nominal_volume = {
96
101
#ifdef FLOAT_MIXENG
329
334
if (conf.log_to_monitor) {
331
term_printf ("%s: ", cap);
336
monitor_printf(cur_mon, "%s: ", cap);
334
term_vprintf (fmt, ap);
339
monitor_vprintf(cur_mon, fmt, ap);
1295
1301
HWVoiceOut *hw = NULL;
1296
1302
SWVoiceOut *sw;
1298
while ((hw = audio_pcm_hw_find_any_enabled_out (s, hw))) {
1304
while ((hw = audio_pcm_hw_find_any_enabled_out (hw))) {
1300
1306
int live, free, nb_live, cleanup_required, prev_rpos;
1610
1616
s->drv_opaque = drv->init ();
1612
1618
if (s->drv_opaque) {
1613
audio_init_nb_voices_out (s, drv);
1614
audio_init_nb_voices_in (s, drv);
1619
audio_init_nb_voices_out (drv);
1620
audio_init_nb_voices_in (drv);
1630
1636
int op = running ? VOICE_ENABLE : VOICE_DISABLE;
1632
1638
s->vm_running = running;
1633
while ((hwo = audio_pcm_hw_find_any_enabled_out (s, hwo))) {
1639
while ((hwo = audio_pcm_hw_find_any_enabled_out (hwo))) {
1634
1640
hwo->pcm_ops->ctl_out (hwo, op);
1637
while ((hwi = audio_pcm_hw_find_any_enabled_in (s, hwi))) {
1643
while ((hwi = audio_pcm_hw_find_any_enabled_in (hwi))) {
1638
1644
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)
1698
static void audio_init (void)
1711
1702
const char *drvname;
1712
1703
AudioState *s = &glob_audio_state;
1714
1709
LIST_INIT (&s->hw_head_out);
1715
1710
LIST_INIT (&s->hw_head_in);
1716
1711
LIST_INIT (&s->cap_head);
1719
1714
s->ts = qemu_new_timer (vm_clock, audio_timer, s);
1721
dolog ("Could not create audio timer\n");
1716
hw_error("Could not create audio timer\n");
1725
1719
audio_process_options ("AUDIO", audio_options);
1773
1767
done = !audio_driver_init (s, &no_audio_driver);
1775
dolog ("Could not initialize audio subsystem\n");
1769
hw_error("Could not initialize audio subsystem\n");
1778
1772
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");
1776
VMChangeStateEntry *e;
1778
if (conf.period.hertz <= 0) {
1779
if (conf.period.hertz < 0) {
1780
dolog ("warning: Timer period is negative - %d "
1781
"treating as zero\n",
1784
conf.period.ticks = 1;
1786
conf.period.ticks = ticks_per_sec / conf.period.hertz;
1804
qemu_del_timer (s->ts);
1789
e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);
1791
dolog ("warning: Could not register change state handler\n"
1792
"(Audio can continue looping even after stopping the VM)\n");
1808
1795
LIST_INIT (&s->card_head);
1809
1796
register_savevm ("audio", 0, 1, audio_save, audio_load, s);
1810
1797
qemu_mod_timer (s->ts, qemu_get_clock (vm_clock) + conf.period.ticks);
1800
void AUD_register_card (const char *name, QEMUSoundCard *card)
1803
card->name = qemu_strdup (name);
1804
memset (&card->entries, 0, sizeof (card->entries));
1805
LIST_INSERT_HEAD (&glob_audio_state.card_head, card, entries);
1808
void AUD_remove_card (QEMUSoundCard *card)
1810
LIST_REMOVE (card, entries);
1811
qemu_free (card->name);
1814
1815
CaptureVoiceOut *AUD_add_capture (
1816
1816
struct audsettings *as,
1817
1817
struct audio_capture_ops *ops,
1818
1818
void *cb_opaque
1821
AudioState *s = &glob_audio_state;
1821
1822
CaptureVoiceOut *cap;
1822
1823
struct capture_callback *cb;
1826
s = &glob_audio_state;
1829
1825
if (audio_validate_settings (as)) {
1830
1826
dolog ("Invalid settings were passed when trying to add capture\n");
1831
1827
audio_print_settings (as);
1891
1887
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);
1890
while ((hw = audio_pcm_hw_find_any_out (hw))) {
1891
audio_attach_capture (hw);