better handling of chunk buffer
This commit is contained in:
@@ -8,11 +8,14 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#include "audio_playback.hpp"
|
||||
#include "esp_console.h"
|
||||
|
||||
namespace console {
|
||||
|
||||
std::string toSdPath(std::string filepath) {
|
||||
static AppConsole* sInstance = nullptr;
|
||||
|
||||
std::string toSdPath(const std::string& filepath) {
|
||||
return std::string(drivers::kStoragePath) + "/" + filepath;
|
||||
}
|
||||
|
||||
@@ -57,12 +60,7 @@ int CmdPlayFile(int argc, char** argv) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
sInstance->playback_->Play(toSdPath(argv[1]));
|
||||
if (argc == 3) {
|
||||
sInstance->playback_->SetNextFile(toSdPath(argv[2]));
|
||||
}
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -125,14 +123,12 @@ void RegisterVolume() {
|
||||
esp_console_cmd_register(&cmd);
|
||||
}
|
||||
|
||||
/*
|
||||
AppConsole::AppConsole() {
|
||||
AppConsole::AppConsole(audio::AudioPlayback* playback) : playback_(playback) {
|
||||
sInstance = this;
|
||||
}
|
||||
AppConsole::~AppConsole() {
|
||||
sInstance = nullptr;
|
||||
}
|
||||
*/
|
||||
|
||||
auto AppConsole::RegisterExtraComponents() -> void {
|
||||
RegisterListDir();
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "audio_playback.hpp"
|
||||
#include "console.hpp"
|
||||
#include "storage.hpp"
|
||||
|
||||
@@ -9,8 +10,10 @@ namespace console {
|
||||
|
||||
class AppConsole : public Console {
|
||||
public:
|
||||
AppConsole() {}
|
||||
virtual ~AppConsole() {}
|
||||
explicit AppConsole(audio::AudioPlayback* playback);
|
||||
virtual ~AppConsole();
|
||||
|
||||
audio::AudioPlayback* playback_;
|
||||
|
||||
protected:
|
||||
virtual auto RegisterExtraComponents() -> void;
|
||||
|
||||
+5
-16
@@ -24,6 +24,7 @@
|
||||
#include "widgets/lv_label.h"
|
||||
|
||||
#include "app_console.hpp"
|
||||
#include "audio_playback.hpp"
|
||||
#include "battery.hpp"
|
||||
#include "dac.hpp"
|
||||
#include "display.hpp"
|
||||
@@ -102,7 +103,7 @@ extern "C" void app_main(void) {
|
||||
ESP_LOGE(TAG, "Failed: %d", storage_res.error());
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<drivers::SdStorage> storage = std::move(storage_res.value());
|
||||
std::shared_ptr<drivers::SdStorage> storage = std::move(storage_res.value());
|
||||
|
||||
LvglArgs* lvglArgs = (LvglArgs*)calloc(1, sizeof(LvglArgs));
|
||||
lvglArgs->gpio_expander = expander;
|
||||
@@ -110,32 +111,20 @@ extern "C" void app_main(void) {
|
||||
(void*)lvglArgs, 1, sLvglStack,
|
||||
&sLvglTaskBuffer, 1);
|
||||
|
||||
/*
|
||||
ESP_LOGI(TAG, "Init audio output (I2S)");
|
||||
auto sink_res = drivers::I2SAudioOutput::create(expander);
|
||||
if (sink_res.has_error()) {
|
||||
ESP_LOGE(TAG, "Failed: %d", sink_res.error());
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<drivers::IAudioOutput> sink = std::move(sink_res.value());
|
||||
|
||||
ESP_LOGI(TAG, "Init audio pipeline");
|
||||
auto playback_res = drivers::AudioPlayback::create(std::move(sink));
|
||||
auto playback_res = audio::AudioPlayback::create(expander, storage);
|
||||
if (playback_res.has_error()) {
|
||||
ESP_LOGE(TAG, "Failed: %d", playback_res.error());
|
||||
return;
|
||||
}
|
||||
std::unique_ptr<drivers::AudioPlayback> playback =
|
||||
std::shared_ptr<audio::AudioPlayback> playback =
|
||||
std::move(playback_res.value());
|
||||
playback->SetVolume(130);
|
||||
*/
|
||||
|
||||
ESP_LOGI(TAG, "Launch console");
|
||||
console::AppConsole console;
|
||||
console::AppConsole console(playback.get());
|
||||
console.Launch();
|
||||
|
||||
while (1) {
|
||||
// playback->ProcessEvents(5);
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user