File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -260,13 +260,6 @@ class SPDIFStream16Bit2Channels : public AudioStreamX {
260
260
261
261
// / Start with the provided parameters
262
262
bool begin (SPDIFConfig cfg) {
263
- if (out == nullptr ) {
264
- #if USE_ESP32_I2S == 1
265
- out = new SPDFOutI2SESP32 ();
266
- #else
267
- out = new SPDIFOutI2S ();
268
- #endif
269
- }
270
263
if (i2sOn){
271
264
out->end ();
272
265
}
@@ -284,8 +277,6 @@ class SPDIFStream16Bit2Channels : public AudioStreamX {
284
277
bool result = true ;
285
278
if (out != nullptr ) {
286
279
result = out->end ();
287
- delete out;
288
- out = nullptr ;
289
280
}
290
281
i2sOn = false ;
291
282
return result;
@@ -389,6 +380,16 @@ class SPDIFStream : public AudioStreamX {
389
380
// / start SPDIF with the indicated configuration
390
381
bool begin (SPDIFConfig cfg) {
391
382
this ->cfg = cfg;
383
+ // Define output class if not yet defined
384
+ if (spdif_out == nullptr ) {
385
+ #if USE_ESP32_I2S == 1
386
+ spdif_out = new SPDFOutI2SESP32 ();
387
+ #else
388
+ spdif_out = new SPDIFOutI2S ();
389
+ #endif
390
+ spdif.setOutput (spdif_out);
391
+ }
392
+
392
393
// define source format
393
394
converter.setInputInfo (cfg);
394
395
// define target format for converter
@@ -430,7 +431,7 @@ class SPDIFStream : public AudioStreamX {
430
431
SPDIFConfig cfg;
431
432
SPDIFStream16Bit2Channels spdif;
432
433
FormatConverterStream converter{spdif};
433
- SPDIFOutGeneric *spdif_out=nullptr ;
434
+ SPDIFOut *spdif_out=nullptr ;
434
435
};
435
436
436
437
} // namespace audio_tools
You can’t perform that action at this time.
0 commit comments