Skip to content

Commit d98af9a

Browse files
committed
fix some warnings
1 parent 4d24091 commit d98af9a

File tree

2 files changed

+14
-26
lines changed

2 files changed

+14
-26
lines changed

src/Audio.cpp

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
audio.cpp
44
55
Created on: Oct 28.2018 */char audioI2SVers[] ="\
6-
Version 3.4.2h ";
7-
/* Updated on: Sep 05.2025
6+
Version 3.4.2i ";
7+
/* Updated on: Sep 07.2025
88
99
Author: Wolle (schreibfaul1)
1010
Audio library for ESP32, ESP32-S3 or ESP32-P4
@@ -136,7 +136,7 @@ void AudioBuffer::bytesWritten(size_t bw) {
136136
if(!bw) return;
137137
m_writePtr += bw;
138138
if(m_writePtr == m_endPtr) { m_writePtr = m_buffer.get(); }
139-
if(m_writePtr > m_endPtr) log_e("AudioBuffer: m_writePtr %i > m_endPtr %i", m_writePtr, m_endPtr);
139+
if(m_writePtr > m_endPtr) log_e("AudioBuffer: m_writePtr %p > m_endPtr %p", m_writePtr, m_endPtr);
140140
m_f_isEmpty = false;
141141
}
142142

@@ -183,13 +183,16 @@ Audio::Audio(uint8_t i2sPort) {
183183
m_i2s_num = i2sPort; // i2s port number
184184

185185
// -------- I2S configuration -------------------------------------------------------------------------------------------
186+
memset(&m_i2s_chan_cfg, 0, sizeof(i2s_chan_config_t));
186187
m_i2s_chan_cfg.id = (i2s_port_t)m_i2s_num; // I2S_NUM_AUTO, I2S_NUM_0, I2S_NUM_1
187188
m_i2s_chan_cfg.role = I2S_ROLE_MASTER; // I2S controller master role, bclk and lrc signal will be set to output
188189
m_i2s_chan_cfg.dma_desc_num = 16; // number of DMA buffer
189190
m_i2s_chan_cfg.dma_frame_num = 512; // I2S frame number in one DMA buffer.
190191
m_i2s_chan_cfg.auto_clear = true; // i2s will always send zero automatically if no data to send
192+
m_i2s_chan_cfg.allow_pd = false;
191193
i2s_new_channel(&m_i2s_chan_cfg, &m_i2s_tx_handle, NULL);
192194

195+
memset(&m_i2s_std_cfg, 0, sizeof(i2s_std_config_t));
193196
m_i2s_std_cfg.slot_cfg = I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_STEREO); // Set to enable bit shift in Philips mode
194197
m_i2s_std_cfg.gpio_cfg.bclk = I2S_GPIO_UNUSED; // BCLK, Assignment in setPinout()
195198
m_i2s_std_cfg.gpio_cfg.din = I2S_GPIO_UNUSED; // not used
@@ -2274,7 +2277,7 @@ int Audio::read_M4A_Header(uint8_t* data, size_t len) {
22742277
atom_name.copy_from((const char*)data + 4, 4);
22752278

22762279
if(atom_name.equals("ftyp")){
2277-
AUDIO_LOG_DEBUG("atom %s @ %i, size: %i, ends @ %i", atom_name.c_get(), m_m4aHdr.headerSize, atom_size.to_uint32(16), m_m4aHdr.headerSize + atom_size.to_uint32(16));
2280+
AUDIO_LOG_DEBUG("atom %s @ %zu, size: %u, ends @ %zu", atom_name.c_get(), m_m4aHdr.headerSize, (uint32_t)atom_size.to_uint32(16), m_m4aHdr.headerSize + (size_t)atom_size.to_uint32(16));
22782281
m_m4aHdr.sizeof_ftyp = atom_size.to_uint32(16);
22792282
m_controlCounter = M4A_FTYP;
22802283
}
@@ -2631,7 +2634,7 @@ int Audio::read_M4A_Header(uint8_t* data, size_t len) {
26312634
// esds_buffer.hex_dump(m_m4aHdr.sizeof_esds);
26322635

26332636
// search for decoderConfigDescriptor (tag 0x04)
2634-
int32_t dec_config_descriptor_offset = esds_buffer.special_index_of("\x04\x80\x80\x80", 4, m_m4aHdr.sizeof_esds);
2637+
int32_t dec_config_descriptor_offset = esds_buffer.special_index_of("\x04\x80\x80\x80", 4, (uint32_t) m_m4aHdr.sizeof_esds);
26352638
if(dec_config_descriptor_offset > 0){ //decoderConfigDescriptor found
26362639
uint8_t dec_config_descriptor_length = ((uint8_t*)esds_buffer.get())[dec_config_descriptor_offset + 4]; // Length after Tag + 3 Extended Length Bytes
26372640
m_m4aHdr.objectTypeIndicator = ((uint8_t*)esds_buffer.get())[dec_config_descriptor_offset + 5]; // 0x40 (AAC)
@@ -3741,7 +3744,7 @@ void Audio::processLocalFile() {
37413744
else {stopSong(); return;}
37423745
m_lastGranulePosition = getLastGranulePosition();
37433746
m_controlCounter = 100;
3744-
log_w("%lu, lastGranulePosition %llu", __LINE__, m_lastGranulePosition);
3747+
log_w("%i, lastGranulePosition %llu", __LINE__, m_lastGranulePosition);
37453748
return;
37463749
}
37473750
if(m_controlCounter != 100) {
@@ -3913,7 +3916,7 @@ void Audio::processWebFile() {
39133916
else {stopSong(); return;}
39143917
m_lastGranulePosition = getLastGranulePosition(); // to calculate the duration
39153918
m_controlCounter = 100;
3916-
log_w("%lu, lastGranulePosition %llu", __LINE__, m_lastGranulePosition);
3919+
log_w("%i, lastGranulePosition %llu", __LINE__, m_lastGranulePosition);
39173920
return;
39183921
}
39193922
if(m_controlCounter != 100) {
@@ -5231,7 +5234,7 @@ int Audio::sendBytes(uint8_t* data, size_t len) {
52315234
if(res < 0){ return decodeError(res, data, bytesDecoded);} // Error, skip the frame...
52325235
if(res > 99){ return decodeContinue(res, data, bytesDecoded);} // decoder needs more data...
52335236

5234-
if(bytesDecoded == 0 && !m_codec == CODEC_VORBIS) { // unlikely framesize, exept VORBIS decodes lastSegmentTable
5237+
if((bytesDecoded == 0) && (m_codec != CODEC_VORBIS)) { // unlikely framesize, exept VORBIS decodes lastSegmentTable
52355238
info(evt_info, "framesize is 0, start decoding again");
52365239
m_f_playing = false; // seek for new syncword
52375240
// we're here because there was a wrong sync word so skip one byte and seek for the next
@@ -6514,7 +6517,6 @@ bool Audio::readID3V1Tag() {
65146517
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
65156518
int32_t Audio::newInBuffStart(int32_t m_resumeFilePos){
65166519
int32_t offset = 0, buffFillValue = 0, res = 0;
6517-
uint32_t timeOut = 0;
65186520

65196521
if(m_controlCounter != 100){AUDIO_LOG_WARN("timeOffset not possible"); m_resumeFilePos = -1; offset = -1; goto exit;}
65206522
if(m_resumeFilePos >= (int32_t)m_audioDataStart + m_audioDataSize) { m_resumeFilePos = -1; offset = -1; goto exit;}
@@ -6538,17 +6540,7 @@ int32_t Audio::newInBuffStart(int32_t m_resumeFilePos){
65386540
res = audioFileSeek(m_resumeFilePos);
65396541
InBuff.resetBuffer();
65406542
offset = 0;
6541-
timeOut = millis();
65426543
audioFileRead(InBuff.getReadPtr() + offset, buffFillValue);
6543-
// while (remaining > 0) {
6544-
// int bytesRead = audioFileRead(InBuff.getReadPtr() + offset, remaining);
6545-
// if (bytesRead <= 0) {
6546-
// if(millis() > timeOut + 2000){AUDIO_LOG_ERROR("timeout, not enough data from host"); buffFillSize = offset; break;}
6547-
// continue; // ggf. Sleep oder Timeout prüfen, um Endlosschleife zu vermeiden
6548-
// }
6549-
// remaining -= bytesRead;
6550-
// offset += bytesRead;
6551-
// }
65526544
InBuff.bytesWritten(buffFillValue);
65536545

65546546
/* process after */

