Merge pull request #4335 from tyomitch/main

[nrf] No need to store `buffer_length` as part of `audiopwmio_pwmaudioout_obj_t`
This commit is contained in:
Jeff Epler 2021-03-05 15:54:10 -06:00 committed by GitHub
commit d2056a46ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View File

@ -259,10 +259,10 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t* self,
if (max_buffer_length > UINT16_MAX) { if (max_buffer_length > UINT16_MAX) {
mp_raise_ValueError_varg(translate("Buffer length %d too big. It must be less than %d"), max_buffer_length, UINT16_MAX); mp_raise_ValueError_varg(translate("Buffer length %d too big. It must be less than %d"), max_buffer_length, UINT16_MAX);
} }
self->buffer_length = (uint16_t)max_buffer_length; uint16_t buffer_length = (uint16_t)max_buffer_length;
self->buffers[0] = m_malloc(self->buffer_length * 2 * sizeof(uint16_t), false); self->buffers[0] = m_malloc(buffer_length * 2 * sizeof(uint16_t), false);
if (!self->single_buffer) if (!self->single_buffer)
self->buffers[1] = m_malloc(self->buffer_length * 2 * sizeof(uint16_t), false); self->buffers[1] = m_malloc(buffer_length * 2 * sizeof(uint16_t), false);
uint32_t top; uint32_t top;

View File

@ -35,7 +35,6 @@ typedef struct {
NRF_PWM_Type *pwm; NRF_PWM_Type *pwm;
uint16_t *buffers[2]; uint16_t *buffers[2];
uint16_t buffer_length;
uint16_t quiescent_value; uint16_t quiescent_value;
uint16_t scale; uint16_t scale;