Lines Matching defs:sw

55 #define SW_NAME(sw) (sw)->name ? (sw)->name : "unknown"
783 SWVoiceOut *sw;
786 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
787 if (sw->active) {
801 SWVoiceOut *sw = &sc->sw;
803 int was_active = sw->active;
805 if (sw->rate) {
806 st_rate_stop (sw->rate);
807 sw->rate = NULL;
810 LIST_REMOVE (sw, entries);
830 SWVoiceOut *sw;
841 sw = &sc->sw;
842 sw->hw = hw_cap;
843 sw->info = hw->info;
844 sw->empty = 1;
845 sw->active = hw->enabled;
846 sw->conv = noop_conv;
847 sw->ratio = ((int64_t) hw_cap->info.freq << 32) / sw->info.freq;
848 sw->rate = st_rate_start (sw->info.freq, hw_cap->info.freq);
849 if (!sw->rate) {
850 dolog ("Could not start rate conversion for `%s'\n", SW_NAME (sw));
851 qemu_free (sw);
854 LIST_INSERT_HEAD (&hw_cap->sw_head, sw, entries);
857 asprintf (&sw->name, "for %p %d,%d,%d",
858 hw, sw->info.freq, sw->info.bits, sw->info.nchannels);
859 dolog ("Added %s active = %d\n", sw->name, sw->active);
861 if (sw->active) {
873 SWVoiceIn *sw;
876 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
877 if (sw->active) {
878 m = audio_MIN (m, sw->total_hw_samples_acquired);
897 static int audio_pcm_sw_get_rpos_in (SWVoiceIn *sw)
899 HWVoiceIn *hw = sw->hw;
900 int live = hw->total_samples_captured - sw->total_hw_samples_acquired;
917 int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int size)
919 HWVoiceIn *hw = sw->hw;
921 st_sample_t *src, *dst = sw->buf;
923 rpos = audio_pcm_sw_get_rpos_in (sw) % hw->samples;
925 live = hw->total_samples_captured - sw->total_hw_samples_acquired;
931 samples = size >> sw->info.shift;
936 swlim = (live * sw->ratio) >> 32;
957 if (ret + osamp > sw->buf_samples)
959 ret, osamp, sw->buf_samples));
960 st_rate_flow (sw->rate, src, dst, &isamp, &osamp);
968 if (ret > sw->buf_samples)
969 Log(("audio_pcm_sw_read: buffer overflow!! ret = %d, buf_samples = %d\n", ret, sw->buf_samples));
970 sw->clip (buf, sw->buf, ret);
971 sw->total_hw_samples_acquired += total;
972 return ret << sw->info.shift;
980 SWVoiceOut *sw;
984 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
985 if (sw->active || !sw->empty) {
986 m = audio_MIN (m, sw->total_hw_samples_mixed);
1031 int audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int size)
1036 if (!sw) {
1040 hwsamples = sw->hw->samples;
1042 live = sw->total_hw_samples_mixed;
1050 dolog ("%s is full %d\n", sw->name, live);
1055 wpos = (sw->hw->rpos + live) % hwsamples;
1056 samples = size >> sw->info.shift;
1059 swlim = ((int64_t) dead << 32) / sw->ratio;
1061 if (swlim > sw->buf_samples)
1063 swlim, pos, sw->buf_samples));
1066 sw->conv (sw->buf, buf, swlim, &sw->vol);
1068 sw->conv (sw->buf, buf, swlim, &sum_out_volume);
1081 if (pos + isamp > sw->buf_samples)
1083 isamp, pos, sw->buf_samples));
1085 sw->rate,
1086 sw->buf + pos,
1087 sw->hw->mix_buf + wpos,
1099 sw->total_hw_samples_mixed += total;
1100 sw->empty = sw->total_hw_samples_mixed == 0;
1104 "%s: write size %d ret %d total sw %d\n",
1105 SW_NAME (sw),
1106 size >> sw->info.shift,
1108 sw->total_hw_samples_mixed
1112 return ret << sw->info.shift;
1128 int AUD_write (SWVoiceOut *sw, void *buf, int size)
1132 if (!sw) {
1137 if (!sw->hw->enabled) {
1138 dolog ("Writing to disabled voice %s\n", SW_NAME (sw));
1142 bytes = sw->hw->pcm_ops->write (sw, buf, size);
1146 int AUD_read (SWVoiceIn *sw, void *buf, int size)
1150 if (!sw) {
1155 if (!sw->hw->enabled) {
1156 dolog ("Reading from disabled voice %s\n", SW_NAME (sw));
1160 bytes = sw->hw->pcm_ops->read (sw, buf, size);
1164 int AUD_get_buffer_size_out (SWVoiceOut *sw)
1166 return sw->hw->samples << sw->hw->info.shift;
1169 void AUD_set_active_out (SWVoiceOut *sw, int on)
1173 if (!sw) {
1177 hw = sw->hw;
1178 if (sw->active != on) {
1203 sc->sw.active = hw->enabled;
1208 sw->active = on;
1212 void AUD_set_active_in (SWVoiceIn *sw, int on)
1216 if (!sw) {
1220 hw = sw->hw;
1221 if (sw->active != on) {
1229 sw->total_hw_samples_acquired = hw->total_samples_captured;
1246 sw->active = on;
1250 static int audio_get_avail (SWVoiceIn *sw)
1254 if (!sw) {
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);
1266 SW_NAME (sw),
1267 live, (((int64_t) live << 32) / sw->ratio) << sw->info.shift
1270 return (((int64_t) live << 32) / sw->ratio) << sw->info.shift;
1273 static int audio_get_free (SWVoiceOut *sw)
1277 if (!sw) {
1281 live = sw->total_hw_samples_mixed;
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;
1292 SW_NAME (sw),
1293 live, dead, (((int64_t) dead << 32) / sw->ratio) << sw->info.shift);
1296 return (((int64_t) dead << 32) / sw->ratio) << sw->info.shift;
1307 SWVoiceOut *sw = &sc->sw;
1317 sw->buf = hw->mix_buf + rpos2;
1318 written = audio_pcm_sw_write (sw, NULL, bytes);
1339 SWVoiceOut *sw;
1364 sc->sw.active = 0;
1371 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
1372 if (sw->active) {
1373 myfree = audio_get_free (sw);
1375 sw->callback.fn (sw->callback.opaque, myfree);
1400 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
1401 if (!sw->active && sw->empty) {
1405 if (audio_bug (AUDIO_FUNC, played > sw->total_hw_samples_mixed)) {
1406 dolog ("played=%d sw->total_hw_samples_mixed=%d\n",
1407 played, sw->total_hw_samples_mixed);
1408 played = sw->total_hw_samples_mixed;
1411 sw->total_hw_samples_mixed -= played;
1413 if (!sw->total_hw_samples_mixed) {
1414 sw->empty = 1;
1415 cleanup_required |= !sw->active && !sw->callback.fn;
1418 if (sw->active) {
1419 myfree = audio_get_free (sw);
1421 sw->callback.fn (sw->callback.opaque, myfree);
1429 sw = hw->sw_head.lh_first;
1430 while (sw) {
1431 sw1 = sw->entries.le_next;
1432 if (!sw->active && !sw->callback.fn) {
1436 audio_close_out (s, sw);
1438 sw = sw1;
1449 SWVoiceIn *sw;
1458 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
1459 sw->total_hw_samples_acquired -= min;
1461 if (sw->active) {
1464 avail = audio_get_avail (sw);
1466 sw->callback.fn (sw->callback.opaque, avail);
1480 SWVoiceOut *sw;
1503 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
1504 if (!sw->active && sw->empty) {
1508 if (audio_bug (AUDIO_FUNC, captured > sw->total_hw_samples_mixed)) {
1509 dolog ("captured=%d sw->total_hw_samples_mixed=%d\n",
1510 captured, sw->total_hw_samples_mixed);
1511 captured = sw->total_hw_samples_mixed;
1514 sw->total_hw_samples_mixed -= captured;
1515 sw->empty = sw->total_hw_samples_mixed == 0;
1887 SWVoiceOut *sw = cap->hw.sw_head.lh_first, *sw1;
1889 while (sw) {
1890 SWVoiceCap *sc = (SWVoiceCap *) sw;
1892 dolog ("freeing %s\n", sw->name);
1895 sw1 = sw->entries.le_next;
1896 if (sw->rate) {
1897 st_rate_stop (sw->rate);
1898 sw->rate = NULL;
1900 LIST_REMOVE (sw, entries);
1903 sw = sw1;
1913 void AUD_set_volume_out (SWVoiceOut *sw, int mute, uint8_t lvol, uint8_t rvol)
1915 if (sw)
1917 sw->vol.mute = mute;
1918 sw->vol.l = (uint32_t)lvol * 0x808080; /* maximum is INT_MAX = 0x7fffffff */
1919 sw->vol.r = (uint32_t)rvol * 0x808080; /* maximum is INT_MAX = 0x7fffffff */
1970 int AUD_is_host_voice_in_ok(SWVoiceIn *sw)
1974 if (sw == NULL) {
1978 return filteraudio_is_host_voice_in_ok(s->drv, sw->hw);
1981 int AUD_is_host_voice_out_ok(SWVoiceOut *sw)
1985 if (sw == NULL) {
1989 return filteraudio_is_host_voice_out_ok(s->drv, sw->hw);