src/psram_unique_ptr.hpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -921,8 +921,6 @@ size_t copy_from_utf16(const uint8_t* src, bool is_big_endian = false) {
921921
// ps_ptr<char> haystack; // Contains data, e.g., stsd atom content
922922
// int32_t idx = haystack.index_of("mp4a", 1024); // Search for "mp4a"
923923
// int32_t idx2 = haystack.index_of("\x00\x01\xFF", 3, 1024); // Search for byte sequence
924-
template <typename U = T>
925-
requires std::is_same_v<U, char>
926924
int32_t special_index_of(const char* needle, uint32_t needle_length, uint32_t max_length) const {
927925
static_assert(std::is_same_v<T, char>, "index_of is only valid for ps_ptr<char>");
928926
if (!mem || !get()) {
@@ -944,7 +942,7 @@ size_t copy_from_utf16(const uint8_t* src, bool is_big_endian = false) {
944942
return static_cast<int32_t>(i);
945943
}
946944
}
947-
log_d("index_of: Needle not found within %u bytes", max_length);
945+
log_d("index_of: Needle not found within %lu bytes", max_length);
948946
return -1;
949947
}
950948

@@ -1484,8 +1482,6 @@ void unicodeToUTF8(const char* src) {
14841482
// Usage:
14851483
// ps_ptr<char> size = "227213779"; uint32_t val = size.to_uint32(10); // Returns 227213779
14861484
// ps_ptr<char> addr = "0x1A3B"; uint32_t val = addr.to_uint32(16); // Returns 6715
1487-
template <typename U = T>
1488-
requires std::is_same_v<U, char>
14891485
uint32_t to_uint32(int base = 10) const {
14901486
static_assert(std::is_same_v<T, char>, "to_uint32 is only valid for ps_ptr<char>");
14911487
if (!mem || !get()) {
@@ -1496,11 +1492,11 @@ void unicodeToUTF8(const char* src) {
14961492
char* end = nullptr;
14971493
unsigned long result = std::strtoul(str, &end, base);
14981494
if (end == str) {
1499-
log_e("to_uint32: Invalid numeric value in '%s' for base %d", str, base);
1495+
log_e("to_uint32: Invalid numeric value in '%s' for base %i", str, base);
15001496
return 0;
15011497
}
15021498
if (result > UINT32_MAX) {
1503-
log_e("to_uint32: Value in '%s' exceeds UINT32_MAX (%u) for base %d", str, UINT32_MAX, base);
1499+
log_e("to_uint32: Value in '%s' exceeds UINT32_MAX (%u) for base %i", str, UINT32_MAX, base);
15041500
return 0;
15051501
}
15061502
return static_cast<uint32_t>(result);

0 commit comments

Comments
 (0)