28
28
#include "audio/audio.h"
29
29
#include "qemu/module.h"
30
30
#include "qemu/timer.h"
31
+ #include "qemu/error-report.h"
31
32
#include "hw/timer/i8254.h"
32
33
#include "migration/vmstate.h"
33
34
#include "hw/audio/pcspk.h"
@@ -112,11 +113,15 @@ static void pcspk_callback(void *opaque, int free)
112
113
}
113
114
}
114
115
115
- static int pcspk_audio_init (ISABus * bus )
116
+ static int pcspk_audio_init (PCSpkState * s )
116
117
{
117
- PCSpkState * s = pcspk_state ;
118
118
struct audsettings as = {PCSPK_SAMPLE_RATE , 1 , AUDIO_FORMAT_U8 , 0 };
119
119
120
+ if (s -> voice ) {
121
+ /* already initialized */
122
+ return 0 ;
123
+ }
124
+
120
125
AUD_register_card (s_spk , & s -> card );
121
126
122
127
s -> voice = AUD_open_out (& s -> card , s -> voice , s_spk , s , pcspk_callback , & as );
@@ -185,6 +190,10 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp)
185
190
186
191
isa_register_ioport (isadev , & s -> ioport , s -> iobase );
187
192
193
+ if (s -> card .state ) {
194
+ pcspk_audio_init (s );
195
+ }
196
+
188
197
pcspk_state = s ;
189
198
}
190
199
@@ -210,7 +219,7 @@ static const VMStateDescription vmstate_spk = {
210
219
211
220
static Property pcspk_properties [] = {
212
221
DEFINE_AUDIO_PROPERTIES (PCSpkState , card ),
213
- DEFINE_PROP_UINT32 ("iobase" , PCSpkState , iobase , -1 ),
222
+ DEFINE_PROP_UINT32 ("iobase" , PCSpkState , iobase , 0x61 ),
214
223
DEFINE_PROP_BOOL ("migrate" , PCSpkState , migrate , true),
215
224
DEFINE_PROP_END_OF_LIST (),
216
225
};
@@ -236,9 +245,18 @@ static const TypeInfo pcspk_info = {
236
245
.class_init = pcspk_class_initfn ,
237
246
};
238
247
248
+ static int pcspk_audio_init_soundhw (ISABus * bus )
249
+ {
250
+ PCSpkState * s = pcspk_state ;
251
+
252
+ warn_report ("'-soundhw pcspk' is deprecated, "
253
+ "please set a backend using '-machine pcspk-audiodev=<name>' instead" );
254
+ return pcspk_audio_init (s );
255
+ }
256
+
239
257
static void pcspk_register (void )
240
258
{
241
259
type_register_static (& pcspk_info );
242
- isa_register_soundhw ("pcspk" , "PC speaker" , pcspk_audio_init );
260
+ isa_register_soundhw ("pcspk" , "PC speaker" , pcspk_audio_init_soundhw );
243
261
}
244
262
type_init (pcspk_register )
0 commit comments