Skip to content

Commit

Permalink
Defer reading of output socket source address until status is sent
Browse files Browse the repository at this point in the history
  • Loading branch information
ka9q committed May 7, 2024
1 parent 1c1334d commit 3e26ec8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 0 additions & 8 deletions radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,6 @@ struct channel *create_chan(uint32_t ssrc){
}
chan->lifetime = 20 * 1000 / Blocktime; // If freq == 0, goes away 20 sec after last command

// Get the local socket for the output stream
// Going connectionless with Output_fd broke this. The source port is filled in, but the source address is all zeroes because
// it depends on the specific output address, which is only known from a routing table lookup. Oh well.
{
socklen_t len = sizeof(chan->output.source_socket);
getsockname(Output_fd,(struct sockaddr *)&chan->output.source_socket,&len);
}

pthread_mutex_unlock(&Channel_list_mutex);
return chan;
}
Expand Down
8 changes: 8 additions & 0 deletions radio_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,14 @@ static int encode_radio_status(struct frontend const *frontend,struct channel co
encode_float(&bp,DEMOD_SNR,power2dB(chan->sig.snr)); // abs ratio -> dB

// Source address we're using to send data
// Get the local socket for the output stream
// Going connectionless with Output_fd broke this. The source port is filled in, but the source address is all zeroes because
// it depends on the specific output address, which is only known from a routing table lookup. Oh well.
// Also this doesn't return anything until the socket is first transmitted on
{
socklen_t len = sizeof(chan->output.source_socket);
getsockname(Output_fd,(struct sockaddr *)&chan->output.source_socket,&len);
}
encode_socket(&bp,OUTPUT_DATA_SOURCE_SOCKET,&chan->output.source_socket);
// Where we're sending PCM output
encode_socket(&bp,OUTPUT_DATA_DEST_SOCKET,&chan->output.dest_socket);
Expand Down

0 comments on commit 3e26ec8

Please sign in to comment.