3 #include "qemu-common.h"
6 #define AUDIO_CAP "win-int"
11 #include "audio_int.h"
12 #include "audio_win_int.h"
14 int waveformat_from_audio_settings (WAVEFORMATEX
*wfx
,
15 struct audsettings
*as
)
17 memset (wfx
, 0, sizeof (*wfx
));
19 wfx
->wFormatTag
= WAVE_FORMAT_PCM
;
20 wfx
->nChannels
= as
->nchannels
;
21 wfx
->nSamplesPerSec
= as
->freq
;
22 wfx
->nAvgBytesPerSec
= as
->freq
<< (as
->nchannels
== 2);
23 wfx
->nBlockAlign
= 1 << (as
->nchannels
== 2);
29 wfx
->wBitsPerSample
= 8;
34 wfx
->wBitsPerSample
= 16;
35 wfx
->nAvgBytesPerSec
<<= 1;
36 wfx
->nBlockAlign
<<= 1;
41 wfx
->wBitsPerSample
= 32;
42 wfx
->nAvgBytesPerSec
<<= 2;
43 wfx
->nBlockAlign
<<= 2;
47 dolog ("Internal logic error: Bad audio format %d\n", as
->freq
);
54 int waveformat_to_audio_settings (WAVEFORMATEX
*wfx
,
55 struct audsettings
*as
)
57 if (wfx
->wFormatTag
!= WAVE_FORMAT_PCM
) {
58 dolog ("Invalid wave format, tag is not PCM, but %d\n",
63 if (!wfx
->nSamplesPerSec
) {
64 dolog ("Invalid wave format, frequency is zero\n");
67 as
->freq
= wfx
->nSamplesPerSec
;
69 switch (wfx
->nChannels
) {
80 "Invalid wave format, number of channels is not 1 or 2, but %d\n",
86 switch (wfx
->wBitsPerSample
) {
92 as
->fmt
= AUD_FMT_S16
;
96 as
->fmt
= AUD_FMT_S32
;
100 dolog ("Invalid wave format, bits per sample is not "
101 "8, 16 or 32, but %d\n",
102 wfx
->wBitsPerSample
);