@@ -73,7 +73,7 @@ void microbit_audio_stop(void) {
73
73
static void audio_data_pull_from_source (void ) {
74
74
if (audio_source_frame != NULL ) {
75
75
// 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 ) {
77
77
// AudioFrame is exhausted.
78
78
audio_source_frame = NULL ;
79
79
}
@@ -154,7 +154,7 @@ static void audio_data_fetcher(mp_sched_node_t *node) {
154
154
size_t size ;
155
155
if (audio_source_frame != NULL ) {
156
156
src = & audio_source_frame -> data [audio_source_frame_offset ];
157
- size = audio_source_frame -> used_size ;
157
+ size = audio_source_frame -> alloc_size ;
158
158
} else {
159
159
src = & audio_source_track -> data [audio_source_frame_offset ];
160
160
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
405
405
mp_raise_ValueError (MP_ERROR_TEXT ("value out of range" ));
406
406
}
407
407
self -> data [index ] = value ;
408
- self -> used_size = MAX (self -> used_size , index + 1 );
409
408
return mp_const_none ;
410
409
}
411
410
}
@@ -426,10 +425,6 @@ static mp_int_t audio_frame_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufin
426
425
bufinfo -> buf = self -> data ;
427
426
bufinfo -> len = self -> alloc_size ;
428
427
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
- }
433
428
return 0 ;
434
429
}
435
430
@@ -448,7 +443,6 @@ static void add_into(microbit_audio_frame_obj_t *self, microbit_audio_frame_obj_
448
443
449
444
static microbit_audio_frame_obj_t * copy (microbit_audio_frame_obj_t * self ) {
450
445
microbit_audio_frame_obj_t * result = microbit_audio_frame_make_new (self -> alloc_size , self -> rate );
451
- result -> used_size = self -> used_size ;
452
446
for (int i = 0 ; i < self -> alloc_size ; i ++ ) {
453
447
result -> data [i ] = self -> data [i ];
454
448
}
@@ -578,7 +572,6 @@ microbit_audio_frame_obj_t *microbit_audio_frame_make_new(size_t size, uint32_t
578
572
microbit_audio_frame_obj_t * res = m_new_obj_var (microbit_audio_frame_obj_t , data , uint8_t , size );
579
573
res -> base .type = & microbit_audio_frame_type ;
580
574
res -> alloc_size = size ;
581
- res -> used_size = 0 ;
582
575
res -> rate = rate ;
583
576
memset (res -> data , 128 , size );
584
577
return res ;
0 commit comments