Skip to content

SimpleStream improvements and logging#1123

Open
jameson-dev wants to merge 5 commits intoTrunkRecorder:masterfrom
jameson-dev:upstream/simplestream-improvements
Open

SimpleStream improvements and logging#1123
jameson-dev wants to merge 5 commits intoTrunkRecorder:masterfrom
jameson-dev:upstream/simplestream-improvements

Conversation

@jameson-dev
Copy link
Copy Markdown
Contributor

Description for changes have been added to each commit. Happy for criticism on these changes 😄

Here's a brief breakdown on the changes:

  • Move streams, my_tcp_io_service, and max_tcp_index from file-scope globals into the Simple_Stream class as private members, preventing shared state between instances

  • Fix BOOST_FOREACH loops to iterate by const reference rather than copying the struct by value on every audio packet

  • Wrap TCP send() calls in try/catch to prevent a dropped connection from crashing the entire trunk-recorder process

  • Log a warning when UDP send_to() fails silently so network errors are visible in logs

  • Replace ip::address::from_string() with Boost.Asio resolvers for both UDP and TCP connections, allowing hostnames to be used in the config in addition to literal IP addresses

Note: I haven't actually tested these changes at all not having a TR setup to test with at the moment, but I'm rather confident of the changes. I would definitely test these changes first.

File-scope globals were shared across every instance of the class. If more than one SimpleStream instance were ever loaded, they would silently share the same stream list and TCP I/O service, likely causing data corruption and race conditions.
Copying a struct with a raw pointer wont manage the socket lifetime, and two copies of the same pointer could interact badly. It also needlessly copies two std::string members and a UDP endpoint on every audio packet, which is a hot path. The const auto & form avoids all copies entirely. The start() and stop() loops already used auto& correctly, so this change just introduces consistency
Dropped TCP connections throws boots::system::system_error, which would terminate the TR process. It  should now log errors and continue. For UDP, there was no logging for errors to know when packets are dropped
from_string() only accepts literal IP addresses, entering a hostname would throw an error and crash TR with no explanation.
@Dygear
Copy link
Copy Markdown
Contributor

Dygear commented Apr 8, 2026

I really wanted someone to make udp://hostname.tld:8600 or tcp://hostname.tld:8600 possible. We got the hostname part, so that's cool. That way it's a much tighter config statement.

Adds support for a url field in the simplestream config.  Can now be defined as udp://hostname:port or tcp://hostname:port instead of
separate address, port, and useTCP fields.

Added deprecation warning log and updated documentation to reflect changes and deprecation intent
@jameson-dev
Copy link
Copy Markdown
Contributor Author

Something like this 318c58c, @Dygear?

@Dygear
Copy link
Copy Markdown
Contributor

Dygear commented Apr 10, 2026

Exactly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants