Skip to content

Commit

Permalink
Merge pull request #1347 from elafargue/macos-udp-fix
Browse files Browse the repository at this point in the history
Fix UDP streaming on MacOS, it was broken due to large UDP packets being truncated
  • Loading branch information
argilo authored Apr 18, 2024
2 parents 1ed619f + 27771fa commit 702ef6b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ The following people and organisations have contributed to gqrx:
* Dominic Chen
* Doron Behar
* Doug Hammond
* Edouard Lafargue
* Elias Önal
* Federico Fuga
* Frank Brickle, AB2KT
Expand Down
1 change: 1 addition & 0 deletions resources/news.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
NEW: Airspy support in Windows binary release.
IMPROVED: Updated GNU Radio, SDR driver, and Qt versions in AppImage release.
FIXED: Respond correctly to pipelined remote control commands.
FIXED: Limit UDP packet size to 1024, for compatibility with netcat.
REMOVED: FreeSRP support in AppImage release.


Expand Down
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
else()
add_subdirectory(osxaudio)
endif()
add_definitions(-DGQRX_OS_MACX)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux|FreeBSD")
if(${LINUX_AUDIO_BACKEND} MATCHES "Pulseaudio")
add_subdirectory(pulseaudio)
Expand Down
16 changes: 8 additions & 8 deletions src/interfaces/udp_sink_f.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ static const int MAX_IN = 2; /*!< Maximum number of input streams. */
static const int MIN_OUT = 0; /*!< Minimum number of output streams. */
static const int MAX_OUT = 0; /*!< Maximum number of output streams. */

// nc is used widely for receiving UDP streams and some versions of nc,
// notably on MacOS, use a 1024 byte buffer so we need to make sure we
// don't send packets that are larger than that, otherwise data will be
// lost.
static const int PAYLOAD_SIZE = 1024;

udp_sink_f::udp_sink_f()
: gr::hier_block2("udp_sink_f",
gr::io_signature::make(MIN_IN, MAX_IN, sizeof(float)),
Expand All @@ -59,13 +65,7 @@ udp_sink_f::udp_sink_f()

d_f2s = gr::blocks::float_to_short::make(1, 32767);
#if GNURADIO_VERSION < 0x031000
#ifdef GQRX_OS_MACX
// There seems to be excessive packet loss (even to localhost) on OS X
// unless the buffer size is limited.
d_sink = gr::blocks::udp_sink::make(sizeof(short), "localhost", 7355, 512);
#else
d_sink = gr::blocks::udp_sink::make(sizeof(short), "localhost", 7355);
#endif
d_sink = gr::blocks::udp_sink::make(sizeof(short), "localhost", 7355, PAYLOAD_SIZE);
d_sink->disconnect();
#endif

Expand Down Expand Up @@ -96,7 +96,7 @@ void udp_sink_f::start_streaming(const std::string host, int port, bool stereo)
std::cout << (stereo ? "Stereo" : "Mono") << std::endl;

#if GNURADIO_VERSION >= 0x031000
d_sink = gr::network::udp_sink::make(sizeof(short), 1, host, port, HEADERTYPE_NONE, 1448, true);
d_sink = gr::network::udp_sink::make(sizeof(short), 1, host, port, HEADERTYPE_NONE, PAYLOAD_SIZE, true);
#endif

if (stereo)
Expand Down

0 comments on commit 702ef6b

Please sign in to comment.