2 * QEMU NULL audio output driver
4 * Copyright (c) 2004 Vassili Karpov (malc)
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 #include "audio/audio_int.h"
28 typedef struct NoVoice {
33 #define dolog(...) AUD_log ("noaudio", __VA_ARGS__)
35 #define ldebug(...) dolog (__VA_ARGS__)
40 static void no_hw_run (HWVoice *hw)
42 NoVoice *no = (NoVoice *) hw;
43 int rpos, live, decr, samples;
46 int64_t now = qemu_get_clock (vm_clock);
47 int64_t ticks = now - no->old_ticks;
48 int64_t bytes = (ticks * hw->bytes_per_second) / ticks_per_sec;
51 samples = INT_MAX >> hw->shift;
53 samples = bytes >> hw->shift;
55 live = pcm_hw_get_live (hw);
60 decr = audio_MIN (live, samples);
64 int left_till_end_samples = hw->samples - rpos;
65 int convert_samples = audio_MIN (samples, left_till_end_samples);
67 src = advance (hw->mix_buf, rpos * sizeof (st_sample_t));
68 memset (src, 0, convert_samples * sizeof (st_sample_t));
70 rpos = (rpos + convert_samples) % hw->samples;
71 samples -= convert_samples;
74 pcm_hw_dec_live (hw, decr);
78 static int no_hw_write (SWVoice *sw, void *buf, int len)
80 return pcm_hw_write (sw, buf, len);
83 static int no_hw_init (HWVoice *hw, int freq, int nchannels, audfmt_e fmt)
85 NoVoice *no = (NoVoice *) hw;
87 hw->nchannels = nchannels;
93 static void no_hw_fini (HWVoice *hw)
98 static int no_hw_ctl (HWVoice *hw, int cmd, ...)
105 static void *no_audio_init (void)
107 return &no_audio_init;
110 static void no_audio_fini (void *opaque)
114 struct pcm_ops no_pcm_ops = {
122 struct audio_output_driver no_output_driver = {