Skip to content

Commit d0e2b01

Browse files
committed
Rename last_record to last_index.
1 parent 9a0d1c2 commit d0e2b01

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

ports/raspberrypi/audio_dma.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ audio_dma_result audio_dma_setup(
411411
irq_set_mask_enabled(1 << DMA_IRQ_1, true);
412412
}
413413

414-
dma->last_record = -1;
414+
dma->input_index = -1;
415415
dma->recording_in_progress = true;
416416
dma_channel_start(dma->input_channel[0]);
417417
}
@@ -671,16 +671,16 @@ bool audio_dma_get_recording(audio_dma_t *dma) {
671671
}
672672

673673
uint8_t *audio_dma_get_buffer(audio_dma_t *dma) {
674-
if (!dma->input_register_address || dma->last_record >= 2) {
674+
if (!dma->input_register_address || dma->input_index >= 2) {
675675
return NULL;
676676
}
677-
uint8_t *buffer = dma->input_buffer[dma->last_record];
678-
dma->last_record = -1;
677+
uint8_t *buffer = dma->input_buffer[dma->input_index];
678+
dma->input_index = -1;
679679
return buffer;
680680
}
681681

682682
bool audio_dma_has_buffer(audio_dma_t *dma) {
683-
return dma->input_register_address && dma->last_record < 2;
683+
return dma->input_register_address && dma->input_index < 2;
684684
}
685685

686686
// WARN(tannewt): DO NOT print from here, or anything it calls. Printing calls
@@ -751,8 +751,8 @@ void __not_in_flash_func(isr_dma_1)(void) {
751751
dma_hw->ints1 = mask;
752752
if (MP_STATE_PORT(recording_audio)[i] != NULL) {
753753
audio_dma_t *dma = MP_STATE_PORT(recording_audio)[i];
754-
// Rotate buffer to continue recording.
755-
dma->last_record = (uint8_t)(i != dma->input_channel[0]);
754+
// Update last recorded buffer.
755+
dma->input_index = (uint8_t)(i != dma->input_channel[0]);
756756
}
757757
if (MP_STATE_PORT(background_pio)[i] != NULL) {
758758
rp2pio_statemachine_obj_t *pio = MP_STATE_PORT(background_pio)[i];

ports/raspberrypi/audio_dma.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ typedef struct {
3636
bool playing_in_progress;
3737
bool recording_in_progress;
3838
bool swap_channel;
39-
uint8_t last_record;
39+
uint8_t input_index;
4040
} audio_dma_t;
4141

4242
typedef enum {

0 commit comments

Comments
 (0)