static int waveformat_from_audio_settings (WAVEFORMATEX *wfx, audsettings_t *as)

{

    memset (wfx, 0, sizeof (*wfx));



    wfx->wFormatTag = WAVE_FORMAT_PCM;

    wfx->nChannels = as->nchannels;

    wfx->nSamplesPerSec = as->freq;

    wfx->nAvgBytesPerSec = as->freq << (as->nchannels == 2);

    wfx->nBlockAlign = 1 << (as->nchannels == 2);

    wfx->cbSize = 0;



    switch (as->fmt) {

    case AUD_FMT_S8:

    case AUD_FMT_U8:

        wfx->wBitsPerSample = 8;

        break;



    case AUD_FMT_S16:

    case AUD_FMT_U16:

        wfx->wBitsPerSample = 16;

        wfx->nAvgBytesPerSec <<= 1;

        wfx->nBlockAlign <<= 1;

        break;



    case AUD_FMT_S32:

    case AUD_FMT_U32:

        wfx->wBitsPerSample = 32;

        wfx->nAvgBytesPerSec <<= 2;

        wfx->nBlockAlign <<= 2;

        break;



    default:

        dolog ("Internal logic error: Bad audio format %d\n", as->freq);

        return -1;

    }



    return 0;

}

static int waveformat_from_audio_settings (WAVEFORMATEX *wfx, audsettings_t *as)

{

    memset (wfx, 0, sizeof (*wfx));



    wfx->wFormatTag = WAVE_FORMAT_PCM;

    wfx->nChannels = as->nchannels;

    wfx->nSamplesPerSec = as->freq;

    wfx->nAvgBytesPerSec = as->freq << (as->nchannels == 2);

    wfx->nBlockAlign = 1 << (as->nchannels == 2);

    wfx->cbSize = 0;



    switch (as->fmt) {

    case AUD_FMT_S8:

    case AUD_FMT_U8:

        wfx->wBitsPerSample = 8;

        break;



    case AUD_FMT_S16:

    case AUD_FMT_U16:

        wfx->wBitsPerSample = 16;

        wfx->nAvgBytesPerSec <<= 1;

        wfx->nBlockAlign <<= 1;

        break;



    case AUD_FMT_S32:

    case AUD_FMT_U32:

        wfx->wBitsPerSample = 32;

        wfx->nAvgBytesPerSec <<= 2;

        wfx->nBlockAlign <<= 2;

        break;



    default:

        dolog ("Internal logic error: Bad audio format %d\n", as->freq);

        return -1;

    }



    return 0;

}

static int FUNC_0 (WAVEFORMATEX *VAR_0, audsettings_t *VAR_1)

{

    memset (VAR_0, 0, sizeof (*VAR_0));



    VAR_0->wFormatTag = WAVE_FORMAT_PCM;

    VAR_0->nChannels = VAR_1->nchannels;

    VAR_0->nSamplesPerSec = VAR_1->freq;

    VAR_0->nAvgBytesPerSec = VAR_1->freq << (VAR_1->nchannels == 2);

    VAR_0->nBlockAlign = 1 << (VAR_1->nchannels == 2);

    VAR_0->cbSize = 0;



    switch (VAR_1->fmt) {

    case AUD_FMT_S8:

    case AUD_FMT_U8:

        VAR_0->wBitsPerSample = 8;

        break;



    case AUD_FMT_S16:

    case AUD_FMT_U16:

        VAR_0->wBitsPerSample = 16;

        VAR_0->nAvgBytesPerSec <<= 1;

        VAR_0->nBlockAlign <<= 1;

        break;



    case AUD_FMT_S32:

    case AUD_FMT_U32:

        VAR_0->wBitsPerSample = 32;

        VAR_0->nAvgBytesPerSec <<= 2;

        VAR_0->nBlockAlign <<= 2;

        break;



    default:

        dolog ("Internal logic error: Bad audio format %d\n", VAR_1->freq);

        return -1;

    }



    return 0;

}

static int FUNC_0 (WAVEFORMATEX *VAR_0, audsettings_t *VAR_1)
{ memset (VAR_0, 0, sizeof (*VAR_0)); VAR_0->wFormatTag = WAVE_FORMAT_PCM; VAR_0->nChannels = VAR_1->nchannels; VAR_0->nSamplesPerSec = VAR_1->freq; VAR_0->nAvgBytesPerSec = VAR_1->freq << (VAR_1->nchannels == 2); VAR_0->nBlockAlign = 1 << (VAR_1->nchannels == 2); VAR_0->cbSize = 0; switch (VAR_1->fmt) { case AUD_FMT_S8:
case AUD_FMT_U8:
VAR_0->wBitsPerSample = 8; break; case AUD_FMT_S16:
case AUD_FMT_U16:
VAR_0->wBitsPerSample = 16; VAR_0->nAvgBytesPerSec <<= 1; VAR_0->nBlockAlign <<= 1; break; case AUD_FMT_S32:
case AUD_FMT_U32:
VAR_0->wBitsPerSample = 32; VAR_0->nAvgBytesPerSec <<= 2; VAR_0->nBlockAlign <<= 2; break; default:
dolog ("Internal logic error: Bad audio format %d\n", VAR_1->freq); return -1; } return 0; }