Skip to content

Commit e9d6d6b

Browse files
committed
acap/fluidsynth: refuse unsupported ch_count/bps
1 parent 3a60095 commit e9d6d6b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/audio/capture/fluidsynth.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,16 @@ audio_cap_fluidsynth_init(struct module *parent, const char *cfg)
241241
return NULL;
242242
}
243243

244+
/// @todo add other if some-one needs that...
245+
if (audio_capture_bps != 0 && audio_capture_bps != FLUIDSYNTH_BPS) {
246+
MSG(ERROR, "Only %d bits-per-second supported so far...\n", FLUIDSYNTH_BPS);
247+
goto error;
248+
}
249+
if (audio_capture_channels > 2) {
250+
MSG(ERROR, "Only 1 or 2 channels currently supported...\n");
251+
goto error;
252+
}
253+
244254
s->audio.bps = FLUIDSYNTH_BPS;
245255
s->audio.ch_count = audio_capture_channels < 2 ? 1 : 2;
246256
s->audio.sample_rate = audio_capture_sample_rate > 0
@@ -303,7 +313,7 @@ audio_cap_fluidsynth_read(void *state)
303313
if (s->audio.ch_count == 1) {
304314
fluid_synth_write_s16(s->synth, CHUNK_SIZE, s->audio.data, 0, 1,
305315
s->right, 0, 1);
306-
} else {
316+
} else { // drop right channel, keep the left
307317
assert(s->audio.ch_count == 2);
308318
fluid_synth_write_s16(s->synth, CHUNK_SIZE, s->left, 0, 1,
309319
s->right, 0, 1);

0 commit comments

Comments
 (0)