blob: 9a7c5fc0c7fc2bbdec957996beeca995bf99540e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#pragma once
#include <cstdint>
#include <memory>
#include <string>
#include <vector>
#include "audio_element.hpp"
#include "esp_err.h"
#include "gpio_expander.hpp"
#include "result.hpp"
#include "span.hpp"
#include "storage.hpp"
#include "stream_buffer.hpp"
namespace audio {
/*
* TODO.
*/
class AudioPlayback {
public:
enum Error { ERR_INIT_ELEMENT, ERR_MEM };
static auto create(drivers::GpioExpander* expander,
std::shared_ptr<drivers::SdStorage> storage)
-> cpp::result<std::unique_ptr<AudioPlayback>, Error>;
// TODO(jacqueline): configure on the fly once we have things to configure.
AudioPlayback();
~AudioPlayback();
auto Play(const std::string& filename) -> void;
// Not copyable or movable.
AudioPlayback(const AudioPlayback&) = delete;
AudioPlayback& operator=(const AudioPlayback&) = delete;
private:
auto ConnectElements(IAudioElement* src, IAudioElement* sink) -> void;
StreamBuffer stream_start_;
StreamBuffer stream_end_;
std::vector<std::unique_ptr<StreamBuffer>> element_buffers_;
};
} // namespace audio
|