*: use std::scoped_lock with implicit template parameter

This commit is contained in:
Max Kellermann
2024-05-23 20:43:31 +02:00
parent 4fc3230fe6
commit 381215fd73
68 changed files with 253 additions and 253 deletions

View File

@@ -95,7 +95,7 @@ NeedChunks(DecoderControl &dc, std::unique_lock<Mutex> &lock) noexcept
static DecoderCommand
LockNeedChunks(DecoderControl &dc) noexcept
{
std::unique_lock<Mutex> lock(dc.mutex);
std::unique_lock lock{dc.mutex};
return NeedChunks(dc, lock);
}
@@ -135,7 +135,7 @@ DecoderBridge::FlushChunk() noexcept
if (!chunk->IsEmpty())
dc.pipe->Push(std::move(chunk));
const std::scoped_lock<Mutex> protect(dc.mutex);
const std::scoped_lock protect{dc.mutex};
dc.client_cond.notify_one();
}
@@ -197,7 +197,7 @@ DecoderBridge::GetVirtualCommand() noexcept
DecoderCommand
DecoderBridge::LockGetVirtualCommand() noexcept
{
const std::scoped_lock<Mutex> protect(dc.mutex);
const std::scoped_lock protect{dc.mutex};
return GetVirtualCommand();
}
@@ -257,7 +257,7 @@ DecoderBridge::Ready(const AudioFormat audio_format,
seekable);
{
const std::scoped_lock<Mutex> protect(dc.mutex);
const std::scoped_lock protect{dc.mutex};
dc.SetReady(audio_format, seekable, duration);
}
@@ -283,7 +283,7 @@ DecoderBridge::GetCommand() noexcept
void
DecoderBridge::CommandFinished() noexcept
{
const std::scoped_lock<Mutex> protect(dc.mutex);
const std::scoped_lock protect{dc.mutex};
assert(dc.command != DecoderCommand::NONE || initial_seek_running);
assert(dc.command != DecoderCommand::SEEK ||
@@ -379,7 +379,7 @@ DecoderBridge::OpenUri(const char *uri)
auto is = InputStream::Open(uri, mutex);
is->SetHandler(&dc);
std::unique_lock<Mutex> lock(mutex);
std::unique_lock lock{mutex};
while (true) {
if (dc.command == DecoderCommand::STOP)
throw StopDecoder();
@@ -403,7 +403,7 @@ try {
if (dest.empty())
return 0;
std::unique_lock<Mutex> lock(is.mutex);
std::unique_lock lock{is.mutex};
while (true) {
if (CheckCancelRead())

View File

@@ -215,7 +215,7 @@ public:
[[gnu::pure]]
bool LockIsIdle() const noexcept {
const std::scoped_lock<Mutex> protect(mutex);
const std::scoped_lock protect{mutex};
return IsIdle();
}
@@ -225,7 +225,7 @@ public:
[[gnu::pure]]
bool LockIsStarting() const noexcept {
const std::scoped_lock<Mutex> protect(mutex);
const std::scoped_lock protect{mutex};
return IsStarting();
}
@@ -237,13 +237,13 @@ public:
[[gnu::pure]]
bool LockHasFailed() const noexcept {
const std::scoped_lock<Mutex> protect(mutex);
const std::scoped_lock protect{mutex};
return HasFailed();
}
[[gnu::pure]]
bool LockIsReplayGainEnabled() const noexcept {
const std::scoped_lock<Mutex> protect(mutex);
const std::scoped_lock protect{mutex};
return replay_gain_mode != ReplayGainMode::OFF;
}
@@ -274,7 +274,7 @@ public:
* Like CheckRethrowError(), but locks and unlocks the object.
*/
void LockCheckRethrowError() const {
const std::scoped_lock<Mutex> protect(mutex);
const std::scoped_lock protect{mutex};
CheckRethrowError();
}
@@ -344,13 +344,13 @@ private:
* object.
*/
void LockSynchronousCommand(DecoderCommand cmd) noexcept {
std::unique_lock<Mutex> lock(mutex);
std::unique_lock lock{mutex};
ClearError();
SynchronousCommandLocked(lock, cmd);
}
void LockAsynchronousCommand(DecoderCommand cmd) noexcept {
const std::scoped_lock<Mutex> protect(mutex);
const std::scoped_lock protect{mutex};
command = cmd;
Signal();
}

View File

@@ -272,7 +272,7 @@ TryUriDecode(DecoderBridge &bridge, const char *uri)
if (!plugin.SupportsUri(uri))
return false;
std::unique_lock<Mutex> lock(bridge.dc.mutex);
std::unique_lock lock{bridge.dc.mutex};
bridge.Reset();
return DecoderUriDecode(plugin, bridge, uri);
});
@@ -296,7 +296,7 @@ decoder_run_stream(DecoderBridge &bridge, const char *uri)
MaybeLoadReplayGain(bridge, *input_stream);
std::unique_lock<Mutex> lock(dc.mutex);
std::unique_lock lock{dc.mutex};
bool tried = false;
return dc.command == DecoderCommand::STOP ||
@@ -326,10 +326,10 @@ TryDecoderFile(DecoderBridge &bridge, Path path_fs, std::string_view suffix,
DecoderControl &dc = bridge.dc;
if (plugin.file_decode != nullptr) {
const std::scoped_lock<Mutex> protect(dc.mutex);
const std::scoped_lock protect{dc.mutex};
return decoder_file_decode(plugin, bridge, path_fs);
} else if (plugin.stream_decode != nullptr) {
std::unique_lock<Mutex> lock(dc.mutex);
std::unique_lock lock{dc.mutex};
return decoder_stream_decode(plugin, bridge, input_stream,
lock);
} else
@@ -354,7 +354,7 @@ TryContainerDecoder(DecoderBridge &bridge, Path path_fs,
bridge.Reset();
DecoderControl &dc = bridge.dc;
const std::scoped_lock<Mutex> protect(dc.mutex);
const std::scoped_lock protect{dc.mutex};
return decoder_file_decode(plugin, bridge, path_fs);
}
@@ -545,7 +545,7 @@ DecoderControl::RunThread() noexcept
{
SetThreadName("decoder");
std::unique_lock<Mutex> lock(mutex);
std::unique_lock lock{mutex};
do {
assert(state == DecoderState::STOP ||