Skip to content

Commit

Permalink
Correct Broken AudioPlayer (Fade)
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Nov 4, 2023
1 parent ecd8ddf commit 520f391
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/AudioCodecs/AudioEncoded.h
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ class EncodedAudioOutput : public AudioStream {
return 0;
}

if(availableForWrite()==0){
if(check_available_for_write && availableForWrite()==0){
return 0;
}

Expand All @@ -400,14 +400,19 @@ class EncodedAudioOutput : public AudioStream {
void setLogLevel(AudioLogger::LogLevel level){
custom_log_level.set(level);
}
/// Is Available for Write check activated ?
bool isCheckAvailableForWrite() {
return check_available_for_write;
}

protected:
//AudioInfo info;
AudioDecoder *decoder_ptr = CodecNOP::instance(); // decoder
AudioEncoder *encoder_ptr = CodecNOP::instance(); // decoder
AudioWriter *writer_ptr = nullptr;
Print *ptr_out = nullptr;
bool active;
bool active = false;
bool check_available_for_write = false;
CustomLogLevel custom_log_level;
};

Expand Down
4 changes: 1 addition & 3 deletions src/AudioTools/AudioPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,7 @@ namespace audio_tools {
autonext = p_source->isAutoNext();

// initial audio info for fade from output when not defined yet
if (fade.audioInfo().channels==0){
setupFade();
}
setupFade();

// start dependent objects
p_out_decoding->begin();
Expand Down
2 changes: 2 additions & 0 deletions src/AudioTools/Fade.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ class FadeStream : public AudioStream {
/// same as setStream
void setOutput(Stream &io) {
p_io = &io;
p_out = &io;
}

/// same as setOutput
Expand All @@ -277,6 +278,7 @@ class FadeStream : public AudioStream {
int available() override { return p_io == nullptr ? 0 : p_io->available(); }

size_t write(const uint8_t *buffer, size_t size) override {
if (p_out==nullptr) return 0;
if (!active) {
LOGE("%s", error_msg);
return 0;
Expand Down

0 comments on commit 520f391

Please sign in to comment.