Skip to content

Commit a78d9ad

Browse files
committed
codal_port/modaudio: Remove used_size entry from AudioFrame type.
It's no longer needed now that there is AudioTrack. Signed-off-by: Damien George <[email protected]>
1 parent b75ef0e commit a78d9ad

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

src/codal_port/modaudio.c

+2-9
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void microbit_audio_stop(void) {
7373
static void audio_data_pull_from_source(void) {
7474
if (audio_source_frame != NULL) {
7575
// An existing AudioFrame is being played, see if there's any data left.
76-
if (audio_source_frame_offset >= audio_source_frame->used_size) {
76+
if (audio_source_frame_offset >= audio_source_frame->alloc_size) {
7777
// AudioFrame is exhausted.
7878
audio_source_frame = NULL;
7979
}
@@ -154,7 +154,7 @@ static void audio_data_fetcher(mp_sched_node_t *node) {
154154
size_t size;
155155
if (audio_source_frame != NULL) {
156156
src = &audio_source_frame->data[audio_source_frame_offset];
157-
size = audio_source_frame->used_size;
157+
size = audio_source_frame->alloc_size;
158158
} else {
159159
src = &audio_source_track->data[audio_source_frame_offset];
160160
size = audio_source_track->size;
@@ -405,7 +405,6 @@ static mp_obj_t audio_frame_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t
405405
mp_raise_ValueError(MP_ERROR_TEXT("value out of range"));
406406
}
407407
self->data[index] = value;
408-
self->used_size = MAX(self->used_size, index + 1);
409408
return mp_const_none;
410409
}
411410
}
@@ -426,10 +425,6 @@ static mp_int_t audio_frame_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufin
426425
bufinfo->buf = self->data;
427426
bufinfo->len = self->alloc_size;
428427
bufinfo->typecode = 'B';
429-
if (flags == MP_BUFFER_WRITE) {
430-
// Assume that writing to the buffer will make all data valid for playback.
431-
self->used_size = self->alloc_size;
432-
}
433428
return 0;
434429
}
435430

@@ -448,7 +443,6 @@ static void add_into(microbit_audio_frame_obj_t *self, microbit_audio_frame_obj_
448443

449444
static microbit_audio_frame_obj_t *copy(microbit_audio_frame_obj_t *self) {
450445
microbit_audio_frame_obj_t *result = microbit_audio_frame_make_new(self->alloc_size, self->rate);
451-
result->used_size = self->used_size;
452446
for (int i = 0; i < self->alloc_size; i++) {
453447
result->data[i] = self->data[i];
454448
}
@@ -578,7 +572,6 @@ microbit_audio_frame_obj_t *microbit_audio_frame_make_new(size_t size, uint32_t
578572
microbit_audio_frame_obj_t *res = m_new_obj_var(microbit_audio_frame_obj_t, data, uint8_t, size);
579573
res->base.type = &microbit_audio_frame_type;
580574
res->alloc_size = size;
581-
res->used_size = 0;
582575
res->rate = rate;
583576
memset(res->data, 128, size);
584577
return res;

src/codal_port/modaudio.h

-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
typedef struct _microbit_audio_frame_obj_t {
3636
mp_obj_base_t base;
3737
size_t alloc_size;
38-
size_t used_size;
3938
uint32_t rate;
4039
uint8_t data[];
4140
} microbit_audio_frame_obj_t;

0 commit comments

Comments
 (0)