Skip to content

Commit 724e1af

Browse files
Additional clang-tidy fixes
1 parent 8bcea38 commit 724e1af

3 files changed

Lines changed: 22 additions & 22 deletions

File tree

include/livekit/subscription_thread_dispatcher.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ class SubscriptionThreadDispatcher {
404404
/// is extracted and returned to the caller for joining outside the lock.
405405
std::thread startAudioReaderLocked(const CallbackKey &key,
406406
const std::shared_ptr<Track> &track,
407-
AudioFrameCallback cb,
407+
const AudioFrameCallback &cb,
408408
const AudioStream::Options &opts);
409409

410410
/// Start a video reader thread for \p key using \p track.
@@ -413,7 +413,7 @@ class SubscriptionThreadDispatcher {
413413
/// is extracted and returned to the caller for joining outside the lock.
414414
std::thread startVideoReaderLocked(const CallbackKey &key,
415415
const std::shared_ptr<Track> &track,
416-
VideoFrameCallback cb,
416+
const VideoFrameCallback &cb,
417417
const VideoStream::Options &opts);
418418

419419
/// Extract and close the data reader for a given callback ID, returning its
@@ -429,7 +429,7 @@ class SubscriptionThreadDispatcher {
429429
std::thread
430430
startDataReaderLocked(DataFrameCallbackId id, const DataCallbackKey &key,
431431
const std::shared_ptr<RemoteDataTrack> &track,
432-
DataFrameCallback cb);
432+
const DataFrameCallback &cb);
433433

434434
/// Protects callback registration maps and active reader state.
435435
mutable std::mutex lock_;

src/subscription_thread_dispatcher.cpp

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void SubscriptionThreadDispatcher::setOnVideoFrameCallback(
8787
std::lock_guard<std::mutex> lock(lock_);
8888
const bool replacing = video_callbacks_.find(key) != video_callbacks_.end();
8989
video_callbacks_[key] =
90-
RegisteredVideoCallback{std::move(callback), std::move(opts)};
90+
RegisteredVideoCallback{std::move(callback), opts};
9191
LK_LOG_DEBUG("Registered video frame callback for participant={} source={} "
9292
"replacing_existing={} total_video_callbacks={}",
9393
participant_identity, static_cast<int>(source), replacing,
@@ -102,7 +102,7 @@ void SubscriptionThreadDispatcher::setOnVideoFrameCallback(
102102
std::lock_guard<std::mutex> lock(lock_);
103103
const bool replacing = video_callbacks_.find(key) != video_callbacks_.end();
104104
video_callbacks_[key] =
105-
RegisteredVideoCallback{std::move(callback), std::move(opts)};
105+
RegisteredVideoCallback{std::move(callback), opts};
106106
LK_LOG_DEBUG(
107107
"Registered video frame callback for participant={} track_name={} "
108108
"replacing_existing={} total_video_callbacks={}",
@@ -212,11 +212,10 @@ void SubscriptionThreadDispatcher::handleTrackSubscribed(
212212
std::thread old_thread;
213213
{
214214
std::lock_guard<std::mutex> lock(lock_);
215-
if (track->kind() == TrackKind::KIND_AUDIO &&
216-
audio_callbacks_.find(key) == audio_callbacks_.end()) {
217-
key = fallback_key;
218-
} else if (track->kind() == TrackKind::KIND_VIDEO &&
219-
video_callbacks_.find(key) == video_callbacks_.end()) {
215+
if ((track->kind() == TrackKind::KIND_AUDIO &&
216+
audio_callbacks_.find(key) == audio_callbacks_.end()) ||
217+
(track->kind() == TrackKind::KIND_VIDEO &&
218+
video_callbacks_.find(key) == video_callbacks_.end())) {
220219
key = fallback_key;
221220
}
222221
old_thread = startReaderLocked(key, track);
@@ -475,7 +474,7 @@ std::thread SubscriptionThreadDispatcher::startReaderLocked(
475474

476475
std::thread SubscriptionThreadDispatcher::startAudioReaderLocked(
477476
const CallbackKey &key, const std::shared_ptr<Track> &track,
478-
AudioFrameCallback cb, const AudioStream::Options &opts) {
477+
const AudioFrameCallback &cb, const AudioStream::Options &opts) {
479478
LK_LOG_DEBUG("Starting audio reader for participant={} source={}",
480479
key.participant_identity, static_cast<int>(key.source));
481480
auto old_thread = extractReaderThreadLocked(key);
@@ -498,15 +497,15 @@ std::thread SubscriptionThreadDispatcher::startAudioReaderLocked(
498497

499498
ActiveReader reader;
500499
reader.audio_stream = stream;
501-
auto stream_copy = stream;
502500
const std::string participant_identity = key.participant_identity;
503501
const TrackSource source = key.source;
502+
// NOLINTBEGIN(bugprone-lambda-function-name)
504503
reader.thread =
505-
std::thread([stream_copy, cb, participant_identity, source]() {
504+
std::thread([stream, cb, participant_identity, source]() {
506505
LK_LOG_DEBUG("Audio reader thread started for participant={} source={}",
507506
participant_identity, static_cast<int>(source));
508507
AudioFrameEvent ev;
509-
while (stream_copy->read(ev)) {
508+
while (stream->read(ev)) {
510509
try {
511510
cb(ev.frame);
512511
} catch (const std::exception &e) {
@@ -516,6 +515,7 @@ std::thread SubscriptionThreadDispatcher::startAudioReaderLocked(
516515
LK_LOG_DEBUG("Audio reader thread exiting for participant={} source={}",
517516
participant_identity, static_cast<int>(source));
518517
});
518+
// NOLINTEND(bugprone-lambda-function-name)
519519
active_readers_[key] = std::move(reader);
520520
LK_LOG_DEBUG("Started audio reader for participant={} source={} "
521521
"active_readers={}",
@@ -526,7 +526,7 @@ std::thread SubscriptionThreadDispatcher::startAudioReaderLocked(
526526

527527
std::thread SubscriptionThreadDispatcher::startVideoReaderLocked(
528528
const CallbackKey &key, const std::shared_ptr<Track> &track,
529-
VideoFrameCallback cb, const VideoStream::Options &opts) {
529+
const VideoFrameCallback &cb, const VideoStream::Options &opts) {
530530
LK_LOG_DEBUG("Starting video reader for participant={} source={}",
531531
key.participant_identity, static_cast<int>(key.source));
532532
auto old_thread = extractReaderThreadLocked(key);
@@ -549,15 +549,15 @@ std::thread SubscriptionThreadDispatcher::startVideoReaderLocked(
549549

550550
ActiveReader reader;
551551
reader.video_stream = stream;
552-
auto stream_copy = stream;
553552
const std::string participant_identity = key.participant_identity;
554553
const TrackSource source = key.source;
554+
// NOLINTBEGIN(bugprone-lambda-function-name)
555555
reader.thread =
556-
std::thread([stream_copy, cb, participant_identity, source]() {
556+
std::thread([stream, cb, participant_identity, source]() {
557557
LK_LOG_DEBUG("Video reader thread started for participant={} source={}",
558558
participant_identity, static_cast<int>(source));
559559
VideoFrameEvent ev;
560-
while (stream_copy->read(ev)) {
560+
while (stream->read(ev)) {
561561
try {
562562
cb(ev.frame, ev.timestamp_us);
563563
} catch (const std::exception &e) {
@@ -567,6 +567,7 @@ std::thread SubscriptionThreadDispatcher::startVideoReaderLocked(
567567
LK_LOG_DEBUG("Video reader thread exiting for participant={} source={}",
568568
participant_identity, static_cast<int>(source));
569569
});
570+
// NOLINTEND(bugprone-lambda-function-name)
570571
active_readers_[key] = std::move(reader);
571572
LK_LOG_DEBUG("Started video reader for participant={} source={} "
572573
"active_readers={}",
@@ -620,7 +621,7 @@ std::thread SubscriptionThreadDispatcher::extractDataReaderThreadLocked(
620621

621622
std::thread SubscriptionThreadDispatcher::startDataReaderLocked(
622623
DataFrameCallbackId id, const DataCallbackKey &key,
623-
const std::shared_ptr<RemoteDataTrack> &track, DataFrameCallback cb) {
624+
const std::shared_ptr<RemoteDataTrack> &track, const DataFrameCallback &cb) {
624625
auto old_thread = extractDataReaderThreadLocked(id);
625626

626627
int total_active = static_cast<int>(active_readers_.size()) +
@@ -639,6 +640,7 @@ std::thread SubscriptionThreadDispatcher::startDataReaderLocked(
639640
reader->remote_track = track;
640641
auto identity = key.participant_identity;
641642
auto track_name = key.track_name;
643+
// NOLINTBEGIN(bugprone-lambda-function-name)
642644
reader->thread = std::thread([reader, track, cb, identity, track_name]() {
643645
LK_LOG_INFO("Data reader thread: subscribing to \"{}\" track=\"{}\"",
644646
identity, track_name);
@@ -673,6 +675,7 @@ std::thread SubscriptionThreadDispatcher::startDataReaderLocked(
673675
LK_LOG_INFO("Data reader thread exiting for \"{}\" track=\"{}\"", identity,
674676
track_name);
675677
});
678+
// NOLINTEND(bugprone-lambda-function-name)
676679
active_data_readers_[id] = reader;
677680
return old_thread;
678681
}

src/track_proto_converter.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ TrackKind fromProto(proto::TrackKind in) {
5656
case proto::TrackKind::KIND_VIDEO:
5757
return TrackKind::KIND_VIDEO;
5858
case proto::TrackKind::KIND_UNKNOWN:
59-
return TrackKind::KIND_UNKNOWN;
6059
default:
6160
return TrackKind::KIND_UNKNOWN;
6261
}
@@ -69,7 +68,6 @@ StreamState fromProto(proto::StreamState in) {
6968
case proto::StreamState::STATE_PAUSED:
7069
return StreamState::STATE_PAUSED;
7170
case proto::StreamState::STATE_UNKNOWN:
72-
return StreamState::STATE_UNKNOWN;
7371
default:
7472
return StreamState::STATE_UNKNOWN;
7573
}
@@ -86,7 +84,6 @@ TrackSource fromProto(proto::TrackSource in) {
8684
case proto::TrackSource::SOURCE_SCREENSHARE_AUDIO:
8785
return TrackSource::SOURCE_SCREENSHARE_AUDIO;
8886
case proto::TrackSource::SOURCE_UNKNOWN:
89-
return TrackSource::SOURCE_UNKNOWN;
9087
default:
9188
return TrackSource::SOURCE_UNKNOWN;
9289
}

0 commit comments

Comments
 (0)