summaryrefslogtreecommitdiff
path: root/src/drivers/include/fatfs_audio_input.hpp
blob: 705f6e7d3187ecdf36518616816ab7636f2e4bdf (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
/*
 * Copyright 2023 jacqueline <me@jacqueline.id.au>
 *
 * SPDX-License-Identifier: GPL-3.0-only
 */

#pragma once

namespace drivers {

class FatfsAudioInput {
 public:
  FatfsAudioInput(std::shared_ptr<SdStorage> storage);
  ~FatfsAudioInput();

  enum Status {
    /*
     * Successfully read data into the output buffer, and there is still
     * data remaining in the file.
     */
    OKAY,

    /*
     * The ringbuffer was full. No data was read.
     */
    RINGBUF_FULL,

    /*
     * Some data may have been read into the output buffer, but the file is
     * now empty.
     */
    FILE_EMPTY,
  };
  auto Process() -> Status;

  auto GetOutputBuffer() -> RingbufHandle_t;

 private:
  std::shared_ptr<SdStorage> storage_;
  RingbufHandle_t output_;

  std::pmr::string path_;
};

}  // namespace drivers