aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-12-17 03:06:52 -0800
committerChris Robinson <[email protected]>2020-12-17 03:06:52 -0800
commit4d1ac95ae2ef1ca3a20205b4cc9893b02f0c7c22 (patch)
tree6d10b74a983ee2495704f010d554f5bfb26e63af /alc/backends
parentd578bc6cb1b9bce4954ded9b138d51980163c233 (diff)
Don't return an enum from captureSamples
It's always no_error
Diffstat (limited to 'alc/backends')
-rw-r--r--alc/backends/alsa.cpp16
-rw-r--r--alc/backends/base.cpp16
-rw-r--r--alc/backends/base.h8
-rw-r--r--alc/backends/coreaudio.cpp17
-rw-r--r--alc/backends/dsound.cpp21
-rw-r--r--alc/backends/opensl.cpp18
-rw-r--r--alc/backends/oss.cpp15
-rw-r--r--alc/backends/portaudio.cpp15
-rw-r--r--alc/backends/pulseaudio.cpp20
-rw-r--r--alc/backends/sndio.cpp15
-rw-r--r--alc/backends/wasapi.cpp15
-rw-r--r--alc/backends/winmm.cpp15
12 files changed, 83 insertions, 108 deletions
diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp
index 0166e28c..78f841c8 100644
--- a/alc/backends/alsa.cpp
+++ b/alc/backends/alsa.cpp
@@ -872,8 +872,8 @@ struct AlsaCapture final : public BackendBase {
void open(const ALCchar *name) override;
void start() override;
void stop() override;
- ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
- ALCuint availableSamples() override;
+ void captureSamples(al::byte *buffer, uint samples) override;
+ uint availableSamples() override;
ClockLatency getClockLatency() override;
snd_pcm_t *mPcmHandle{nullptr};
@@ -1031,12 +1031,12 @@ void AlsaCapture::stop()
mDoCapture = false;
}
-ALCenum AlsaCapture::captureSamples(al::byte *buffer, ALCuint samples)
+void AlsaCapture::captureSamples(al::byte *buffer, uint samples)
{
if(mRing)
{
mRing->read(buffer, samples);
- return ALC_NO_ERROR;
+ return;
}
mLastAvail -= samples;
@@ -1090,11 +1090,9 @@ ALCenum AlsaCapture::captureSamples(al::byte *buffer, ALCuint samples)
if(samples > 0)
std::fill_n(buffer, snd_pcm_frames_to_bytes(mPcmHandle, samples),
al::byte((mDevice->FmtType == DevFmtUByte) ? 0x80 : 0));
-
- return ALC_NO_ERROR;
}
-ALCuint AlsaCapture::availableSamples()
+uint AlsaCapture::availableSamples()
{
snd_pcm_sframes_t avail{0};
if(mDevice->Connected.load(std::memory_order_acquire) && mDoCapture)
@@ -1123,7 +1121,7 @@ ALCuint AlsaCapture::availableSamples()
if(avail < 0) avail = 0;
avail += snd_pcm_bytes_to_frames(mPcmHandle, static_cast<ssize_t>(mBuffer.size()));
if(avail > mLastAvail) mLastAvail = avail;
- return static_cast<ALCuint>(mLastAvail);
+ return static_cast<uint>(mLastAvail);
}
while(avail > 0)
@@ -1161,7 +1159,7 @@ ALCuint AlsaCapture::availableSamples()
avail -= amt;
}
- return static_cast<ALCuint>(mRing->readSpace());
+ return static_cast<uint>(mRing->readSpace());
}
ClockLatency AlsaCapture::getClockLatency()
diff --git a/alc/backends/base.cpp b/alc/backends/base.cpp
index 9d8d0c64..b33e0c6d 100644
--- a/alc/backends/base.cpp
+++ b/alc/backends/base.cpp
@@ -12,7 +12,7 @@
#include <mmreg.h>
#endif
-#include "AL/al.h"
+#include "AL/alc.h"
#include "alcmain.h"
#include "alexcpt.h"
@@ -25,17 +25,17 @@
bool BackendBase::reset()
{ throw al::backend_exception{ALC_INVALID_DEVICE, "Invalid BackendBase call"}; }
-ALCenum BackendBase::captureSamples(al::byte*, ALCuint)
-{ return ALC_INVALID_DEVICE; }
+void BackendBase::captureSamples(al::byte*, uint)
+{ }
-ALCuint BackendBase::availableSamples()
+uint BackendBase::availableSamples()
{ return 0; }
ClockLatency BackendBase::getClockLatency()
{
ClockLatency ret;
- ALuint refcount;
+ uint refcount;
do {
refcount = mDevice->waitForMix();
ret.ClockTime = GetDeviceClockTime(mDevice);
@@ -179,12 +179,12 @@ void BackendBase::setChannelOrderFromWFXMask(ALuint chanmask)
return al::nullopt;
};
- const ALuint numchans{mDevice->channelsFromFmt()};
- ALuint idx{0};
+ const uint numchans{mDevice->channelsFromFmt()};
+ uint idx{0};
while(chanmask)
{
const int bit{CountTrailingZeros(chanmask)};
- const ALuint mask{1u << bit};
+ const uint mask{1u << bit};
chanmask &= ~mask;
if(auto label = get_channel(mask))
diff --git a/alc/backends/base.h b/alc/backends/base.h
index 2b89e893..99e2f12b 100644
--- a/alc/backends/base.h
+++ b/alc/backends/base.h
@@ -6,13 +6,13 @@
#include <mutex>
#include <string>
-#include "AL/alc.h"
-
#include "albyte.h"
#include "alcmain.h"
#include "alexcpt.h"
+using uint = unsigned int;
+
struct ClockLatency {
std::chrono::nanoseconds ClockTime;
std::chrono::nanoseconds Latency;
@@ -25,8 +25,8 @@ struct BackendBase {
virtual void start() = 0;
virtual void stop() = 0;
- virtual ALCenum captureSamples(al::byte *buffer, ALCuint samples);
- virtual ALCuint availableSamples();
+ virtual void captureSamples(al::byte *buffer, uint samples);
+ virtual uint availableSamples();
virtual ClockLatency getClockLatency();
diff --git a/alc/backends/coreaudio.cpp b/alc/backends/coreaudio.cpp
index 80259667..b9c95ff7 100644
--- a/alc/backends/coreaudio.cpp
+++ b/alc/backends/coreaudio.cpp
@@ -309,8 +309,8 @@ struct CoreAudioCapture final : public BackendBase {
void open(const ALCchar *name) override;
void start() override;
void stop() override;
- ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
- ALCuint availableSamples() override;
+ void captureSamples(al::byte *buffer, uint samples) override;
+ uint availableSamples() override;
AudioUnit mAudioUnit{0};
@@ -609,18 +609,18 @@ void CoreAudioCapture::stop()
ERR("AudioOutputUnitStop failed\n");
}
-ALCenum CoreAudioCapture::captureSamples(al::byte *buffer, ALCuint samples)
+void CoreAudioCapture::captureSamples(al::byte *buffer, uint samples)
{
if(!mConverter)
{
mRing->read(buffer, samples);
- return ALC_NO_ERROR;
+ return;
}
auto rec_vec = mRing->getReadVector();
const void *src0{rec_vec.first.buf};
auto src0len = static_cast<ALuint>(rec_vec.first.len);
- ALuint got{mConverter->convert(&src0, &src0len, buffer, samples)};
+ uint got{mConverter->convert(&src0, &src0len, buffer, samples)};
size_t total_read{rec_vec.first.len - src0len};
if(got < samples && !src0len && rec_vec.second.len > 0)
{
@@ -631,13 +631,12 @@ ALCenum CoreAudioCapture::captureSamples(al::byte *buffer, ALCuint samples)
}
mRing->readAdvance(total_read);
- return ALC_NO_ERROR;
}
-ALCuint CoreAudioCapture::availableSamples()
+uint CoreAudioCapture::availableSamples()
{
- if(!mConverter) return static_cast<ALCuint>(mRing->readSpace());
- return mConverter->availableOut(static_cast<ALCuint>(mRing->readSpace()));
+ if(!mConverter) return static_cast<uint>(mRing->readSpace());
+ return mConverter->availableOut(static_cast<uint>(mRing->readSpace()));
}
} // namespace
diff --git a/alc/backends/dsound.cpp b/alc/backends/dsound.cpp
index 061e9a18..71ad0611 100644
--- a/alc/backends/dsound.cpp
+++ b/alc/backends/dsound.cpp
@@ -564,8 +564,8 @@ struct DSoundCapture final : public BackendBase {
void open(const ALCchar *name) override;
void start() override;
void stop() override;
- ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
- ALCuint availableSamples() override;
+ void captureSamples(al::byte *buffer, uint samples) override;
+ uint availableSamples() override;
IDirectSoundCapture *mDSC{nullptr};
IDirectSoundCaptureBuffer *mDSCbuffer{nullptr};
@@ -735,18 +735,15 @@ void DSoundCapture::stop()
}
}
-ALCenum DSoundCapture::captureSamples(al::byte *buffer, ALCuint samples)
-{
- mRing->read(buffer, samples);
- return ALC_NO_ERROR;
-}
+void DSoundCapture::captureSamples(al::byte *buffer, uint samples)
+{ mRing->read(buffer, samples); }
-ALCuint DSoundCapture::availableSamples()
+uint DSoundCapture::availableSamples()
{
if(!mDevice->Connected.load(std::memory_order_acquire))
- return static_cast<ALCuint>(mRing->readSpace());
+ return static_cast<uint>(mRing->readSpace());
- const ALuint FrameSize{mDevice->frameSizeFromFmt()};
+ const uint FrameSize{mDevice->frameSizeFromFmt()};
const DWORD BufferBytes{mBufferBytes};
const DWORD LastCursor{mCursor};
@@ -757,7 +754,7 @@ ALCuint DSoundCapture::availableSamples()
if(SUCCEEDED(hr))
{
const DWORD NumBytes{(BufferBytes+ReadCursor-LastCursor) % BufferBytes};
- if(!NumBytes) return static_cast<ALCuint>(mRing->readSpace());
+ if(!NumBytes) return static_cast<uint>(mRing->readSpace());
hr = mDSCbuffer->Lock(LastCursor, NumBytes, &ReadPtr1, &ReadCnt1, &ReadPtr2, &ReadCnt2, 0);
}
if(SUCCEEDED(hr))
@@ -775,7 +772,7 @@ ALCuint DSoundCapture::availableSamples()
mDevice->handleDisconnect("Failure retrieving capture data: 0x%lx", hr);
}
- return static_cast<ALCuint>(mRing->readSpace());
+ return static_cast<uint>(mRing->readSpace());
}
} // namespace
diff --git a/alc/backends/opensl.cpp b/alc/backends/opensl.cpp
index 185c9999..11a6a9eb 100644
--- a/alc/backends/opensl.cpp
+++ b/alc/backends/opensl.cpp
@@ -174,7 +174,7 @@ struct OpenSLPlayback final : public BackendBase {
std::mutex mMutex;
- ALuint mFrameSize{0};
+ uint mFrameSize{0};
std::atomic<bool> mKillNow{true};
std::thread mThread;
@@ -632,8 +632,8 @@ struct OpenSLCapture final : public BackendBase {
void open(const ALCchar *name) override;
void start() override;
void stop() override;
- ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
- ALCuint availableSamples() override;
+ void captureSamples(al::byte *buffer, uint samples) override;
+ uint availableSamples() override;
/* engine interfaces */
SLObjectItf mEngineObj{nullptr};
@@ -643,9 +643,9 @@ struct OpenSLCapture final : public BackendBase {
SLObjectItf mRecordObj{nullptr};
RingBufferPtr mRing{nullptr};
- ALCuint mSplOffset{0u};
+ uint mSplOffset{0u};
- ALuint mFrameSize{0};
+ uint mFrameSize{0};
DEF_NEWDEL(OpenSLCapture)
};
@@ -864,7 +864,7 @@ void OpenSLCapture::stop()
}
}
-ALCenum OpenSLCapture::captureSamples(al::byte *buffer, ALCuint samples)
+void OpenSLCapture::captureSamples(al::byte *buffer, uint samples)
{
SLAndroidSimpleBufferQueueItf bufferQueue{};
if LIKELY(mDevice->Connected.load(std::memory_order_acquire))
@@ -918,12 +918,10 @@ ALCenum OpenSLCapture::captureSamples(al::byte *buffer, ALCuint samples)
i += rem;
}
-
- return ALC_NO_ERROR;
}
-ALCuint OpenSLCapture::availableSamples()
-{ return static_cast<ALuint>(mRing->readSpace()*mDevice->UpdateSize - mSplOffset); }
+uint OpenSLCapture::availableSamples()
+{ return static_cast<uint>(mRing->readSpace()*mDevice->UpdateSize - mSplOffset); }
} // namespace
diff --git a/alc/backends/oss.cpp b/alc/backends/oss.cpp
index 513f481a..f61e5c0d 100644
--- a/alc/backends/oss.cpp
+++ b/alc/backends/oss.cpp
@@ -447,8 +447,8 @@ struct OSScapture final : public BackendBase {
void open(const ALCchar *name) override;
void start() override;
void stop() override;
- ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
- ALCuint availableSamples() override;
+ void captureSamples(al::byte *buffer, uint samples) override;
+ uint availableSamples() override;
int mFd{-1};
@@ -615,14 +615,11 @@ void OSScapture::stop()
ERR("Error resetting device: %s\n", strerror(errno));
}
-ALCenum OSScapture::captureSamples(al::byte *buffer, ALCuint samples)
-{
- mRing->read(buffer, samples);
- return ALC_NO_ERROR;
-}
+void OSScapture::captureSamples(al::byte *buffer, uint samples)
+{ mRing->read(buffer, samples); }
-ALCuint OSScapture::availableSamples()
-{ return static_cast<ALCuint>(mRing->readSpace()); }
+uint OSScapture::availableSamples()
+{ return static_cast<uint>(mRing->readSpace()); }
} // namespace
diff --git a/alc/backends/portaudio.cpp b/alc/backends/portaudio.cpp
index 54fac803..5eb87950 100644
--- a/alc/backends/portaudio.cpp
+++ b/alc/backends/portaudio.cpp
@@ -242,8 +242,8 @@ struct PortCapture final : public BackendBase {
void open(const ALCchar *name) override;
void start() override;
void stop() override;
- ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
- ALCuint availableSamples() override;
+ void captureSamples(al::byte *buffer, uint samples) override;
+ uint availableSamples() override;
PaStream *mStream{nullptr};
PaStreamParameters mParams;
@@ -339,14 +339,11 @@ void PortCapture::stop()
}
-ALCuint PortCapture::availableSamples()
-{ return static_cast<ALCuint>(mRing->readSpace()); }
+uint PortCapture::availableSamples()
+{ return static_cast<uint>(mRing->readSpace()); }
-ALCenum PortCapture::captureSamples(al::byte *buffer, ALCuint samples)
-{
- mRing->read(buffer, samples);
- return ALC_NO_ERROR;
-}
+void PortCapture::captureSamples(al::byte *buffer, uint samples)
+{ mRing->read(buffer, samples); }
} // namespace
diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp
index 73312722..57a6619e 100644
--- a/alc/backends/pulseaudio.cpp
+++ b/alc/backends/pulseaudio.cpp
@@ -1149,15 +1149,15 @@ struct PulseCapture final : public BackendBase {
void open(const ALCchar *name) override;
void start() override;
void stop() override;
- ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
- ALCuint availableSamples() override;
+ void captureSamples(al::byte *buffer, uint samples) override;
+ uint availableSamples() override;
ClockLatency getClockLatency() override;
PulseMainloop mMainloop;
std::string mDeviceName;
- ALCuint mLastReadable{0u};
+ uint mLastReadable{0u};
al::byte mSilentVal{};
al::span<const al::byte> mCapBuffer;
@@ -1329,13 +1329,13 @@ void PulseCapture::stop()
mMainloop.waitForOperation(op, plock);
}
-ALCenum PulseCapture::captureSamples(al::byte *buffer, ALCuint samples)
+void PulseCapture::captureSamples(al::byte *buffer, uint samples)
{
al::span<al::byte> dstbuf{buffer, samples * pa_frame_size(&mSpec)};
/* Capture is done in fragment-sized chunks, so we loop until we get all
* that's available */
- mLastReadable -= static_cast<ALCuint>(dstbuf.size());
+ mLastReadable -= static_cast<uint>(dstbuf.size());
while(!dstbuf.empty())
{
if(!mCapBuffer.empty())
@@ -1386,11 +1386,9 @@ ALCenum PulseCapture::captureSamples(al::byte *buffer, ALCuint samples)
}
if(!dstbuf.empty())
std::fill(dstbuf.begin(), dstbuf.end(), mSilentVal);
-
- return ALC_NO_ERROR;
}
-ALCuint PulseCapture::availableSamples()
+uint PulseCapture::availableSamples()
{
size_t readable{mCapBuffer.size()};
@@ -1411,9 +1409,9 @@ ALCuint PulseCapture::availableSamples()
}
}
- readable = std::min<size_t>(readable, std::numeric_limits<ALCuint>::max());
- mLastReadable = std::max(mLastReadable, static_cast<ALCuint>(readable));
- return mLastReadable / static_cast<ALCuint>(pa_frame_size(&mSpec));
+ readable = std::min<size_t>(readable, std::numeric_limits<uint>::max());
+ mLastReadable = std::max(mLastReadable, static_cast<uint>(readable));
+ return mLastReadable / static_cast<uint>(pa_frame_size(&mSpec));
}
diff --git a/alc/backends/sndio.cpp b/alc/backends/sndio.cpp
index 4e9af3bc..52bdb21e 100644
--- a/alc/backends/sndio.cpp
+++ b/alc/backends/sndio.cpp
@@ -296,8 +296,8 @@ struct SndioCapture final : public BackendBase {
void open(const ALCchar *name) override;
void start() override;
void stop() override;
- ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
- ALCuint availableSamples() override;
+ void captureSamples(al::byte *buffer, uint samples) override;
+ uint availableSamples() override;
sio_hdl *mSndHandle{nullptr};
@@ -471,14 +471,11 @@ void SndioCapture::stop()
ERR("Error stopping device\n");
}
-ALCenum SndioCapture::captureSamples(al::byte *buffer, ALCuint samples)
-{
- mRing->read(buffer, samples);
- return ALC_NO_ERROR;
-}
+void SndioCapture::captureSamples(al::byte *buffer, uint samples)
+{ mRing->read(buffer, samples); }
-ALCuint SndioCapture::availableSamples()
-{ return static_cast<ALCuint>(mRing->readSpace()); }
+uint SndioCapture::availableSamples()
+{ return static_cast<uint>(mRing->readSpace()); }
} // namespace
diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp
index 154355f2..3b732d2c 100644
--- a/alc/backends/wasapi.cpp
+++ b/alc/backends/wasapi.cpp
@@ -1233,8 +1233,8 @@ struct WasapiCapture final : public BackendBase, WasapiProxy {
void stop() override;
void stopProxy() override;
- ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
- ALCuint availableSamples() override;
+ void captureSamples(al::byte *buffer, uint samples) override;
+ uint availableSamples() override;
std::wstring mDevId;
@@ -1771,14 +1771,11 @@ void WasapiCapture::stopProxy()
}
-ALCuint WasapiCapture::availableSamples()
-{ return static_cast<ALCuint>(mRing->readSpace()); }
+void WasapiCapture::captureSamples(al::byte *buffer, uint samples)
+{ mRing->read(buffer, samples); }
-ALCenum WasapiCapture::captureSamples(al::byte *buffer, ALCuint samples)
-{
- mRing->read(buffer, samples);
- return ALC_NO_ERROR;
-}
+uint WasapiCapture::availableSamples()
+{ return static_cast<uint>(mRing->readSpace()); }
} // namespace
diff --git a/alc/backends/winmm.cpp b/alc/backends/winmm.cpp
index d4e7c786..cdbfd461 100644
--- a/alc/backends/winmm.cpp
+++ b/alc/backends/winmm.cpp
@@ -378,8 +378,8 @@ struct WinMMCapture final : public BackendBase {
void open(const ALCchar *name) override;
void start() override;
void stop() override;
- ALCenum captureSamples(al::byte *buffer, ALCuint samples) override;
- ALCuint availableSamples() override;
+ void captureSamples(al::byte *buffer, uint samples) override;
+ uint availableSamples() override;
std::atomic<ALuint> mReadable{0u};
al::semaphore mSem;
@@ -575,14 +575,11 @@ void WinMMCapture::stop()
mIdx = 0;
}
-ALCenum WinMMCapture::captureSamples(al::byte *buffer, ALCuint samples)
-{
- mRing->read(buffer, samples);
- return ALC_NO_ERROR;
-}
+void WinMMCapture::captureSamples(al::byte *buffer, uint samples)
+{ mRing->read(buffer, samples); }
-ALCuint WinMMCapture::availableSamples()
-{ return static_cast<ALCuint>(mRing->readSpace()); }
+uint WinMMCapture::availableSamples()
+{ return static_cast<uint>(mRing->readSpace()); }
} // namespace