3 #include "qemu-common.h"
5 #define AUDIO_CAP "win-int"
10 #include "audio_int.h"
11 #include "audio_win_int.h"
13 int waveformat_from_audio_settings (WAVEFORMATEX
*wfx
,
14 struct audsettings
*as
)
16 memset (wfx
, 0, sizeof (*wfx
));
18 wfx
->wFormatTag
= WAVE_FORMAT_PCM
;
19 wfx
->nChannels
= as
->nchannels
;
20 wfx
->nSamplesPerSec
= as
->freq
;
21 wfx
->nAvgBytesPerSec
= as
->freq
<< (as
->nchannels
== 2);
22 wfx
->nBlockAlign
= 1 << (as
->nchannels
== 2);
28 wfx
->wBitsPerSample
= 8;
33 wfx
->wBitsPerSample
= 16;
34 wfx
->nAvgBytesPerSec
<<= 1;
35 wfx
->nBlockAlign
<<= 1;
40 wfx
->wBitsPerSample
= 32;
41 wfx
->nAvgBytesPerSec
<<= 2;
42 wfx
->nBlockAlign
<<= 2;
46 dolog ("Internal logic error: Bad audio format %d\n", as
->freq
);
53 int waveformat_to_audio_settings (WAVEFORMATEX
*wfx
,
54 struct audsettings
*as
)
56 if (wfx
->wFormatTag
!= WAVE_FORMAT_PCM
) {
57 dolog ("Invalid wave format, tag is not PCM, but %d\n",
62 if (!wfx
->nSamplesPerSec
) {
63 dolog ("Invalid wave format, frequency is zero\n");
66 as
->freq
= wfx
->nSamplesPerSec
;
68 switch (wfx
->nChannels
) {
79 "Invalid wave format, number of channels is not 1 or 2, but %d\n",
85 switch (wfx
->wBitsPerSample
) {
91 as
->fmt
= AUD_FMT_S16
;
95 as
->fmt
= AUD_FMT_S32
;
99 dolog ("Invalid wave format, bits per sample is not "
100 "8, 16 or 32, but %d\n",
101 wfx
->wBitsPerSample
);