thread/Mutex: remove ScopeLock, use std::lock_guard directly
This commit is contained in:
@@ -92,7 +92,7 @@ RoarOutput::RoarOutput(const ConfigBlock &block)
|
||||
inline int
|
||||
RoarOutput::GetVolume() const
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
if (vss == nullptr || !alive)
|
||||
return -1;
|
||||
@@ -116,7 +116,7 @@ RoarOutput::SetVolume(unsigned volume)
|
||||
{
|
||||
assert(volume <= 100);
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
if (vss == nullptr || !alive)
|
||||
throw std::runtime_error("closed");
|
||||
|
||||
@@ -177,7 +177,7 @@ roar_use_audio_format(struct roar_audio_info *info,
|
||||
inline void
|
||||
RoarOutput::Open(AudioFormat &audio_format)
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
if (roar_simple_connect(&con,
|
||||
host.empty() ? nullptr : host.c_str(),
|
||||
@@ -201,7 +201,7 @@ RoarOutput::Open(AudioFormat &audio_format)
|
||||
inline void
|
||||
RoarOutput::Close()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
alive = false;
|
||||
|
||||
@@ -214,7 +214,7 @@ RoarOutput::Close()
|
||||
inline void
|
||||
RoarOutput::Cancel()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
if (vss == nullptr)
|
||||
return;
|
||||
@@ -306,7 +306,7 @@ RoarOutput::SendTag(const Tag &tag)
|
||||
if (vss == nullptr)
|
||||
return;
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
size_t cnt = 0;
|
||||
struct roar_keyval vals[32];
|
||||
|
||||
@@ -56,7 +56,7 @@ HttpdClient::Close()
|
||||
void
|
||||
HttpdClient::LockClose()
|
||||
{
|
||||
const ScopeLock protect(httpd.mutex);
|
||||
const std::lock_guard<Mutex> protect(httpd.mutex);
|
||||
Close();
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ HttpdClient::GetBytesTillMetaData() const
|
||||
inline bool
|
||||
HttpdClient::TryWrite()
|
||||
{
|
||||
const ScopeLock protect(httpd.mutex);
|
||||
const std::lock_guard<Mutex> protect(httpd.mutex);
|
||||
|
||||
assert(state == RESPONSE);
|
||||
|
||||
|
||||
@@ -200,7 +200,7 @@ public:
|
||||
*/
|
||||
gcc_pure
|
||||
bool LockHasClients() const {
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
return HasClients();
|
||||
}
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ HttpdOutput::RunDeferred()
|
||||
/* this method runs in the IOThread; it broadcasts pages from
|
||||
our own queue to all clients */
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
while (!pages.empty()) {
|
||||
Page *page = pages.front();
|
||||
@@ -200,7 +200,7 @@ HttpdOutput::OnAccept(int fd, SocketAddress address, gcc_unused int uid)
|
||||
(void)address;
|
||||
#endif /* HAVE_WRAP */
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
if (fd >= 0) {
|
||||
/* can we allow additional client */
|
||||
@@ -296,7 +296,7 @@ httpd_output_open(AudioOutput *ao, AudioFormat &audio_format)
|
||||
{
|
||||
HttpdOutput *httpd = HttpdOutput::Cast(ao);
|
||||
|
||||
const ScopeLock protect(httpd->mutex);
|
||||
const std::lock_guard<Mutex> protect(httpd->mutex);
|
||||
httpd->Open(audio_format);
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ httpd_output_close(AudioOutput *ao)
|
||||
{
|
||||
HttpdOutput *httpd = HttpdOutput::Cast(ao);
|
||||
|
||||
const ScopeLock protect(httpd->mutex);
|
||||
const std::lock_guard<Mutex> protect(httpd->mutex);
|
||||
httpd->Close();
|
||||
}
|
||||
|
||||
@@ -496,7 +496,7 @@ HttpdOutput::SendTag(const Tag &tag)
|
||||
|
||||
metadata = icy_server_metadata_page(tag, &types[0]);
|
||||
if (metadata != nullptr) {
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
for (auto &client : clients)
|
||||
client.PushMetaData(metadata);
|
||||
}
|
||||
@@ -514,7 +514,7 @@ httpd_output_tag(AudioOutput *ao, const Tag &tag)
|
||||
inline void
|
||||
HttpdOutput::CancelAllClients()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
while (!pages.empty()) {
|
||||
Page *page = pages.front();
|
||||
|
||||
@@ -319,7 +319,7 @@ SlesOutput::Play(const void *chunk, size_t size)
|
||||
pause = false;
|
||||
}
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
assert(filled < BUFFER_SIZE);
|
||||
|
||||
@@ -348,7 +348,7 @@ SlesOutput::Play(const void *chunk, size_t size)
|
||||
inline void
|
||||
SlesOutput::Drain()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
|
||||
assert(filled < BUFFER_SIZE);
|
||||
|
||||
@@ -371,7 +371,7 @@ SlesOutput::Cancel()
|
||||
FormatWarning(sles_domain,
|
||||
"AndroidSimpleBufferQueue.Clear() failed");
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
n_queued = 0;
|
||||
filled = 0;
|
||||
}
|
||||
@@ -398,7 +398,7 @@ SlesOutput::Pause()
|
||||
inline void
|
||||
SlesOutput::PlayedCallback()
|
||||
{
|
||||
const ScopeLock protect(mutex);
|
||||
const std::lock_guard<Mutex> protect(mutex);
|
||||
assert(n_queued > 0);
|
||||
--n_queued;
|
||||
cond.signal();
|
||||
|
||||
Reference in New Issue
Block a user