예제 #1
0
ALCboolean alcDSoundInit(BackendFuncs *FuncList)
{
    if(!DSoundLoad())
        return ALC_FALSE;
    *FuncList = DSoundFuncs;
    return ALC_TRUE;
}
예제 #2
0
static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceName)
{
    DSoundData *pData = NULL;
    LPGUID guid = NULL;
    HRESULT hr;

    if(!DSoundLoad())
        return ALC_FALSE;

    if(!deviceName)
        deviceName = dsDevice;
    else if(strcmp(deviceName, dsDevice) != 0)
    {
        ALuint i;

        if(!DeviceList)
        {
            hr = pDirectSoundEnumerateA(DSoundEnumDevices, NULL);
            if(FAILED(hr))
                AL_PRINT("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr);
        }

        for(i = 0; i < NumDevices; i++)
        {
            if(strcmp(deviceName, DeviceList[i].name) == 0)
            {
                if(i > 0)
                    guid = &DeviceList[i].guid;
                break;
            }
        }
        if(i == NumDevices)
            return ALC_FALSE;
    }

    //Initialise requested device
    pData = calloc(1, sizeof(DSoundData));
    if(!pData)
    {
        alcSetError(device, ALC_OUT_OF_MEMORY);
        return ALC_FALSE;
    }

    //DirectSound Init code
    hr = pDirectSoundCreate(guid, &pData->lpDS, NULL);
    if(SUCCEEDED(hr))
        hr = IDirectSound_SetCooperativeLevel(pData->lpDS, GetForegroundWindow(), DSSCL_PRIORITY);
    if(FAILED(hr))
    {
        if(pData->lpDS)
            IDirectSound_Release(pData->lpDS);
        free(pData);
        AL_PRINT("Device init failed: 0x%08lx\n", hr);
        return ALC_FALSE;
    }

    device->szDeviceName = strdup(deviceName);
    device->ExtraData = pData;
    return ALC_TRUE;
}
예제 #3
0
파일: dsound.c 프로젝트: 3dseals/furseal
void alcDSoundProbe(int type)
{
    if(!DSoundLoad()) return;

    if(type == DEVICE_PROBE)
        AppendDeviceList(dsDevice);
    else if(type == ALL_DEVICE_PROBE)
    {
        HRESULT hr;
        ALuint i;

        for(i = 0;i < NumDevices;++i)
            free(DeviceList[i].name);
        free(DeviceList);
        DeviceList = NULL;
        NumDevices = 0;

        hr = pDirectSoundEnumerateA(DSoundEnumDevices, NULL);
        if(FAILED(hr))
            AL_PRINT("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr);
        else
        {
            for(i = 0;i < NumDevices;i++)
                AppendAllDeviceList(DeviceList[i].name);
        }
    }
}
예제 #4
0
static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceName)
{
    DSoundData *pData = NULL;
    LPGUID guid = NULL;
    HRESULT hr;

    if(!deviceName)
        deviceName = dsDevice;
    else if(strcmp(deviceName, dsDevice) != 0)
    {
        ALuint i;
        for(i = 0;i < NumDevices;i++)
        {
            if(strcmp(deviceName, DeviceList[i].name) == 0)
            {
                guid = &DeviceList[i].guid;
                break;
            }
        }
        if(i == NumDevices)
            return ALC_FALSE;
    }

    DSoundLoad();
    if(ds_handle == NULL)
        return ALC_FALSE;

    //Initialise requested device

    pData = calloc(1, sizeof(DSoundData));
    if(!pData)
    {
        alcSetError(ALC_OUT_OF_MEMORY);
        DSoundUnload();
        return ALC_FALSE;
    }

    //DirectSound Init code
    hr = pDirectSoundCreate(guid, &pData->lpDS, NULL);
    if(SUCCEEDED(hr))
        hr = IDirectSound_SetCooperativeLevel(pData->lpDS, GetForegroundWindow(), DSSCL_PRIORITY);
    if(FAILED(hr))
    {
        if(pData->lpDS)
            IDirectSound_Release(pData->lpDS);
        free(pData);
        DSoundUnload();
        return ALC_FALSE;
    }

    device->szDeviceName = strdup(deviceName);
    device->ExtraData = pData;
    return ALC_TRUE;
}