Lines Matching refs:sw

42 #define SW_NAME(sw) (sw)->name ? (sw)->name : "unknown"
851 SWVoiceOut *sw;
854 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
855 if (sw->active) {
869 SWVoiceOut *sw = &sc->sw;
871 int was_active = sw->active;
873 if (sw->rate) {
874 st_rate_stop (sw->rate);
875 sw->rate = NULL;
878 QLIST_REMOVE (sw, entries);
899 SWVoiceOut *sw;
910 sw = &sc->sw;
911 sw->hw = hw_cap;
912 sw->info = hw->info;
913 sw->empty = 1;
914 sw->active = hw->enabled;
915 sw->conv = noop_conv;
916 sw->ratio = ((int64_t) hw_cap->info.freq << 32) / sw->info.freq;
917 sw->rate = st_rate_start (sw->info.freq, hw_cap->info.freq);
918 if (!sw->rate) {
919 dolog ("Could not start rate conversion for `%s'\n", SW_NAME (sw));
920 g_free (sw);
923 QLIST_INSERT_HEAD (&hw_cap->sw_head, sw, entries);
926 asprintf (&sw->name, "for %p %d,%d,%d",
927 hw, sw->info.freq, sw->info.bits, sw->info.nchannels);
928 dolog ("Added %s active = %d\n", sw->name, sw->active);
930 if (sw->active) {
942 SWVoiceIn *sw;
945 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
946 if (sw->active) {
947 m = audio_MIN (m, sw->total_hw_samples_acquired);
988 static int audio_pcm_sw_get_rpos_in (SWVoiceIn *sw)
990 HWVoiceIn *hw = sw->hw;
991 int live = hw->total_samples_captured - sw->total_hw_samples_acquired;
1008 int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int size)
1010 HWVoiceIn *hw = sw->hw;
1012 struct st_sample *src, *dst = sw->buf;
1014 rpos = audio_pcm_sw_get_rpos_in (sw) % hw->samples;
1016 live = hw->total_samples_captured - sw->total_hw_samples_acquired;
1022 samples = size >> sw->info.shift;
1027 swlim = (live * sw->ratio) >> 32;
1048 st_rate_flow (sw->rate, src, dst, &isamp, &osamp);
1056 sw->clip (buf, sw->buf, ret);
1057 sw->total_hw_samples_acquired += total;
1058 return ret << sw->info.shift;
1066 SWVoiceOut *sw;
1070 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
1071 if (sw->active && !sw->empty) {
1072 m = audio_MIN (m, sw->total_hw_samples_mixed);
1106 int audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int size)
1111 if (!sw) {
1115 hwsamples = sw->hw->samples;
1117 live = sw->total_hw_samples_mixed;
1125 dolog ("%s is full %d\n", sw->name, live);
1130 wpos = (sw->hw->rpos + live) % hwsamples;
1131 samples = size >> sw->info.shift;
1134 swlim = ((int64_t) dead << 32) / sw->ratio;
1137 sw->conv (sw->buf, buf, swlim, &sw->vol);
1150 sw->rate,
1151 sw->buf + pos,
1152 sw->hw->mix_buf + wpos,
1164 sw->total_hw_samples_mixed += total;
1165 sw->empty = sw->total_hw_samples_mixed == 0;
1169 "%s: write size %d ret %d total sw %d\n",
1170 SW_NAME (sw),
1171 size >> sw->info.shift,
1173 sw->total_hw_samples_mixed
1177 return ret << sw->info.shift;
1263 int AUD_write (SWVoiceOut *sw, void *buf, int size)
1267 if (!sw) {
1272 if (!sw->hw->enabled) {
1273 dolog ("Writing to disabled voice %s\n", SW_NAME (sw));
1277 bytes = sw->hw->pcm_ops->write (sw, buf, size);
1281 int AUD_read (SWVoiceIn *sw, void *buf, int size)
1285 if (!sw) {
1290 if (!sw->hw->enabled) {
1291 dolog ("Reading from disabled voice %s\n", SW_NAME (sw));
1295 bytes = sw->hw->pcm_ops->read (sw, buf, size);
1299 int AUD_get_buffer_size_out (SWVoiceOut *sw)
1301 return sw->hw->samples << sw->hw->info.shift;
1304 void AUD_set_active_out (SWVoiceOut *sw, int on)
1308 if (!sw) {
1312 hw = sw->hw;
1313 if (sw->active != on) {
1342 sc->sw.active = hw->enabled;
1347 sw->active = on;
1351 void AUD_set_active_in (SWVoiceIn *sw, int on)
1355 if (!sw) {
1359 hw = sw->hw;
1360 if (sw->active != on) {
1371 sw->total_hw_samples_acquired = hw->total_samples_captured;
1388 sw->active = on;
1392 static int audio_get_avail (SWVoiceIn *sw)
1396 if (!sw) {
1400 live = sw->hw->total_samples_captured - sw->total_hw_samples_acquired;
1401 if (audio_bug (AUDIO_FUNC, live < 0 || live > sw->hw->samples)) {
1402 dolog ("live=%d sw->hw->samples=%d\n", live, sw->hw->samples);
1408 SW_NAME (sw),
1409 live, (((int64_t) live << 32) / sw->ratio) << sw->info.shift
1412 return (((int64_t) live << 32) / sw->ratio) << sw->info.shift;
1415 static int audio_get_free (SWVoiceOut *sw)
1419 if (!sw) {
1423 live = sw->total_hw_samples_mixed;
1425 if (audio_bug (AUDIO_FUNC, live < 0 || live > sw->hw->samples)) {
1426 dolog ("live=%d sw->hw->samples=%d\n", live, sw->hw->samples);
1430 dead = sw->hw->samples - live;
1434 SW_NAME (sw),
1435 live, dead, (((int64_t) dead << 32) / sw->ratio) << sw->info.shift);
1438 return (((int64_t) dead << 32) / sw->ratio) << sw->info.shift;
1449 SWVoiceOut *sw = &sc->sw;
1459 sw->buf = hw->mix_buf + rpos2;
1460 written = audio_pcm_sw_write (sw, NULL, bytes);
1481 SWVoiceOut *sw;
1506 sc->sw.active = 0;
1513 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
1514 if (sw->active) {
1515 free = audio_get_free (sw);
1517 sw->callback.fn (sw->callback.opaque, free);
1542 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
1543 if (!sw->active || sw->empty) {
1547 if (audio_bug (AUDIO_FUNC, played > sw->total_hw_samples_mixed)) {
1548 dolog ("played=%d sw->total_hw_samples_mixed=%d\n",
1549 played, sw->total_hw_samples_mixed);
1550 played = sw->total_hw_samples_mixed;
1553 sw->total_hw_samples_mixed -= played;
1555 if (!sw->total_hw_samples_mixed) {
1556 sw->empty = 1;
1557 cleanup_required |= !sw->active && !sw->callback.fn;
1560 if (sw->active) {
1561 free = audio_get_free (sw);
1563 sw->callback.fn (sw->callback.opaque, free);
1571 sw = hw->sw_head.lh_first;
1572 while (sw) {
1573 sw1 = sw->entries.le_next;
1574 if (!sw->active && !sw->callback.fn) {
1578 audio_close_out (sw);
1580 sw = sw1;
1591 SWVoiceIn *sw;
1600 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
1601 sw->total_hw_samples_acquired -= min;
1603 if (sw->active) {
1606 avail = audio_get_avail (sw);
1608 sw->callback.fn (sw->callback.opaque, avail);
1622 SWVoiceOut *sw;
1645 for (sw = hw->sw_head.lh_first; sw; sw = sw->entries.le_next) {
1646 if (!sw->active && sw->empty) {
1650 if (audio_bug (AUDIO_FUNC, captured > sw->total_hw_samples_mixed)) {
1651 dolog ("captured=%d sw->total_hw_samples_mixed=%d\n",
1652 captured, sw->total_hw_samples_mixed);
1653 captured = sw->total_hw_samples_mixed;
1656 sw->total_hw_samples_mixed -= captured;
1657 sw->empty = sw->total_hw_samples_mixed == 0;
2171 SWVoiceOut *sw = cap->hw.sw_head.lh_first, *sw1;
2173 while (sw) {
2174 SWVoiceCap *sc = (SWVoiceCap *) sw;
2176 dolog ("freeing %s\n", sw->name);
2179 sw1 = sw->entries.le_next;
2180 if (sw->rate) {
2181 st_rate_stop (sw->rate);
2182 sw->rate = NULL;
2184 QLIST_REMOVE (sw, entries);
2187 sw = sw1;
2197 void AUD_set_volume_out (SWVoiceOut *sw, int mute, uint8_t lvol, uint8_t rvol)
2199 if (sw) {
2200 sw->vol.mute = mute;
2201 sw->vol.l = nominal_volume.l * lvol / 255;
2202 sw->vol.r = nominal_volume.r * rvol / 255;
2206 void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t rvol)
2208 if (sw) {
2209 sw->vol.mute = mute;
2210 sw->vol.l = nominal_volume.l * lvol / 255;
2211 sw->vol.r = nominal_volume.r * rvol / 255;