Skip to content

Commit 08cdf15

Browse files
aguavivadevyte
authored andcommitted
added int16_t i2s_available(); it returns the number of samples than can be (#3988)
written before blocking
1 parent 26980b3 commit 08cdf15

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

cores/esp8266/core_esp8266_i2s.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ bool ICACHE_FLASH_ATTR i2s_is_empty(){
6565
return (i2s_slc_queue_len >= SLC_BUF_CNT-1);
6666
}
6767

68+
int16_t ICACHE_FLASH_ATTR i2s_available(){
69+
return (SLC_BUF_CNT - i2s_slc_queue_len) * SLC_BUF_LEN;
70+
}
71+
6872
uint32_t ICACHE_FLASH_ATTR i2s_slc_queue_next_item(){ //pop the top off the queue
6973
uint8_t i;
7074
uint32_t item = i2s_slc_queue[0];

cores/esp8266/i2s.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ bool i2s_write_sample_nb(uint32_t sample);//same as above but does not block whe
4848
bool i2s_write_lr(int16_t left, int16_t right);//combines both channels and calls i2s_write_sample with the result
4949
bool i2s_is_full();//returns true if DMA is full and can not take more bytes (overflow)
5050
bool i2s_is_empty();//returns true if DMA is empty (underflow)
51+
int16_t i2s_available();// returns the number of samples than can be written before blocking
5152

5253
#ifdef __cplusplus
5354
}

0 commit comments

Comments
 (0)