Lines Matching defs:sw
30 #define SW SWVoiceOut
35 #define SW SWVoiceIn
93 static void glue (audio_pcm_sw_free_resources_, TYPE) (SW *sw)
95 if (sw->buf) {
96 qemu_free (sw->buf);
99 if (sw->rate) {
100 st_rate_stop (sw->rate);
103 sw->buf = NULL;
104 sw->rate = NULL;
107 static int glue (audio_pcm_sw_alloc_resources_, TYPE) (SW *sw)
112 samples = sw->hw->samples;
114 samples = ((int64_t) sw->hw->samples << 32) / sw->ratio;
117 sw->buf = audio_calloc (AUDIO_FUNC, samples, sizeof (struct st_sample));
118 if (!sw->buf) {
120 SW_NAME (sw), samples);
125 sw->rate = st_rate_start (sw->info.freq, sw->hw->info.freq);
127 sw->rate = st_rate_start (sw->hw->info.freq, sw->info.freq);
129 if (!sw->rate) {
130 qemu_free (sw->buf);
131 sw->buf = NULL;
138 SW *sw,
146 audio_pcm_init_info (&sw->info, as);
147 sw->hw = hw;
148 sw->active = 0;
150 sw->ratio = ((int64_t) sw->hw->info.freq << 32) / sw->info.freq;
151 sw->total_hw_samples_mixed = 0;
152 sw->empty = 1;
154 sw->ratio = ((int64_t) sw->info.freq << 32) / sw->hw->info.freq;
158 sw->conv = mixeng_conv
160 sw->clip = mixeng_clip
162 [sw->info.nchannels == 2]
163 [sw->info.sign]
164 [sw->info.swap_endianness]
165 [audio_bits_to_index (sw->info.bits)];
167 sw->name = qemu_strdup (name);
168 err = glue (audio_pcm_sw_alloc_resources_, TYPE) (sw);
170 qemu_free (sw->name);
171 sw->name = NULL;
176 static void glue (audio_pcm_sw_fini_, TYPE) (SW *sw)
178 glue (audio_pcm_sw_free_resources_, TYPE) (sw);
179 if (sw->name) {
180 qemu_free (sw->name);
181 sw->name = NULL;
185 static void glue (audio_pcm_hw_add_sw_, TYPE) (HW *hw, SW *sw)
187 QLIST_INSERT_HEAD (&hw->sw_head, sw, entries);
190 static void glue (audio_pcm_hw_del_sw_, TYPE) (SW *sw)
192 QLIST_REMOVE (sw, entries);
342 static SW *glue (audio_pcm_create_voice_pair_, TYPE) (
347 SW *sw;
358 sw = audio_calloc (AUDIO_FUNC, 1, sizeof (*sw));
359 if (!sw) {
361 sw_name ? sw_name : "unknown", sizeof (*sw));
370 glue (audio_pcm_hw_add_sw_, TYPE) (hw, sw);
372 if (glue (audio_pcm_sw_init_, TYPE) (sw, hw, sw_name, as)) {
376 return sw;
379 glue (audio_pcm_hw_del_sw_, TYPE) (sw);
382 qemu_free (sw);
387 static void glue (audio_close_, TYPE) (SW *sw)
389 glue (audio_pcm_sw_fini_, TYPE) (sw);
390 glue (audio_pcm_hw_del_sw_, TYPE) (sw);
391 glue (audio_pcm_hw_gc_, TYPE) (&sw->hw);
392 qemu_free (sw);
395 void glue (AUD_close_, TYPE) (QEMUSoundCard *card, SW *sw)
397 if (sw) {
403 glue (audio_close_, TYPE) (sw);
407 SW *glue (AUD_open_, TYPE) (
409 SW *sw,
419 SW *old_sw = NULL;
441 if (sw && audio_pcm_info_eq (&sw->info, as)) {
442 return sw;
446 if (conf.plive && sw && (!sw->active && !sw->empty)) {
447 live = sw->total_hw_samples_mixed;
450 dolog ("Replacing voice %s with %d live samples\n", SW_NAME (sw), live);
452 SW_NAME (sw), sw->info.freq, sw->info.bits, sw->info.nchannels);
461 old_sw = sw;
463 sw = NULL;
468 if (!glue (conf.fixed_, TYPE).enabled && sw) {
469 glue (AUD_close_, TYPE) (card, sw);
470 sw = NULL;
473 if (sw) {
474 HW *hw = sw->hw;
478 SW_NAME (sw));
482 glue (audio_pcm_sw_fini_, TYPE) (sw);
483 if (glue (audio_pcm_sw_init_, TYPE) (sw, hw, name, as)) {
488 sw = glue (audio_pcm_create_voice_pair_, TYPE) (name, as);
489 if (!sw) {
495 sw->card = card;
496 sw->vol = nominal_volume;
497 sw->callback.fn = callback_fn;
498 sw->callback.opaque = callback_opaque;
500 sw->empty = 1;
508 / sw->info.bytes_per_second;
513 sw->total_hw_samples_mixed += mixed;
519 audio_pcm_print_info ("hw", &sw->hw->info);
520 audio_pcm_print_info ("sw", &sw->info);
523 return sw;
526 glue (AUD_close_, TYPE) (card, sw);
530 int glue (AUD_is_active_, TYPE) (SW *sw)
532 return sw ? sw->active : 0;
535 void glue (AUD_init_time_stamp_, TYPE) (SW *sw, QEMUAudioTimeStamp *ts)
537 if (!sw) {
541 ts->old_ts = sw->hw->ts_helper;
544 uint64_t glue (AUD_get_elapsed_usec_, TYPE) (SW *sw, QEMUAudioTimeStamp *ts)
548 if (!sw) {
552 cur_ts = sw->hw->ts_helper;
567 return muldiv64 (delta, sw->hw->info.freq, 1000000);
572 #undef SW