X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=shared%2Fhttpd.cpp;h=5442e7f123f7533b9740fc244241acd9123b1703;hb=43be1e6d8d769da60b694aa09c58e589bdbc39af;hp=782d18b7e2f7b2924bbf4e23365494dcfe423be0;hpb=0c95058b25adce6f634279bc7feb04158242e63e;p=nageru diff --git a/shared/httpd.cpp b/shared/httpd.cpp index 782d18b..5442e7f 100644 --- a/shared/httpd.cpp +++ b/shared/httpd.cpp @@ -61,7 +61,7 @@ void HTTPD::stop() void HTTPD::add_data(StreamType stream_type, const char *buf, size_t size, bool keyframe, int64_t time, AVRational timebase) { - unique_lock lock(streams_mutex); + lock_guard lock(streams_mutex); for (Stream *stream : streams) { if (stream->get_stream_type() == stream_type) { stream->add_data(buf, size, keyframe ? Stream::DATA_TYPE_KEYFRAME : Stream::DATA_TYPE_OTHER, time, timebase); @@ -133,7 +133,7 @@ int HTTPD::answer_to_connection(MHD_Connection *connection, HTTPD::Stream *stream = new HTTPD::Stream(this, framing, stream_type); stream->add_data(header[stream_type].data(), header[stream_type].size(), Stream::DATA_TYPE_HEADER, AV_NOPTS_VALUE, AVRational{ 1, 0 }); { - unique_lock lock(streams_mutex); + lock_guard lock(streams_mutex); streams.insert(stream); } ++metric_num_connected_clients; @@ -164,7 +164,7 @@ void HTTPD::free_stream(void *cls) --httpd->metric_num_connected_multicam_clients; } { - unique_lock lock(httpd->streams_mutex); + lock_guard lock(httpd->streams_mutex); delete stream; httpd->streams.erase(stream); } @@ -223,7 +223,7 @@ void HTTPD::Stream::add_data(const char *buf, size_t buf_size, HTTPD::Stream::Da return; } - unique_lock lock(buffer_mutex); + lock_guard lock(buffer_mutex); if (framing == FRAMING_METACUBE) { int flags = 0; @@ -284,7 +284,7 @@ void HTTPD::Stream::add_data(const char *buf, size_t buf_size, HTTPD::Stream::Da void HTTPD::Stream::stop() { - unique_lock lock(buffer_mutex); + lock_guard lock(buffer_mutex); should_quit = true; has_buffered_data.notify_all(); }