Skip to content

Commit db803be

Browse files
committed
avoid some warnings in P4
1 parent 10b3ed1 commit db803be

File tree

8 files changed

+246
-198
lines changed

8 files changed

+246
-198
lines changed

src/Audio.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
Created on: Oct 28.2018 */
66
char audioI2SVers[] = "\
7-
Version 3.4.3a ";
7+
Version 3.4.3b ";
88
/* Updated on: Sep 25.2025
99
1010
Author: Wolle (schreibfaul1)
@@ -1503,7 +1503,7 @@ int Audio::read_FLAC_Header(uint8_t* data, size_t len) {
15031503
}
15041504
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15051505
if (m_controlCounter == FLAC_BEGIN) { // init
1506-
memset(&m_rflh, 0, sizeof(audiolib::rflh_t));
1506+
m_rflh.reset();
15071507
m_controlCounter = FLAC_MAGIC;
15081508
m_rflh.picVec.clear();
15091509
return 0;

src/Audio.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
*/
55

6-
// #define SR_48K
6+
#define SR_48K
77

88
#pragma once
99
#pragma GCC optimize("Ofast")

src/audiolib_structs.hpp

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -265,22 +265,27 @@ struct rwh_t { // used in read_WAV_Header
265265
uint8_t bts = 0;
266266
};
267267

268-
struct rflh_t { // used in read_FLAC_Header
269-
std::vector<uint32_t> picVec;
270-
size_t headerSize;
271-
size_t retvalue;
272-
bool f_lastMetaBlock;
273-
uint32_t picPos;
274-
uint32_t picLen;
275-
uint32_t duration;
276-
uint32_t nominalBitrate;
277-
uint8_t numChannels;
278-
uint8_t bitsPerSample;
279-
uint32_t sampleRate;
280-
uint32_t maxFrameSize;
281-
uint32_t maxBlockSize;
282-
uint32_t totalSamplesInStream;
283-
};
268+
typedef struct _rflh { // used in read_FLAC_Header
269+
std::vector<uint32_t> picVec{};
270+
size_t headerSize{};
271+
size_t retvalue{};
272+
bool f_lastMetaBlock{};
273+
uint32_t picPos{};
274+
uint32_t picLen{};
275+
uint32_t duration{};
276+
uint32_t nominalBitrate{};
277+
uint8_t numChannels{};
278+
uint8_t bitsPerSample{};
279+
uint32_t sampleRate{};
280+
uint32_t maxFrameSize{};
281+
uint32_t maxBlockSize{};
282+
uint32_t totalSamplesInStream{};
283+
284+
void reset() {
285+
// Default-initialize alles neu (inklusive Array)
286+
*this = _rflh{};
287+
}
288+
} rflh_t;
284289

285290
struct phreh_t { // used in parseHttpResponseHeader
286291
uint32_t ctime;

src/mp3_decoder/mp3_decoder.cpp

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3245,13 +3245,29 @@ void MP3Decoder::FDCT32(int32_t* buf, int32_t* dest, int32_t offset, int32_t odd
32453245
* P O L Y P H A S E
32463246
*/
32473247
int16_t MP3Decoder::ClipToShort(int32_t x, int32_t fracBits) {
3248-
3248+
#if(defined CONFIG_IDF_TARGET_ESP32 || defined CONFIG_IDF_TARGET_ESP32S3)
32493249
/* assumes you've already rounded (x += (1 << (fracBits-1))) */
32503250
x >>= fracBits;
3251-
32523251
// this is better on xtensa (fb)
32533252
asm("clamps %0, %1, 15" : "=a"(x) : "a"(x) :);
32543253
return x;
3254+
#endif
3255+
3256+
#if (defined CONFIG_IDF_TARGET_ESP32P4)
3257+
int32_t sign;
3258+
3259+
/* assumes you've already rounded (x += (1 << (fracBits-1))) */
3260+
x >>= fracBits;
3261+
3262+
/* Ken's trick: clips to [-32768, 32767] */
3263+
sign = x >> 31;
3264+
if (sign != (x >> 15)) {
3265+
x = sign ^ ((1 << 15) - 1);
3266+
}
3267+
3268+
return (int16_t)x;
3269+
#endif
3270+
32553271
}
32563272
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
32573273
/*

src/opus_decoder/opus_decoder.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ bool OpusDecoder::isValid() {
8787
}
8888
// —————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————
8989
void OpusDecoder::OPUSsetDefaults() {
90-
memset(&m_ofp2, 0, sizeof(m_ofp2));
91-
memset(&m_ofp3, 0, sizeof(m_ofp3));
92-
memset(&m_odp3, 0, sizeof(m_odp3));
90+
m_ofp2.reset();
91+
m_ofp3.reset();
92+
m_odp3.reset();
9393
m_ofp3.firstCall = true;
9494
m_f_opusParseOgg = false;
9595
m_f_newSteamTitle = false; // streamTitle

0 commit comments

Comments
 (0)