ALCboolean alc_pa_init(BackendFuncs *func_list) { if(!pa_load()) return ALC_FALSE; *func_list = pa_funcs; return ALC_TRUE; }
void alc_pa_probe(int type) { if(!pa_load()) return; if(type == DEVICE_PROBE) AppendDeviceList(pa_device); else if(type == ALL_DEVICE_PROBE) AppendAllDeviceList(pa_device); else if(type == CAPTURE_DEVICE_PROBE) AppendCaptureDeviceList(pa_device); }
void alc_pa_probe(int type) { pa_load(); if(!pa_handle) return; if(type == DEVICE_PROBE) AppendDeviceList(pa_device); else if(type == ALL_DEVICE_PROBE) AppendAllDeviceList(pa_device); pa_unload(); }
static ALCboolean pa_open_capture(ALCdevice *device, const ALCchar *deviceName) { PaStreamParameters inParams; ALuint frame_size; pa_data *data; PaError err; if(!deviceName) deviceName = pa_device; else if(strcmp(deviceName, pa_device) != 0) return ALC_FALSE; if(!pa_load()) return ALC_FALSE; data = (pa_data*)calloc(1, sizeof(pa_data)); if(data == NULL) { alcSetError(device, ALC_OUT_OF_MEMORY); return ALC_FALSE; } frame_size = aluFrameSizeFromFormat(device->Format); data->ring = CreateRingBuffer(frame_size, device->UpdateSize*device->NumUpdates); if(data->ring == NULL) { alcSetError(device, ALC_OUT_OF_MEMORY); goto error; } inParams.device = GetConfigValueInt("port", "capture", -1); if(inParams.device < 0) inParams.device = pPa_GetDefaultOutputDevice(); inParams.suggestedLatency = 0.0f; inParams.hostApiSpecificStreamInfo = NULL; switch(aluBytesFromFormat(device->Format)) { case 1: inParams.sampleFormat = paUInt8; break; case 2: inParams.sampleFormat = paInt16; break; case 4: inParams.sampleFormat = paFloat32; break; default: AL_PRINT("Unknown format: 0x%x\n", device->Format); goto error; } inParams.channelCount = aluChannelsFromFormat(device->Format); err = pPa_OpenStream(&data->stream, &inParams, NULL, device->Frequency, paFramesPerBufferUnspecified, paNoFlag, pa_capture_cb, device); if(err != paNoError) { AL_PRINT("Pa_OpenStream() returned an error: %s\n", pPa_GetErrorText(err)); goto error; } device->szDeviceName = strdup(deviceName); device->ExtraData = data; return ALC_TRUE; error: DestroyRingBuffer(data->ring); free(data); return ALC_FALSE; }
static ALCboolean pa_open_playback(ALCdevice *device, const ALCchar *deviceName) { const PaStreamInfo *streamInfo; PaStreamParameters outParams; pa_data *data; PaError err; if(!deviceName) deviceName = pa_device; else if(strcmp(deviceName, pa_device) != 0) return ALC_FALSE; if(!pa_load()) return ALC_FALSE; data = (pa_data*)calloc(1, sizeof(pa_data)); data->update_size = device->UpdateSize; device->ExtraData = data; outParams.device = GetConfigValueInt("port", "device", -1); if(outParams.device < 0) outParams.device = pPa_GetDefaultOutputDevice(); outParams.suggestedLatency = (device->UpdateSize*device->NumUpdates) / (float)device->Frequency; outParams.hostApiSpecificStreamInfo = NULL; switch(aluBytesFromFormat(device->Format)) { case 1: outParams.sampleFormat = paUInt8; break; case 2: outParams.sampleFormat = paInt16; break; case 4: outParams.sampleFormat = paFloat32; break; default: AL_PRINT("Unknown format: 0x%x\n", device->Format); device->ExtraData = NULL; free(data); return ALC_FALSE; } outParams.channelCount = aluChannelsFromFormat(device->Format); SetDefaultChannelOrder(device); err = pPa_OpenStream(&data->stream, NULL, &outParams, device->Frequency, device->UpdateSize, paNoFlag, pa_callback, device); if(err != paNoError) { AL_PRINT("Pa_OpenStream() returned an error: %s\n", pPa_GetErrorText(err)); device->ExtraData = NULL; free(data); return ALC_FALSE; } streamInfo = pPa_GetStreamInfo(data->stream); device->szDeviceName = strdup(deviceName); device->Frequency = streamInfo->sampleRate; return ALC_TRUE; }