Skip to content

Commit d89c0c7

Browse files
rm assert calls
1 parent bdb4cd2 commit d89c0c7

4 files changed

Lines changed: 16 additions & 8 deletions

File tree

hello_livekit/receiver/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@
2525
/// LIVEKIT_URL, LIVEKIT_RECEIVER_TOKEN, LIVEKIT_SENDER_IDENTITY
2626

2727
#include <atomic>
28-
#include <cassert>
2928
#include <chrono>
3029
#include <csignal>
3130
#include <cstdlib>
3231
#include <iostream>
32+
#include <stdexcept>
3333
#include <thread>
3434

3535
#include "livekit/livekit.h"
@@ -84,7 +84,9 @@ int main(int argc, char* argv[]) {
8484
}
8585

8686
auto lp = room->localParticipant().lock();
87-
assert(lp);
87+
if (!lp) {
88+
throw std::runtime_error("[receiver] local participant is null");
89+
}
8890

8991
std::cout << "[info] [receiver] Connected as identity='" << lp->identity() << "' room='" << room->roomInfo().name
9092
<< "'; subscribing to sender identity='" << sender_identity << "'\n";

hello_livekit/sender/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
/// LIVEKIT_URL, LIVEKIT_SENDER_TOKEN
2525

2626
#include <atomic>
27-
#include <cassert>
2827
#include <chrono>
2928
#include <csignal>
3029
#include <cstdlib>
3130
#include <iomanip>
3231
#include <iostream>
3332
#include <sstream>
33+
#include <stdexcept>
3434
#include <thread>
3535

3636
#include "livekit/livekit.h"
@@ -89,7 +89,9 @@ int main(int argc, char* argv[]) {
8989
std::shared_ptr<VideoSource> video_source;
9090
{
9191
auto lp = room->localParticipant().lock();
92-
assert(lp);
92+
if (!lp) {
93+
throw std::runtime_error("[sender] local participant is null");
94+
}
9395

9496
std::cout << "[info] [sender] Connected as identity='" << lp->identity() << "' room='" << room->roomInfo().name
9597
<< "' — pass this identity to HelloLivekitReceiver\n";

ping_pong/ping/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
/// identity is `ping`.
2020

2121
#include <atomic>
22-
#include <cassert>
2322
#include <csignal>
2423
#include <cstdint>
2524
#include <exception>
2625
#include <iostream>
2726
#include <memory>
2827
#include <mutex>
2928
#include <optional>
29+
#include <stdexcept>
3030
#include <string>
3131
#include <thread>
3232
#include <unordered_map>
@@ -101,7 +101,9 @@ int main(int argc, char* argv[]) {
101101
std::shared_ptr<LocalDataTrack> ping_track;
102102
{
103103
auto local_participant = room->localParticipant().lock();
104-
assert(local_participant);
104+
if (!local_participant) {
105+
throw std::runtime_error("[ping] local participant is null");
106+
}
105107

106108
std::cout << "[info] ping connected as identity='" << local_participant->identity() << "' room='"
107109
<< room->roomInfo().name << "'\n";

ping_pong/pong/main.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
/// on the "pong" data track. Use a token whose identity is `pong`.
1919

2020
#include <atomic>
21-
#include <cassert>
2221
#include <csignal>
2322
#include <cstdint>
2423
#include <exception>
2524
#include <iostream>
2625
#include <memory>
2726
#include <optional>
27+
#include <stdexcept>
2828
#include <string>
2929
#include <thread>
3030
#include <vector>
@@ -81,7 +81,9 @@ int main(int argc, char* argv[]) {
8181
{
8282
// limit the scope of the local participant
8383
auto local_participant = room->localParticipant().lock();
84-
assert(local_participant);
84+
if (!local_participant) {
85+
throw std::runtime_error("[pong] local participant is null");
86+
}
8587

8688
std::cout << "[info] pong connected as identity='" << local_participant->identity() << "' room='"
8789
<< room->roomInfo().name << "'\n";

0 commit comments

Comments
 (0)