]> git.proxmox.com Git - mirror_qemu.git/blame - audio/noaudio.c
migration/postcopy: mis->have_listen_thread check will never be touched
[mirror_qemu.git] / audio / noaudio.c
CommitLineData
7372f88d 1/*
1d14ffa9
FB
2 * QEMU Timer based audio emulation
3 *
4 * Copyright (c) 2004-2005 Vassili Karpov (malc)
5 *
7372f88d
FB
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:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
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
22 * THE SOFTWARE.
23 */
0b8fa32f 24
6086a565 25#include "qemu/osdep.h"
87776ab7 26#include "qemu/host-utils.h"
0b8fa32f 27#include "qemu/module.h"
87ecb68b 28#include "audio.h"
1de7afc9 29#include "qemu/timer.h"
7372f88d 30
1d14ffa9
FB
31#define AUDIO_CAP "noaudio"
32#include "audio_int.h"
7372f88d 33
1d14ffa9
FB
34typedef struct NoVoiceOut {
35 HWVoiceOut hw;
857271a2 36 RateCtl rate;
1d14ffa9 37} NoVoiceOut;
7372f88d 38
1d14ffa9
FB
39typedef struct NoVoiceIn {
40 HWVoiceIn hw;
857271a2 41 RateCtl rate;
1d14ffa9 42} NoVoiceIn;
7372f88d 43
affc691a 44static size_t no_write(HWVoiceOut *hw, void *buf, size_t len)
7372f88d 45{
1d14ffa9 46 NoVoiceOut *no = (NoVoiceOut *) hw;
857271a2 47 return audio_rate_get_bytes(&hw->info, &no->rate, len);
1d14ffa9 48}
7372f88d 49
5706db1d 50static int no_init_out(HWVoiceOut *hw, struct audsettings *as, void *drv_opaque)
1d14ffa9 51{
857271a2
KZ
52 NoVoiceOut *no = (NoVoiceOut *) hw;
53
d929eba5 54 audio_pcm_init_info (&hw->info, as);
c0fe3827 55 hw->samples = 1024;
857271a2 56 audio_rate_start(&no->rate);
1d14ffa9
FB
57 return 0;
58}
7372f88d 59
1d14ffa9
FB
60static void no_fini_out (HWVoiceOut *hw)
61{
62 (void) hw;
7372f88d
FB
63}
64
571a8c52 65static void no_enable_out(HWVoiceOut *hw, bool enable)
7372f88d 66{
857271a2
KZ
67 NoVoiceOut *no = (NoVoiceOut *) hw;
68
571a8c52 69 if (enable) {
857271a2
KZ
70 audio_rate_start(&no->rate);
71 }
7372f88d
FB
72}
73
5706db1d 74static int no_init_in(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
7372f88d 75{
857271a2
KZ
76 NoVoiceIn *no = (NoVoiceIn *) hw;
77
d929eba5 78 audio_pcm_init_info (&hw->info, as);
c0fe3827 79 hw->samples = 1024;
857271a2 80 audio_rate_start(&no->rate);
7372f88d
FB
81 return 0;
82}
83
1d14ffa9 84static void no_fini_in (HWVoiceIn *hw)
7372f88d
FB
85{
86 (void) hw;
87}
88
affc691a 89static size_t no_read(HWVoiceIn *hw, void *buf, size_t size)
1d14ffa9
FB
90{
91 NoVoiceIn *no = (NoVoiceIn *) hw;
857271a2 92 int64_t bytes = audio_rate_get_bytes(&hw->info, &no->rate, size);
affc691a 93
857271a2
KZ
94 audio_pcm_info_clear_buf(&hw->info, buf, bytes >> hw->info.shift);
95 return bytes;
1d14ffa9
FB
96}
97
571a8c52 98static void no_enable_in(HWVoiceIn *hw, bool enable)
7372f88d 99{
857271a2
KZ
100 NoVoiceIn *no = (NoVoiceIn *) hw;
101
571a8c52 102 if (enable) {
857271a2
KZ
103 audio_rate_start(&no->rate);
104 }
7372f88d
FB
105}
106
71830221 107static void *no_audio_init(Audiodev *dev)
7372f88d
FB
108{
109 return &no_audio_init;
110}
111
112static void no_audio_fini (void *opaque)
113{
1d14ffa9 114 (void) opaque;
7372f88d
FB
115}
116
35f4b58c 117static struct audio_pcm_ops no_pcm_ops = {
1dd3e4d1
JQ
118 .init_out = no_init_out,
119 .fini_out = no_fini_out,
affc691a 120 .write = no_write,
571a8c52 121 .enable_out = no_enable_out,
1dd3e4d1
JQ
122
123 .init_in = no_init_in,
124 .fini_in = no_fini_in,
affc691a 125 .read = no_read,
571a8c52 126 .enable_in = no_enable_in
7372f88d
FB
127};
128
d3893a39 129static struct audio_driver no_audio_driver = {
bee37f32
JQ
130 .name = "none",
131 .descr = "Timer based audio emulation",
bee37f32
JQ
132 .init = no_audio_init,
133 .fini = no_audio_fini,
134 .pcm_ops = &no_pcm_ops,
135 .can_be_default = 1,
136 .max_voices_out = INT_MAX,
137 .max_voices_in = INT_MAX,
138 .voice_size_out = sizeof (NoVoiceOut),
139 .voice_size_in = sizeof (NoVoiceIn)
7372f88d 140};
d3893a39
GH
141
142static void register_audio_none(void)
143{
144 audio_driver_register(&no_audio_driver);
145}
146type_init(register_audio_none);