mirror of https://github.com/arendst/Tasmota.git
commit
5cbadf4d54
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
AudioFileSourceHTTPStream
|
||||
Connect to a HTTP based streaming service
|
||||
|
||||
|
||||
Copyright (C) 2017 Earle F. Philhower, III
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
@ -25,6 +25,7 @@
|
|||
#ifdef ESP32
|
||||
#include <HTTPClient.h>
|
||||
#else
|
||||
#include <WiFiClient.h>
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#endif
|
||||
#include "AudioFileSource.h"
|
||||
|
@ -37,7 +38,7 @@ class AudioFileSourceHTTPStream : public AudioFileSource
|
|||
AudioFileSourceHTTPStream();
|
||||
AudioFileSourceHTTPStream(const char *url);
|
||||
virtual ~AudioFileSourceHTTPStream() override;
|
||||
|
||||
|
||||
virtual bool open(const char *url) override;
|
||||
virtual uint32_t read(void *data, uint32_t len) override;
|
||||
virtual uint32_t readNonBlock(void *data, uint32_t len) override;
|
||||
|
@ -63,4 +64,3 @@ class AudioFileSourceHTTPStream : public AudioFileSource
|
|||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
AudioFileSourceHTTPStream
|
||||
Connect to a HTTP based streaming service
|
||||
|
||||
|
||||
Copyright (C) 2017 Earle F. Philhower, III
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
@ -36,7 +36,7 @@ class AudioFileSourceICYStream : public AudioFileSourceHTTPStream
|
|||
AudioFileSourceICYStream();
|
||||
AudioFileSourceICYStream(const char *url);
|
||||
virtual ~AudioFileSourceICYStream() override;
|
||||
|
||||
|
||||
virtual bool open(const char *url) override;
|
||||
|
||||
private:
|
||||
|
@ -47,4 +47,3 @@ class AudioFileSourceICYStream : public AudioFileSourceHTTPStream
|
|||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
AudioFileSourceSPIFFS
|
||||
Input SD card "file" to be used by AudioGenerator
|
||||
|
||||
|
||||
Copyright (C) 2017 Earle F. Philhower, III
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
@ -22,6 +22,10 @@
|
|||
#define _AUDIOFILESOURCESD_H
|
||||
|
||||
#include "AudioFileSource.h"
|
||||
#ifdef ESP8266
|
||||
#include <SdFat.h>
|
||||
#include <SDFS.h>
|
||||
#endif
|
||||
#include <SD.h>
|
||||
|
||||
|
||||
|
@ -31,7 +35,7 @@ class AudioFileSourceSD : public AudioFileSource
|
|||
AudioFileSourceSD();
|
||||
AudioFileSourceSD(const char *filename);
|
||||
virtual ~AudioFileSourceSD() override;
|
||||
|
||||
|
||||
virtual bool open(const char *filename) override;
|
||||
virtual uint32_t read(void *data, uint32_t len) override;
|
||||
virtual bool seek(int32_t pos, int dir) override;
|
||||
|
@ -46,4 +50,3 @@ class AudioFileSourceSD : public AudioFileSource
|
|||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
AudioGeneratorMP3
|
||||
Wrap libmad MP3 library to play audio
|
||||
|
||||
|
||||
Copyright (C) 2017 Earle F. Philhower, III
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
|
@ -52,7 +52,7 @@ AudioGeneratorMP3::~AudioGeneratorMP3()
|
|||
free(synth);
|
||||
free(frame);
|
||||
free(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -153,7 +153,7 @@ bool AudioGeneratorMP3::GetOneSample(int16_t sample[2])
|
|||
output->SetChannels(synth->pcm.channels);
|
||||
lastChannels = synth->pcm.channels;
|
||||
}
|
||||
|
||||
|
||||
// If we're here, we have one decoded frame and sent 0 or more samples out
|
||||
if (samplePtr < synth->pcm.length) {
|
||||
sample[AudioOutput::LEFTCHANNEL ] = synth->pcm.samples[0][samplePtr];
|
||||
|
@ -161,7 +161,7 @@ bool AudioGeneratorMP3::GetOneSample(int16_t sample[2])
|
|||
samplePtr++;
|
||||
} else {
|
||||
samplePtr = 0;
|
||||
|
||||
|
||||
switch ( mad_synth_frame_onens(synth, frame, nsCount++) ) {
|
||||
case MAD_FLOW_STOP:
|
||||
case MAD_FLOW_BREAK: audioLogger->printf_P(PSTR("msf1ns failed\n"));
|
||||
|
@ -272,17 +272,19 @@ bool AudioGeneratorMP3::begin(AudioFileSource *source, AudioOutput *output)
|
|||
stream = NULL;
|
||||
frame = NULL;
|
||||
synth = NULL;
|
||||
uint32_t size = buffLen + sizeof(struct mad_stream) + sizeof(struct mad_frame) + sizeof(struct mad_synth);
|
||||
audioLogger->printf_P("OOM error in MP3: Want %d bytes\n", size);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mad_stream_init(stream);
|
||||
mad_frame_init(frame);
|
||||
mad_synth_init(synth);
|
||||
synth->pcm.length = 0;
|
||||
mad_stream_options(stream, 0); // TODO - add options support
|
||||
madInitted = true;
|
||||
|
||||
|
||||
running = true;
|
||||
return true;
|
||||
}
|
||||
|
@ -349,4 +351,3 @@ extern "C" {
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue