synthio: get_buffer: return error if object deinited

this may fix a weird crash during shutdown
This commit is contained in:
Jeff Epler 2023-05-04 07:45:45 -05:00
parent 2b0231e9d3
commit e23e7d3b3f
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
2 changed files with 8 additions and 0 deletions

View File

@ -158,6 +158,10 @@ void synthio_miditrack_reset_buffer(synthio_miditrack_obj_t *self,
audioio_get_buffer_result_t synthio_miditrack_get_buffer(synthio_miditrack_obj_t *self,
bool single_channel_output, uint8_t channel, uint8_t **buffer, uint32_t *buffer_length) {
if (common_hal_synthio_miditrack_deinited(self)) {
*buffer_length = 0;
return GET_BUFFER_ERROR;
}
synthio_synth_synthesize(&self->synth, buffer, buffer_length, single_channel_output ? 0 : channel);
if (self->synth.span.dur == 0) {

View File

@ -62,6 +62,10 @@ void synthio_synthesizer_reset_buffer(synthio_synthesizer_obj_t *self,
audioio_get_buffer_result_t synthio_synthesizer_get_buffer(synthio_synthesizer_obj_t *self,
bool single_channel_output, uint8_t channel, uint8_t **buffer, uint32_t *buffer_length) {
if (common_hal_synthio_synthesizer_deinited(self)) {
*buffer_length = 0;
return GET_BUFFER_ERROR;
}
self->synth.span.dur = SYNTHIO_MAX_DUR;
synthio_synth_synthesize(&self->synth, buffer, buffer_length, single_channel_output ? channel : 0);
return GET_BUFFER_MORE_DATA;