-
Notifications
You must be signed in to change notification settings - Fork 15
Connection: Add stop signals for connection failures and reconnections #36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||
|
|
||||||
| #include "moq-output.h" | ||||||
| #include "util/util_uint64.h" | ||||||
| #include "util/threading.h" | ||||||
|
|
||||||
| extern "C" { | ||||||
| #include "moq.h" | ||||||
|
|
@@ -15,7 +16,8 @@ MoQOutput::MoQOutput(obs_data_t *, obs_output_t *output) | |||||
| connect_time_ms(0), | ||||||
| origin(moq_origin_create()), | ||||||
| session(0), | ||||||
| broadcast(moq_publish_create()) | ||||||
| broadcast(moq_publish_create()), | ||||||
| reconnecting(false) | ||||||
| { | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -81,8 +83,19 @@ bool MoQOutput::Start() | |||||
| self->connect_time_ms = static_cast<int>(std::chrono::duration_cast<std::chrono::milliseconds>(elapsed).count()); | ||||||
| LOG_INFO("MoQ session established (%d ms): %s", self->connect_time_ms, | ||||||
| self->server_url.c_str()); | ||||||
|
|
||||||
| if (self->reconnecting) | ||||||
| os_atomic_set_bool(&self->reconnecting, false); | ||||||
| } else if (error_code == -2) { | ||||||
| //on swrver disconnection. Signal to attempt to reconnect | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix typo in comment. "swrver" should be "server". 📝 Proposed fix- //on swrver disconnection. Signal to attempt to reconnect
+ //on server disconnection. Signal to attempt to reconnect📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| LOG_INFO("MoQ session disconnected (%d): %s", error_code, self->server_url.c_str()); | ||||||
| obs_output_signal_stop(self->output, OBS_OUTPUT_DISCONNECTED); | ||||||
| os_atomic_set_bool(&self->reconnecting, true); | ||||||
| } else { | ||||||
| LOG_INFO("MoQ session closed (%d): %s", error_code, self->server_url.c_str()); | ||||||
| // signal connection failure and stop the broadcast | ||||||
| obs_output_signal_stop(self->output, OBS_OUTPUT_CONNECT_FAILED); | ||||||
| os_atomic_set_bool(&self->reconnecting, false); | ||||||
| } | ||||||
| }; | ||||||
|
|
||||||
|
|
@@ -133,6 +146,8 @@ void MoQOutput::Stop(bool signal) | |||||
| obs_output_signal_stop(output, OBS_OUTPUT_SUCCESS); | ||||||
| } | ||||||
|
|
||||||
| os_atomic_set_bool(&reconnecting, false); | ||||||
|
|
||||||
| return; | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -46,6 +46,8 @@ class MoQOutput | |||||
| int broadcast; | ||||||
| std::map<obs_encoder_t *, int> video_tracks; | ||||||
| std::map<obs_encoder_t *, int> audio_tracks; | ||||||
|
|
||||||
| volatile bool reconnecting; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Description: Check OBS threading utility signatures for atomic bool operations
# Search for os_atomic_set_bool and os_atomic_load_bool declarations
rg -n -A2 -B2 'os_atomic_(set|load)_bool' --type=c --type=cppRepository: moq-dev/obs Length of output: 1220 🏁 Script executed: # Find where os_atomic_set_bool is declared/defined
rg -n 'os_atomic_set_bool|define.*os_atomic_set_bool' --type=c --type=h --type=hppRepository: moq-dev/obs Length of output: 83 🏁 Script executed: # Also search in common OBS headers or utility files for atomic macros/functions
fd -e h -e hpp | xargs rg -l 'atomic' | head -20Repository: moq-dev/obs Length of output: 37 🏁 Script executed: # Check the actual declaration in moq-output.h around line 50
cat -n src/moq-output.h | sed -n '45,55p'Repository: moq-dev/obs Length of output: 317 🏁 Script executed: # Search for os_atomic_set_bool definition across header and source files (.h, .c)
rg -n 'os_atomic_set_bool' --type=c --type=h -B3 -A3Repository: moq-dev/obs Length of output: 37 🏁 Script executed: # Look for the definition in typical OBS locations or macros
rg -n 'define.*atomic|#define.*set_bool' --type=c --type=hRepository: moq-dev/obs Length of output: 37 🏁 Script executed: # Check what headers are included in moq-output.h to understand where os_atomic comes from
head -30 src/moq-output.hRepository: moq-dev/obs Length of output: 591 🏁 Script executed: # Search for all os_atomic usages in the codebase to see the pattern
rg -n 'os_atomic' --type=c --type=hRepository: moq-dev/obs Length of output: 37 🏁 Script executed: # Look for other volatile declarations in the codebase
rg -n 'volatile' --type=c --type=hRepository: moq-dev/obs Length of output: 107 🏁 Script executed: # Check for any compilation or type-related issues - look at build configuration
find . -name "CMakeLists.txt" -o -name "Makefile" -o -name "build.sh" | head -5Repository: moq-dev/obs Length of output: 72 🏁 Script executed: # Check CMakeLists.txt to understand build configuration and dependencies
head -50 ./CMakeLists.txtRepository: moq-dev/obs Length of output: 1646 🏁 Script executed: # Look at actual usage context in moq-output.cpp around the os_atomic_set_bool calls
sed -n '85,100p' src/moq-output.cppRepository: moq-dev/obs Length of output: 740 🏁 Script executed: # Check if there are any warnings or issues related to type mismatches
# Look for any casting or type conversions around reconnecting variable
rg -n 'reconnecting' --type=c --type=h -B1 -A1Repository: moq-dev/obs Length of output: 151 Remove The Proposed fix- volatile bool reconnecting;
+ bool reconnecting;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| }; | ||||||
|
|
||||||
| void register_moq_output(); | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent atomic access to
reconnecting.Line 87 reads
self->reconnectingnon-atomically (direct access), but line 88 writes it atomically usingos_atomic_set_bool. For proper thread safety, both read and write operations should use atomic functions. Useos_atomic_load_bool(&self->reconnecting)for the read.🔒 Proposed fix for consistent atomic access
🤖 Prompt for AI Agents