Home | History | Annotate | Download | only in audio

Lines Matching refs:hw

25 #include "hw/hw.h"
37 HWVoiceOut hw;
57 static int wav_out_run (HWVoiceOut *hw, int live)
59 WAVVoiceOut *wav = (WAVVoiceOut *) hw;
66 muldiv64 (ticks, hw->info.bytes_per_second, get_ticks_per_sec ());
69 samples = INT_MAX >> hw->info.shift;
72 samples = bytes >> hw->info.shift;
78 rpos = hw->rpos;
80 int left_till_end_samples = hw->samples - rpos;
83 src = hw->mix_buf + rpos;
84 dst = advance (wav->pcm_buf, rpos << hw->info.shift);
86 hw->clip (dst, src, convert_samples);
87 if (fwrite (dst, convert_samples << hw->info.shift, 1, wav->f) != 1) {
89 convert_samples << hw->info.shift, strerror (errno));
92 rpos = (rpos + convert_samples) % hw->samples;
97 hw->rpos = rpos;
116 static int wav_out_init (HWVoiceOut *hw, struct audsettings *as)
118 WAVVoiceOut *wav = (WAVVoiceOut *) hw;
151 audio_pcm_init_info (&hw->info, &wav_as);
153 hw->samples = 1024;
154 wav->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
157 hw->samples << hw->info.shift);
161 le_store (hdr + 22, hw->info.nchannels, 2);
162 le_store (hdr + 24, hw->info.freq, 4);
163 le_store (hdr + 28, hw->info.freq << (bits16 + stereo), 4);
183 static void wav_out_fini (HWVoiceOut *hw)
185 WAVVoiceOut *wav = (WAVVoiceOut *) hw;
188 uint32_t datalen = wav->total_samples << hw->info.shift;
211 static int wav_out_ctl (HWVoiceOut *hw, int cmd, ...)
213 (void) hw;
231 HWVoiceIn hw;
253 wav_in_init (HWVoiceIn *hw, struct audsettings *as)
255 WAVVoiceIn* wav = (WAVVoiceIn *) hw;
320 audio_pcm_init_info (&hw->info, &wav_as);
322 hw->samples = 1024;
323 wav->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
336 static void wav_in_fini (HWVoiceIn *hw)
338 WAVVoiceIn *wav = (WAVVoiceIn *) hw;
351 static int wav_in_run (HWVoiceIn *hw)
353 WAVVoiceIn* wav = (WAVVoiceIn *) hw;
360 int64_t bytes = muldiv64(ticks, hw->info.bytes_per_second, get_ticks_per_sec());
363 samples = INT_MAX >> hw->info.shift;
366 samples = bytes >> hw->info.shift;
369 live = audio_pcm_hw_get_live_in (hw);
378 wpos = hw->wpos;
380 int left_till_end_samples = hw->samples - wpos;
383 dst = hw->conv_buf + wpos;
384 src = advance (wav->pcm_buf, wpos << hw->info.shift);
387 size_t read_bytes = fread(src, 1, convert_samples << hw->info.shift, wav->f);
391 size_t read_samples = read_bytes >> hw->info.shift;
394 wpos = (wpos + read_samples) % hw->samples;
399 hw->wpos = wpos;
408 static int wav_in_ctl (HWVoiceIn *hw, int cmd, ...)
410 (void) hw;