Skip to content

Commit afe0e2e

Browse files
committed
EncodedAudioStream support AudioBaseInfo in begin
1 parent ae43aa1 commit afe0e2e

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/AudioTools/AudioOutput.h

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class EncodedAudioStream : public AudioPrint, public AudioBaseInfoSource {
221221
* @param decoder
222222
*/
223223
EncodedAudioStream(Print &outputStream, AudioDecoder &decoder) {
224-
LOGD(LOG_METHOD);
224+
LOGD(LOG_METHOD);
225225
decoder_ptr = &decoder;
226226
decoder_ptr->setOutputStream(outputStream);
227227
writer_ptr = decoder_ptr;
@@ -236,7 +236,7 @@ class EncodedAudioStream : public AudioPrint, public AudioBaseInfoSource {
236236
* @param decoder
237237
*/
238238
EncodedAudioStream(Print *outputStream, AudioDecoder *decoder) {
239-
LOGD(LOG_METHOD);
239+
LOGD(LOG_METHOD);
240240
decoder_ptr = decoder;
241241
decoder_ptr->setOutputStream(*outputStream);
242242
writer_ptr = decoder_ptr;
@@ -250,7 +250,7 @@ class EncodedAudioStream : public AudioPrint, public AudioBaseInfoSource {
250250
* @param encoder
251251
*/
252252
EncodedAudioStream(Print &outputStream, AudioEncoder &encoder) {
253-
LOGD(LOG_METHOD);
253+
LOGD(LOG_METHOD);
254254
encoder_ptr = &encoder;
255255
encoder_ptr->setOutputStream(outputStream);
256256
writer_ptr = encoder_ptr;
@@ -264,7 +264,7 @@ class EncodedAudioStream : public AudioPrint, public AudioBaseInfoSource {
264264
* @param encoder
265265
*/
266266
EncodedAudioStream(Print *outputStream, AudioEncoder *encoder) {
267-
LOGD(LOG_METHOD);
267+
LOGD(LOG_METHOD);
268268
encoder_ptr = encoder;
269269
encoder_ptr->setOutputStream(*outputStream);
270270
writer_ptr = encoder_ptr;
@@ -317,7 +317,7 @@ class EncodedAudioStream : public AudioPrint, public AudioBaseInfoSource {
317317

318318
/// Starts the processing - sets the status to active
319319
void begin() {
320-
LOGD(LOG_METHOD);
320+
LOGD(LOG_METHOD);
321321
const CodecNOP *nop = CodecNOP::instance();
322322
if (decoder_ptr != nop || encoder_ptr != nop){
323323
decoder_ptr->begin();
@@ -328,6 +328,19 @@ class EncodedAudioStream : public AudioPrint, public AudioBaseInfoSource {
328328
}
329329
}
330330

331+
/// Starts the processing - sets the status to active
332+
void begin(AudioBaseInfo info) {
333+
LOGD(LOG_METHOD);
334+
const CodecNOP *nop = CodecNOP::instance();
335+
if (decoder_ptr != nop || encoder_ptr != nop){
336+
decoder_ptr->begin();
337+
encoder_ptr->setAudioInfo(info);
338+
encoder_ptr->begin();
339+
active = true;
340+
} else {
341+
LOGW("no decoder or encoder defined");
342+
}
343+
}
331344
/// Ends the processing
332345
void end() {
333346
LOGD(LOG_METHOD);

0 commit comments

Comments
 (0)