@@ -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
476475std::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
527527std::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
621622std::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}
0 commit comments