*: use std::scoped_lock with implicit template parameter
This commit is contained in:
parent
4fc3230fe6
commit
381215fd73
|
@ -15,7 +15,7 @@ MusicBuffer::MusicBuffer(unsigned num_chunks)
|
|||
MusicChunkPtr
|
||||
MusicBuffer::Allocate() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
return {buffer.Allocate(), MusicChunkDeleter(*this)};
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ MusicBuffer::Return(MusicChunk *chunk) noexcept
|
|||
chunk->next.reset();
|
||||
chunk->other.reset();
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
assert(!chunk->other || !chunk->other->other);
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
#endif
|
||||
|
||||
bool IsFull() const noexcept {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
return buffer.IsFull();
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
bool
|
||||
MusicPipe::Contains(const MusicChunk *chunk) const noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
for (const MusicChunk *i = head.get(); i != nullptr; i = i->next.get())
|
||||
if (i == chunk)
|
||||
|
@ -25,7 +25,7 @@ MusicPipe::Contains(const MusicChunk *chunk) const noexcept
|
|||
MusicChunkPtr
|
||||
MusicPipe::Shift() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
auto chunk = std::move(head);
|
||||
if (chunk != nullptr) {
|
||||
|
@ -65,7 +65,7 @@ MusicPipe::Push(MusicChunkPtr chunk) noexcept
|
|||
assert(!chunk->IsEmpty());
|
||||
assert(chunk->length == 0 || chunk->audio_format.IsValid());
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
assert(size > 0 || !audio_format.IsDefined());
|
||||
assert(!audio_format.IsDefined() ||
|
||||
|
|
|
@ -61,7 +61,7 @@ public:
|
|||
*/
|
||||
[[gnu::pure]]
|
||||
const MusicChunk *Peek() const noexcept {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
return head.get();
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
*/
|
||||
[[gnu::pure]]
|
||||
unsigned GetSize() const noexcept {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
return size;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ RemoteTagCache::~RemoteTagCache() noexcept
|
|||
void
|
||||
RemoteTagCache::Lookup(const std::string &uri) noexcept
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
auto [tag, value] = map.insert_check(uri);
|
||||
if (value) {
|
||||
|
@ -80,7 +80,7 @@ RemoteTagCache::ItemResolved(Item &item) noexcept
|
|||
void
|
||||
RemoteTagCache::InvokeHandlers() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
|
||||
while (!invoke_list.empty()) {
|
||||
auto &item = invoke_list.pop_front();
|
||||
|
@ -105,7 +105,7 @@ RemoteTagCache::Item::OnRemoteTag(Tag &&_tag) noexcept
|
|||
|
||||
scanner.reset();
|
||||
|
||||
const std::scoped_lock<Mutex> lock(parent.mutex);
|
||||
const std::scoped_lock lock{parent.mutex};
|
||||
parent.ItemResolved(*this);
|
||||
}
|
||||
|
||||
|
@ -117,6 +117,6 @@ RemoteTagCache::Item::OnRemoteTagError(std::exception_ptr e) noexcept
|
|||
|
||||
scanner.reset();
|
||||
|
||||
const std::scoped_lock<Mutex> lock(parent.mutex);
|
||||
const std::scoped_lock lock{parent.mutex};
|
||||
parent.ItemResolved(*this);
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ read_stream_art(Response &r, const std::string_view art_directory,
|
|||
|
||||
std::size_t read_size = 0;
|
||||
if (buffer_size > 0) {
|
||||
std::unique_lock<Mutex> lock(is->mutex);
|
||||
std::unique_lock lock{is->mutex};
|
||||
is->Seek(lock, offset);
|
||||
read_size = is->Read(lock, {buffer.get(), buffer_size});
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ protected:
|
|||
}
|
||||
|
||||
void CancelThread() noexcept override {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
cancel = true;
|
||||
cond.notify_one();
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ GetChromaprintCommand::DecodeFile(std::string_view suffix, InputStream &is,
|
|||
return false;
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
if (cancel)
|
||||
throw StopDecoder();
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ GetChromaprintCommand::OpenUri(const char *uri2)
|
|||
auto is = InputStream::Open(uri2, mutex);
|
||||
is->SetHandler(this);
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
while (true) {
|
||||
if (cancel)
|
||||
throw StopDecoder();
|
||||
|
@ -282,7 +282,7 @@ GetChromaprintCommand::Read(InputStream &is,
|
|||
if (dest.empty())
|
||||
return 0;
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
while (true) {
|
||||
if (cancel)
|
||||
|
|
|
@ -20,7 +20,7 @@ UpdateRemoveService::RunDeferred() noexcept
|
|||
std::forward_list<std::string> copy;
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
std::swap(uris, copy);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ UpdateRemoveService::Remove(std::string &&uri)
|
|||
bool was_empty;
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
was_empty = uris.empty();
|
||||
uris.emplace_front(std::move(uri));
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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 ||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -92,7 +92,7 @@ AllocatedString
|
|||
IcuConverter::ToUTF8(std::string_view s) const
|
||||
{
|
||||
#ifdef HAVE_ICU
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
ucnv_resetToUnicode(converter);
|
||||
|
||||
|
@ -119,7 +119,7 @@ AllocatedString
|
|||
IcuConverter::FromUTF8(std::string_view s) const
|
||||
{
|
||||
#ifdef HAVE_ICU
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
const auto u = UCharFromUTF8(s);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
private:
|
||||
bool LockWaitFinished() noexcept {
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
return cond.wait_for(lock, timeout, [this]{ return finished; });
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ private:
|
|||
* thread.
|
||||
*/
|
||||
void LockSetFinished() noexcept {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
finished = true;
|
||||
cond.notify_one();
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ SmbclientContext::New()
|
|||
SMBCCTX *ctx;
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(global_mutex);
|
||||
const std::scoped_lock protect{global_mutex};
|
||||
ctx = smbc_new_context();
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
~SmbclientContext() noexcept {
|
||||
if (ctx != nullptr) {
|
||||
const std::scoped_lock<Mutex> protect(global_mutex);
|
||||
const std::scoped_lock protect{global_mutex};
|
||||
smbc_free_context(ctx, 1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ UpnpClientGlobalInit(const char* iface)
|
|||
UpnpGlobalInit(iface);
|
||||
|
||||
try {
|
||||
const std::scoped_lock<Mutex> protect(upnp_client_init_mutex);
|
||||
const std::scoped_lock protect{upnp_client_init_mutex};
|
||||
if (upnp_client_ref == 0)
|
||||
DoInit();
|
||||
} catch (...) {
|
||||
|
@ -61,7 +61,7 @@ void
|
|||
UpnpClientGlobalFinish() noexcept
|
||||
{
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(upnp_client_init_mutex);
|
||||
const std::scoped_lock protect{upnp_client_init_mutex};
|
||||
|
||||
assert(upnp_client_ref > 0);
|
||||
if (--upnp_client_ref == 0)
|
||||
|
|
|
@ -88,14 +88,14 @@ UPnPDeviceDirectory::Downloader::Downloader(UPnPDeviceDirectory &_parent,
|
|||
expires(std::chrono::seconds(UpnpDiscovery_get_Expires(&disco))),
|
||||
request(*parent.curl, url.c_str(), *this)
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(parent.mutex);
|
||||
const std::scoped_lock protect{parent.mutex};
|
||||
parent.downloaders.push_back(*this);
|
||||
}
|
||||
|
||||
void
|
||||
UPnPDeviceDirectory::Downloader::Destroy() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(parent.mutex);
|
||||
const std::scoped_lock protect{parent.mutex};
|
||||
unlink();
|
||||
delete this;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ AnnounceLostUPnP(UPnPDiscoveryListener &listener, const UPnPDevice &device) noex
|
|||
inline void
|
||||
UPnPDeviceDirectory::LockAdd(std::string &&id, ContentDirectoryDescriptor &&d) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
const auto i = directories.insert_or_assign(std::move(id), std::move(d)).first;
|
||||
|
||||
|
@ -200,7 +200,7 @@ UPnPDeviceDirectory::LockAdd(std::string &&id, ContentDirectoryDescriptor &&d) n
|
|||
inline void
|
||||
UPnPDeviceDirectory::LockRemove(const std::string_view id) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
if (auto i = directories.find(id); i != directories.end()) {
|
||||
if (listener != nullptr)
|
||||
|
@ -297,7 +297,7 @@ UPnPDeviceDirectory::UPnPDeviceDirectory(EventLoop &event_loop,
|
|||
UPnPDeviceDirectory::~UPnPDeviceDirectory() noexcept
|
||||
{
|
||||
BlockingCall(GetEventLoop(), [this]() {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
downloaders.clear_and_dispose(DeleteDisposer());
|
||||
});
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ UPnPDeviceDirectory::Search()
|
|||
std::vector<ContentDirectoryService>
|
||||
UPnPDeviceDirectory::GetDirectories() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
ExpireDevices();
|
||||
|
||||
|
@ -356,7 +356,7 @@ UPnPDeviceDirectory::GetDirectories() noexcept
|
|||
ContentDirectoryService
|
||||
UPnPDeviceDirectory::GetServer(std::string_view friendly_name)
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
ExpireDevices();
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ DoInit(const char* iface)
|
|||
void
|
||||
UpnpGlobalInit(const char* iface)
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(upnp_init_mutex);
|
||||
const std::scoped_lock protect{upnp_init_mutex};
|
||||
|
||||
if (upnp_ref == 0)
|
||||
DoInit(iface);
|
||||
|
@ -44,7 +44,7 @@ UpnpGlobalInit(const char* iface)
|
|||
void
|
||||
UpnpGlobalFinish() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(upnp_init_mutex);
|
||||
const std::scoped_lock protect{upnp_init_mutex};
|
||||
|
||||
assert(upnp_ref > 0);
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ void
|
|||
SmbclientNeighborExplorer::Close() noexcept
|
||||
{
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
quit = true;
|
||||
cond.notify_one();
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ SmbclientNeighborExplorer::Close() noexcept
|
|||
NeighborExplorer::List
|
||||
SmbclientNeighborExplorer::GetList() const noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ SmbclientNeighborExplorer::ThreadFunc() noexcept
|
|||
{
|
||||
SetThreadName("smbclient");
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
while (!quit) {
|
||||
Run();
|
||||
|
|
|
@ -159,7 +159,7 @@ UdisksNeighborExplorer::Close() noexcept
|
|||
NeighborExplorer::List
|
||||
UdisksNeighborExplorer::GetList() const noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
|
||||
NeighborExplorer::List result;
|
||||
|
||||
|
@ -176,7 +176,7 @@ UdisksNeighborExplorer::Insert(UDisks2::Object &&o) noexcept
|
|||
const NeighborInfo info = ToNeighborInfo(o);
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
auto i = by_uri.emplace(o.GetUri(), info);
|
||||
if (!i.second)
|
||||
i.first->second = info;
|
||||
|
@ -191,7 +191,7 @@ UdisksNeighborExplorer::Insert(UDisks2::Object &&o) noexcept
|
|||
void
|
||||
UdisksNeighborExplorer::Remove(const std::string &path) noexcept
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
auto i = by_path.find(path);
|
||||
if (i == by_path.end())
|
||||
|
|
|
@ -54,7 +54,7 @@ AudioOutputControl::Steal() noexcept
|
|||
|
||||
/* close and disable the output */
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
if (really_enabled && output->SupportsEnableDisable())
|
||||
CommandWait(lock, Command::DISABLE);
|
||||
|
||||
|
@ -65,7 +65,7 @@ AudioOutputControl::Steal() noexcept
|
|||
StopThread();
|
||||
|
||||
/* now we can finally remove it */
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
return std::exchange(output, nullptr);
|
||||
}
|
||||
|
||||
|
@ -77,7 +77,7 @@ AudioOutputControl::ReplaceDummy(std::unique_ptr<FilteredAudioOutput> new_output
|
|||
assert(new_output);
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
output = std::move(new_output);
|
||||
enabled = _enabled;
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ AudioOutputControl::SetAttribute(std::string &&attribute_name,
|
|||
bool
|
||||
AudioOutputControl::LockSetEnabled(bool new_value) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
if (new_value == enabled)
|
||||
return false;
|
||||
|
@ -138,7 +138,7 @@ AudioOutputControl::LockSetEnabled(bool new_value) noexcept
|
|||
bool
|
||||
AudioOutputControl::LockToggleEnabled() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
return enabled = !enabled;
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ AudioOutputControl::CommandWait(std::unique_lock<Mutex> &lock,
|
|||
void
|
||||
AudioOutputControl::LockCommandWait(Command cmd) noexcept
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
CommandWait(lock, cmd);
|
||||
}
|
||||
|
||||
|
@ -300,7 +300,7 @@ AudioOutputControl::LockUpdate(const AudioFormat audio_format,
|
|||
const MusicPipe &mp,
|
||||
bool force) noexcept
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
if (enabled && really_enabled) {
|
||||
if (force || !fail_timer.IsDefined() ||
|
||||
|
@ -325,14 +325,14 @@ AudioOutputControl::IsChunkConsumed(const MusicChunk &chunk) const noexcept
|
|||
bool
|
||||
AudioOutputControl::LockIsChunkConsumed(const MusicChunk &chunk) const noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
return IsChunkConsumed(chunk);
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::LockPlay() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
assert(allow_play);
|
||||
|
||||
|
@ -354,7 +354,7 @@ AudioOutputControl::LockPauseAsync() noexcept
|
|||
if (output)
|
||||
output->Interrupt();
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
assert(allow_play);
|
||||
if (IsOpen())
|
||||
|
@ -364,7 +364,7 @@ AudioOutputControl::LockPauseAsync() noexcept
|
|||
void
|
||||
AudioOutputControl::LockDrainAsync() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
assert(allow_play);
|
||||
if (IsOpen())
|
||||
|
@ -377,7 +377,7 @@ AudioOutputControl::LockCancelAsync() noexcept
|
|||
if (output)
|
||||
output->Interrupt();
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
if (IsOpen()) {
|
||||
allow_play = false;
|
||||
|
@ -388,7 +388,7 @@ AudioOutputControl::LockCancelAsync() noexcept
|
|||
void
|
||||
AudioOutputControl::LockAllowPlay() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
allow_play = true;
|
||||
if (IsOpen())
|
||||
|
@ -410,7 +410,7 @@ AudioOutputControl::LockRelease() noexcept
|
|||
Mixer::LockAutoClose()) */
|
||||
output->mixer->LockAutoClose();
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
assert(!open || !fail_timer.IsDefined());
|
||||
assert(allow_play);
|
||||
|
@ -429,7 +429,7 @@ AudioOutputControl::LockCloseWait() noexcept
|
|||
if (output)
|
||||
output->Interrupt();
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
CloseWait(lock);
|
||||
}
|
||||
|
||||
|
@ -440,7 +440,7 @@ AudioOutputControl::BeginDestroy() noexcept
|
|||
if (output)
|
||||
output->Interrupt();
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
if (!killed) {
|
||||
killed = true;
|
||||
CommandAsync(Command::KILL);
|
||||
|
|
|
@ -355,7 +355,7 @@ public:
|
|||
void WaitForCommand(std::unique_lock<Mutex> &lock) noexcept;
|
||||
|
||||
void LockWaitForCommand() noexcept {
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
WaitForCommand(lock);
|
||||
}
|
||||
|
||||
|
@ -407,7 +407,7 @@ public:
|
|||
void EnableDisableAsync();
|
||||
|
||||
void LockEnableDisableAsync() {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
EnableDisableAsync();
|
||||
}
|
||||
|
||||
|
@ -482,7 +482,7 @@ public:
|
|||
* Locking wrapper for ClearTailChunk().
|
||||
*/
|
||||
void LockClearTailChunk(const MusicChunk &chunk) noexcept {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
ClearTailChunk(chunk);
|
||||
}
|
||||
|
||||
|
|
|
@ -213,7 +213,7 @@ MultipleOutputs::Open(const AudioFormat audio_format)
|
|||
std::exception_ptr first_error;
|
||||
|
||||
for (const auto &ao : outputs) {
|
||||
const std::scoped_lock<Mutex> lock(ao->mutex);
|
||||
const std::scoped_lock lock{ao->mutex};
|
||||
|
||||
/* can't play on this device even if it's enabled */
|
||||
if (ao->AlwaysOff())
|
||||
|
|
|
@ -27,7 +27,7 @@ audio_output_state_save(BufferedOutputStream &os,
|
|||
{
|
||||
for (unsigned i = 0, n = outputs.Size(); i != n; ++i) {
|
||||
const auto &ao = outputs.Get(i);
|
||||
const std::scoped_lock<Mutex> lock(ao.mutex);
|
||||
const std::scoped_lock lock{ao.mutex};
|
||||
|
||||
os.Fmt(FMT_STRING(AUDIO_DEVICE_STATE "{}:{}\n"),
|
||||
(unsigned)ao.IsEnabled(), ao.GetName());
|
||||
|
|
|
@ -417,7 +417,7 @@ AudioOutputControl::Task() noexcept
|
|||
|
||||
SetThreadTimerSlack(std::chrono::microseconds(100));
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
while (true) {
|
||||
switch (command) {
|
||||
|
|
|
@ -294,13 +294,13 @@ private:
|
|||
|
||||
[[gnu::pure]]
|
||||
bool LockIsActive() const noexcept {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
return active;
|
||||
}
|
||||
|
||||
[[gnu::pure]]
|
||||
bool LockIsActiveAndNotWaiting() const noexcept {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
return active && !waiting;
|
||||
}
|
||||
|
||||
|
@ -366,7 +366,7 @@ private:
|
|||
void LockCaughtError() noexcept {
|
||||
period_buffer.Clear();
|
||||
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
error = std::current_exception();
|
||||
active = false;
|
||||
waiting = false;
|
||||
|
@ -381,7 +381,7 @@ private:
|
|||
*/
|
||||
void OnSilenceTimer() noexcept {
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
assert(active);
|
||||
waiting = false;
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ AlsaOutput::AlsaOutput(EventLoop &_loop, const ConfigBlock &block)
|
|||
std::map<std::string, std::string, std::less<>>
|
||||
AlsaOutput::GetAttributes() const noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(attributes_mutex);
|
||||
const std::scoped_lock lock{attributes_mutex};
|
||||
|
||||
return {
|
||||
{"allowed_formats", Alsa::ToString(allowed_formats)},
|
||||
|
@ -461,11 +461,11 @@ void
|
|||
AlsaOutput::SetAttribute(std::string &&name, std::string &&value)
|
||||
{
|
||||
if (name == "allowed_formats") {
|
||||
const std::scoped_lock<Mutex> lock(attributes_mutex);
|
||||
const std::scoped_lock lock{attributes_mutex};
|
||||
allowed_formats = Alsa::AllowedFormat::ParseList(value);
|
||||
#ifdef ENABLE_DSD
|
||||
} else if (name == "dop") {
|
||||
const std::scoped_lock<Mutex> lock(attributes_mutex);
|
||||
const std::scoped_lock lock{attributes_mutex};
|
||||
if (value == "0")
|
||||
dop_setting = false;
|
||||
else if (value == "1")
|
||||
|
@ -773,7 +773,7 @@ AlsaOutput::Open(AudioFormat &audio_format)
|
|||
#endif
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(attributes_mutex);
|
||||
const std::scoped_lock lock{attributes_mutex};
|
||||
#ifdef ENABLE_DSD
|
||||
dop = dop_setting;
|
||||
#endif
|
||||
|
@ -877,7 +877,7 @@ AlsaOutput::Open(AudioFormat &audio_format)
|
|||
void
|
||||
AlsaOutput::Interrupt() noexcept
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::scoped_lock lock{mutex};
|
||||
|
||||
/* the "interrupted" flag will prevent
|
||||
LockWaitWriteAvailable() from actually waiting, and will
|
||||
|
@ -951,7 +951,7 @@ AlsaOutput::CopyRingToPeriodBuffer() noexcept
|
|||
|
||||
period_buffer.AppendBytes(nbytes);
|
||||
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
/* notify the OutputThread that there is now
|
||||
room in ring_buffer */
|
||||
cond.notify_one();
|
||||
|
@ -1069,7 +1069,7 @@ AlsaOutput::DrainInternal()
|
|||
void
|
||||
AlsaOutput::Drain()
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
if (error)
|
||||
std::rethrow_exception(error);
|
||||
|
@ -1110,7 +1110,7 @@ void
|
|||
AlsaOutput::Cancel() noexcept
|
||||
{
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::lock_guard lock{mutex};
|
||||
interrupted = false;
|
||||
}
|
||||
|
||||
|
@ -1128,7 +1128,7 @@ AlsaOutput::Cancel() noexcept
|
|||
#ifdef ENABLE_DSD
|
||||
if (stop_dsd_silence && use_dsd) {
|
||||
/* play some DSD silence instead of snd_pcm_drop() */
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
in_stop_dsd_silence = true;
|
||||
drain = true;
|
||||
cond.wait(lock, [this]{ return !drain || !active; });
|
||||
|
@ -1144,7 +1144,7 @@ AlsaOutput::Cancel() noexcept
|
|||
bool
|
||||
AlsaOutput::Pause() noexcept
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::lock_guard lock{mutex};
|
||||
interrupted = false;
|
||||
|
||||
/* not implemented - this override exists only to reset the
|
||||
|
@ -1174,7 +1174,7 @@ AlsaOutput::LockWaitWriteAvailable()
|
|||
const size_t out_block_size = pcm_export->GetOutputBlockSize();
|
||||
const size_t min_available = 2 * out_block_size;
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
while (true) {
|
||||
if (error)
|
||||
|
@ -1265,7 +1265,7 @@ try {
|
|||
}
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
|
||||
assert(active);
|
||||
|
||||
|
@ -1305,7 +1305,7 @@ try {
|
|||
smaller than the ALSA-PCM buffer */
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
waiting = true;
|
||||
cond.notify_one();
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ private:
|
|||
void Disconnect() noexcept;
|
||||
|
||||
void Shutdown(const char *reason) noexcept {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
error = std::make_exception_ptr(FmtRuntimeError("JACK connection shutdown: {}",
|
||||
reason));
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ public:
|
|||
|
||||
private:
|
||||
bool LockWasShutdown() const noexcept {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
return !!error;
|
||||
}
|
||||
};
|
||||
|
@ -618,7 +618,7 @@ JackOutput::Open(AudioFormat &new_audio_format)
|
|||
void
|
||||
JackOutput::Interrupt() noexcept
|
||||
{
|
||||
const std::unique_lock<Mutex> lock(mutex);
|
||||
const std::lock_guard lock{mutex};
|
||||
|
||||
/* the "interrupted" flag will prevent Play() from waiting,
|
||||
and will instead throw AudioOutputInterrupted */
|
||||
|
@ -680,7 +680,7 @@ JackOutput::Play(std::span<const std::byte> _src)
|
|||
|
||||
while (true) {
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
if (error)
|
||||
std::rethrow_exception(error);
|
||||
|
||||
|
@ -702,7 +702,7 @@ JackOutput::Play(std::span<const std::byte> _src)
|
|||
void
|
||||
JackOutput::Cancel() noexcept
|
||||
{
|
||||
const std::unique_lock<Mutex> lock(mutex);
|
||||
const std::lock_guard lock{mutex};
|
||||
interrupted = false;
|
||||
}
|
||||
|
||||
|
@ -710,7 +710,7 @@ inline bool
|
|||
JackOutput::Pause()
|
||||
{
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
interrupted = false;
|
||||
if (error)
|
||||
std::rethrow_exception(error);
|
||||
|
|
|
@ -34,7 +34,7 @@ HttpdClient::Close() noexcept
|
|||
void
|
||||
HttpdClient::LockClose() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(httpd.mutex);
|
||||
const std::scoped_lock protect{httpd.mutex};
|
||||
Close();
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ HttpdClient::GetBytesTillMetaData() const noexcept
|
|||
inline bool
|
||||
HttpdClient::TryWrite() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(httpd.mutex);
|
||||
const std::scoped_lock protect{httpd.mutex};
|
||||
|
||||
assert(state == State::RESPONSE);
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ public:
|
|||
*/
|
||||
[[gnu::pure]]
|
||||
bool LockHasClients() const noexcept {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
return HasClients();
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ HttpdOutput::OnDeferredBroadcast() noexcept
|
|||
/* this method runs in the IOThread; it broadcasts pages from
|
||||
our own queue to all clients */
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
while (!pages.empty()) {
|
||||
PagePtr page = std::move(pages.front());
|
||||
|
@ -118,7 +118,7 @@ HttpdOutput::OnAccept(UniqueSocketDescriptor fd,
|
|||
/* the listener socket has become readable - a client has
|
||||
connected */
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
/* can we allow additional client */
|
||||
if (open && (clients_max == 0 || clients.size() < clients_max))
|
||||
|
@ -197,7 +197,7 @@ HttpdOutput::Open(AudioFormat &audio_format)
|
|||
assert(!open);
|
||||
assert(clients.empty());
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
OpenEncoder(audio_format);
|
||||
|
||||
|
@ -219,7 +219,7 @@ HttpdOutput::Close() noexcept
|
|||
BlockingCall(GetEventLoop(), [this](){
|
||||
defer_broadcast.Cancel();
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
open = false;
|
||||
clients.clear_and_dispose(DeleteDisposer());
|
||||
});
|
||||
|
@ -272,7 +272,7 @@ HttpdOutput::BroadcastPage(PagePtr page) noexcept
|
|||
assert(page != nullptr);
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
pages.emplace(std::move(page));
|
||||
}
|
||||
|
||||
|
@ -284,7 +284,7 @@ HttpdOutput::BroadcastFromEncoder() noexcept
|
|||
{
|
||||
/* synchronize with the IOThread */
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
cond.wait(lock, [this]{ return pages.empty(); });
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ HttpdOutput::BroadcastFromEncoder() noexcept
|
|||
|
||||
PagePtr page;
|
||||
while ((page = ReadPage()) != nullptr) {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
pages.emplace(std::move(page));
|
||||
empty = false;
|
||||
}
|
||||
|
@ -384,7 +384,7 @@ HttpdOutput::SendTag(const Tag &tag)
|
|||
|
||||
metadata = icy_server_metadata_page(tag, &types[0]);
|
||||
if (metadata != nullptr) {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
for (auto &client : clients)
|
||||
client.PushMetaData(metadata);
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ HttpdOutput::SendTag(const Tag &tag)
|
|||
inline void
|
||||
HttpdOutput::CancelAllClients() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
while (!pages.empty()) {
|
||||
PagePtr page = std::move(pages.front());
|
||||
|
|
|
@ -330,7 +330,7 @@ SlesOutput::Play(std::span<const std::byte> src)
|
|||
pause = false;
|
||||
}
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
assert(filled < BUFFER_SIZE);
|
||||
|
||||
|
@ -360,7 +360,7 @@ SlesOutput::Play(std::span<const std::byte> src)
|
|||
void
|
||||
SlesOutput::Drain()
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
assert(filled < BUFFER_SIZE);
|
||||
|
||||
|
@ -382,7 +382,7 @@ SlesOutput::Cancel() noexcept
|
|||
LogWarning(sles_domain,
|
||||
"AndroidSimpleBufferQueue.Clear() failed");
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
n_queued = 0;
|
||||
filled = 0;
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ SlesOutput::Pause()
|
|||
inline void
|
||||
SlesOutput::PlayedCallback()
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
assert(n_queued > 0);
|
||||
--n_queued;
|
||||
cond.notify_one();
|
||||
|
|
|
@ -40,7 +40,7 @@ SnapcastClient::Close() noexcept
|
|||
void
|
||||
SnapcastClient::LockClose() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(output.mutex);
|
||||
const std::scoped_lock protect{output.mutex};
|
||||
Close();
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ SnapcastClient::Push(SnapcastChunkPtr chunk) noexcept
|
|||
SnapcastChunkPtr
|
||||
SnapcastClient::LockPopQueue() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(output.mutex);
|
||||
const std::scoped_lock protect{output.mutex};
|
||||
if (chunks.empty())
|
||||
return nullptr;
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ public:
|
|||
*/
|
||||
[[gnu::pure]]
|
||||
bool LockHasClients() const noexcept {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
return HasClients();
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ SnapcastOutput::OnAccept(UniqueSocketDescriptor fd,
|
|||
/* the listener socket has become readable - a client has
|
||||
connected */
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
/* can we allow additional client */
|
||||
if (open)
|
||||
|
@ -130,7 +130,7 @@ SnapcastOutput::Open(AudioFormat &audio_format)
|
|||
assert(!open);
|
||||
assert(clients.empty());
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
OpenEncoder(audio_format);
|
||||
|
||||
|
@ -152,7 +152,7 @@ SnapcastOutput::Close() noexcept
|
|||
BlockingCall(GetEventLoop(), [this](){
|
||||
inject_event.Cancel();
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
open = false;
|
||||
clients.clear_and_dispose(DeleteDisposer{});
|
||||
});
|
||||
|
@ -166,7 +166,7 @@ SnapcastOutput::Close() noexcept
|
|||
void
|
||||
SnapcastOutput::OnInject() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
while (!chunks.empty()) {
|
||||
const auto chunk = std::move(chunks.front());
|
||||
|
@ -272,7 +272,7 @@ SnapcastOutput::SendTag(const Tag &tag)
|
|||
|
||||
const auto payload = std::as_bytes(std::span{json});
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
// TODO: enqueue StreamTags, don't send directly
|
||||
for (auto &client : clients)
|
||||
client.SendStreamTags(payload);
|
||||
|
@ -320,7 +320,7 @@ SnapcastOutput::Play(std::span<const std::byte> src)
|
|||
|
||||
unflushed_input = 0;
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
if (chunks.empty())
|
||||
inject_event.Schedule();
|
||||
|
||||
|
@ -350,14 +350,14 @@ SnapcastOutput::IsDrained() const noexcept
|
|||
void
|
||||
SnapcastOutput::Drain()
|
||||
{
|
||||
std::unique_lock<Mutex> protect(mutex);
|
||||
std::unique_lock protect{mutex};
|
||||
drain_cond.wait(protect, [this]{ return IsDrained(); });
|
||||
}
|
||||
|
||||
void
|
||||
SnapcastOutput::Cancel() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
ClearQueue(chunks);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ PlayerControl::Play(std::unique_ptr<DetachedSong> song)
|
|||
|
||||
assert(song != nullptr);
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
SeekLocked(lock, std::move(song), SongTime::zero());
|
||||
|
||||
if (state == PlayerState::PAUSE)
|
||||
|
@ -110,7 +110,7 @@ PlayerControl::PauseLocked(std::unique_lock<Mutex> &lock) noexcept
|
|||
void
|
||||
PlayerControl::LockPause() noexcept
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
PauseLocked(lock);
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ PlayerControl::LockSetPause(bool pause_flag) noexcept
|
|||
if (!thread.IsDefined())
|
||||
return;
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
switch (state) {
|
||||
case PlayerState::STOP:
|
||||
|
@ -141,7 +141,7 @@ PlayerControl::LockSetPause(bool pause_flag) noexcept
|
|||
void
|
||||
PlayerControl::LockSetBorderPause(bool _border_pause) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
border_pause = _border_pause;
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ PlayerControl::LockGetStatus() noexcept
|
|||
{
|
||||
PlayerStatus status;
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
if (!occupied && thread.IsDefined())
|
||||
SynchronousCommand(lock, PlayerCommand::REFRESH);
|
||||
|
||||
|
@ -182,14 +182,14 @@ PlayerControl::SetError(PlayerError type, std::exception_ptr &&_error) noexcept
|
|||
void
|
||||
PlayerControl::LockClearError() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
ClearError();
|
||||
}
|
||||
|
||||
void
|
||||
PlayerControl::LockSetTaggedSong(const DetachedSong &song) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
tagged_song.reset();
|
||||
tagged_song = std::make_unique<DetachedSong>(song);
|
||||
}
|
||||
|
@ -209,7 +209,7 @@ PlayerControl::ReadTaggedSong() noexcept
|
|||
std::unique_ptr<DetachedSong>
|
||||
PlayerControl::LockReadTaggedSong() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
return ReadTaggedSong();
|
||||
}
|
||||
|
||||
|
@ -219,7 +219,7 @@ PlayerControl::LockEnqueueSong(std::unique_ptr<DetachedSong> song) noexcept
|
|||
assert(thread.IsDefined());
|
||||
assert(song != nullptr);
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
EnqueueSongLocked(lock, std::move(song));
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ PlayerControl::LockSeek(std::unique_ptr<DetachedSong> song, SongTime t)
|
|||
|
||||
assert(song != nullptr);
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
SeekLocked(lock, std::move(song), t);
|
||||
}
|
||||
|
||||
|
|
|
@ -224,7 +224,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();
|
||||
}
|
||||
|
||||
|
@ -293,7 +293,7 @@ public:
|
|||
}
|
||||
|
||||
void LockSetReplayGainMode(ReplayGainMode _mode) noexcept {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
replay_gain_mode = _mode;
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ public:
|
|||
|
||||
[[gnu::pure]]
|
||||
SyncInfo LockGetSyncInfo() const noexcept {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
return {state, next_song != nullptr};
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ private:
|
|||
* this function.
|
||||
*/
|
||||
void LockSignal() noexcept {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
Signal();
|
||||
}
|
||||
|
||||
|
@ -391,7 +391,7 @@ private:
|
|||
}
|
||||
|
||||
void LockCommandFinished() noexcept {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
CommandFinished();
|
||||
}
|
||||
|
||||
|
@ -409,7 +409,7 @@ private:
|
|||
unsigned threshold) noexcept;
|
||||
|
||||
bool LockWaitOutputConsumed(unsigned threshold) noexcept {
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
return WaitOutputConsumed(lock, threshold);
|
||||
}
|
||||
|
||||
|
@ -448,7 +448,7 @@ private:
|
|||
* object.
|
||||
*/
|
||||
void LockSynchronousCommand(PlayerCommand cmd) noexcept {
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
SynchronousCommand(lock, cmd);
|
||||
}
|
||||
|
||||
|
@ -486,7 +486,7 @@ private:
|
|||
}
|
||||
|
||||
void LockSetOutputError(std::exception_ptr &&_error) noexcept {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
SetOutputError(std::move(_error));
|
||||
}
|
||||
|
||||
|
|
|
@ -923,7 +923,7 @@ PlayerControl::PlayChunk(DetachedSong &song, MusicChunkPtr chunk,
|
|||
return;
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
bit_rate = chunk->bit_rate;
|
||||
}
|
||||
|
||||
|
@ -997,7 +997,7 @@ Player::PlayNextChunk() noexcept
|
|||
} else {
|
||||
/* there are not enough decoded chunks yet */
|
||||
|
||||
std::unique_lock<Mutex> lock(pc.mutex);
|
||||
std::unique_lock lock{pc.mutex};
|
||||
|
||||
if (dc.IsIdle()) {
|
||||
/* the decoder isn't running, abort
|
||||
|
@ -1045,7 +1045,7 @@ Player::PlayNextChunk() noexcept
|
|||
return false;
|
||||
}
|
||||
|
||||
const std::scoped_lock<Mutex> lock(pc.mutex);
|
||||
const std::scoped_lock lock{pc.mutex};
|
||||
|
||||
/* this formula should prevent that the decoder gets woken up
|
||||
with each chunk; it is more efficient to make it decode a
|
||||
|
@ -1096,7 +1096,7 @@ Player::Run() noexcept
|
|||
{
|
||||
pipe = std::make_shared<MusicPipe>();
|
||||
|
||||
std::unique_lock<Mutex> lock(pc.mutex);
|
||||
std::unique_lock lock{pc.mutex};
|
||||
|
||||
StartDecoder(lock, pipe, true);
|
||||
ActivateDecoder();
|
||||
|
@ -1248,7 +1248,7 @@ try {
|
|||
|
||||
MusicBuffer buffer{config.buffer_chunks};
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
while (true) {
|
||||
switch (command) {
|
||||
|
|
|
@ -179,7 +179,7 @@ CompositeStorage::~CompositeStorage() = default;
|
|||
Storage *
|
||||
CompositeStorage::GetMount(std::string_view uri) noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
auto result = FindStorage(uri);
|
||||
if (!result.uri.empty())
|
||||
|
@ -192,7 +192,7 @@ CompositeStorage::GetMount(std::string_view uri) noexcept
|
|||
void
|
||||
CompositeStorage::Mount(const char *uri, std::unique_ptr<Storage> storage)
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
Directory &directory = root.Make(uri);
|
||||
assert(!directory.storage);
|
||||
|
@ -202,7 +202,7 @@ CompositeStorage::Mount(const char *uri, std::unique_ptr<Storage> storage)
|
|||
bool
|
||||
CompositeStorage::Unmount(const char *uri)
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
return root.Unmount(uri);
|
||||
}
|
||||
|
@ -231,7 +231,7 @@ CompositeStorage::FindStorage(std::string_view uri) const noexcept
|
|||
StorageFileInfo
|
||||
CompositeStorage::GetInfo(std::string_view uri, bool follow)
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
std::exception_ptr error;
|
||||
|
||||
|
@ -257,7 +257,7 @@ CompositeStorage::GetInfo(std::string_view uri, bool follow)
|
|||
std::unique_ptr<StorageDirectoryReader>
|
||||
CompositeStorage::OpenDirectory(std::string_view uri)
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
auto f = FindStorage(uri);
|
||||
const Directory *directory = f.directory->Find(f.uri);
|
||||
|
@ -284,7 +284,7 @@ CompositeStorage::OpenDirectory(std::string_view uri)
|
|||
std::string
|
||||
CompositeStorage::MapUTF8(std::string_view uri) const noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
auto f = FindStorage(uri);
|
||||
if (f.directory->storage == nullptr)
|
||||
|
@ -296,7 +296,7 @@ CompositeStorage::MapUTF8(std::string_view uri) const noexcept
|
|||
AllocatedPath
|
||||
CompositeStorage::MapFS(std::string_view uri) const noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
auto f = FindStorage(uri);
|
||||
if (f.directory->storage == nullptr)
|
||||
|
@ -308,7 +308,7 @@ CompositeStorage::MapFS(std::string_view uri) const noexcept
|
|||
std::string_view
|
||||
CompositeStorage::MapToRelativeUTF8(std::string_view uri) const noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
|
||||
if (root.storage != nullptr) {
|
||||
auto result = root.storage->MapToRelativeUTF8(uri);
|
||||
|
@ -325,7 +325,7 @@ CompositeStorage::MapToRelativeUTF8(std::string_view uri) const noexcept
|
|||
InputStreamPtr
|
||||
CompositeStorage::OpenFile(std::string_view uri_utf8, Mutex &_mutex)
|
||||
{
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
const std::lock_guard lock{mutex};
|
||||
|
||||
auto f = FindStorage(uri_utf8);
|
||||
if (f.directory->storage == nullptr)
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
*/
|
||||
template<typename T>
|
||||
void VisitMounts(T t) const {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
std::string uri;
|
||||
VisitMounts(uri, root, t);
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public:
|
|||
*/
|
||||
[[gnu::pure]] [[gnu::nonnull]]
|
||||
bool IsMounted(const char *storage_uri) const noexcept {
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
return IsMounted(root, storage_uri);
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public:
|
|||
}
|
||||
|
||||
void Wait() {
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
cond.wait(lock, [this]{ return done; });
|
||||
|
||||
if (postponed_error)
|
||||
|
@ -130,7 +130,7 @@ protected:
|
|||
}
|
||||
|
||||
void LockSetDone() {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
SetDone();
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ private:
|
|||
|
||||
/* virtual methods from CurlResponseHandler */
|
||||
void OnError(std::exception_ptr e) noexcept final {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
postponed_error = std::move(e);
|
||||
SetDone();
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ private:
|
|||
void SetState(State _state) noexcept {
|
||||
assert(GetEventLoop().IsInside());
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
state = _state;
|
||||
cond.notify_all();
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ private:
|
|||
void SetState(State _state, std::exception_ptr &&e) noexcept {
|
||||
assert(GetEventLoop().IsInside());
|
||||
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
state = _state;
|
||||
last_exception = std::move(e);
|
||||
cond.notify_all();
|
||||
|
@ -172,7 +172,7 @@ private:
|
|||
}
|
||||
|
||||
void WaitConnected() {
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
while (true) {
|
||||
switch (state) {
|
||||
|
|
|
@ -89,7 +89,7 @@ GetInfo(SmbclientContext &ctx, Mutex &mutex, const char *path)
|
|||
struct stat st;
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
if (ctx.Stat(path, st) != 0)
|
||||
throw MakeErrno("Failed to access file");
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ SmbclientStorage::OpenDirectory(std::string_view uri_utf8)
|
|||
SMBCFILE *handle;
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
const std::scoped_lock protect{mutex};
|
||||
handle = ctx.OpenDirectory(mapped.c_str());
|
||||
}
|
||||
|
||||
|
@ -152,14 +152,14 @@ SkipNameFS(PathTraitsFS::const_pointer name) noexcept
|
|||
|
||||
SmbclientDirectoryReader::~SmbclientDirectoryReader()
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(storage.mutex);
|
||||
const std::scoped_lock lock{storage.mutex};
|
||||
storage.ctx.CloseDirectory(handle);
|
||||
}
|
||||
|
||||
const char *
|
||||
SmbclientDirectoryReader::Read() noexcept
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(storage.mutex);
|
||||
const std::scoped_lock protect{storage.mutex};
|
||||
|
||||
while (auto e = storage.ctx.ReadDirectory(handle)) {
|
||||
name = e->name;
|
||||
|
|
|
@ -151,7 +151,7 @@ UdisksStorage::SetMountPoint(Path mount_point)
|
|||
void
|
||||
UdisksStorage::LockSetMountPoint(Path mount_point)
|
||||
{
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
SetMountPoint(mount_point);
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ UdisksStorage::OnListReply(ODBus::Message reply) noexcept
|
|||
return;
|
||||
}
|
||||
} catch (...) {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
mount_error = std::current_exception();
|
||||
want_mount = false;
|
||||
cond.notify_all();
|
||||
|
@ -196,7 +196,7 @@ UdisksStorage::OnListReply(ODBus::Message reply) noexcept
|
|||
void
|
||||
UdisksStorage::MountWait()
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
if (mounted_storage)
|
||||
/* already mounted */
|
||||
|
@ -239,7 +239,7 @@ try {
|
|||
mount_request.Send(connection, *msg.Get(),
|
||||
[this](auto o) { return OnMountNotify(std::move(o)); });
|
||||
} catch (...) {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
mount_error = std::current_exception();
|
||||
want_mount = false;
|
||||
cond.notify_all();
|
||||
|
@ -258,7 +258,7 @@ try {
|
|||
const char *mount_path = i.GetString();
|
||||
LockSetMountPoint(Path::FromFS(mount_path));
|
||||
} catch (...) {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
mount_error = std::current_exception();
|
||||
want_mount = false;
|
||||
cond.notify_all();
|
||||
|
@ -267,7 +267,7 @@ try {
|
|||
void
|
||||
UdisksStorage::UnmountWait()
|
||||
{
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
if (!mounted_storage)
|
||||
/* not mounted */
|
||||
|
@ -296,7 +296,7 @@ try {
|
|||
mount_request.Send(connection, *msg.Get(),
|
||||
[this](auto u) { return OnUnmountNotify(std::move(u)); });
|
||||
} catch (...) {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
mount_error = std::current_exception();
|
||||
mounted_storage.reset();
|
||||
cond.notify_all();
|
||||
|
@ -308,12 +308,12 @@ try {
|
|||
using namespace ODBus;
|
||||
reply.CheckThrowError();
|
||||
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
mount_error = {};
|
||||
mounted_storage.reset();
|
||||
cond.notify_all();
|
||||
} catch (...) {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
mount_error = std::current_exception();
|
||||
mounted_storage.reset();
|
||||
cond.notify_all();
|
||||
|
|
|
@ -23,7 +23,7 @@ struct ApeFooter {
|
|||
bool
|
||||
tag_ape_scan(InputStream &is, const ApeTagCallback& callback)
|
||||
try {
|
||||
std::unique_lock<Mutex> lock(is.mutex);
|
||||
std::unique_lock lock{is.mutex};
|
||||
|
||||
if (!is.KnownSize() || !is.CheapSeeking())
|
||||
return false;
|
||||
|
|
|
@ -20,7 +20,7 @@ TagBuilder::TagBuilder(const Tag &other) noexcept
|
|||
const std::size_t n = other.num_items;
|
||||
if (n > 0) {
|
||||
items.reserve(other.num_items);
|
||||
const std::scoped_lock<Mutex> protect(tag_pool_lock);
|
||||
const std::scoped_lock protect{tag_pool_lock};
|
||||
for (std::size_t i = 0; i != n; ++i)
|
||||
items.push_back(tag_pool_dup_item(other.items[i]));
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ TagBuilder::operator=(const TagBuilder &other) noexcept
|
|||
items = other.items;
|
||||
|
||||
/* increment the tag pool refcounters */
|
||||
const std::scoped_lock<Mutex> protect(tag_pool_lock);
|
||||
const std::scoped_lock protect{tag_pool_lock};
|
||||
for (auto &i : items)
|
||||
i = tag_pool_dup_item(i);
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ TagBuilder::Complement(const Tag &other) noexcept
|
|||
|
||||
items.reserve(items.size() + n);
|
||||
|
||||
const std::scoped_lock<Mutex> protect(tag_pool_lock);
|
||||
const std::scoped_lock protect{tag_pool_lock};
|
||||
for (std::size_t i = 0; i != n; ++i) {
|
||||
TagItem *item = other.items[i];
|
||||
if (!present[item->type])
|
||||
|
@ -185,7 +185,7 @@ TagBuilder::AddItemUnchecked(TagType type, std::string_view value) noexcept
|
|||
TagItem *i;
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(tag_pool_lock);
|
||||
const std::scoped_lock protect{tag_pool_lock};
|
||||
i = tag_pool_get_item(type, value);
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ TagBuilder::RemoveAll() noexcept
|
|||
return;
|
||||
|
||||
{
|
||||
const std::scoped_lock<Mutex> protect(tag_pool_lock);
|
||||
const std::scoped_lock protect{tag_pool_lock};
|
||||
for (auto i : items)
|
||||
tag_pool_put_item(i);
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ TagBuilder::RemoveType(TagType type) noexcept
|
|||
|
||||
const auto begin = items.begin(), end = items.end();
|
||||
|
||||
const std::scoped_lock<Mutex> protect(tag_pool_lock);
|
||||
const std::scoped_lock protect{tag_pool_lock};
|
||||
items.erase(std::remove_if(begin, end,
|
||||
[type](TagItem *item) {
|
||||
if (item->type != type)
|
||||
|
|
|
@ -193,7 +193,7 @@ try {
|
|||
UniqueId3Tag
|
||||
tag_id3_load(InputStream &is)
|
||||
try {
|
||||
std::unique_lock<Mutex> lock(is.mutex);
|
||||
std::unique_lock lock{is.mutex};
|
||||
|
||||
auto tag = tag_id3_find_from_beginning(is, lock);
|
||||
if (tag == nullptr && is.CheapSeeking()) {
|
||||
|
|
|
@ -15,7 +15,7 @@ Tag::Clear() noexcept
|
|||
|
||||
if (num_items > 0) {
|
||||
assert(items != nullptr);
|
||||
const std::scoped_lock<Mutex> protect(tag_pool_lock);
|
||||
const std::scoped_lock protect{tag_pool_lock};
|
||||
for (unsigned i = 0; i < num_items; ++i)
|
||||
tag_pool_put_item(items[i]);
|
||||
num_items = 0;
|
||||
|
@ -32,7 +32,7 @@ Tag::Tag(const Tag &other) noexcept
|
|||
if (num_items > 0) {
|
||||
items = new TagItem *[num_items];
|
||||
|
||||
const std::scoped_lock<Mutex> protect(tag_pool_lock);
|
||||
const std::scoped_lock protect{tag_pool_lock};
|
||||
for (unsigned i = 0; i < num_items; i++)
|
||||
items[i] = tag_pool_dup_item(other.items[i]);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class SafeSingleton {
|
|||
public:
|
||||
template<typename... Args>
|
||||
explicit SafeSingleton(Args&&... args) {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
|
||||
if (ref == 0)
|
||||
instance = new T(std::forward<Args>(args)...);
|
||||
|
@ -34,7 +34,7 @@ public:
|
|||
}
|
||||
|
||||
~SafeSingleton() noexcept {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
if (--ref > 0)
|
||||
return;
|
||||
|
||||
|
|
|
@ -70,24 +70,24 @@ private:
|
|||
|
||||
public:
|
||||
bool is_ready() const noexcept {
|
||||
std::unique_lock<CriticalSection> lock(mutex);
|
||||
const std::lock_guard lock{mutex};
|
||||
return ready;
|
||||
}
|
||||
|
||||
bool already_retrieved() const noexcept {
|
||||
std::unique_lock<CriticalSection> lock(mutex);
|
||||
const std::lock_guard lock{mutex};
|
||||
return retrieved;
|
||||
}
|
||||
|
||||
void wait() {
|
||||
std::unique_lock<CriticalSection> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
condition.wait(lock, [this]() { return ready; });
|
||||
}
|
||||
|
||||
template <class Rep, class Period>
|
||||
WinFutureStatus
|
||||
wait_for(const std::chrono::duration<Rep, Period> &timeout_duration) const {
|
||||
std::unique_lock<CriticalSection> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
// deferred function not support yet
|
||||
if (condition.wait_for(lock, timeout_duration,
|
||||
[this]() { return ready; })) {
|
||||
|
@ -97,7 +97,7 @@ public:
|
|||
}
|
||||
|
||||
virtual T &get_value() {
|
||||
std::unique_lock<CriticalSection> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
if (retrieved) {
|
||||
throw WinFutureError(WinFutureErrc::future_already_retrieved);
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ public:
|
|||
}
|
||||
|
||||
void set_value(const T &value) {
|
||||
std::unique_lock<CriticalSection> lock(mutex);
|
||||
const std::lock_guard lock{mutex};
|
||||
if (!std::holds_alternative<std::monostate>(result)) {
|
||||
throw WinFutureError(WinFutureErrc::promise_already_satisfied);
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
}
|
||||
|
||||
void set_value(T &&value) {
|
||||
std::unique_lock<CriticalSection> lock(mutex);
|
||||
const std::lock_guard lock{mutex};
|
||||
if (!std::holds_alternative<std::monostate>(result)) {
|
||||
throw WinFutureError(WinFutureErrc::promise_already_satisfied);
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ public:
|
|||
}
|
||||
|
||||
void set_exception(std::exception_ptr eptr) {
|
||||
std::unique_lock<CriticalSection> lock(mutex);
|
||||
const std::lock_guard lock{mutex};
|
||||
if (!std::holds_alternative<std::monostate>(result)) {
|
||||
throw WinFutureError(WinFutureErrc::promise_already_satisfied);
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ TEST(RewindInputStream, Basic)
|
|||
EXPECT_TRUE(ris.get() != sis);
|
||||
EXPECT_TRUE(ris != nullptr);
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
ris->Update();
|
||||
EXPECT_TRUE(ris->IsReady());
|
||||
|
|
|
@ -54,7 +54,7 @@ dump_input_stream(InputStreamPtr &&is)
|
|||
dump_text_file(tis);
|
||||
}
|
||||
|
||||
const std::scoped_lock<Mutex> protect(is->mutex);
|
||||
const std::scoped_lock protect{is->mutex};
|
||||
|
||||
is->Check();
|
||||
return 0;
|
||||
|
|
|
@ -149,7 +149,7 @@ dump_input_stream(InputStream &is, FileDescriptor out,
|
|||
{
|
||||
out.SetBinaryMode();
|
||||
|
||||
std::unique_lock<Mutex> lock(is.mutex);
|
||||
std::unique_lock lock{is.mutex};
|
||||
|
||||
if (seek > 0)
|
||||
is.Seek(lock, seek);
|
||||
|
@ -195,7 +195,7 @@ class DumpRemoteTagHandler final : public RemoteTagHandler {
|
|||
|
||||
public:
|
||||
Tag Wait() {
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
cond.wait(lock, [this]{ return done; });
|
||||
|
||||
if (error)
|
||||
|
@ -206,14 +206,14 @@ public:
|
|||
|
||||
/* virtual methods from RemoteTagHandler */
|
||||
void OnRemoteTag(Tag &&_tag) noexcept override {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
tag = std::move(_tag);
|
||||
done = true;
|
||||
cond.notify_all();
|
||||
}
|
||||
|
||||
void OnRemoteTagError(std::exception_ptr e) noexcept override {
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
const std::scoped_lock lock{mutex};
|
||||
error = std::move(e);
|
||||
done = true;
|
||||
cond.notify_all();
|
||||
|
|
|
@ -253,7 +253,7 @@ Cat(Storage &storage, const char *path)
|
|||
auto is = storage.OpenFile(path, mutex);
|
||||
assert(is);
|
||||
|
||||
std::unique_lock<Mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
WaitReady(*is, lock);
|
||||
Cat(*is, lock, FileDescriptor{STDOUT_FILENO});
|
||||
|
||||
|
|
Loading…
Reference in New Issue