Skip to content

Commit 8c1b1d3

Browse files
committed
control_socket: Make reported audio ch count configurable
And raise the default to 16. Refers to GH-366
1 parent 9622095 commit 8c1b1d3

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/control_socket.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ struct control_state {
106106
queue<string> stat_event_queue;
107107

108108
bool stats_on;
109+
int audio_channel_report_count = 16;
109110
};
110111

111112
#define CONTROL_EXIT -1
@@ -152,6 +153,9 @@ static void new_message(struct module *m) {
152153
}
153154
}
154155

156+
ADD_TO_PARAM("control-report-audio-ch-count", "* control-report-audio-ch-count=<count>\n"
157+
" The number of channels reported over control port.\n");
158+
155159
int control_init(int port, int connection_type, struct control_state **state, struct module *root_module, int force_ip_version)
156160
{
157161
control_state *s = new control_state();
@@ -274,6 +278,10 @@ int control_init(int port, int connection_type, struct control_state **state, st
274278

275279
module_register(&s->mod, root_module);
276280

281+
if (const char *val = get_commandline_param("control-report-audio-ch-count")) {
282+
s->audio_channel_report_count = strtoll(val, NULL, 0);
283+
}
284+
277285
*state = s;
278286
return 0;
279287

@@ -1010,6 +1018,10 @@ bool control_stats_enabled(struct control_state *s)
10101018
return s && s->stats_on;
10111019
}
10121020

1021+
int control_audio_ch_report_count(struct control_state *state){
1022+
return state ? state->audio_channel_report_count : 0;
1023+
}
1024+
10131025
static void print_control_help() {
10141026
color_printf("Control internal commands:\n"
10151027
TBOLD("\texit") "\n"

src/control_socket.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ void control_done(struct control_state *s);
5656
void control_report_stats(struct control_state *state, const std::string & stat_line);
5757
void control_report_event(struct control_state *state, const std::string & event_line);
5858
bool control_stats_enabled(struct control_state *state);
59+
int control_audio_ch_report_count(struct control_state *state);
5960

6061

6162
#endif // control_socket_h_

src/rtp/audio_decoders.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,8 @@ int decode_audio_frame(struct coded_data *cdata, void *pbuf_data, struct pbuf_st
850850

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

0 commit comments

Comments
 (0)