summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Epler <jeff@adafruit.com>2021-03-05 15:54:10 -0600
committerGitHub <noreply@github.com>2021-03-05 15:54:10 -0600
commitd2056a46eebe1a4aff6bc7ca925f6f806a6ce2a2 (patch)
tree758c401c8fea726051c1a9d9d3f0e56024ed741a
parentbed96a98d2bda5ced647c0ad12fd5e10d1c7ea91 (diff)
parente0b96c0f433b31ad91b785086f1c9625970c9643 (diff)
Merge pull request #4335 from tyomitch/main
[nrf] No need to store `buffer_length` as part of `audiopwmio_pwmaudioout_obj_t`
-rw-r--r--ports/nrf/common-hal/audiopwmio/PWMAudioOut.c6
-rw-r--r--ports/nrf/common-hal/audiopwmio/PWMAudioOut.h1
2 files changed, 3 insertions, 4 deletions
diff --git a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
index ed1bf81e4..802f2bdc2 100644
--- a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
+++ b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c
@@ -259,10 +259,10 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t* self,
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);
}
- self->buffer_length = (uint16_t)max_buffer_length;
- self->buffers[0] = m_malloc(self->buffer_length * 2 * sizeof(uint16_t), false);
+ uint16_t buffer_length = (uint16_t)max_buffer_length;
+ self->buffers[0] = m_malloc(buffer_length * 2 * sizeof(uint16_t), false);
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;
diff --git a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.h b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.h
index fdd6289a4..be147bb9b 100644
--- a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.h
+++ b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.h
@@ -35,7 +35,6 @@ typedef struct {
NRF_PWM_Type *pwm;
uint16_t *buffers[2];
- uint16_t buffer_length;
uint16_t quiescent_value;
uint16_t scale;