aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
Diffstat (limited to 'alc')
-rw-r--r--alc/backends/wasapi.cpp22
-rw-r--r--alc/converter.cpp8
-rw-r--r--alc/converter.h10
3 files changed, 7 insertions, 33 deletions
diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp
index dbf1208d..ec1ee936 100644
--- a/alc/backends/wasapi.cpp
+++ b/alc/backends/wasapi.cpp
@@ -1166,7 +1166,7 @@ struct WasapiCapture final : public BackendBase, WasapiProxy {
IAudioCaptureClient *mCapture{nullptr};
HANDLE mNotifyEvent{nullptr};
- ChannelConverterPtr mChannelConv;
+ ChannelConverter mChannelConv{};
SampleConverterPtr mSampleConv;
RingBufferPtr mRing;
@@ -1216,10 +1216,10 @@ FORCE_ALIGN int WasapiCapture::recordProc()
ERR("Failed to get capture buffer: 0x%08lx\n", hr);
else
{
- if(mChannelConv)
+ if(mChannelConv.is_active())
{
samples.resize(numsamples*2);
- mChannelConv->convert(rdata, samples.data(), numsamples);
+ mChannelConv.convert(rdata, samples.data(), numsamples);
rdata = reinterpret_cast<BYTE*>(samples.data());
}
@@ -1487,7 +1487,7 @@ HRESULT WasapiCapture::resetProxy()
}
mSampleConv = nullptr;
- mChannelConv = nullptr;
+ mChannelConv = {};
if(wfx != nullptr)
{
@@ -1546,12 +1546,7 @@ HRESULT WasapiCapture::resetProxy()
if(mDevice->FmtChans == DevFmtMono && OutputType.Format.nChannels == 2)
{
- mChannelConv = CreateChannelConverter(srcType, DevFmtStereo, mDevice->FmtChans);
- if(!mChannelConv)
- {
- ERR("Failed to create %s stereo-to-mono converter\n", DevFmtTypeString(srcType));
- return E_FAIL;
- }
+ mChannelConv = ChannelConverter{srcType, DevFmtStereo, mDevice->FmtChans};
TRACE("Created %s stereo-to-mono converter\n", DevFmtTypeString(srcType));
/* The channel converter always outputs float, so change the input type
* for the resampler/type-converter.
@@ -1560,12 +1555,7 @@ HRESULT WasapiCapture::resetProxy()
}
else if(mDevice->FmtChans == DevFmtStereo && OutputType.Format.nChannels == 1)
{
- mChannelConv = CreateChannelConverter(srcType, DevFmtMono, mDevice->FmtChans);
- if(!mChannelConv)
- {
- ERR("Failed to create %s mono-to-stereo converter\n", DevFmtTypeString(srcType));
- return E_FAIL;
- }
+ mChannelConv = ChannelConverter{srcType, DevFmtMono, mDevice->FmtChans};
TRACE("Created %s mono-to-stereo converter\n", DevFmtTypeString(srcType));
srcType = DevFmtFloat;
}
diff --git a/alc/converter.cpp b/alc/converter.cpp
index de61415a..7e3c17cc 100644
--- a/alc/converter.cpp
+++ b/alc/converter.cpp
@@ -327,14 +327,6 @@ ALuint SampleConverter::convert(const ALvoid **src, ALuint *srcframes, ALvoid *d
}
-ChannelConverterPtr CreateChannelConverter(DevFmtType srcType, DevFmtChannels srcChans, DevFmtChannels dstChans)
-{
- if(srcChans != dstChans && !((srcChans == DevFmtMono && dstChans == DevFmtStereo) ||
- (srcChans == DevFmtStereo && dstChans == DevFmtMono)))
- return nullptr;
- return al::make_unique<ChannelConverter>(srcType, srcChans, dstChans);
-}
-
void ChannelConverter::convert(const ALvoid *src, ALfloat *dst, ALuint frames) const
{
if(mSrcChans == DevFmtStereo && mDstChans == DevFmtMono)
diff --git a/alc/converter.h b/alc/converter.h
index 50254213..62f09af1 100644
--- a/alc/converter.h
+++ b/alc/converter.h
@@ -58,17 +58,9 @@ struct ChannelConverter {
DevFmtChannels mSrcChans;
DevFmtChannels mDstChans;
- ChannelConverter(DevFmtType srctype, DevFmtChannels srcchans, DevFmtChannels dstchans)
- : mSrcType(srctype), mSrcChans(srcchans), mDstChans(dstchans)
- { }
+ bool is_active() const noexcept { return mSrcChans != mDstChans; }
void convert(const ALvoid *src, ALfloat *dst, ALuint frames) const;
-
- DEF_NEWDEL(ChannelConverter)
};
-using ChannelConverterPtr = std::unique_ptr<ChannelConverter>;
-
-ChannelConverterPtr CreateChannelConverter(DevFmtType srcType, DevFmtChannels srcChans,
- DevFmtChannels dstChans);
#endif /* CONVERTER_H */