summaryrefslogtreecommitdiff
path: root/src/tangara/audio/bt_audio_output.hpp
blob: 53d2c1a49d44a49b872ecf356aca5d89a4b0189c (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
 * Copyright 2023 jacqueline <me@jacqueline.id.au>
 *
 * SPDX-License-Identifier: GPL-3.0-only
 */

#pragma once

#include <stdint.h>
#include <cstdint>
#include <memory>
#include <vector>

#include "drivers/pcm_buffer.hpp"
#include "result.hpp"

#include "audio/audio_sink.hpp"
#include "drivers/bluetooth.hpp"
#include "drivers/gpios.hpp"
#include "drivers/i2s_dac.hpp"
#include "tasks.hpp"

namespace audio {

class BluetoothAudioOutput : public IAudioOutput {
 public:
  BluetoothAudioOutput(drivers::Bluetooth& bt,
                       drivers::OutputBuffers& bufs,
                       tasks::WorkerPool&);
  ~BluetoothAudioOutput();

  auto SetVolumeImbalance(int_fast8_t balance) -> void override;

  auto SetVolume(uint16_t) -> void override;

  auto GetVolume() -> uint16_t override;

  auto GetVolumePct() -> uint_fast8_t override;
  auto SetVolumePct(uint_fast8_t val) -> bool override;
  auto GetVolumeDb() -> int_fast16_t override;
  auto SetVolumeDb(int_fast16_t) -> bool override;

  auto AdjustVolumeUp() -> bool override;
  auto AdjustVolumeDown() -> bool override;

  auto PrepareFormat(const Format&) -> Format override;
  auto Configure(const Format& format) -> void override;

  BluetoothAudioOutput(const BluetoothAudioOutput&) = delete;
  BluetoothAudioOutput& operator=(const BluetoothAudioOutput&) = delete;

 protected:
  auto changeMode(Modes) -> void override;

 private:
  drivers::Bluetooth& bluetooth_;
  drivers::OutputBuffers& buffers_;
  tasks::WorkerPool& bg_worker_;

  uint16_t volume_;
};

}  // namespace audio