Merge remote-tracking branches 'neheb/1', 'neheb/2', 'neheb/3', 'neheb/4' and 'neheb/5'
This commit is contained in:
@@ -79,7 +79,7 @@ AudioOutputControl::Steal() noexcept
|
||||
StopThread();
|
||||
|
||||
/* now we can finally remove it */
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
return std::exchange(output, nullptr);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ AudioOutputControl::ReplaceDummy(std::unique_ptr<FilteredAudioOutput> new_output
|
||||
assert(new_output);
|
||||
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
output = std::move(new_output);
|
||||
enabled = _enabled;
|
||||
}
|
||||
@@ -146,7 +146,7 @@ AudioOutputControl::SetAttribute(std::string &&attribute_name,
|
||||
bool
|
||||
AudioOutputControl::LockSetEnabled(bool new_value) noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
|
||||
if (new_value == enabled)
|
||||
return false;
|
||||
@@ -158,7 +158,7 @@ AudioOutputControl::LockSetEnabled(bool new_value) noexcept
|
||||
bool
|
||||
AudioOutputControl::LockToggleEnabled() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
return enabled = !enabled;
|
||||
}
|
||||
|
||||
@@ -342,14 +342,14 @@ AudioOutputControl::IsChunkConsumed(const MusicChunk &chunk) const noexcept
|
||||
bool
|
||||
AudioOutputControl::LockIsChunkConsumed(const MusicChunk &chunk) const noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
return IsChunkConsumed(chunk);
|
||||
}
|
||||
|
||||
void
|
||||
AudioOutputControl::LockPlay() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
|
||||
assert(allow_play);
|
||||
|
||||
@@ -371,7 +371,7 @@ AudioOutputControl::LockPauseAsync() noexcept
|
||||
if (output)
|
||||
output->Interrupt();
|
||||
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
|
||||
assert(allow_play);
|
||||
if (IsOpen())
|
||||
@@ -381,7 +381,7 @@ AudioOutputControl::LockPauseAsync() noexcept
|
||||
void
|
||||
AudioOutputControl::LockDrainAsync() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
|
||||
assert(allow_play);
|
||||
if (IsOpen())
|
||||
@@ -394,7 +394,7 @@ AudioOutputControl::LockCancelAsync() noexcept
|
||||
if (output)
|
||||
output->Interrupt();
|
||||
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
|
||||
if (IsOpen()) {
|
||||
allow_play = false;
|
||||
@@ -405,7 +405,7 @@ AudioOutputControl::LockCancelAsync() noexcept
|
||||
void
|
||||
AudioOutputControl::LockAllowPlay() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
|
||||
allow_play = true;
|
||||
if (IsOpen())
|
||||
@@ -457,7 +457,7 @@ AudioOutputControl::BeginDestroy() noexcept
|
||||
if (output)
|
||||
output->Interrupt();
|
||||
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
if (!killed) {
|
||||
killed = true;
|
||||
CommandAsync(Command::KILL);
|
||||
|
@@ -405,7 +405,7 @@ public:
|
||||
void EnableDisableAsync();
|
||||
|
||||
void LockEnableDisableAsync() {
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
EnableDisableAsync();
|
||||
}
|
||||
|
||||
@@ -480,7 +480,7 @@ public:
|
||||
* Locking wrapper for ClearTailChunk().
|
||||
*/
|
||||
void LockClearTailChunk(const MusicChunk &chunk) noexcept {
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
ClearTailChunk(chunk);
|
||||
}
|
||||
|
||||
|
@@ -229,7 +229,7 @@ MultipleOutputs::Open(const AudioFormat audio_format)
|
||||
std::exception_ptr first_error;
|
||||
|
||||
for (const auto &ao : outputs) {
|
||||
const std::lock_guard<Mutex> lock(ao->mutex);
|
||||
const std::scoped_lock<Mutex> lock(ao->mutex);
|
||||
|
||||
if (ao->IsEnabled())
|
||||
enabled = true;
|
||||
|
@@ -41,7 +41,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::lock_guard<Mutex> lock(ao.mutex);
|
||||
const std::scoped_lock<Mutex> lock(ao.mutex);
|
||||
|
||||
os.Format(AUDIO_DEVICE_STATE "%d:%s\n",
|
||||
ao.IsEnabled(), ao.GetName());
|
||||
|
@@ -311,13 +311,13 @@ private:
|
||||
|
||||
gcc_pure
|
||||
bool LockIsActive() const noexcept {
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
return active;
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
bool LockIsActiveAndNotWaiting() const noexcept {
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
return active && !waiting;
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ private:
|
||||
void LockCaughtError() noexcept {
|
||||
period_buffer.Clear();
|
||||
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
error = std::current_exception();
|
||||
active = false;
|
||||
waiting = false;
|
||||
@@ -398,7 +398,7 @@ private:
|
||||
*/
|
||||
void OnSilenceTimer() noexcept {
|
||||
{
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
assert(active);
|
||||
waiting = false;
|
||||
}
|
||||
@@ -464,7 +464,7 @@ AlsaOutput::AlsaOutput(EventLoop &_loop, const ConfigBlock &block)
|
||||
std::map<std::string, std::string>
|
||||
AlsaOutput::GetAttributes() const noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> lock(attributes_mutex);
|
||||
const std::scoped_lock<Mutex> lock(attributes_mutex);
|
||||
|
||||
return {
|
||||
{"allowed_formats", Alsa::ToString(allowed_formats)},
|
||||
@@ -478,11 +478,11 @@ void
|
||||
AlsaOutput::SetAttribute(std::string &&name, std::string &&value)
|
||||
{
|
||||
if (name == "allowed_formats") {
|
||||
const std::lock_guard<Mutex> lock(attributes_mutex);
|
||||
const std::scoped_lock<Mutex> lock(attributes_mutex);
|
||||
allowed_formats = Alsa::AllowedFormat::ParseList(value);
|
||||
#ifdef ENABLE_DSD
|
||||
} else if (name == "dop") {
|
||||
const std::lock_guard<Mutex> lock(attributes_mutex);
|
||||
const std::scoped_lock<Mutex> lock(attributes_mutex);
|
||||
if (value == "0")
|
||||
dop_setting = false;
|
||||
else if (value == "1")
|
||||
@@ -790,7 +790,7 @@ AlsaOutput::Open(AudioFormat &audio_format)
|
||||
#endif
|
||||
|
||||
{
|
||||
const std::lock_guard<Mutex> lock(attributes_mutex);
|
||||
const std::scoped_lock<Mutex> lock(attributes_mutex);
|
||||
#ifdef ENABLE_DSD
|
||||
dop = dop_setting;
|
||||
#endif
|
||||
@@ -966,7 +966,7 @@ AlsaOutput::CopyRingToPeriodBuffer() noexcept
|
||||
|
||||
period_buffer.AppendBytes(nbytes);
|
||||
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
/* notify the OutputThread that there is now
|
||||
room in ring_buffer */
|
||||
cond.notify_one();
|
||||
@@ -1276,7 +1276,7 @@ try {
|
||||
}
|
||||
|
||||
{
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
|
||||
assert(active);
|
||||
|
||||
@@ -1316,7 +1316,7 @@ try {
|
||||
smaller than the ALSA-PCM buffer */
|
||||
|
||||
{
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
waiting = true;
|
||||
cond.notify_one();
|
||||
}
|
||||
|
@@ -121,7 +121,7 @@ private:
|
||||
void Disconnect() noexcept;
|
||||
|
||||
void Shutdown(const char *reason) noexcept {
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
error = std::make_exception_ptr(FormatRuntimeError("JACK connection shutdown: %s",
|
||||
reason));
|
||||
}
|
||||
@@ -185,7 +185,7 @@ public:
|
||||
|
||||
private:
|
||||
bool LockWasShutdown() const noexcept {
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
return !!error;
|
||||
}
|
||||
};
|
||||
@@ -700,7 +700,7 @@ JackOutput::Play(const void *chunk, size_t size)
|
||||
|
||||
while (true) {
|
||||
{
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
if (error)
|
||||
std::rethrow_exception(error);
|
||||
|
||||
@@ -730,7 +730,7 @@ inline bool
|
||||
JackOutput::Pause()
|
||||
{
|
||||
{
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
interrupted = false;
|
||||
if (error)
|
||||
std::rethrow_exception(error);
|
||||
|
@@ -153,7 +153,7 @@ class PipeWireOutput final : AudioOutput {
|
||||
public:
|
||||
static AudioOutput *Create(EventLoop &,
|
||||
const ConfigBlock &block) {
|
||||
pw_init(0, nullptr);
|
||||
pw_init(nullptr, nullptr);
|
||||
|
||||
return new PipeWireOutput(block);
|
||||
}
|
||||
@@ -250,7 +250,7 @@ private:
|
||||
uint32_t id,
|
||||
const struct spa_pod *param) noexcept
|
||||
{
|
||||
if (id != SPA_PARAM_Format || param == NULL)
|
||||
if (id != SPA_PARAM_Format || param == nullptr)
|
||||
return;
|
||||
|
||||
auto &o = *(PipeWireOutput *)data;
|
||||
@@ -273,7 +273,7 @@ private:
|
||||
pw_thread_loop_signal(thread_loop, false);
|
||||
}
|
||||
|
||||
std::chrono::steady_clock::duration Delay() const noexcept override;
|
||||
[[nodiscard]] std::chrono::steady_clock::duration Delay() const noexcept override;
|
||||
size_t Play(const void *chunk, size_t size) override;
|
||||
|
||||
void Drain() override;
|
||||
|
@@ -47,7 +47,7 @@ HttpdClient::Close() noexcept
|
||||
void
|
||||
HttpdClient::LockClose() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(httpd.mutex);
|
||||
const std::scoped_lock<Mutex> protect(httpd.mutex);
|
||||
Close();
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ HttpdClient::GetBytesTillMetaData() const noexcept
|
||||
inline bool
|
||||
HttpdClient::TryWrite() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(httpd.mutex);
|
||||
const std::scoped_lock<Mutex> protect(httpd.mutex);
|
||||
|
||||
assert(state == State::RESPONSE);
|
||||
|
||||
|
@@ -202,7 +202,7 @@ public:
|
||||
*/
|
||||
gcc_pure
|
||||
bool LockHasClients() const noexcept {
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
return HasClients();
|
||||
}
|
||||
|
||||
|
@@ -104,7 +104,7 @@ HttpdOutput::OnDeferredBroadcast() noexcept
|
||||
/* this method runs in the IOThread; it broadcasts pages from
|
||||
our own queue to all clients */
|
||||
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
|
||||
while (!pages.empty()) {
|
||||
PagePtr page = std::move(pages.front());
|
||||
@@ -126,7 +126,7 @@ HttpdOutput::OnAccept(UniqueSocketDescriptor fd,
|
||||
/* the listener socket has become readable - a client has
|
||||
connected */
|
||||
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
|
||||
/* can we allow additional client */
|
||||
if (open && (clients_max == 0 || clients.size() < clients_max))
|
||||
@@ -186,7 +186,7 @@ HttpdOutput::Open(AudioFormat &audio_format)
|
||||
assert(!open);
|
||||
assert(clients.empty());
|
||||
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
|
||||
OpenEncoder(audio_format);
|
||||
|
||||
@@ -208,7 +208,7 @@ HttpdOutput::Close() noexcept
|
||||
BlockingCall(GetEventLoop(), [this](){
|
||||
defer_broadcast.Cancel();
|
||||
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
open = false;
|
||||
clients.clear_and_dispose(DeleteDisposer());
|
||||
});
|
||||
@@ -261,7 +261,7 @@ HttpdOutput::BroadcastPage(PagePtr page) noexcept
|
||||
assert(page != nullptr);
|
||||
|
||||
{
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
pages.emplace(std::move(page));
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ HttpdOutput::BroadcastFromEncoder()
|
||||
|
||||
PagePtr page;
|
||||
while ((page = ReadPage()) != nullptr) {
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
const std::scoped_lock<Mutex> lock(mutex);
|
||||
pages.emplace(std::move(page));
|
||||
empty = false;
|
||||
}
|
||||
@@ -373,7 +373,7 @@ HttpdOutput::SendTag(const Tag &tag)
|
||||
|
||||
metadata = icy_server_metadata_page(tag, &types[0]);
|
||||
if (metadata != nullptr) {
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
for (auto &client : clients)
|
||||
client.PushMetaData(metadata);
|
||||
}
|
||||
@@ -383,7 +383,7 @@ HttpdOutput::SendTag(const Tag &tag)
|
||||
inline void
|
||||
HttpdOutput::CancelAllClients() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
|
||||
while (!pages.empty()) {
|
||||
PagePtr page = std::move(pages.front());
|
||||
|
@@ -398,7 +398,7 @@ SlesOutput::Cancel() noexcept
|
||||
LogWarning(sles_domain,
|
||||
"AndroidSimpleBufferQueue.Clear() failed");
|
||||
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
n_queued = 0;
|
||||
filled = 0;
|
||||
}
|
||||
@@ -423,7 +423,7 @@ SlesOutput::Pause()
|
||||
inline void
|
||||
SlesOutput::PlayedCallback()
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
assert(n_queued > 0);
|
||||
--n_queued;
|
||||
cond.notify_one();
|
||||
|
@@ -53,7 +53,7 @@ SnapcastClient::Close() noexcept
|
||||
void
|
||||
SnapcastClient::LockClose() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(output.mutex);
|
||||
const std::scoped_lock<Mutex> protect(output.mutex);
|
||||
Close();
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ SnapcastClient::Push(SnapcastChunkPtr chunk) noexcept
|
||||
SnapcastChunkPtr
|
||||
SnapcastClient::LockPopQueue() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(output.mutex);
|
||||
const std::scoped_lock<Mutex> protect(output.mutex);
|
||||
if (chunks.empty())
|
||||
return nullptr;
|
||||
|
||||
|
@@ -134,7 +134,7 @@ public:
|
||||
*/
|
||||
[[gnu::pure]]
|
||||
bool LockHasClients() const noexcept {
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
return HasClients();
|
||||
}
|
||||
|
||||
|
@@ -114,7 +114,7 @@ SnapcastOutput::OnAccept(UniqueSocketDescriptor fd,
|
||||
/* the listener socket has become readable - a client has
|
||||
connected */
|
||||
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
|
||||
/* can we allow additional client */
|
||||
if (open)
|
||||
@@ -152,7 +152,7 @@ SnapcastOutput::Open(AudioFormat &audio_format)
|
||||
assert(!open);
|
||||
assert(clients.empty());
|
||||
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
|
||||
OpenEncoder(audio_format);
|
||||
|
||||
@@ -174,7 +174,7 @@ SnapcastOutput::Close() noexcept
|
||||
BlockingCall(GetEventLoop(), [this](){
|
||||
inject_event.Cancel();
|
||||
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
open = false;
|
||||
clients.clear_and_dispose(DeleteDisposer{});
|
||||
});
|
||||
@@ -188,7 +188,7 @@ SnapcastOutput::Close() noexcept
|
||||
void
|
||||
SnapcastOutput::OnInject() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
|
||||
while (!chunks.empty()) {
|
||||
const auto chunk = std::move(chunks.front());
|
||||
@@ -296,7 +296,7 @@ SnapcastOutput::SendTag(const Tag &tag)
|
||||
|
||||
const ConstBuffer payload(json.data(), json.size());
|
||||
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
// TODO: enqueue StreamTags, don't send directly
|
||||
for (auto &client : clients)
|
||||
client.SendStreamTags(payload.ToVoid());
|
||||
@@ -344,7 +344,7 @@ SnapcastOutput::Play(const void *chunk, size_t size)
|
||||
|
||||
unflushed_input = 0;
|
||||
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
if (chunks.empty())
|
||||
inject_event.Schedule();
|
||||
|
||||
@@ -382,7 +382,7 @@ SnapcastOutput::Drain()
|
||||
void
|
||||
SnapcastOutput::Cancel() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
const std::scoped_lock<Mutex> protect(mutex);
|
||||
|
||||
ClearQueue(chunks);
|
||||
|
||||
|
Reference in New Issue
Block a user