~aleteoryx/muditaos

ref: a3e512a89b698b4d8a8f8046521c327ab2eec147 muditaos/module-bluetooth/Bluetooth/audio/BluetoothAudioDevice.hpp -rw-r--r-- 1.7 KiB
a3e512a8 — Marcin Smoczyński [EGD-6674] Change negotiation of audio block size 4 years ago
                                                                                
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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <Audio/AudioDevice.hpp>
#include <interface/profiles/A2DP/MediaContext.hpp>

namespace bluetooth
{

    class BluetoothAudioDevice : public audio::AudioDevice
    {
      public:
        BluetoothAudioDevice() = default;
        explicit BluetoothAudioDevice(MediaContext *mediaContext);
        virtual ~BluetoothAudioDevice();

        void setMediaContext(MediaContext *MediaContext);

        auto Start(const Configuration &format) -> audio::AudioDevice::RetCode override;
        auto Stop() -> audio::AudioDevice::RetCode override;

        auto OutputVolumeCtrl(float vol) -> audio::AudioDevice::RetCode override;
        auto InputGainCtrl(float gain) -> audio::AudioDevice::RetCode override;
        auto OutputPathCtrl(OutputPath outputPath) -> audio::AudioDevice::RetCode override;
        auto InputPathCtrl(InputPath inputPath) -> audio::AudioDevice::RetCode override;
        auto IsFormatSupported(const Configuration &format) -> bool override;
        auto getSupportedFormats() -> const std::vector<audio::AudioFormat> & override;
        auto getTraits() const -> Traits override;

        // Endpoint control methods
        void onDataSend() override;
        void onDataReceive() override;
        void enableInput() override;
        void enableOutput() override;
        void disableInput() override;
        void disableOutput() override;

      private:
        auto fillSbcAudioBuffer(MediaContext *context) -> int;

        MediaContext *ctx  = nullptr;
        bool outputEnabled = false;
        std::vector<audio::AudioFormat> formats;
    };

} // namespace bluetooth