Skip to content

Commit

Permalink
SPDIFOutput prevent NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Oct 8, 2023
1 parent e960b44 commit 9396adc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/AudioTools/AudioSPDIF.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ class SPDIFOutput : public AudioStream {

// Setup I2S
int sample_rate = cfg.sample_rate * BMC_BITS_FACTOR;
if (sample_rate==0){
TRACEE();
return false;
}
int bclk = sample_rate * I2S_BITS_PER_SAMPLE * I2S_CHANNELS;
int mclk = (I2S_BUG_MAGIC / bclk) * bclk; // use mclk for avoiding I2S bug

Expand All @@ -168,8 +172,7 @@ class SPDIFOutput : public AudioStream {
i2s_cfg.use_apll = true;
i2s_cfg.fixed_mclk = mclk;
#endif
i2s.begin(i2s_cfg);
i2sOn = true;
i2sOn = i2s.begin(i2s_cfg);
return i2sOn;
}

Expand Down

0 comments on commit 9396adc

Please sign in to comment.