8000 Fix 'i2s_write_bytes' was not declared in this scope on ESP32 (#428) · murarduino/ESP8266Audio@6882b6e · GitHub
[go: up one dir, main page]

Skip to content

Commit 6882b6e

Browse files
authored
Fix 'i2s_write_bytes' was not declared in this scope on ESP32 (earlephilhower#428)
1 parent 6ed2604 commit 6882b6e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/AudioOutputI2S.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,12 @@ bool AudioOutputI2S::ConsumeSample(int16_t sample[2])
269269
{
270270
s32 = ((Amplify(ms[RIGHTCHANNEL])) << 16) | (Amplify(ms[LEFTCHANNEL]) & 0xffff);
271271
}
272-
return i2s_write_bytes((i2s_port_t)portNo, (const char *)&s32, sizeof(uint32_t), 0);
272+
//"i2s_write_bytes" has been removed in the ESP32 Arduino 2.0.0, use "i2s_write" instead.
273+
// return i2s_write_bytes((i2s_port_t)portNo, (const char *)&s32, sizeof(uint32_t), 0);
274+
275+
size_t i2s_bytes_written;
276+
i2s_write((i2s_port_t)portNo, (const char*)&s32, sizeof(uint32_t), &i2s_bytes_written, 0);
277+
return i2s_bytes_written;
273278
#elif defined(ESP8266)
274279
uint32_t s32 = ((Amplify(ms[RIGHTCHANNEL])) << 16) | (Amplify(ms[LEFTCHANNEL]) & 0xffff);
275280
return i2s_write_sample_nb(s32); // If we can't store it, return false. OTW true

src/AudioOutputI2SNoDAC.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,14 @@ bool AudioOutputI2SNoDAC::ConsumeSample(int16_t sample[2])
9595

9696
// Either send complete pulse stream or nothing
9797
#ifdef ESP32
98< 7AD3 /code>-
if (!i2s_write_bytes((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), 0))
98+
//"i2s_write_bytes" has been removed in the ESP32 Arduino 2.0.0, use "i2s_write" instead.
99+
// if (!i2s_write_bytes((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), 0))
100+
101+
size_t i2s_bytes_written;
102+
i2s_write((i2s_port_t)portNo, (const char *)dsBuff, sizeof(uint32_t) * (oversample/32), &i2s_bytes_written, 0);
103+
if (!i2s_bytes_written){
99104
return false;
105+
}
100106
#elif defined(ESP8266)
101107
if (!i2s_write_sample_nb(dsBuff[0])) return false; // No room at the inn
102108
// At this point we've sent in first of possibly 8 32-bits, need to send

0 commit comments

Comments
 (0)
0