diff options
author | Chris Robinson <[email protected]> | 2023-01-01 16:06:19 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-01-01 16:06:19 -0800 |
commit | 073f970788a35657537da1b1dc7c4af450888698 (patch) | |
tree | 96f9d5f5918d49f2243dedce525d98374fed22ae | |
parent | cba526e1b082150f4a7160775f2ee6cb2deb024c (diff) |
Avoid some explicit casts and references
-rw-r--r-- | al/effect.cpp | 2 | ||||
-rw-r--r-- | al/source.cpp | 6 | ||||
-rw-r--r-- | alc/backends/pipewire.cpp | 10 | ||||
-rw-r--r-- | alc/backends/pulseaudio.cpp | 18 | ||||
-rw-r--r-- | alc/effects/convolution.cpp | 3 |
5 files changed, 20 insertions, 19 deletions
diff --git a/al/effect.cpp b/al/effect.cpp index a4004a40..bb4e9de6 100644 --- a/al/effect.cpp +++ b/al/effect.cpp @@ -140,7 +140,7 @@ const EffectPropsItem *getEffectPropsItemByType(ALenum type) auto iter = std::find_if(std::begin(EffectPropsList), std::end(EffectPropsList), [type](const EffectPropsItem &item) noexcept -> bool { return item.Type == type; }); - return (iter != std::end(EffectPropsList)) ? std::addressof(*iter) : nullptr; + return (iter != std::end(EffectPropsList)) ? al::to_address(iter) : nullptr; } void InitEffectParams(ALeffect *effect, ALenum type) diff --git a/al/source.cpp b/al/source.cpp index 1ebacf5e..5d95ba8a 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -257,7 +257,7 @@ double GetSourceSecOffset(ALsource *Source, ALCcontext *context, nanoseconds *cl const ALbuffer *BufferFmt{nullptr}; auto BufferList = Source->mQueue.cbegin(); - while(BufferList != Source->mQueue.cend() && std::addressof(*BufferList) != Current) + while(BufferList != Source->mQueue.cend() && al::to_address(BufferList) != Current) { if(!BufferFmt) BufferFmt = BufferList->mBuffer; readPos += int64_t{BufferList->mSampleLen} << MixerFracBits; @@ -306,7 +306,7 @@ double GetSourceOffset(ALsource *Source, ALenum name, ALCcontext *context) const ALbuffer *BufferFmt{nullptr}; auto BufferList = Source->mQueue.cbegin(); - while(BufferList != Source->mQueue.cend() && std::addressof(*BufferList) != Current) + while(BufferList != Source->mQueue.cend() && al::to_address(BufferList) != Current) { if(!BufferFmt) BufferFmt = BufferList->mBuffer; readPos += BufferList->mSampleLen; @@ -3674,7 +3674,7 @@ START_API_FUNC if(NewListStart != 0) { auto iter = source->mQueue.begin() + ptrdiff_t(NewListStart); - (iter-1)->mNext.store(std::addressof(*iter), std::memory_order_release); + (iter-1)->mNext.store(al::to_address(iter), std::memory_order_release); } } END_API_FUNC diff --git a/alc/backends/pipewire.cpp b/alc/backends/pipewire.cpp index 3b3a72c0..9fe19e64 100644 --- a/alc/backends/pipewire.cpp +++ b/alc/backends/pipewire.cpp @@ -367,7 +367,7 @@ using PwStreamPtr = std::unique_ptr<pw_stream,PwStreamDeleter>; /* Enums for bitflags... again... *sigh* */ constexpr pw_stream_flags operator|(pw_stream_flags lhs, pw_stream_flags rhs) noexcept -{ return static_cast<pw_stream_flags>(lhs | std::underlying_type_t<pw_stream_flags>{rhs}); } +{ return static_cast<pw_stream_flags>(lhs | al::to_underlying(rhs)); } class ThreadMainloop { pw_thread_loop *mLoop{}; @@ -608,7 +608,7 @@ DeviceNode *DeviceNode::Find(uint32_t id) { return n.mId == id; }; auto match = std::find_if(sList.begin(), sList.end(), match_id); - if(match != sList.end()) return std::addressof(*match); + if(match != sList.end()) return al::to_address(match); return nullptr; } @@ -862,10 +862,8 @@ void NodeProxy::infoCallback(const pw_node_info *info) NodeType ntype{}; if(al::strcasecmp(media_class, AudioSinkClass) == 0) ntype = NodeType::Sink; - else if( - al::strcasecmp(media_class, AudioSourceClass) == 0 - || al::strcasecmp(media_class, AudioSourceVirtualClass) == 0 - ) + else if(al::strcasecmp(media_class, AudioSourceClass) == 0 + || al::strcasecmp(media_class, AudioSourceVirtualClass) == 0) ntype = NodeType::Source; else if(al::strcasecmp(media_class, AudioDuplexClass) == 0) ntype = NodeType::Duplex; diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp index 0e9bf268..5eef8f87 100644 --- a/alc/backends/pulseaudio.cpp +++ b/alc/backends/pulseaudio.cpp @@ -247,22 +247,26 @@ constexpr pa_channel_map MonoChanMap{ /* *grumble* Don't use enums for bitflags. */ -constexpr inline pa_stream_flags_t operator|(pa_stream_flags_t lhs, pa_stream_flags_t rhs) -{ return pa_stream_flags_t(int(lhs) | int(rhs)); } -inline pa_stream_flags_t& operator|=(pa_stream_flags_t &lhs, pa_stream_flags_t rhs) +constexpr pa_stream_flags_t operator|(pa_stream_flags_t lhs, pa_stream_flags_t rhs) +{ return pa_stream_flags_t(lhs | al::to_underlying(rhs)); } +constexpr pa_stream_flags_t& operator|=(pa_stream_flags_t &lhs, pa_stream_flags_t rhs) { lhs = lhs | rhs; return lhs; } -inline pa_stream_flags_t& operator&=(pa_stream_flags_t &lhs, int rhs) +constexpr pa_stream_flags_t operator~(pa_stream_flags_t flag) +{ return pa_stream_flags_t(~al::to_underlying(flag)); } +constexpr pa_stream_flags_t& operator&=(pa_stream_flags_t &lhs, pa_stream_flags_t rhs) { - lhs = pa_stream_flags_t(int(lhs) & rhs); + lhs = pa_stream_flags_t(al::to_underlying(lhs) & rhs); return lhs; } -inline pa_context_flags_t& operator|=(pa_context_flags_t &lhs, pa_context_flags_t rhs) +constexpr pa_context_flags_t operator|(pa_context_flags_t lhs, pa_context_flags_t rhs) +{ return pa_context_flags_t(lhs | al::to_underlying(rhs)); } +constexpr pa_context_flags_t& operator|=(pa_context_flags_t &lhs, pa_context_flags_t rhs) { - lhs = pa_context_flags_t(int(lhs) | int(rhs)); + lhs = lhs | rhs; return lhs; } diff --git a/alc/effects/convolution.cpp b/alc/effects/convolution.cpp index 20510af2..20e5eff7 100644 --- a/alc/effects/convolution.cpp +++ b/alc/effects/convolution.cpp @@ -517,8 +517,7 @@ void ConvolutionState::process(const size_t samplesToDo, for(size_t c{0};c < chans.size();++c) { auto buf_iter = chans[c].mBuffer.begin() + base; - apply_fir({std::addressof(*buf_iter), todo}, mInput.data()+1 + mFifoPos, - mFilter[c].data()); + apply_fir({buf_iter, todo}, mInput.data()+1 + mFifoPos, mFilter[c].data()); auto fifo_iter = mOutput[c].begin() + mFifoPos; std::transform(fifo_iter, fifo_iter+todo, buf_iter, buf_iter, std::plus<>{}); |