wf.wBitsPerSample  = Is16bit ? 16 : 8; 
if (dpm.encoding & PE_24BIT) { wf.wBitsPerSample  = 24; } else if (dpm.encoding & PE_16BIT) { wf.wBitsPerSample  = 16; } else { wf.wBitsPerSample  = 8; } 
static int open_output(void){    int             i;    int             j;    int             IsMono;    int             Is16bit;    WAVEFORMATEX    wf;    WAVEOUTCAPS     woc;    MMRESULT        Result;    UINT            DeviceID;    if (dpm.extra_param[0] < 8)    {        ctl->cmsg(CMSG_WARNING, VERB_NORMAL, "Too small -B option: %d", dpm.extra_param[0]);        dpm.extra_param[0] = 8;    }/** Check if there is at least one audio device. **/    if (waveOutGetNumDevs() == 0)    {        ctl->cmsg (CMSG_ERROR, VERB_NORMAL, "No audio devices present!");        return -1;    }/** They can't mean these. **/    dpm.encoding &= ~(PE_ULAW | PE_ALAW | PE_BYTESWAP);    if (dpm.encoding & PE_16BIT)        dpm.encoding |= PE_SIGNED;    else        dpm.encoding &= ~PE_SIGNED;    IsMono  = (dpm.encoding & PE_MONO);    Is16bit = (dpm.encoding & PE_16BIT);    memset(&wf, 0, sizeof(wf));    wf.wFormatTag     = WAVE_FORMAT_PCM;    wf.nChannels      = IsMono ? 1 : 2;    wf.nSamplesPerSec = dpm.rate;    i = dpm.rate;    j = 1;    if (!IsMono)    {        i *= 2;        j *= 2;    }    if (Is16bit)    {        i *= 2;        j *= 2;    }    wf.nAvgBytesPerSec = i;    wf.nBlockAlign     = j;    wf.wBitsPerSample  = Is16bit ? 16 : 8;    wf.cbSize          = sizeof(WAVEFORMAT);/** Open the device. **/    { CHAR  b[256]; wsprintf(b, "Opening device...\n"); OutputDebugString(b); }    hDevice = 0;    if (AllowSynchronousWaveforms)        Result = waveOutOpen(&hDevice, WAVE_MAPPER, (LPWAVEFORMATEX) &wf, (DWORD) OnPlaybackEvent, 0, CALLBACK_FUNCTION | WAVE_ALLOWSYNC);    else        Result = waveOutOpen(&hDevice, WAVE_MAPPER, (LPWAVEFORMATEX) &wf, (DWORD) OnPlaybackEvent, 0, CALLBACK_FUNCTION);    if (Result)    {        ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Can't open audio device: " "encoding=<%s>, rate=<%d>, ch=<%d>: %s", output_encoding_string(dpm.encoding), dpm.rate, wf.nChannels, MMErrorMessage(Result));        return -1;    }    else        { CHAR  b[256]; wsprintf(b, "Device opened.\n"); OutputDebugString(b); }/** Get the device ID. **/    DeviceID = 0;    waveOutGetID(hDevice, &DeviceID);/** Get the device capabilities. **/    memset(&woc, 0, sizeof(WAVEOUTCAPS));    Result = waveOutGetDevCaps(DeviceID, &woc, sizeof(WAVEOUTCAPS));    ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Device ID: %d",              DeviceID);    ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Manufacture ID: %d",         woc.wMid);    ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Product ID: %d",             woc.wPid);    ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Driver version: %d",         woc.vDriverVersion);    ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Product name: %s",           woc.szPname);    ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Formats supported: 0x%08X",  woc.dwFormats);    ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Max. channels: %d",          woc.wChannels);    ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Supported features: 0x%08X", woc.dwSupport);/** Calculate the buffer delay. **/    BufferDelay = AUDIO_BUFFER_SIZE;    if (NOT (dpm.encoding & PE_MONO))        BufferDelay *= 2;    if (dpm.encoding & PE_16BIT)        BufferDelay *= 2;    BufferDelay = (BufferDelay * 1000) / dpm.rate;/** Create the buffer pool. **/    Buffers = (struct MMBuffer *) safe_malloc(DATA_BLOCK_NUM * sizeof(struct MMBuffer));    for (i = 0; i < DATA_BLOCK_NUM; i++)    {        struct MMBuffer *   b;        b = &Buffers[i];        b->hData = GlobalAlloc(GMEM_ZEROINIT, DATA_BLOCK_SIZE);        b->Data  = GlobalLock (b->hData);        b->hHead = GlobalAlloc(GMEM_ZEROINIT, sizeof(WAVEHDR));        b->Head  = GlobalLock (b->hHead);    }    BufferPoolReset();/** Set the file descriptor. **/    dpm.fd = 0;    return 0;}
4357	/local/tlutelli/issta_data/temp/c/2005_temp/2005/4357/1094ce45aef7aea71b6455d1e4865880143f5cba/w32_a.c/clean/timidity/w32_a.c