OPUS_GET_BITRATE always returns default value for opus_multistream_encoder
When I call the OPUS_GET_BITRATE control on a multistream encoder, it always returns the default value, e.g. 144000 for 2 channels at 48 kHz
int32_t bitrate = 64000; // could also be OPUS_BITRATE_MAX
opus_multistream_encoder_ctl(state, OPUS_SET_BITRATE(bitrate));
// always returns the default...
opus_multistream_encoder_ctl(state, OPUS_GET_BITRATE(&bitrate));
other controls like OPUS_GET_COMPLEXITY or OPUS_GET_SIGNAL work as expected.
Here's the reason:
opus_multistream_encoder has a dedicated field bitrate_bps and OPUS_SET_BITRATE sets it as expected. OPUS_GET_BITRATE, however, internally calls opus_encoder_ctl on the sub-states, which gets the value of user_bitrate_bps. Since the latter is initialized to OPUS_AUTO and never overriden, it would always return the value of the default bitrate.
Not sure what's the best approach to fix this...
I can reproduce this, so it's not just you. The function itself appears correct, but somehow the allocation isn't being propagated to all the channels.
It looks like there's no test converage of the multistream encoder api, so not surprising it's broken.
Thanks for the report. I'll try to investigate over the coming week if no one beats me to it.
Oh, I didn't notice your edit. Thanks for investigating further. That sounds about right.
Step one, write some tests!