~aleteoryx/muditaos

ref: 7d7003d62639426be8eb00f4fc288b68139f5566 muditaos/module-audio/Audio/BluetoothProxyAudio.cpp -rw-r--r-- 2.9 KiB
7d7003d6 — Marcin Smoczyński Merge branch 'master' into stable 5 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "BluetoothProxyAudio.hpp"
#include <service-bluetooth/BluetoothMessage.hpp>

namespace bsp
{
    BluetoothProxyAudio::BluetoothProxyAudio(AudioServiceMessage::Callback callback,
                                             audio::Stream &dataStreamOut,
                                             audio::Stream &dataStreamIn,
                                             AudioDevice::Format &format)
        : AudioDevice(nullptr), dataStreamOut(dataStreamOut), dataStreamIn(dataStreamIn), serviceCallback(callback),
          audioFormat(format)
    {
        LOG_DEBUG("BluetoothProxyAudio created.");
    }

    AudioDevice::RetCode BluetoothProxyAudio::Start(const AudioDevice::Format &format)
    {
        auto msg = BluetoothProxyStartMessage(dataStreamOut, dataStreamIn, format);
        serviceCallback(&msg);
        return AudioDevice::RetCode::Success;
    }

    AudioDevice::RetCode BluetoothProxyAudio::Stop()
    {
        auto msg = BluetoothProxyStopMessage(audioFormat);
        serviceCallback(&msg);
        return AudioDevice::RetCode::Success;
    }

    AudioDevice::RetCode BluetoothProxyAudio::OutputVolumeCtrl(float vol)
    {
        audioFormat.outputVolume = vol;
        auto msg                 = BluetoothProxySetVolumeMessage(audioFormat);
        serviceCallback(&msg);
        return AudioDevice::RetCode::Success;
    }

    AudioDevice::RetCode BluetoothProxyAudio::InputGainCtrl(float gain)
    {
        audioFormat.inputGain = gain;
        auto msg              = BluetoothProxySetGainMessage(audioFormat);
        serviceCallback(&msg);
        return AudioDevice::RetCode::Success;
    }

    AudioDevice::RetCode BluetoothProxyAudio::OutputPathCtrl(AudioDevice::OutputPath outputPath)
    {
        audioFormat.outputPath = outputPath;
        auto msg               = BluetoothProxySetOutputPathMessage(audioFormat);
        serviceCallback(&msg);
        return AudioDevice::RetCode::Success;
    }

    AudioDevice::RetCode BluetoothProxyAudio::InputPathCtrl(AudioDevice::InputPath inputPath)
    {
        audioFormat.inputPath = inputPath;
        auto msg              = BluetoothProxySetInputPathMessage(audioFormat);
        serviceCallback(&msg);
        return AudioDevice::RetCode::Success;
    }

    bool BluetoothProxyAudio::IsFormatSupported(const AudioDevice::Format &format)
    {
        LOG_DEBUG("Format assumed to be supported");
        return true;
    }

    BluetoothProxyAudio::~BluetoothProxyAudio()
    {
        Stop();
    }

    void BluetoothProxyAudio::onDataReceive()
    {}

    void BluetoothProxyAudio::onDataSend()
    {}

    void BluetoothProxyAudio::enableInput()
    {}

    void BluetoothProxyAudio::enableOutput()
    {}

    void BluetoothProxyAudio::disableInput()
    {}

    void BluetoothProxyAudio::disableOutput()
    {}
} // namespace bsp