Skip to content

Commit

Permalink
Div. compile warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Nov 17, 2023
1 parent 783042a commit aeb5c5c
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 23 deletions.
14 changes: 7 additions & 7 deletions src/AudioAnalog/AnalogAudioESP32V1.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
uint16_t *result16 = (uint16_t *)dest;
uint16_t *end = (uint16_t *)(dest + size_bytes);
int result_count = result_cont / sizeof(adc_digi_output_data_t);
LOGD("adc_continuous_read -> %d bytes / %d samples", result_cont,
LOGD("adc_continuous_read -> %u bytes / %d samples", (unsigned) result_cont,
result_count);

for (int i = 0; i < result_count; i++) {
Expand All @@ -168,7 +168,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
uint32_t data = AUDIO_ADC_GET_DATA(p);

if (isValidADCChannel((adc_channel_t)chan_num)) {
LOGD("Idx: %d, channel: %d, data: %u", i, chan_num, data);
LOGD("Idx: %d, channel: %d, data: %u", i, chan_num, (unsigned) data);

assert(result16 < end); // make sure we dont write past the end
if (self->cfg.adc_calibration_active) {
Expand Down Expand Up @@ -196,7 +196,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
}

} else {
LOGD("invalid channel: %d, data: %u", chan_num, data);
LOGD("invalid channel: %d, data: %u", chan_num, (unsigned) data);
}
}
// make sure that the center is at 0, so the result will be int16_t
Expand Down Expand Up @@ -313,7 +313,7 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
}
dig_cfg.adc_pattern = adc_pattern;

