diff --git a/cores/esp8266/core_esp8266_i2s.c b/cores/esp8266/core_esp8266_i2s.c index a154ac85d..119e8e78a 100644 --- a/cores/esp8266/core_esp8266_i2s.c +++ b/cores/esp8266/core_esp8266_i2s.c @@ -65,6 +65,10 @@ bool ICACHE_FLASH_ATTR i2s_is_empty(){ return (i2s_slc_queue_len >= SLC_BUF_CNT-1); } +int16_t ICACHE_FLASH_ATTR i2s_available(){ + return (SLC_BUF_CNT - i2s_slc_queue_len) * SLC_BUF_LEN; +} + uint32_t ICACHE_FLASH_ATTR i2s_slc_queue_next_item(){ //pop the top off the queue uint8_t i; uint32_t item = i2s_slc_queue[0]; diff --git a/cores/esp8266/i2s.h b/cores/esp8266/i2s.h index f248d590c..fd8e0ab0e 100644 --- a/cores/esp8266/i2s.h +++ b/cores/esp8266/i2s.h @@ -48,6 +48,7 @@ bool i2s_write_sample_nb(uint32_t sample);//same as above but does not block whe bool i2s_write_lr(int16_t left, int16_t right);//combines both channels and calls i2s_write_sample with the result bool i2s_is_full();//returns true if DMA is full and can not take more bytes (overflow) bool i2s_is_empty();//returns true if DMA is empty (underflow) +int16_t i2s_available();// returns the number of samples than can be written before blocking #ifdef __cplusplus }