3 #include "qemu/osdep.h"
4 #include "qemu-common.h"
6 #define AUDIO_CAP "win-int"
12 #include "audio_int.h"
13 #include "audio_win_int.h"
15 int waveformat_from_audio_settings (WAVEFORMATEX
*wfx
,
16 struct audsettings
*as
)
18 memset (wfx
, 0, sizeof (*wfx
));
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
->wFormatTag
= WAVE_FORMAT_PCM
;
30 wfx
->wBitsPerSample
= 8;
33 case AUDIO_FORMAT_S16
:
34 case AUDIO_FORMAT_U16
:
35 wfx
->wFormatTag
= WAVE_FORMAT_PCM
;
36 wfx
->wBitsPerSample
= 16;
37 wfx
->nAvgBytesPerSec
<<= 1;
38 wfx
->nBlockAlign
<<= 1;
41 case AUDIO_FORMAT_S32
:
42 case AUDIO_FORMAT_U32
:
43 wfx
->wFormatTag
= WAVE_FORMAT_PCM
;
44 wfx
->wBitsPerSample
= 32;
45 wfx
->nAvgBytesPerSec
<<= 2;
46 wfx
->nBlockAlign
<<= 2;
49 case AUDIO_FORMAT_F32
:
50 wfx
->wFormatTag
= WAVE_FORMAT_IEEE_FLOAT
;
51 wfx
->wBitsPerSample
= 32;
52 wfx
->nAvgBytesPerSec
<<= 2;
53 wfx
->nBlockAlign
<<= 2;
57 dolog("Internal logic error: Bad audio format %d\n", as
->fmt
);
64 int waveformat_to_audio_settings (WAVEFORMATEX
*wfx
,
65 struct audsettings
*as
)
67 if (!wfx
->nSamplesPerSec
) {
68 dolog ("Invalid wave format, frequency is zero\n");
71 as
->freq
= wfx
->nSamplesPerSec
;
73 switch (wfx
->nChannels
) {
84 "Invalid wave format, number of channels is not 1 or 2, but %d\n",
90 if (wfx
->wFormatTag
== WAVE_FORMAT_PCM
) {
91 switch (wfx
->wBitsPerSample
) {
93 as
->fmt
= AUDIO_FORMAT_U8
;
97 as
->fmt
= AUDIO_FORMAT_S16
;
101 as
->fmt
= AUDIO_FORMAT_S32
;
105 dolog("Invalid PCM wave format, bits per sample is not "
106 "8, 16 or 32, but %d\n",
107 wfx
->wBitsPerSample
);
110 } else if (wfx
->wFormatTag
== WAVE_FORMAT_IEEE_FLOAT
) {
111 switch (wfx
->wBitsPerSample
) {
113 as
->fmt
= AUDIO_FORMAT_F32
;
117 dolog("Invalid IEEE_FLOAT wave format, bits per sample is not "
119 wfx
->wBitsPerSample
);
123 dolog("Invalid wave format, tag is not PCM and not IEEE_FLOAT, "