Skip to content

Commit

Permalink
control_socket: Make reported audio ch count configurable
Browse files Browse the repository at this point in the history
And raise the default to 16. Refers to GH-366
  • Loading branch information
mpiatka committed Jan 22, 2024
1 parent 9622095 commit 8c1b1d3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/control_socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ struct control_state {
queue<string> stat_event_queue;

bool stats_on;
int audio_channel_report_count = 16;
};

#define CONTROL_EXIT -1
Expand Down Expand Up @@ -152,6 +153,9 @@ static void new_message(struct module *m) {
}
}

ADD_TO_PARAM("control-report-audio-ch-count", "* control-report-audio-ch-count=<count>\n"
" The number of channels reported over control port.\n");

int control_init(int port, int connection_type, struct control_state **state, struct module *root_module, int force_ip_version)
{
control_state *s = new control_state();
Expand Down Expand Up @@ -274,6 +278,10 @@ int control_init(int port, int connection_type, struct control_state **state, st

module_register(&s->mod, root_module);

if (const char *val = get_commandline_param("control-report-audio-ch-count")) {
s->audio_channel_report_count = strtoll(val, NULL, 0);
}

*state = s;
return 0;

Expand Down Expand Up @@ -1010,6 +1018,10 @@ bool control_stats_enabled(struct control_state *s)
return s && s->stats_on;
}

int control_audio_ch_report_count(struct control_state *state){
return state ? state->audio_channel_report_count : 0;
}

static void print_control_help() {
color_printf("Control internal commands:\n"
TBOLD("\texit") "\n"
Expand Down
1 change: 1 addition & 0 deletions src/control_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ void control_done(struct control_state *s);
void control_report_stats(struct control_state *state, const std::string & stat_line);
void control_report_event(struct control_state *state, const std::string & event_line);
bool control_stats_enabled(struct control_state *state);
int control_audio_ch_report_count(struct control_state *state);


#endif // control_socket_h_
Expand Down
3 changes: 2 additions & 1 deletion src/rtp/audio_decoders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,8 @@ int decode_audio_frame(struct coded_data *cdata, void *pbuf_data, struct pbuf_st

if (control_stats_enabled(decoder->control)) {
std::string report = "ARECV";
for(int i = 0; i < decompressed.get_channel_count() && i <= 8; i++){
int num_ch = std::min(decompressed.get_channel_count(), control_audio_ch_report_count(decoder->control));
for(int i = 0; i < num_ch; i++){
double rms, peak;
rms = calculate_rms(&decompressed, i, &peak);
double rms_dbfs0 = 20 * log(rms) / log(10);
Expand Down

0 comments on commit 8c1b1d3

Please sign in to comment.