Lines Matching refs:hw

751         if (audio_pcm_info_eq (&cap->hw.info, as)) {
772 if (cap->hw.enabled != enabled) {
774 cap->hw.enabled = enabled;
782 HWVoiceOut *hw = &cap->hw;
786 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
795 static void audio_detach_capture (HWVoiceOut *hw)
797 SWVoiceCap *sc = hw->cap_head.lh_first;
823 static int audio_attach_capture (AudioState *s, HWVoiceOut *hw)
827 audio_detach_capture (hw);
831 HWVoiceOut *hw_cap = &cap->hw;
842 sw->hw = hw_cap;
843 sw->info = hw->info;
845 sw->active = hw->enabled;
855 LIST_INSERT_HEAD (&hw->cap_head, sc, entries);
858 hw, sw->info.freq, sw->info.bits, sw->info.nchannels);
871 static int audio_pcm_hw_find_min_in (HWVoiceIn *hw)
874 int m = hw->total_samples_captured;
876 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
884 int audio_pcm_hw_get_live_in (HWVoiceIn *hw)
886 int live = hw->total_samples_captured - audio_pcm_hw_find_min_in (hw);
887 if (audio_bug (AUDIO_FUNC, live < 0 || live > hw->samples)) {
888 dolog ("live=%d hw->samples=%d\n", live, hw->samples);
899 HWVoiceIn *hw = sw->hw;
900 int live = hw->total_samples_captured - sw->total_hw_samples_acquired;
903 if (audio_bug (AUDIO_FUNC, live < 0 || live > hw->samples)) {
904 dolog ("live=%d hw->samples=%d\n", live, hw->samples);
908 rpos = hw->wpos - live;
913 return hw->samples + rpos;
919 HWVoiceIn *hw = sw->hw;
923 rpos = audio_pcm_sw_get_rpos_in (sw) % hw->samples;
925 live = hw->total_samples_captured - sw->total_hw_samples_acquired;
926 if (audio_bug (AUDIO_FUNC, live < 0 || live > hw->samples)) {
927 dolog ("live_in=%d hw->samples=%d\n", live, hw->samples);
940 src = hw->conv_buf + rpos;
941 isamp = hw->wpos - rpos;
944 isamp = hw->samples - rpos;
962 rpos = (rpos + isamp) % hw->samples;
978 static int audio_pcm_hw_find_min_out (HWVoiceOut *hw, int *nb_livep)
984 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
995 int audio_pcm_hw_get_live_out2 (HWVoiceOut *hw, int *nb_live)
999 smin = audio_pcm_hw_find_min_out (hw, nb_live);
1007 if (audio_bug (AUDIO_FUNC, live < 0 || live > hw->samples)) {
1008 dolog ("live=%d hw->samples=%d\n", live, hw->samples);
1015 int audio_pcm_hw_get_live_out (HWVoiceOut *hw)
1020 live = audio_pcm_hw_get_live_out2 (hw, &nb_live);
1021 if (audio_bug (AUDIO_FUNC, live < 0 || live > hw->samples)) {
1022 dolog ("live=%d hw->samples=%d\n", live, hw->samples);
1040 hwsamples = sw->hw->samples;
1044 dolog ("live=%d hw->samples=%d\n", live, hwsamples);
1055 wpos = (sw->hw->rpos + live) % hwsamples;
1087 sw->hw->mix_buf + wpos,
1137 if (!sw->hw->enabled) {
1142 bytes = sw->hw->pcm_ops->write (sw, buf, size);
1155 if (!sw->hw->enabled) {
1160 bytes = sw->hw->pcm_ops->read (sw, buf, size);
1166 return sw->hw->samples << sw->hw->info.shift;
1171 HWVoiceOut *hw;
1177 hw = sw->hw;
1183 hw->pending_disable = 0;
1184 if (!hw->enabled) {
1185 hw->enabled = 1;
1186 hw->pcm_ops->ctl_out (hw, VOICE_ENABLE);
1190 if (hw->enabled) {
1193 for (temp_sw = hw->sw_head.lh_first; temp_sw;
1198 hw->pending_disable = nb_active == 1;
1202 for (sc = hw->cap_head.lh_first; sc; sc = sc->entries.le_next) {
1203 sc->sw.active = hw->enabled;
1204 if (hw->enabled) {
1214 HWVoiceIn *hw;
1220 hw = sw->hw;
1225 if (!hw->enabled) {
1226 hw->enabled = 1;
1227 hw->pcm_ops->ctl_in (hw, VOICE_ENABLE);
1229 sw->total_hw_samples_acquired = hw->total_samples_captured;
1232 if (hw->enabled) {
1235 for (temp_sw = hw->sw_head.lh_first; temp_sw;
1241 hw->enabled = 0;
1242 hw->pcm_ops->ctl_in (hw, VOICE_DISABLE);
1258 live = sw->hw->total_samples_captured - sw->total_hw_samples_acquired;
1259 if (audio_bug (AUDIO_FUNC, live < 0 || live > sw->hw->samples)) {
1260 dolog ("live=%d sw->hw->samples=%d\n", live, sw->hw->samples);
1283 if (audio_bug (AUDIO_FUNC, live < 0 || live > sw->hw->samples)) {
1284 dolog ("live=%d sw->hw->samples=%d\n", live, sw->hw->samples);
1288 dead = sw->hw->samples - live;
1299 static void audio_capture_mix_and_clear (HWVoiceOut *hw, int rpos, int samples)
1303 if (hw->enabled) {
1306 for (sc = hw->cap_head.lh_first; sc; sc = sc->entries.le_next) {
1312 int till_end_of_hw = hw->samples - rpos2;
1314 int bytes = to_write << hw->info.shift;
1317 sw->buf = hw->mix_buf + rpos2;
1326 rpos2 = (rpos2 + to_write) % hw->samples;
1331 n = audio_MIN (samples, hw->samples - rpos);
1332 mixeng_sniff_and_clear (hw, hw->mix_buf + rpos, n);
1333 mixeng_sniff_and_clear (hw, hw->mix_buf, samples - n);
1338 HWVoiceOut *hw = NULL;
1341 while ((hw = audio_pcm_hw_find_any_enabled_out (s, hw))) {
1345 live = audio_pcm_hw_get_live_out2 (hw, &nb_live);
1350 if (audio_bug (AUDIO_FUNC, live < 0 || live > hw->samples)) {
1351 dolog ("live=%d hw->samples=%d\n", live, hw->samples);
1355 if (hw->pending_disable && !nb_live) {
1360 hw->enabled = 0;
1361 hw->pending_disable = 0;
1362 hw->pcm_ops->ctl_out (hw, VOICE_DISABLE);
1363 for (sc = hw->cap_head.lh_first; sc; sc = sc->entries.le_next) {
1371 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
1382 prev_rpos = hw->rpos;
1383 played = hw->pcm_ops->run_out (hw);
1384 if (audio_bug (AUDIO_FUNC, hw->rpos >= hw->samples)) {
1385 dolog ("hw->rpos=%d hw->samples=%d played=%d\n",
1386 hw->rpos, hw->samples, played);
1387 hw->rpos = 0;
1395 hw->ts_helper += played;
1396 audio_capture_mix_and_clear (hw, prev_rpos, played);
1400 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
1429 sw = hw->sw_head.lh_first;
1446 HWVoiceIn *hw = NULL;
1448 while ((hw = audio_pcm_hw_find_any_enabled_in (s, hw))) {
1452 captured = hw->pcm_ops->run_in (hw);
1454 min = audio_pcm_hw_find_min_in (hw);
1455 hw->total_samples_captured += captured - min;
1456 hw->ts_helper += captured;
1458 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
1479 HWVoiceOut *hw = &cap->hw;
1482 captured = live = audio_pcm_hw_get_live_out (hw);
1483 rpos = hw->rpos;
1485 int left = hw->samples - rpos;
1490 src = hw->mix_buf + rpos;
1491 hw->clip (cap->buf, src, to_capture);
1492 mixeng_sniff_and_clear (hw, src, to_capture);
1496 to_capture << hw->info.shift);
1498 rpos = (rpos + to_capture) % hw->samples;
1501 hw->rpos = rpos;
1503 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
1814 HWVoiceOut *hw;
1826 hw = &cap->hw;
1827 LIST_INIT (&hw->sw_head);
1831 hw->samples = 4096 * 4;
1832 hw->mix_buf = audio_calloc (AUDIO_FUNC, hw->samples,
1834 if (!hw->mix_buf) {
1836 hw->samples);
1840 audio_pcm_init_info (&hw->info, as);
1842 cap->buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
1846 hw->samples, 1 << hw->info.shift);
1850 hw->clip = mixeng_clip
1851 [hw->info.nchannels == 2]
1852 [hw->info.sign]
1853 [hw->info.swap_endianness]
1854 [audio_bits_to_index (hw->info.bits)];
1859 hw = NULL;
1860 while ((hw = audio_pcm_hw_find_any_out (s, hw))) {
1861 audio_attach_capture (s, hw);
1866 qemu_free (cap->hw.mix_buf);
1887 SWVoiceOut *sw = cap->hw.sw_head.lh_first, *sw1;
1978 return filteraudio_is_host_voice_in_ok(s->drv, sw->hw);
1989 return filteraudio_is_host_voice_out_ok(s->drv, sw->hw);