Skip to content

Commit

Permalink
millis is uint32_t
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Oct 30, 2023
1 parent 17f901b commit e6387c0
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 23 deletions.
6 changes: 1 addition & 5 deletions src/AudioCodecs/DecoderFromStreaming.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ namespace audio_tools {
*/
class DecoderFromStreaming : public AudioDecoder {
public:
/**
* @brief Constructor for a new DecoderBase64 object
*
* @param out_buffeream Output Stream to which we write the decoded result
*/
/// Default Constructor
DecoderFromStreaming(StreamingDecoder &dec, int bufferSize) {
TRACED();
p_dec = &dec;
Expand Down
4 changes: 2 additions & 2 deletions src/AudioConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,8 @@ extern "C" void app_main();
// delay and millis is needed by this framework
namespace audio_tools {

void delay(uint64_t ms){ vTaskDelay(1000 / portTICK_PERIOD_MS);}
uint64_t millis() {return (xTaskGetTickCount() * portTICK_PERIOD_MS);}
void delay(uint32_t ms){ vTaskDelay(1000 / portTICK_PERIOD_MS);}
uint32_t millis() {return (xTaskGetTickCount() * portTICK_PERIOD_MS);}

}
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/AudioLibs/Desktop/Millis.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
namespace audio_tools {

/// Waits for the indicated milliseconds
void delay(uint64_t ms) {
void delay(uint32_t ms) {
//std::this_thread::sleep_for(std::chrono::milliseconds(ms));
auto end = millis()+ms;
while(millis()<=end);
}

/// Returns the milliseconds since the start
uint64_t millis(){
uint32_t millis(){
using namespace std::chrono;
// Get current time with precision of milliseconds
auto now = time_point_cast<milliseconds>(system_clock::now());
Expand Down
2 changes: 1 addition & 1 deletion src/AudioLibs/RTSP.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class RTSPSourceFromAudioStream : public IAudioSource {

protected:
AudioStream *p_audiostream = nullptr;
uint64_t time_of_last_read = 0;
uint32_t time_of_last_read = 0;
bool started = true;
RTSPOutputPCMInfo pcmInfo;
RTSPFormatPCM format{pcmInfo};
Expand Down
12 changes: 6 additions & 6 deletions src/AudioTools/AudioIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class RateMeasuringStream : public AudioStream {
void setReportAt(int at) { count_at = at; }

/// Defines an alternative method to determine millis()
void setTimeCallback(uint64_t (*cb_ms)(void)) { millis_cb = cb_ms; }
void setTimeCallback(uint32_t (*cb_ms)(void)) { millis_cb = cb_ms; }

int availableForWrite() override {
if (p_out == nullptr)
Expand Down Expand Up @@ -419,12 +419,12 @@ class RateMeasuringStream : public AudioStream {
Print *p_out = nullptr;
uint32_t counter = 0;
uint32_t count_at = -1;
uint64_t start_time = 0;
uint64_t last_time = 0;
uint64_t total_bytes = 0;
uint64_t (*millis_cb)(void) = nullptr;
uint32_t start_time = 0;
uint32_t last_time = 0;
uint32_t total_bytes = 0;
uint32_t (*millis_cb)(void) = nullptr;

inline uint64_t ms() {
inline uint32_t ms() {
if (millis_cb)
return millis_cb();
return millis();
Expand Down
6 changes: 3 additions & 3 deletions src/AudioTools/AudioOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -811,10 +811,10 @@ class Throttle : public AudioOutput {
}

protected:
uint64_t start_time;
uint64_t sum_samples = 0;
uint32_t start_time = 0;
uint32_t sum_samples = 0;
ThrottleConfig info;
int bytesPerSample;
int bytesPerSample = 0;
Print *p_out = nullptr;
};

Expand Down
2 changes: 1 addition & 1 deletion src/AudioTools/AudioPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ namespace audio_tools {
StreamCopy copier; // copies sound into i2s
AudioInfo info;
bool meta_active = false;
uint64_t timeout = 0;
uint32_t timeout = 0;
int stream_increment = 1; // +1 moves forward; -1 moves backward
float current_volume = -1.0; // illegal value which will trigger an update
int delay_if_full = 100;
Expand Down
6 changes: 3 additions & 3 deletions src/AudioTools/AudioStreams.h
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ class MeasuringStream : public AudioStream {
}

/// Provides the time when the last measurement was started
uint64_t startTime() {
uint32_t startTime() {
return start_time;
}

Expand All @@ -1071,7 +1071,7 @@ class MeasuringStream : public AudioStream {
int count=0;
Stream *p_stream=nullptr;
Print *p_print=nullptr;
uint64_t start_time;
uint32_t start_time;
int total_bytes = 0;
int bytes_per_second = 0;
int sample_div = 0;
Expand All @@ -1083,7 +1083,7 @@ class MeasuringStream : public AudioStream {
total_bytes+=len;

if (count<0){
uint64_t end_time = millis();
uint32_t end_time = millis();
int time_diff = end_time - start_time; // in ms
if (time_diff>0){
bytes_per_second = total_bytes / time_diff * 1000;
Expand Down

0 comments on commit e6387c0

Please sign in to comment.