LOGI("dig_cfg.sample_freq_hz: %u", dig_cfg.sample_freq_hz);
LOGI("dig_cfg.sample_freq_hz: %u", (unsigned) dig_cfg.sample_freq_hz);
LOGI("dig_cfg.conv_mode: %u", dig_cfg.conv_mode);
LOGI("dig_cfg.format: %u", dig_cfg.format);
for (int i = 0; i < cfg.channels; i++) {
Expand Down Expand Up @@ -356,12 +356,12 @@ class AnalogDriverESP32V1 : public AnalogDriverBase {
bool checkADCBitWidth() {
if ((cfg.adc_bit_width < SOC_ADC_DIGI_MIN_BITWIDTH) ||
(cfg.adc_bit_width > SOC_ADC_DIGI_MAX_BITWIDTH)) {
LOGE("adc bit width: %u cannot be set, range: %u to %u",
SOC_ADC_DIGI_MIN_BITWIDTH, SOC_ADC_DIGI_MAX_BITWIDTH);
LOGE("adc bit width: %u cannot be set, range: %u to %u", cfg.adc_bit_width,
(unsigned)SOC_ADC_DIGI_MIN_BITWIDTH, (unsigned)SOC_ADC_DIGI_MAX_BITWIDTH);
return false;
}
LOGI("adc bit width: %u, range: %u to %u", cfg.adc_bit_width,
SOC_ADC_DIGI_MIN_BITWIDTH, SOC_ADC_DIGI_MAX_BITWIDTH);
(unsigned)SOC_ADC_DIGI_MIN_BITWIDTH, (unsigned)SOC_ADC_DIGI_MAX_BITWIDTH);
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/AudioHttp/HLSStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ class URLLoader {
//assert(urls[0]!=url);

#ifdef ESP32
LOGI("Free heap: %d", ESP.getFreeHeap());
LOGI("Free heap: %u", (unsigned) ESP.getFreeHeap());
#endif
LOGI("Playing %s of %d", p_stream->urlStr(), urls.size());
LOGI("Playing %s of %zu", p_stream->urlStr(), urls.size());
}

int to_write = min(buffer.availableForWrite(),DEFAULT_BUFFER_SIZE);
Expand Down
2 changes: 1 addition & 1 deletion src/AudioHttp/HttpRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class HttpRequest {
}

#if defined(ESP32) && defined(ARDUINO)
LOGI("Free heap: %u", ESP.getFreeHeap());
LOGI("Free heap: %u", (unsigned)ESP.getFreeHeap());
#endif

reply_header.setProcessed();
Expand Down
2 changes: 1 addition & 1 deletion src/AudioTimer/AudioTimerESP32.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class TimerAlarmRepeatingDriverESP32 : public TimerAlarmRepeatingDriverBase {
}
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 1 , 0)
uint32_t freq = AudioTime::AudioTime::toRateUs(timeUs);
LOGI("Timer freq: %u hz", freq);
LOGI("Timer freq: %u hz",(unsigned) freq);
adc_timer = timerBegin(freq); // divider=80 -> 1000000 calls per second
#else
LOGI("Timer every: %u us", timeUs);
Expand Down
41 changes: 30 additions & 11 deletions src/AudioTools/AudioIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,24 +186,30 @@ class TimedStream : public AudioStream {
p_stream = &io;
p_print = &io;
p_info = &io;
setStartSecond(startSeconds);
setEndSecond(endSeconds);
setStartSec(startSeconds);
setEndSec(endSeconds);
}

TimedStream(AudioOutput &o, long startSeconds = 0, long endSeconds = -1) {
p_print = &o;
p_info = &o;
setStartSecond(startSeconds);
setEndSecond(endSeconds);
setStartSec(startSeconds);
setEndSec(endSeconds);
}

/// Defines the start time in seconds. The audio before the start time will be
/// skipped
void setStartSecond(long startSeconds) { start_seconds = startSeconds; }
void setStartSec(uint32_t startSeconds) { start_ms = startSeconds*1000; }

/// Defines the start time in milliseconds
void setStartMs(uint32_t ms) { start_ms = ms; }

/// Defines (an optional) the end time in seconds. After the end time no audio
/// is played and available() will return 0
void setEndSecond(long endSeconds) { end_seconds = endSeconds; }
void setEndSec(uint32_t endSeconds) { end_ms = endSeconds*1000; }

/// Defines the (optional) end time in milliseconds
void setEndMs(uint32_t ms) { end_ms = ms; }

/// Returns true if we are in a valid time range and are still playing sound
bool isPlaying() {
Expand Down Expand Up @@ -283,22 +289,35 @@ class TimedStream : public AudioStream {
return info.sample_rate * info.channels * info.bits_per_sample / 8;
}

void setOutput(Print &out){
p_print = &out;
}

void setStream(Print &out){
p_print = &out;
}

void setStream(Stream &stream){
p_print = &stream;
p_stream = &stream;
}

protected:
Stream *p_stream = nullptr;
Print *p_print = nullptr;
AudioInfoSupport *p_info = nullptr;
uint32_t start_seconds = 0;
uint32_t end_seconds = UINT32_MAX;
uint32_t start_ms = 0;
uint32_t end_ms = UINT32_MAX;
uint32_t start_bytes = 0;
uint32_t end_bytes = UINT32_MAX;
uint32_t current_bytes = 0;
float compression_ratio = 1.0;

void calculateByteLimits() {
int bytes_per_second = bytesPerSecond();
float bytes_per_second = bytesPerSecond();
if (bytes_per_second > 0) {
start_bytes = bytes_per_second * start_seconds / compression_ratio;
end_bytes = bytes_per_second * end_seconds / compression_ratio;
start_bytes = bytes_per_second * start_ms / compression_ratio / 1000;
end_bytes = bytes_per_second * end_ms / compression_ratio / 1000;
} else {
LOGE("AudioInfo not defined");
}
Expand Down
2 changes: 1 addition & 1 deletion src/AudioTools/AudioRuntime.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ inline void stop() {
inline static void checkMemory(bool memoryCheck=false) {
#if defined(ESP32) && defined(ARDUINO)
assert(heap_caps_check_integrity_all(true));
if (memoryCheck) printf("==> Available stack: %d - heap: %d\n", uxTaskGetStackHighWaterMark(NULL), ESP.getFreeHeap());
if (memoryCheck) printf("==> Available stack: %d - heap: %u\n",(int) uxTaskGetStackHighWaterMark(NULL), (unsigned)ESP.getFreeHeap());
#endif
}

Expand Down

0 comments on commit aeb5c5c

Please sign in to comment.