*: use std::scoped_lock with implicit template parameter
This commit is contained in:
@@ -242,7 +242,7 @@ AsyncInputStream::AppendToBuffer(std::span<const std::byte> src) noexcept
|
||||
void
|
||||
AsyncInputStream::DeferredResume() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
try {
|
||||
Resume();
|
||||
@@ -255,7 +255,7 @@ AsyncInputStream::DeferredResume() noexcept
|
||||
void
|
||||
AsyncInputStream::DeferredSeek() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
if (seek_state != SeekState::SCHEDULED)
|
||||
return;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ BufferingInputStream::BufferingInputStream(InputStreamPtr _input)
|
||||
BufferingInputStream::~BufferingInputStream() noexcept
|
||||
{
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
stop = true;
|
||||
wake_cond.notify_one();
|
||||
}
|
||||
@@ -166,7 +166,7 @@ BufferingInputStream::RunThread() noexcept
|
||||
{
|
||||
SetThreadName("buffering");
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
try {
|
||||
RunThreadLocked(lock);
|
||||
|
||||
@@ -61,14 +61,14 @@ InputStream::Seek(std::unique_lock<Mutex> &, [[maybe_unused]] offset_type new_of
|
||||
void
|
||||
InputStream::LockSeek(offset_type _offset)
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
Seek(lock, _offset);
|
||||
}
|
||||
|
||||
void
|
||||
InputStream::LockSkip(offset_type _offset)
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
Skip(lock, _offset);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ InputStream::ReadTag() noexcept
|
||||
std::unique_ptr<Tag>
|
||||
InputStream::LockReadTag() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
return ReadTag();
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ InputStream::LockRead(std::span<std::byte> dest)
|
||||
{
|
||||
assert(!dest.empty());
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
return Read(lock, dest);
|
||||
}
|
||||
|
||||
@@ -119,14 +119,14 @@ InputStream::LockReadFull(std::span<std::byte> dest)
|
||||
{
|
||||
assert(!dest.empty());
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
ReadFull(lock, dest);
|
||||
}
|
||||
|
||||
bool
|
||||
InputStream::LockIsEOF() const noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
return IsEOF();
|
||||
}
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ public:
|
||||
}
|
||||
|
||||
void LockRewind() {
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
Rewind(lock);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ ThreadInputStream::Stop() noexcept
|
||||
return;
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
close = true;
|
||||
wake_cond.notify_one();
|
||||
}
|
||||
@@ -53,7 +53,7 @@ ThreadInputStream::ThreadFunc() noexcept
|
||||
{
|
||||
FmtThreadName("input:{}", plugin);
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
try {
|
||||
Open();
|
||||
|
||||
Vendored
+2
-2
@@ -21,14 +21,14 @@ InputCacheItem::~InputCacheItem() noexcept
|
||||
void
|
||||
InputCacheItem::AddLease(InputCacheLease &lease) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
leases.push_back(lease);
|
||||
}
|
||||
|
||||
void
|
||||
InputCacheItem::RemoveLease(InputCacheLease &lease) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
auto i = leases.iterator_to(lease);
|
||||
if (i == next_lease)
|
||||
++next_lease;
|
||||
|
||||
Vendored
+1
-1
@@ -43,7 +43,7 @@ public:
|
||||
using BufferingInputStream::size;
|
||||
|
||||
bool IsInUse() const noexcept {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
return !leases.empty();
|
||||
}
|
||||
|
||||
|
||||
Vendored
+4
-4
@@ -20,7 +20,7 @@ CacheInputStream::Check()
|
||||
const ScopeUnlock unlock(mutex);
|
||||
|
||||
auto &i = GetCacheItem();
|
||||
const std::scoped_lock<Mutex> protect(i.mutex);
|
||||
const std::scoped_lock protect{i.mutex};
|
||||
|
||||
i.Check();
|
||||
}
|
||||
@@ -44,7 +44,7 @@ CacheInputStream::IsAvailable() const noexcept
|
||||
const ScopeUnlock unlock(mutex);
|
||||
|
||||
auto &i = GetCacheItem();
|
||||
const std::scoped_lock<Mutex> protect(i.mutex);
|
||||
const std::scoped_lock protect{i.mutex};
|
||||
|
||||
return i.IsAvailable(_offset);
|
||||
}
|
||||
@@ -60,7 +60,7 @@ CacheInputStream::Read(std::unique_lock<Mutex> &lock,
|
||||
|
||||
{
|
||||
const ScopeUnlock unlock(mutex);
|
||||
const std::scoped_lock<Mutex> protect(i.mutex);
|
||||
const std::scoped_lock protect{i.mutex};
|
||||
|
||||
nbytes = i.Read(lock, _offset, dest);
|
||||
}
|
||||
@@ -75,6 +75,6 @@ CacheInputStream::OnInputCacheAvailable() noexcept
|
||||
auto &i = GetCacheItem();
|
||||
const ScopeUnlock unlock(i.mutex);
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
InvokeOnAvailable();
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ AlsaInputStream::DispatchSockets() noexcept
|
||||
try {
|
||||
non_block.DispatchSockets(*this, capture_handle);
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
auto w = PrepareWriteBuffer();
|
||||
const snd_pcm_uframes_t w_frames = w.size() / frame_size;
|
||||
|
||||
@@ -266,7 +266,7 @@ CurlInputStream::OnHeaders(unsigned status,
|
||||
FmtBuffer<40>("got HTTP status {}",
|
||||
status).c_str());
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
if (IsSeekPending()) {
|
||||
/* don't update metadata while seeking */
|
||||
@@ -329,7 +329,7 @@ CurlInputStream::OnData(std::span<const std::byte> data)
|
||||
{
|
||||
assert(!data.empty());
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
if (IsSeekPending())
|
||||
SeekDone();
|
||||
@@ -345,7 +345,7 @@ CurlInputStream::OnData(std::span<const std::byte> data)
|
||||
void
|
||||
CurlInputStream::OnEnd()
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
InvokeOnAvailable();
|
||||
|
||||
AsyncInputStream::SetClosed();
|
||||
@@ -354,7 +354,7 @@ CurlInputStream::OnEnd()
|
||||
void
|
||||
CurlInputStream::OnError(std::exception_ptr e) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
postponed_exception = std::move(e);
|
||||
|
||||
if (IsSeekPending())
|
||||
|
||||
@@ -138,7 +138,7 @@ NfsInputStream::DoSeek(offset_type new_offset)
|
||||
void
|
||||
NfsInputStream::OnNfsFileOpen(uint64_t _size) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
if (reconnecting) {
|
||||
/* reconnect has succeeded */
|
||||
@@ -158,7 +158,7 @@ NfsInputStream::OnNfsFileOpen(uint64_t _size) noexcept
|
||||
void
|
||||
NfsInputStream::OnNfsFileRead(std::span<const std::byte> src) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
assert(!IsBufferFull());
|
||||
assert(IsBufferFull() == (GetBufferSpace() == 0));
|
||||
|
||||
@@ -172,7 +172,7 @@ NfsInputStream::OnNfsFileRead(std::span<const std::byte> src) noexcept
|
||||
void
|
||||
NfsInputStream::OnNfsFileError(std::exception_ptr &&e) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
if (IsPaused()) {
|
||||
/* while we're paused, don't report this error to the
|
||||
|
||||
@@ -71,7 +71,7 @@ QobuzClient::StartLogin()
|
||||
void
|
||||
QobuzClient::AddLoginHandler(QobuzSessionHandler &h) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
assert(!h.is_linked());
|
||||
|
||||
const bool was_empty = handlers.empty();
|
||||
@@ -98,7 +98,7 @@ QobuzClient::AddLoginHandler(QobuzSessionHandler &h) noexcept
|
||||
QobuzSession
|
||||
QobuzClient::GetSession() const
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
if (error)
|
||||
std::rethrow_exception(error);
|
||||
@@ -113,7 +113,7 @@ void
|
||||
QobuzClient::OnQobuzLoginSuccess(QobuzSession &&_session) noexcept
|
||||
{
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
session = std::move(_session);
|
||||
login_request.reset();
|
||||
}
|
||||
@@ -125,7 +125,7 @@ void
|
||||
QobuzClient::OnQobuzLoginError(std::exception_ptr _error) noexcept
|
||||
{
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
error = std::move(_error);
|
||||
login_request.reset();
|
||||
}
|
||||
@@ -136,7 +136,7 @@ QobuzClient::OnQobuzLoginError(std::exception_ptr _error) noexcept
|
||||
void
|
||||
QobuzClient::InvokeHandlers() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
while (!handlers.empty()) {
|
||||
auto &h = handlers.front();
|
||||
handlers.pop_front();
|
||||
|
||||
@@ -67,7 +67,7 @@ public:
|
||||
void AddLoginHandler(QobuzSessionHandler &h) noexcept;
|
||||
|
||||
void RemoveLoginHandler(QobuzSessionHandler &h) noexcept {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
if (h.is_linked())
|
||||
h.unlink();
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ private:
|
||||
void
|
||||
QobuzInputStream::OnQobuzSession() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
try {
|
||||
const auto session = qobuz_client->GetSession();
|
||||
@@ -87,7 +87,7 @@ QobuzInputStream::OnQobuzSession() noexcept
|
||||
void
|
||||
QobuzInputStream::OnQobuzTrackSuccess(std::string url) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
track_request.reset();
|
||||
|
||||
try {
|
||||
@@ -101,7 +101,7 @@ QobuzInputStream::OnQobuzTrackSuccess(std::string url) noexcept
|
||||
void
|
||||
QobuzInputStream::OnQobuzTrackError(std::exception_ptr e) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
track_request.reset();
|
||||
|
||||
Failed(e);
|
||||
|
||||
@@ -133,7 +133,7 @@ UringInputStream::OnRead(std::unique_ptr<std::byte[]> data,
|
||||
{
|
||||
read_operation.reset();
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
if (nbytes == 0) {
|
||||
postponed_exception = std::make_exception_ptr(std::runtime_error("Premature end of file"));
|
||||
@@ -154,7 +154,7 @@ UringInputStream::OnReadError(int error) noexcept
|
||||
{
|
||||
read_operation.reset();
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
postponed_exception = std::make_exception_ptr(MakeErrno(error, "Read failed"));
|
||||
InvokeOnAvailable();
|
||||
|
||||
Reference in New Issue
Block a user