Revision 1a7dafce audio/audio.c
b/audio/audio.c | ||
---|---|---|
707 | 707 |
} |
708 | 708 |
|
709 | 709 |
static CaptureVoiceOut *audio_pcm_capture_find_specific ( |
710 |
AudioState *s, |
|
711 | 710 |
struct audsettings *as |
712 | 711 |
) |
713 | 712 |
{ |
714 | 713 |
CaptureVoiceOut *cap; |
714 |
AudioState *s = &glob_audio_state; |
|
715 | 715 |
|
716 | 716 |
for (cap = s->cap_head.lh_first; cap; cap = cap->entries.le_next) { |
717 | 717 |
if (audio_pcm_info_eq (&cap->hw.info, as)) { |
... | ... | |
786 | 786 |
} |
787 | 787 |
} |
788 | 788 |
|
789 |
static int audio_attach_capture (AudioState *s, HWVoiceOut *hw)
|
|
789 |
static int audio_attach_capture (HWVoiceOut *hw) |
|
790 | 790 |
{ |
791 |
AudioState *s = &glob_audio_state; |
|
791 | 792 |
CaptureVoiceOut *cap; |
792 | 793 |
|
793 | 794 |
audio_detach_capture (hw); |
... | ... | |
1295 | 1296 |
HWVoiceOut *hw = NULL; |
1296 | 1297 |
SWVoiceOut *sw; |
1297 | 1298 |
|
1298 |
while ((hw = audio_pcm_hw_find_any_enabled_out (s, hw))) {
|
|
1299 |
while ((hw = audio_pcm_hw_find_any_enabled_out (hw))) { |
|
1299 | 1300 |
int played; |
1300 | 1301 |
int live, free, nb_live, cleanup_required, prev_rpos; |
1301 | 1302 |
|
... | ... | |
1390 | 1391 |
#ifdef DEBUG_PLIVE |
1391 | 1392 |
dolog ("Finishing with old voice\n"); |
1392 | 1393 |
#endif |
1393 |
audio_close_out (s, sw);
|
|
1394 |
audio_close_out (sw); |
|
1394 | 1395 |
} |
1395 | 1396 |
sw = sw1; |
1396 | 1397 |
} |
... | ... | |
1402 | 1403 |
{ |
1403 | 1404 |
HWVoiceIn *hw = NULL; |
1404 | 1405 |
|
1405 |
while ((hw = audio_pcm_hw_find_any_enabled_in (s, hw))) {
|
|
1406 |
while ((hw = audio_pcm_hw_find_any_enabled_in (hw))) { |
|
1406 | 1407 |
SWVoiceIn *sw; |
1407 | 1408 |
int captured, min; |
1408 | 1409 |
|
... | ... | |
1610 | 1611 |
s->drv_opaque = drv->init (); |
1611 | 1612 |
|
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); |
|
1615 | 1616 |
s->drv = drv; |
1616 | 1617 |
return 0; |
1617 | 1618 |
} |
... | ... | |
1630 | 1631 |
int op = running ? VOICE_ENABLE : VOICE_DISABLE; |
1631 | 1632 |
|
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); |
1635 | 1636 |
} |
1636 | 1637 |
|
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); |
1639 | 1640 |
} |
1640 | 1641 |
} |
... | ... | |
1645 | 1646 |
HWVoiceOut *hwo = NULL; |
1646 | 1647 |
HWVoiceIn *hwi = NULL; |
1647 | 1648 |
|
1648 |
while ((hwo = audio_pcm_hw_find_any_enabled_out (s, hwo))) {
|
|
1649 |
while ((hwo = audio_pcm_hw_find_any_enabled_out (hwo))) { |
|
1649 | 1650 |
SWVoiceCap *sc; |
1650 | 1651 |
|
1651 | 1652 |
hwo->pcm_ops->ctl_out (hwo, VOICE_DISABLE); |
... | ... | |
1661 | 1662 |
} |
1662 | 1663 |
} |
1663 | 1664 |
|
1664 |
while ((hwi = audio_pcm_hw_find_any_enabled_in (s, hwi))) {
|
|
1665 |
while ((hwi = audio_pcm_hw_find_any_enabled_in (hwi))) { |
|
1665 | 1666 |
hwi->pcm_ops->ctl_in (hwi, VOICE_DISABLE); |
1666 | 1667 |
hwi->pcm_ops->fini_in (hwi); |
1667 | 1668 |
} |
... | ... | |
1689 | 1690 |
return 0; |
1690 | 1691 |
} |
1691 | 1692 |
|
1692 |
void AUD_register_card (AudioState *s, const char *name, QEMUSoundCard *card) |
|
1693 |
{ |
|
1694 |
card->audio = s; |
|
1695 |
card->name = qemu_strdup (name); |
|
1696 |
memset (&card->entries, 0, sizeof (card->entries)); |
|
1697 |
LIST_INSERT_HEAD (&s->card_head, card, entries); |
|
1698 |
} |
|
1699 |
|
|
1700 |
void AUD_remove_card (QEMUSoundCard *card) |
|
1701 |
{ |
|
1702 |
LIST_REMOVE (card, entries); |
|
1703 |
card->audio = NULL; |
|
1704 |
qemu_free (card->name); |
|
1705 |
} |
|
1706 |
|
|
1707 |
AudioState *AUD_init (void) |
|
1693 |
static void audio_init (void) |
|
1708 | 1694 |
{ |
1709 | 1695 |
size_t i; |
1710 | 1696 |
int done = 0; |
... | ... | |
1712 | 1698 |
AudioState *s = &glob_audio_state; |
1713 | 1699 |
|
1714 | 1700 |
if (s->drv) { |
1715 |
return s;
|
|
1701 |
return; |
|
1716 | 1702 |
} |
1717 | 1703 |
|
1718 | 1704 |
LIST_INIT (&s->hw_head_out); |
... | ... | |
1804 | 1790 |
LIST_INIT (&s->card_head); |
1805 | 1791 |
register_savevm ("audio", 0, 1, audio_save, audio_load, s); |
1806 | 1792 |
qemu_mod_timer (s->ts, qemu_get_clock (vm_clock) + conf.period.ticks); |
1807 |
return s; |
|
1808 | 1793 |
} |
1809 | 1794 |
|
1795 |
void AUD_register_card (const char *name, QEMUSoundCard *card) |
|
1796 |
{ |
|
1797 |
audio_init (); |
|
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); |
|
1801 |
} |
|
1802 |
|
|
1803 |
void AUD_remove_card (QEMUSoundCard *card) |
|
1804 |
{ |
|
1805 |
LIST_REMOVE (card, entries); |
|
1806 |
qemu_free (card->name); |
|
1807 |
} |
|
1808 |
|
|
1809 |
|
|
1810 | 1810 |
CaptureVoiceOut *AUD_add_capture ( |
1811 |
AudioState *s, |
|
1812 | 1811 |
struct audsettings *as, |
1813 | 1812 |
struct audio_capture_ops *ops, |
1814 | 1813 |
void *cb_opaque |
1815 | 1814 |
) |
1816 | 1815 |
{ |
1816 |
AudioState *s = &glob_audio_state; |
|
1817 | 1817 |
CaptureVoiceOut *cap; |
1818 | 1818 |
struct capture_callback *cb; |
1819 | 1819 |
|
1820 |
if (!s) { |
|
1821 |
/* XXX suppress */ |
|
1822 |
s = &glob_audio_state; |
|
1823 |
} |
|
1824 |
|
|
1825 | 1820 |
if (audio_validate_settings (as)) { |
1826 | 1821 |
dolog ("Invalid settings were passed when trying to add capture\n"); |
1827 | 1822 |
audio_print_settings (as); |
... | ... | |
1837 | 1832 |
cb->ops = *ops; |
1838 | 1833 |
cb->opaque = cb_opaque; |
1839 | 1834 |
|
1840 |
cap = audio_pcm_capture_find_specific (s, as);
|
|
1835 |
cap = audio_pcm_capture_find_specific (as); |
|
1841 | 1836 |
if (cap) { |
1842 | 1837 |
LIST_INSERT_HEAD (&cap->cb_head, cb, entries); |
1843 | 1838 |
return cap; |
... | ... | |
1887 | 1882 |
LIST_INSERT_HEAD (&cap->cb_head, cb, entries); |
1888 | 1883 |
|
1889 | 1884 |
hw = NULL; |
1890 |
while ((hw = audio_pcm_hw_find_any_out (s, hw))) {
|
|
1891 |
audio_attach_capture (s, hw);
|
|
1885 |
while ((hw = audio_pcm_hw_find_any_out (hw))) { |
|
1886 |
audio_attach_capture (hw); |
|
1892 | 1887 |
} |
1893 | 1888 |
return cap; |
1894 | 1889 |
|
Also available in: Unified diff