Skip to content

Commit 3231846

Browse files
Disable interrupts on psram access
1 parent 801a10c commit 3231846

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/ESP32_VS1053_Stream.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,9 @@ void ESP32_VS1053_Stream::_playFromRingBuffer()
396396
while (_remainingBytes && _vs1053->data_request() && millis() - start < MAX_TIME_MS)
397397
{
398398
size_t size = 0;
399+
portDISABLE_INTERRUPTS();
399400
uint8_t *data = (uint8_t *)xRingbufferReceiveUpTo(_ringbuffer_handle, &size, pdMS_TO_TICKS(0), VS1053_PLAYBUFFER_SIZE);
401+
portENABLE_INTERRUPTS();
400402
if (!data)
401403
{
402404
log_i("No ringbuffer data available");
@@ -424,7 +426,9 @@ void ESP32_VS1053_Stream::_streamToRingBuffer(WiFiClient *const stream)
424426
break;
425427

426428
const int BYTES_IN_BUFFER = stream->readBytes(_localbuffer, BYTES_TO_READ);
429+
portDISABLE_INTERRUPTS();
427430
const BaseType_t result = xRingbufferSend(_ringbuffer_handle, _localbuffer, BYTES_IN_BUFFER, pdMS_TO_TICKS(0));
431+
portENABLE_INTERRUPTS();
428432
if (result == pdFALSE)
429433
{
430434
log_e("ringbuffer failed to receive %i bytes. Closing stream.");
@@ -505,7 +509,9 @@ void ESP32_VS1053_Stream::_chunkedStreamToRingBuffer(WiFiClient *const stream)
505509
break;
506510

507511
const int BYTES_IN_BUFFER = stream->readBytes(_localbuffer, BYTES_TO_READ);
512+
portDISABLE_INTERRUPTS();
508513
const BaseType_t result = xRingbufferSend(_ringbuffer_handle, _localbuffer, BYTES_IN_BUFFER, pdMS_TO_TICKS(0));
514+
portENABLE_INTERRUPTS();
509515
if (result == pdFALSE)
510516
{
511517
log_e("ringbuffer failed to receive %i bytes. Closing stream.");

0 commit comments

Comments
 (0)