Clean up some exception messages and avoid duplicate log messages
This commit is contained in:
parent
360330b2ad
commit
7726a06d26
@ -616,11 +616,8 @@ void AlsaPlayback::open(const ALCchar *name)
|
|||||||
TRACE("Opening device \"%s\"\n", driver);
|
TRACE("Opening device \"%s\"\n", driver);
|
||||||
int err{snd_pcm_open(&mPcmHandle, driver, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)};
|
int err{snd_pcm_open(&mPcmHandle, driver, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)};
|
||||||
if(err < 0)
|
if(err < 0)
|
||||||
{
|
throw al::backend_exception{ALC_OUT_OF_MEMORY, "Could not open ALSA device \"%s\"",
|
||||||
ERR("Could not open playback device '%s': %s\n", driver, snd_strerror(err));
|
|
||||||
throw al::backend_exception{ALC_OUT_OF_MEMORY, "Could not open ALSA playback \"%s\"",
|
|
||||||
driver};
|
driver};
|
||||||
}
|
|
||||||
|
|
||||||
/* Free alsa's global config tree. Otherwise valgrind reports a ton of leaks. */
|
/* Free alsa's global config tree. Otherwise valgrind reports a ton of leaks. */
|
||||||
snd_config_update_free_global();
|
snd_config_update_free_global();
|
||||||
@ -917,11 +914,8 @@ void AlsaCapture::open(const ALCchar *name)
|
|||||||
TRACE("Opening device \"%s\"\n", driver);
|
TRACE("Opening device \"%s\"\n", driver);
|
||||||
int err{snd_pcm_open(&mPcmHandle, driver, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK)};
|
int err{snd_pcm_open(&mPcmHandle, driver, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK)};
|
||||||
if(err < 0)
|
if(err < 0)
|
||||||
{
|
throw al::backend_exception{ALC_OUT_OF_MEMORY, "Could not open ALSA device \"%s\"",
|
||||||
ERR("Could not open capture device '%s': %s\n", driver, snd_strerror(err));
|
|
||||||
throw al::backend_exception{ALC_OUT_OF_MEMORY, "Could not open ALSA capture \"%s\"",
|
|
||||||
driver};
|
driver};
|
||||||
}
|
|
||||||
|
|
||||||
/* Free alsa's global config tree. Otherwise valgrind reports a ton of leaks. */
|
/* Free alsa's global config tree. Otherwise valgrind reports a ton of leaks. */
|
||||||
snd_config_update_free_global();
|
snd_config_update_free_global();
|
||||||
@ -989,11 +983,7 @@ void AlsaCapture::open(const ALCchar *name)
|
|||||||
if(needring)
|
if(needring)
|
||||||
{
|
{
|
||||||
mRing = CreateRingBuffer(mDevice->BufferSize, mDevice->frameSizeFromFmt(), false);
|
mRing = CreateRingBuffer(mDevice->BufferSize, mDevice->frameSizeFromFmt(), false);
|
||||||
if(!mRing)
|
if(!mRing) throw al::backend_exception{ALC_INVALID_VALUE, "Failed to create ring buffer"};
|
||||||
{
|
|
||||||
ERR("ring buffer create failed\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to create ring buffer"};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mDevice->DeviceName = name;
|
mDevice->DeviceName = name;
|
||||||
|
@ -108,26 +108,17 @@ void CoreAudioPlayback::open(const ALCchar *name)
|
|||||||
|
|
||||||
AudioComponent comp{AudioComponentFindNext(NULL, &desc)};
|
AudioComponent comp{AudioComponentFindNext(NULL, &desc)};
|
||||||
if(comp == nullptr)
|
if(comp == nullptr)
|
||||||
{
|
|
||||||
ERR("AudioComponentFindNext failed\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not find audio component"};
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not find audio component"};
|
||||||
}
|
|
||||||
|
|
||||||
OSStatus err{AudioComponentInstanceNew(comp, &mAudioUnit)};
|
OSStatus err{AudioComponentInstanceNew(comp, &mAudioUnit)};
|
||||||
if(err != noErr)
|
if(err != noErr)
|
||||||
{
|
|
||||||
ERR("AudioComponentInstanceNew failed\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not create component instance: %u",
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not create component instance: %u",
|
||||||
err};
|
err};
|
||||||
}
|
|
||||||
|
|
||||||
/* init and start the default audio unit... */
|
/* init and start the default audio unit... */
|
||||||
err = AudioUnitInitialize(mAudioUnit);
|
err = AudioUnitInitialize(mAudioUnit);
|
||||||
if(err != noErr)
|
if(err != noErr)
|
||||||
{
|
|
||||||
ERR("AudioUnitInitialize failed\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not initialize audio unit: %u", err};
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not initialize audio unit: %u", err};
|
||||||
}
|
|
||||||
|
|
||||||
mDevice->DeviceName = name;
|
mDevice->DeviceName = name;
|
||||||
}
|
}
|
||||||
@ -418,41 +409,29 @@ void CoreAudioCapture::open(const ALCchar *name)
|
|||||||
// Search for component with given description
|
// Search for component with given description
|
||||||
comp = AudioComponentFindNext(NULL, &desc);
|
comp = AudioComponentFindNext(NULL, &desc);
|
||||||
if(comp == NULL)
|
if(comp == NULL)
|
||||||
{
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not find audio component"};
|
||||||
ERR("AudioComponentFindNext failed\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not finda udio component"};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Open the component
|
// Open the component
|
||||||
err = AudioComponentInstanceNew(comp, &mAudioUnit);
|
err = AudioComponentInstanceNew(comp, &mAudioUnit);
|
||||||
if(err != noErr)
|
if(err != noErr)
|
||||||
{
|
|
||||||
ERR("AudioComponentInstanceNew failed\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not create component instance: %u",
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not create component instance: %u",
|
||||||
err};
|
err};
|
||||||
}
|
|
||||||
|
|
||||||
// Turn off AudioUnit output
|
// Turn off AudioUnit output
|
||||||
enableIO = 0;
|
enableIO = 0;
|
||||||
err = AudioUnitSetProperty(mAudioUnit, kAudioOutputUnitProperty_EnableIO,
|
err = AudioUnitSetProperty(mAudioUnit, kAudioOutputUnitProperty_EnableIO,
|
||||||
kAudioUnitScope_Output, 0, &enableIO, sizeof(ALuint));
|
kAudioUnitScope_Output, 0, &enableIO, sizeof(ALuint));
|
||||||
if(err != noErr)
|
if(err != noErr)
|
||||||
{
|
|
||||||
ERR("AudioUnitSetProperty failed\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE,
|
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||||
"Could not disable audio unit output property: %u", err};
|
"Could not disable audio unit output property: %u", err};
|
||||||
}
|
|
||||||
|
|
||||||
// Turn on AudioUnit input
|
// Turn on AudioUnit input
|
||||||
enableIO = 1;
|
enableIO = 1;
|
||||||
err = AudioUnitSetProperty(mAudioUnit, kAudioOutputUnitProperty_EnableIO,
|
err = AudioUnitSetProperty(mAudioUnit, kAudioOutputUnitProperty_EnableIO,
|
||||||
kAudioUnitScope_Input, 1, &enableIO, sizeof(ALuint));
|
kAudioUnitScope_Input, 1, &enableIO, sizeof(ALuint));
|
||||||
if(err != noErr)
|
if(err != noErr)
|
||||||
{
|
|
||||||
ERR("AudioUnitSetProperty failed\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE,
|
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||||
"Could not enable audio unit input property: %u", err};
|
"Could not enable audio unit input property: %u", err};
|
||||||
}
|
|
||||||
|
|
||||||
#if !TARGET_OS_IOS
|
#if !TARGET_OS_IOS
|
||||||
{
|
{
|
||||||
@ -467,24 +446,15 @@ void CoreAudioCapture::open(const ALCchar *name)
|
|||||||
err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, nullptr,
|
err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0, nullptr,
|
||||||
&propertySize, &inputDevice);
|
&propertySize, &inputDevice);
|
||||||
if(err != noErr)
|
if(err != noErr)
|
||||||
{
|
|
||||||
ERR("AudioObjectGetPropertyData failed\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not get input device: %u", err};
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not get input device: %u", err};
|
||||||
}
|
|
||||||
if(inputDevice == kAudioDeviceUnknown)
|
if(inputDevice == kAudioDeviceUnknown)
|
||||||
{
|
|
||||||
ERR("No input device found\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Unknown input device"};
|
throw al::backend_exception{ALC_INVALID_VALUE, "Unknown input device"};
|
||||||
}
|
|
||||||
|
|
||||||
// Track the input device
|
// Track the input device
|
||||||
err = AudioUnitSetProperty(mAudioUnit, kAudioOutputUnitProperty_CurrentDevice,
|
err = AudioUnitSetProperty(mAudioUnit, kAudioOutputUnitProperty_CurrentDevice,
|
||||||
kAudioUnitScope_Global, 0, &inputDevice, sizeof(AudioDeviceID));
|
kAudioUnitScope_Global, 0, &inputDevice, sizeof(AudioDeviceID));
|
||||||
if(err != noErr)
|
if(err != noErr)
|
||||||
{
|
|
||||||
ERR("AudioUnitSetProperty failed\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not set input device: %u", err};
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not set input device: %u", err};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -495,28 +465,19 @@ void CoreAudioCapture::open(const ALCchar *name)
|
|||||||
err = AudioUnitSetProperty(mAudioUnit, kAudioOutputUnitProperty_SetInputCallback,
|
err = AudioUnitSetProperty(mAudioUnit, kAudioOutputUnitProperty_SetInputCallback,
|
||||||
kAudioUnitScope_Global, 0, &input, sizeof(AURenderCallbackStruct));
|
kAudioUnitScope_Global, 0, &input, sizeof(AURenderCallbackStruct));
|
||||||
if(err != noErr)
|
if(err != noErr)
|
||||||
{
|
|
||||||
ERR("AudioUnitSetProperty failed\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not set capture callback: %u", err};
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not set capture callback: %u", err};
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize the device
|
// Initialize the device
|
||||||
err = AudioUnitInitialize(mAudioUnit);
|
err = AudioUnitInitialize(mAudioUnit);
|
||||||
if(err != noErr)
|
if(err != noErr)
|
||||||
{
|
|
||||||
ERR("AudioUnitInitialize failed\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not initialize audio unit: %u", err};
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not initialize audio unit: %u", err};
|
||||||
}
|
|
||||||
|
|
||||||
// Get the hardware format
|
// Get the hardware format
|
||||||
propertySize = sizeof(AudioStreamBasicDescription);
|
propertySize = sizeof(AudioStreamBasicDescription);
|
||||||
err = AudioUnitGetProperty(mAudioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input,
|
err = AudioUnitGetProperty(mAudioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input,
|
||||||
1, &hardwareFormat, &propertySize);
|
1, &hardwareFormat, &propertySize);
|
||||||
if(err != noErr || propertySize != sizeof(AudioStreamBasicDescription))
|
if(err != noErr || propertySize != sizeof(AudioStreamBasicDescription))
|
||||||
{
|
|
||||||
ERR("AudioUnitGetProperty failed\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not get input format: %u", err};
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not get input format: %u", err};
|
||||||
}
|
|
||||||
|
|
||||||
// Set up the requested format description
|
// Set up the requested format description
|
||||||
switch(mDevice->FmtType)
|
switch(mDevice->FmtType)
|
||||||
@ -540,7 +501,6 @@ void CoreAudioCapture::open(const ALCchar *name)
|
|||||||
case DevFmtByte:
|
case DevFmtByte:
|
||||||
case DevFmtUShort:
|
case DevFmtUShort:
|
||||||
case DevFmtUInt:
|
case DevFmtUInt:
|
||||||
ERR("%s samples not supported\n", DevFmtTypeString(mDevice->FmtType));
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s samples not suppoted",
|
throw al::backend_exception{ALC_INVALID_VALUE, "%s samples not suppoted",
|
||||||
DevFmtTypeString(mDevice->FmtType)};
|
DevFmtTypeString(mDevice->FmtType)};
|
||||||
}
|
}
|
||||||
@ -560,7 +520,6 @@ void CoreAudioCapture::open(const ALCchar *name)
|
|||||||
case DevFmtX61:
|
case DevFmtX61:
|
||||||
case DevFmtX71:
|
case DevFmtX71:
|
||||||
case DevFmtAmbi3D:
|
case DevFmtAmbi3D:
|
||||||
ERR("%s not supported\n", DevFmtChannelsString(mDevice->FmtChans));
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s not supported",
|
throw al::backend_exception{ALC_INVALID_VALUE, "%s not supported",
|
||||||
DevFmtChannelsString(mDevice->FmtChans)};
|
DevFmtChannelsString(mDevice->FmtChans)};
|
||||||
}
|
}
|
||||||
@ -586,10 +545,7 @@ void CoreAudioCapture::open(const ALCchar *name)
|
|||||||
err = AudioUnitSetProperty(mAudioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output,
|
err = AudioUnitSetProperty(mAudioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output,
|
||||||
1, &outputFormat, sizeof(outputFormat));
|
1, &outputFormat, sizeof(outputFormat));
|
||||||
if(err != noErr)
|
if(err != noErr)
|
||||||
{
|
|
||||||
ERR("AudioUnitSetProperty failed\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not set input format: %u", err};
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not set input format: %u", err};
|
||||||
}
|
|
||||||
|
|
||||||
// Set the AudioUnit output format frame count
|
// Set the AudioUnit output format frame count
|
||||||
uint64_t FrameCount64{mDevice->UpdateSize};
|
uint64_t FrameCount64{mDevice->UpdateSize};
|
||||||
@ -597,21 +553,15 @@ void CoreAudioCapture::open(const ALCchar *name)
|
|||||||
mDevice->Frequency;
|
mDevice->Frequency;
|
||||||
FrameCount64 += MAX_RESAMPLER_PADDING;
|
FrameCount64 += MAX_RESAMPLER_PADDING;
|
||||||
if(FrameCount64 > std::numeric_limits<uint32_t>::max()/2)
|
if(FrameCount64 > std::numeric_limits<uint32_t>::max()/2)
|
||||||
{
|
|
||||||
ERR("FrameCount too large\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE,
|
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||||
"Calculated frame count is too lareg: %" PRIu64, FrameCount64};
|
"Calculated frame count is too large: %" PRIu64, FrameCount64};
|
||||||
}
|
|
||||||
|
|
||||||
outputFrameCount = static_cast<uint32_t>(FrameCount64);
|
outputFrameCount = static_cast<uint32_t>(FrameCount64);
|
||||||
err = AudioUnitSetProperty(mAudioUnit, kAudioUnitProperty_MaximumFramesPerSlice,
|
err = AudioUnitSetProperty(mAudioUnit, kAudioUnitProperty_MaximumFramesPerSlice,
|
||||||
kAudioUnitScope_Output, 0, &outputFrameCount, sizeof(outputFrameCount));
|
kAudioUnitScope_Output, 0, &outputFrameCount, sizeof(outputFrameCount));
|
||||||
if(err != noErr)
|
if(err != noErr)
|
||||||
{
|
|
||||||
ERR("AudioUnitSetProperty failed: %d\n", err);
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to set capture frame count: %u",
|
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to set capture frame count: %u",
|
||||||
err};
|
err};
|
||||||
}
|
|
||||||
|
|
||||||
// Set up sample converter if needed
|
// Set up sample converter if needed
|
||||||
if(outputFormat.mSampleRate != mDevice->Frequency)
|
if(outputFormat.mSampleRate != mDevice->Frequency)
|
||||||
|
@ -341,10 +341,7 @@ void DSoundPlayback::open(const ALCchar *name)
|
|||||||
if(SUCCEEDED(hr))
|
if(SUCCEEDED(hr))
|
||||||
hr = mDS->SetCooperativeLevel(GetForegroundWindow(), DSSCL_PRIORITY);
|
hr = mDS->SetCooperativeLevel(GetForegroundWindow(), DSSCL_PRIORITY);
|
||||||
if(FAILED(hr))
|
if(FAILED(hr))
|
||||||
{
|
|
||||||
ERR("Device init failed: 0x%08lx\n", hr);
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device init failed: 0x%08lx", hr};
|
throw al::backend_exception{ALC_INVALID_VALUE, "Device init failed: 0x%08lx", hr};
|
||||||
}
|
|
||||||
|
|
||||||
mDevice->DeviceName = name;
|
mDevice->DeviceName = name;
|
||||||
}
|
}
|
||||||
@ -753,8 +750,6 @@ void DSoundCapture::open(const ALCchar *name)
|
|||||||
|
|
||||||
if(FAILED(hr))
|
if(FAILED(hr))
|
||||||
{
|
{
|
||||||
ERR("Device init failed: 0x%08lx\n", hr);
|
|
||||||
|
|
||||||
mRing = nullptr;
|
mRing = nullptr;
|
||||||
if(mDSCbuffer)
|
if(mDSCbuffer)
|
||||||
mDSCbuffer->Release();
|
mDSCbuffer->Release();
|
||||||
|
@ -336,11 +336,9 @@ void JackPlayback::open(const ALCchar *name)
|
|||||||
jack_status_t status;
|
jack_status_t status;
|
||||||
mClient = jack_client_open(client_name, ClientOptions, &status, nullptr);
|
mClient = jack_client_open(client_name, ClientOptions, &status, nullptr);
|
||||||
if(mClient == nullptr)
|
if(mClient == nullptr)
|
||||||
{
|
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to open client connection: 0x%02x",
|
||||||
ERR("jack_client_open() failed, status = 0x%02x\n", status);
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to connect to JACK server: 0x%02x",
|
|
||||||
status};
|
status};
|
||||||
}
|
|
||||||
if((status&JackServerStarted))
|
if((status&JackServerStarted))
|
||||||
TRACE("JACK server started\n");
|
TRACE("JACK server started\n");
|
||||||
if((status&JackNameNotUnique))
|
if((status&JackNameNotUnique))
|
||||||
|
@ -146,9 +146,9 @@ struct OpenSLPlayback final : public BackendBase {
|
|||||||
OpenSLPlayback(ALCdevice *device) noexcept : BackendBase{device} { }
|
OpenSLPlayback(ALCdevice *device) noexcept : BackendBase{device} { }
|
||||||
~OpenSLPlayback() override;
|
~OpenSLPlayback() override;
|
||||||
|
|
||||||
|
void process(SLAndroidSimpleBufferQueueItf bq);
|
||||||
static void processC(SLAndroidSimpleBufferQueueItf bq, void *context)
|
static void processC(SLAndroidSimpleBufferQueueItf bq, void *context)
|
||||||
{ static_cast<OpenSLPlayback*>(context)->process(bq); }
|
{ static_cast<OpenSLPlayback*>(context)->process(bq); }
|
||||||
void process(SLAndroidSimpleBufferQueueItf bq);
|
|
||||||
|
|
||||||
int mixerProc();
|
int mixerProc();
|
||||||
|
|
||||||
@ -339,8 +339,8 @@ void OpenSLPlayback::open(const ALCchar *name)
|
|||||||
mEngineObj = nullptr;
|
mEngineObj = nullptr;
|
||||||
mEngine = nullptr;
|
mEngine = nullptr;
|
||||||
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to initialize OpenSL: 0x%08x",
|
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||||
result};
|
"Failed to initialize OpenSL device: 0x%08x", result};
|
||||||
}
|
}
|
||||||
|
|
||||||
mDevice->DeviceName = name;
|
mDevice->DeviceName = name;
|
||||||
@ -629,9 +629,9 @@ struct OpenSLCapture final : public BackendBase {
|
|||||||
OpenSLCapture(ALCdevice *device) noexcept : BackendBase{device} { }
|
OpenSLCapture(ALCdevice *device) noexcept : BackendBase{device} { }
|
||||||
~OpenSLCapture() override;
|
~OpenSLCapture() override;
|
||||||
|
|
||||||
|
void process(SLAndroidSimpleBufferQueueItf bq);
|
||||||
static void processC(SLAndroidSimpleBufferQueueItf bq, void *context)
|
static void processC(SLAndroidSimpleBufferQueueItf bq, void *context)
|
||||||
{ static_cast<OpenSLCapture*>(context)->process(bq); }
|
{ static_cast<OpenSLCapture*>(context)->process(bq); }
|
||||||
void process(SLAndroidSimpleBufferQueueItf bq);
|
|
||||||
|
|
||||||
void open(const ALCchar *name) override;
|
void open(const ALCchar *name) override;
|
||||||
bool start() override;
|
bool start() override;
|
||||||
@ -839,8 +839,8 @@ void OpenSLCapture::open(const ALCchar* name)
|
|||||||
mEngineObj = nullptr;
|
mEngineObj = nullptr;
|
||||||
mEngine = nullptr;
|
mEngine = nullptr;
|
||||||
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to initialize OpenSL: 0x%08x",
|
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||||
result};
|
"Failed to initialize OpenSL device: 0x%08x", result};
|
||||||
}
|
}
|
||||||
|
|
||||||
mDevice->DeviceName = name;
|
mDevice->DeviceName = name;
|
||||||
|
@ -350,11 +350,8 @@ void OSSPlayback::open(const ALCchar *name)
|
|||||||
|
|
||||||
mFd = ::open(devname, O_WRONLY);
|
mFd = ::open(devname, O_WRONLY);
|
||||||
if(mFd == -1)
|
if(mFd == -1)
|
||||||
{
|
|
||||||
ERR("Could not open %s: %s\n", devname, strerror(errno));
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open %s: %s", devname,
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open %s: %s", devname,
|
||||||
strerror(errno)};
|
strerror(errno)};
|
||||||
}
|
|
||||||
|
|
||||||
mDevice->DeviceName = name;
|
mDevice->DeviceName = name;
|
||||||
}
|
}
|
||||||
@ -560,11 +557,8 @@ void OSScapture::open(const ALCchar *name)
|
|||||||
|
|
||||||
mFd = ::open(devname, O_RDONLY);
|
mFd = ::open(devname, O_RDONLY);
|
||||||
if(mFd == -1)
|
if(mFd == -1)
|
||||||
{
|
|
||||||
ERR("Could not open %s: %s\n", devname, strerror(errno));
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open %s: %s", devname,
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open %s: %s", devname,
|
||||||
strerror(errno)};
|
strerror(errno)};
|
||||||
}
|
|
||||||
|
|
||||||
int ossFormat{};
|
int ossFormat{};
|
||||||
switch(mDevice->FmtType)
|
switch(mDevice->FmtType)
|
||||||
@ -582,7 +576,6 @@ void OSScapture::open(const ALCchar *name)
|
|||||||
case DevFmtInt:
|
case DevFmtInt:
|
||||||
case DevFmtUInt:
|
case DevFmtUInt:
|
||||||
case DevFmtFloat:
|
case DevFmtFloat:
|
||||||
ERR("%s capture samples not supported\n", DevFmtTypeString(mDevice->FmtType));
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s capture samples not supported",
|
throw al::backend_exception{ALC_INVALID_VALUE, "%s capture samples not supported",
|
||||||
DevFmtTypeString(mDevice->FmtType)};
|
DevFmtTypeString(mDevice->FmtType)};
|
||||||
}
|
}
|
||||||
@ -596,47 +589,30 @@ void OSScapture::open(const ALCchar *name)
|
|||||||
ALuint numFragmentsLogSize{(periods << 16) | log2FragmentSize};
|
ALuint numFragmentsLogSize{(periods << 16) | log2FragmentSize};
|
||||||
|
|
||||||
audio_buf_info info{};
|
audio_buf_info info{};
|
||||||
const char *err;
|
|
||||||
#define CHECKERR(func) if((func) < 0) { \
|
#define CHECKERR(func) if((func) < 0) { \
|
||||||
err = #func; \
|
throw al::backend_exception{ALC_INVALID_VALUE, #func " failed: %s", strerror(errno)}; \
|
||||||
goto err; \
|
|
||||||
}
|
}
|
||||||
CHECKERR(ioctl(mFd, SNDCTL_DSP_SETFRAGMENT, &numFragmentsLogSize));
|
CHECKERR(ioctl(mFd, SNDCTL_DSP_SETFRAGMENT, &numFragmentsLogSize));
|
||||||
CHECKERR(ioctl(mFd, SNDCTL_DSP_SETFMT, &ossFormat));
|
CHECKERR(ioctl(mFd, SNDCTL_DSP_SETFMT, &ossFormat));
|
||||||
CHECKERR(ioctl(mFd, SNDCTL_DSP_CHANNELS, &numChannels));
|
CHECKERR(ioctl(mFd, SNDCTL_DSP_CHANNELS, &numChannels));
|
||||||
CHECKERR(ioctl(mFd, SNDCTL_DSP_SPEED, &ossSpeed));
|
CHECKERR(ioctl(mFd, SNDCTL_DSP_SPEED, &ossSpeed));
|
||||||
CHECKERR(ioctl(mFd, SNDCTL_DSP_GETISPACE, &info));
|
CHECKERR(ioctl(mFd, SNDCTL_DSP_GETISPACE, &info));
|
||||||
if(0)
|
|
||||||
{
|
|
||||||
err:
|
|
||||||
ERR("%s failed: %s\n", err, strerror(errno));
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s failed: %s", err, strerror(errno)};
|
|
||||||
}
|
|
||||||
#undef CHECKERR
|
#undef CHECKERR
|
||||||
|
|
||||||
if(mDevice->channelsFromFmt() != numChannels)
|
if(mDevice->channelsFromFmt() != numChannels)
|
||||||
{
|
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||||
ERR("Failed to set %s, got %d channels instead\n", DevFmtChannelsString(mDevice->FmtChans),
|
"Failed to set %s, got %d channels instead", DevFmtChannelsString(mDevice->FmtChans),
|
||||||
numChannels);
|
numChannels};
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to set %s capture",
|
|
||||||
DevFmtChannelsString(mDevice->FmtChans)};
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!((ossFormat == AFMT_S8 && mDevice->FmtType == DevFmtByte) ||
|
if(!((ossFormat == AFMT_S8 && mDevice->FmtType == DevFmtByte)
|
||||||
(ossFormat == AFMT_U8 && mDevice->FmtType == DevFmtUByte) ||
|
|| (ossFormat == AFMT_U8 && mDevice->FmtType == DevFmtUByte)
|
||||||
(ossFormat == AFMT_S16_NE && mDevice->FmtType == DevFmtShort)))
|
|| (ossFormat == AFMT_S16_NE && mDevice->FmtType == DevFmtShort)))
|
||||||
{
|
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||||
ERR("Failed to set %s samples, got OSS format %#x\n", DevFmtTypeString(mDevice->FmtType), ossFormat);
|
"Failed to set %s samples, got OSS format %#x", DevFmtTypeString(mDevice->FmtType),
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to set %s samples",
|
ossFormat};
|
||||||
DevFmtTypeString(mDevice->FmtType)};
|
|
||||||
}
|
|
||||||
|
|
||||||
mRing = CreateRingBuffer(mDevice->BufferSize, frameSize, false);
|
mRing = CreateRingBuffer(mDevice->BufferSize, frameSize, false);
|
||||||
if(!mRing)
|
if(!mRing) throw al::backend_exception{ALC_INVALID_VALUE, "Failed to create ring buffer"};
|
||||||
{
|
|
||||||
ERR("Ring buffer create failed\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to create ring buffer"};
|
|
||||||
}
|
|
||||||
|
|
||||||
mDevice->DeviceName = name;
|
mDevice->DeviceName = name;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,6 @@ retry_open:
|
|||||||
mParams.sampleFormat = paInt16;
|
mParams.sampleFormat = paInt16;
|
||||||
goto retry_open;
|
goto retry_open;
|
||||||
}
|
}
|
||||||
ERR("Pa_OpenStream() returned an error: %s\n", Pa_GetErrorText(err));
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to open stream: %s",
|
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to open stream: %s",
|
||||||
Pa_GetErrorText(err)};
|
Pa_GetErrorText(err)};
|
||||||
}
|
}
|
||||||
@ -314,7 +313,6 @@ void PortCapture::open(const ALCchar *name)
|
|||||||
break;
|
break;
|
||||||
case DevFmtUInt:
|
case DevFmtUInt:
|
||||||
case DevFmtUShort:
|
case DevFmtUShort:
|
||||||
ERR("%s samples not supported\n", DevFmtTypeString(mDevice->FmtType));
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s samples not supported",
|
throw al::backend_exception{ALC_INVALID_VALUE, "%s samples not supported",
|
||||||
DevFmtTypeString(mDevice->FmtType)};
|
DevFmtTypeString(mDevice->FmtType)};
|
||||||
}
|
}
|
||||||
@ -323,11 +321,8 @@ void PortCapture::open(const ALCchar *name)
|
|||||||
PaError err{Pa_OpenStream(&mStream, &mParams, nullptr, mDevice->Frequency,
|
PaError err{Pa_OpenStream(&mStream, &mParams, nullptr, mDevice->Frequency,
|
||||||
paFramesPerBufferUnspecified, paNoFlag, &PortCapture::readCallbackC, this)};
|
paFramesPerBufferUnspecified, paNoFlag, &PortCapture::readCallbackC, this)};
|
||||||
if(err != paNoError)
|
if(err != paNoError)
|
||||||
{
|
|
||||||
ERR("Pa_OpenStream() returned an error: %s\n", Pa_GetErrorText(err));
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to open stream: %s",
|
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to open stream: %s",
|
||||||
Pa_GetErrorText(err)};
|
Pa_GetErrorText(err)};
|
||||||
}
|
|
||||||
|
|
||||||
mDevice->DeviceName = name;
|
mDevice->DeviceName = name;
|
||||||
}
|
}
|
||||||
|
@ -1211,7 +1211,7 @@ void PulseCapture::open(const ALCchar *name)
|
|||||||
chanmap = X71ChanMap;
|
chanmap = X71ChanMap;
|
||||||
break;
|
break;
|
||||||
case DevFmtAmbi3D:
|
case DevFmtAmbi3D:
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s capture samples not supported",
|
throw al::backend_exception{ALC_INVALID_VALUE, "%s capture not supported",
|
||||||
DevFmtChannelsString(mDevice->FmtChans)};
|
DevFmtChannelsString(mDevice->FmtChans)};
|
||||||
}
|
}
|
||||||
SetChannelOrderFromMap(mDevice, chanmap);
|
SetChannelOrderFromMap(mDevice, chanmap);
|
||||||
|
@ -52,8 +52,9 @@ struct Sdl2Backend final : public BackendBase {
|
|||||||
Sdl2Backend(ALCdevice *device) noexcept : BackendBase{device} { }
|
Sdl2Backend(ALCdevice *device) noexcept : BackendBase{device} { }
|
||||||
~Sdl2Backend() override;
|
~Sdl2Backend() override;
|
||||||
|
|
||||||
static void audioCallbackC(void *ptr, Uint8 *stream, int len);
|
|
||||||
void audioCallback(Uint8 *stream, int len);
|
void audioCallback(Uint8 *stream, int len);
|
||||||
|
static void audioCallbackC(void *ptr, Uint8 *stream, int len)
|
||||||
|
{ static_cast<Sdl2Backend*>(ptr)->audioCallback(stream, len); }
|
||||||
|
|
||||||
void open(const ALCchar *name) override;
|
void open(const ALCchar *name) override;
|
||||||
bool reset() override;
|
bool reset() override;
|
||||||
@ -80,9 +81,6 @@ Sdl2Backend::~Sdl2Backend()
|
|||||||
mDeviceID = 0;
|
mDeviceID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sdl2Backend::audioCallbackC(void *ptr, Uint8 *stream, int len)
|
|
||||||
{ static_cast<Sdl2Backend*>(ptr)->audioCallback(stream, len); }
|
|
||||||
|
|
||||||
void Sdl2Backend::audioCallback(Uint8 *stream, int len)
|
void Sdl2Backend::audioCallback(Uint8 *stream, int len)
|
||||||
{
|
{
|
||||||
const auto ulen = static_cast<unsigned int>(len);
|
const auto ulen = static_cast<unsigned int>(len);
|
||||||
@ -130,16 +128,15 @@ void Sdl2Backend::open(const ALCchar *name)
|
|||||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s", SDL_GetError()};
|
throw al::backend_exception{ALC_INVALID_VALUE, "%s", SDL_GetError()};
|
||||||
|
|
||||||
mDevice->Frequency = static_cast<ALuint>(have.freq);
|
mDevice->Frequency = static_cast<ALuint>(have.freq);
|
||||||
|
|
||||||
if(have.channels == 1)
|
if(have.channels == 1)
|
||||||
mDevice->FmtChans = DevFmtMono;
|
mDevice->FmtChans = DevFmtMono;
|
||||||
else if(have.channels == 2)
|
else if(have.channels == 2)
|
||||||
mDevice->FmtChans = DevFmtStereo;
|
mDevice->FmtChans = DevFmtStereo;
|
||||||
else
|
else
|
||||||
{
|
|
||||||
ERR("Got unhandled SDL channel count: %d\n", int{have.channels});
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Unhandled SDL channel count: %d",
|
throw al::backend_exception{ALC_INVALID_VALUE, "Unhandled SDL channel count: %d",
|
||||||
int{have.channels}};
|
int{have.channels}};
|
||||||
}
|
|
||||||
switch(have.format)
|
switch(have.format)
|
||||||
{
|
{
|
||||||
case AUDIO_U8: mDevice->FmtType = DevFmtUByte; break;
|
case AUDIO_U8: mDevice->FmtType = DevFmtUByte; break;
|
||||||
@ -149,7 +146,6 @@ void Sdl2Backend::open(const ALCchar *name)
|
|||||||
case AUDIO_S32SYS: mDevice->FmtType = DevFmtInt; break;
|
case AUDIO_S32SYS: mDevice->FmtType = DevFmtInt; break;
|
||||||
case AUDIO_F32SYS: mDevice->FmtType = DevFmtFloat; break;
|
case AUDIO_F32SYS: mDevice->FmtType = DevFmtFloat; break;
|
||||||
default:
|
default:
|
||||||
ERR("Got unsupported SDL format: 0x%04x\n", have.format);
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Unhandled SDL format: 0x%04x",
|
throw al::backend_exception{ALC_INVALID_VALUE, "Unhandled SDL format: 0x%04x",
|
||||||
have.format};
|
have.format};
|
||||||
}
|
}
|
||||||
|
@ -117,10 +117,7 @@ void SndioPlayback::open(const ALCchar *name)
|
|||||||
|
|
||||||
mSndHandle = sio_open(nullptr, SIO_PLAY, 0);
|
mSndHandle = sio_open(nullptr, SIO_PLAY, 0);
|
||||||
if(mSndHandle == nullptr)
|
if(mSndHandle == nullptr)
|
||||||
{
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open backend device"};
|
||||||
ERR("Could not open device\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open sound device"};
|
|
||||||
}
|
|
||||||
|
|
||||||
mDevice->DeviceName = name;
|
mDevice->DeviceName = name;
|
||||||
}
|
}
|
||||||
@ -329,10 +326,7 @@ void SndioCapture::open(const ALCchar *name)
|
|||||||
|
|
||||||
mSndHandle = sio_open(nullptr, SIO_REC, 0);
|
mSndHandle = sio_open(nullptr, SIO_REC, 0);
|
||||||
if(mSndHandle == nullptr)
|
if(mSndHandle == nullptr)
|
||||||
{
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open backend device"};
|
||||||
ERR("Could not open device\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open sound device"};
|
|
||||||
}
|
|
||||||
|
|
||||||
sio_par par;
|
sio_par par;
|
||||||
sio_initpar(&par);
|
sio_initpar(&par);
|
||||||
@ -364,7 +358,6 @@ void SndioCapture::open(const ALCchar *name)
|
|||||||
par.sig = 0;
|
par.sig = 0;
|
||||||
break;
|
break;
|
||||||
case DevFmtFloat:
|
case DevFmtFloat:
|
||||||
ERR("%s capture samples not supported\n", DevFmtTypeString(mDevice->FmtType));
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "%s capture samples not supported",
|
throw al::backend_exception{ALC_INVALID_VALUE, "%s capture samples not supported",
|
||||||
DevFmtTypeString(mDevice->FmtType)};
|
DevFmtTypeString(mDevice->FmtType)};
|
||||||
}
|
}
|
||||||
@ -381,40 +374,26 @@ void SndioCapture::open(const ALCchar *name)
|
|||||||
mDevice->BufferSize = par.appbufsz;
|
mDevice->BufferSize = par.appbufsz;
|
||||||
|
|
||||||
if(!sio_setpar(mSndHandle, &par) || !sio_getpar(mSndHandle, &par))
|
if(!sio_setpar(mSndHandle, &par) || !sio_getpar(mSndHandle, &par))
|
||||||
{
|
|
||||||
ERR("Failed to set device parameters\n");
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to set device praameters"};
|
throw al::backend_exception{ALC_INVALID_VALUE, "Failed to set device praameters"};
|
||||||
}
|
|
||||||
|
|
||||||
if(par.bits != par.bps*8)
|
if(par.bits != par.bps*8)
|
||||||
{
|
|
||||||
ERR("Padded samples not supported (%u of %u bits)\n", par.bits, par.bps*8);
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE,
|
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||||
"Padded samples not supported (got %u of %u bits)", par.bits, par.bps*8};
|
"Padded samples not supported (got %u of %u bits)", par.bits, par.bps*8};
|
||||||
}
|
|
||||||
|
|
||||||
if(!((mDevice->FmtType == DevFmtByte && par.bits == 8 && par.sig != 0) ||
|
if(!((mDevice->FmtType == DevFmtByte && par.bits == 8 && par.sig != 0)
|
||||||
(mDevice->FmtType == DevFmtUByte && par.bits == 8 && par.sig == 0) ||
|
|| (mDevice->FmtType == DevFmtUByte && par.bits == 8 && par.sig == 0)
|
||||||
(mDevice->FmtType == DevFmtShort && par.bits == 16 && par.sig != 0) ||
|
|| (mDevice->FmtType == DevFmtShort && par.bits == 16 && par.sig != 0)
|
||||||
(mDevice->FmtType == DevFmtUShort && par.bits == 16 && par.sig == 0) ||
|
|| (mDevice->FmtType == DevFmtUShort && par.bits == 16 && par.sig == 0)
|
||||||
(mDevice->FmtType == DevFmtInt && par.bits == 32 && par.sig != 0) ||
|
|| (mDevice->FmtType == DevFmtInt && par.bits == 32 && par.sig != 0)
|
||||||
(mDevice->FmtType == DevFmtUInt && par.bits == 32 && par.sig == 0)) ||
|
|| (mDevice->FmtType == DevFmtUInt && par.bits == 32 && par.sig == 0))
|
||||||
mDevice->channelsFromFmt() != par.rchan || mDevice->Frequency != par.rate)
|
|| mDevice->channelsFromFmt() != par.rchan || mDevice->Frequency != par.rate)
|
||||||
{
|
throw al::backend_exception{ALC_INVALID_VALUE,
|
||||||
ERR("Failed to set format %s %s %uhz, got %c%u %u-channel %uhz instead\n",
|
"Failed to set format %s %s %uhz, got %c%u %u-channel %uhz instead",
|
||||||
DevFmtTypeString(mDevice->FmtType), DevFmtChannelsString(mDevice->FmtChans),
|
DevFmtTypeString(mDevice->FmtType), DevFmtChannelsString(mDevice->FmtChans),
|
||||||
mDevice->Frequency, par.sig?'s':'u', par.bits, par.rchan, par.rate);
|
mDevice->Frequency, par.sig?'s':'u', par.bits, par.rchan, par.rate};
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not set format %s %s %uhz",
|
|
||||||
DevFmtTypeString(mDevice->FmtType), DevFmtChannelsString(mDevice->FmtChans),
|
|
||||||
mDevice->Frequency};
|
|
||||||
}
|
|
||||||
|
|
||||||
mRing = CreateRingBuffer(mDevice->BufferSize, par.bps*par.rchan, false);
|
mRing = CreateRingBuffer(mDevice->BufferSize, par.bps*par.rchan, false);
|
||||||
if(!mRing)
|
if(!mRing) throw al::backend_exception{ALC_OUT_OF_MEMORY, "Failed to allocate ring buffer"};
|
||||||
{
|
|
||||||
ERR("Failed to allocate %u-byte ringbuffer\n", mDevice->BufferSize*par.bps*par.rchan);
|
|
||||||
throw al::backend_exception{ALC_OUT_OF_MEMORY, "Failed to allocate ring buffer"};
|
|
||||||
}
|
|
||||||
|
|
||||||
SetDefaultChannelOrder(mDevice);
|
SetDefaultChannelOrder(mDevice);
|
||||||
|
|
||||||
|
@ -151,11 +151,8 @@ void SolarisBackend::open(const ALCchar *name)
|
|||||||
|
|
||||||
mFd = ::open(solaris_driver.c_str(), O_WRONLY);
|
mFd = ::open(solaris_driver.c_str(), O_WRONLY);
|
||||||
if(mFd == -1)
|
if(mFd == -1)
|
||||||
{
|
|
||||||
ERR("Could not open %s: %s\n", solaris_driver.c_str(), strerror(errno));
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open %s: %s",
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open %s: %s",
|
||||||
solaris_driver.c_str(), strerror(errno)};
|
solaris_driver.c_str(), strerror(errno)};
|
||||||
}
|
|
||||||
|
|
||||||
mDevice->DeviceName = name;
|
mDevice->DeviceName = name;
|
||||||
}
|
}
|
||||||
|
@ -762,7 +762,6 @@ void WasapiPlayback::open(const ALCchar *name)
|
|||||||
|
|
||||||
mDevId.clear();
|
mDevId.clear();
|
||||||
|
|
||||||
ERR("Device init failed: 0x%08lx\n", hr);
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device init failed: 0x%08lx", hr};
|
throw al::backend_exception{ALC_INVALID_VALUE, "Device init failed: 0x%08lx", hr};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1336,7 +1335,6 @@ void WasapiCapture::open(const ALCchar *name)
|
|||||||
|
|
||||||
mDevId.clear();
|
mDevId.clear();
|
||||||
|
|
||||||
ERR("Device init failed: 0x%08lx\n", hr);
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Device init failed: 0x%08lx", hr};
|
throw al::backend_exception{ALC_INVALID_VALUE, "Device init failed: 0x%08lx", hr};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,11 +223,8 @@ void WaveBackend::open(const ALCchar *name)
|
|||||||
mFile = fopen(fname, "wb");
|
mFile = fopen(fname, "wb");
|
||||||
#endif
|
#endif
|
||||||
if(!mFile)
|
if(!mFile)
|
||||||
{
|
|
||||||
ERR("Could not open file '%s': %s\n", fname, strerror(errno));
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open file '%s': %s", fname,
|
throw al::backend_exception{ALC_INVALID_VALUE, "Could not open file '%s': %s", fname,
|
||||||
strerror(errno)};
|
strerror(errno)};
|
||||||
}
|
|
||||||
|
|
||||||
mDevice->DeviceName = name;
|
mDevice->DeviceName = name;
|
||||||
}
|
}
|
||||||
|
@ -127,8 +127,9 @@ struct WinMMPlayback final : public BackendBase {
|
|||||||
WinMMPlayback(ALCdevice *device) noexcept : BackendBase{device} { }
|
WinMMPlayback(ALCdevice *device) noexcept : BackendBase{device} { }
|
||||||
~WinMMPlayback() override;
|
~WinMMPlayback() override;
|
||||||
|
|
||||||
static void CALLBACK waveOutProcC(HWAVEOUT device, UINT msg, DWORD_PTR instance, DWORD_PTR param1, DWORD_PTR param2);
|
|
||||||
void CALLBACK waveOutProc(HWAVEOUT device, UINT msg, DWORD_PTR param1, DWORD_PTR param2);
|
void CALLBACK waveOutProc(HWAVEOUT device, UINT msg, DWORD_PTR param1, DWORD_PTR param2);
|
||||||
|
static void CALLBACK waveOutProcC(HWAVEOUT device, UINT msg, DWORD_PTR instance, DWORD_PTR param1, DWORD_PTR param2)
|
||||||
|
{ reinterpret_cast<WinMMPlayback*>(instance)->waveOutProc(device, msg, param1, param2); }
|
||||||
|
|
||||||
int mixerProc();
|
int mixerProc();
|
||||||
|
|
||||||
@ -162,10 +163,6 @@ WinMMPlayback::~WinMMPlayback()
|
|||||||
std::fill(mWaveBuffer.begin(), mWaveBuffer.end(), WAVEHDR{});
|
std::fill(mWaveBuffer.begin(), mWaveBuffer.end(), WAVEHDR{});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CALLBACK WinMMPlayback::waveOutProcC(HWAVEOUT device, UINT msg, DWORD_PTR instance, DWORD_PTR param1, DWORD_PTR param2)
|
|
||||||
{ reinterpret_cast<WinMMPlayback*>(instance)->waveOutProc(device, msg, param1, param2); }
|
|
||||||
|
|
||||||
/* WinMMPlayback::waveOutProc
|
/* WinMMPlayback::waveOutProc
|
||||||
*
|
*
|
||||||
* Posts a message to 'WinMMPlayback::mixerProc' everytime a WaveOut Buffer is
|
* Posts a message to 'WinMMPlayback::mixerProc' everytime a WaveOut Buffer is
|
||||||
@ -256,7 +253,6 @@ retry_open:
|
|||||||
mDevice->FmtType = DevFmtShort;
|
mDevice->FmtType = DevFmtShort;
|
||||||
goto retry_open;
|
goto retry_open;
|
||||||
}
|
}
|
||||||
ERR("waveOutOpen failed: %u\n", res);
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "waveOutOpen failed: %u", res};
|
throw al::backend_exception{ALC_INVALID_VALUE, "waveOutOpen failed: %u", res};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,8 +364,9 @@ struct WinMMCapture final : public BackendBase {
|
|||||||
WinMMCapture(ALCdevice *device) noexcept : BackendBase{device} { }
|
WinMMCapture(ALCdevice *device) noexcept : BackendBase{device} { }
|
||||||
~WinMMCapture() override;
|
~WinMMCapture() override;
|
||||||
|
|
||||||
static void CALLBACK waveInProcC(HWAVEIN device, UINT msg, DWORD_PTR instance, DWORD_PTR param1, DWORD_PTR param2);
|
|
||||||
void CALLBACK waveInProc(HWAVEIN device, UINT msg, DWORD_PTR param1, DWORD_PTR param2);
|
void CALLBACK waveInProc(HWAVEIN device, UINT msg, DWORD_PTR param1, DWORD_PTR param2);
|
||||||
|
static void CALLBACK waveInProcC(HWAVEIN device, UINT msg, DWORD_PTR instance, DWORD_PTR param1, DWORD_PTR param2)
|
||||||
|
{ reinterpret_cast<WinMMCapture*>(instance)->waveInProc(device, msg, param1, param2); }
|
||||||
|
|
||||||
int captureProc();
|
int captureProc();
|
||||||
|
|
||||||
@ -407,9 +404,6 @@ WinMMCapture::~WinMMCapture()
|
|||||||
std::fill(mWaveBuffer.begin(), mWaveBuffer.end(), WAVEHDR{});
|
std::fill(mWaveBuffer.begin(), mWaveBuffer.end(), WAVEHDR{});
|
||||||
}
|
}
|
||||||
|
|
||||||
void CALLBACK WinMMCapture::waveInProcC(HWAVEIN device, UINT msg, DWORD_PTR instance, DWORD_PTR param1, DWORD_PTR param2)
|
|
||||||
{ reinterpret_cast<WinMMCapture*>(instance)->waveInProc(device, msg, param1, param2); }
|
|
||||||
|
|
||||||
/* WinMMCapture::waveInProc
|
/* WinMMCapture::waveInProc
|
||||||
*
|
*
|
||||||
* Posts a message to 'WinMMCapture::captureProc' everytime a WaveIn Buffer is
|
* Posts a message to 'WinMMCapture::captureProc' everytime a WaveIn Buffer is
|
||||||
@ -513,10 +507,7 @@ void WinMMCapture::open(const ALCchar *name)
|
|||||||
reinterpret_cast<DWORD_PTR>(&WinMMCapture::waveInProcC),
|
reinterpret_cast<DWORD_PTR>(&WinMMCapture::waveInProcC),
|
||||||
reinterpret_cast<DWORD_PTR>(this), CALLBACK_FUNCTION)};
|
reinterpret_cast<DWORD_PTR>(this), CALLBACK_FUNCTION)};
|
||||||
if(res != MMSYSERR_NOERROR)
|
if(res != MMSYSERR_NOERROR)
|
||||||
{
|
|
||||||
ERR("waveInOpen failed: %u\n", res);
|
|
||||||
throw al::backend_exception{ALC_INVALID_VALUE, "waveInOpen failed: %u", res};
|
throw al::backend_exception{ALC_INVALID_VALUE, "waveInOpen failed: %u", res};
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure each buffer is 50ms each
|
// Ensure each buffer is 50ms each
|
||||||
DWORD BufferSize{mFormat.nAvgBytesPerSec / 20u};
|
DWORD BufferSize{mFormat.nAvgBytesPerSec / 20u};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user