File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -136,10 +136,15 @@ class SPDIFStream : public AudioStreamX {
136136 // / Start with the provided parameters
137137 bool begin (SPDIFConfig cfg) {
138138 LOGD (LOG_METHOD);
139+ // Some validations to make sure that the config is valid
139140 if (!(cfg.channels == 1 | cfg.channels == 2 )) {
140141 LOGE (" Unsupported number of channels: %d" , cfg.channels );
141142 return false ;
142143 }
144+ if (info.bits_per_sample != 16 ) {
145+ LOGE (" Unsupported bits per sample: %d - must be 16!" ,
146+ info.bits_per_sample );
147+ }
143148
144149 if (i2sOn) {
145150 i2s.end ();
@@ -148,6 +153,8 @@ class SPDIFStream : public AudioStreamX {
148153 // initialize S/PDIF buffer
149154 spdif_buf_init ();
150155 spdif_ptr = spdif_buf;
156+
157+ // Setup I2S
151158 int sample_rate = cfg.sample_rate * BMC_BITS_FACTOR;
152159 int bclk = sample_rate * I2S_BITS_PER_SAMPLE * I2S_CHANNELS;
153160 int mclk = (I2S_BUG_MAGIC / bclk) * bclk; // use mclk for avoiding I2S bug
@@ -186,9 +193,6 @@ class SPDIFStream : public AudioStreamX {
186193 LOGE (" Unsupported bits per sample: %d - must be 16!" ,
187194 info.bits_per_sample );
188195 }
189- if (info.channels != 2 ) {
190- LOGE (" Unsupported number of channels: %d - must be 2!" , info.channels );
191- }
192196 begin (cfg);
193197 }
194198
You can’t perform that action at this time.
0 commit comments