~aleteoryx/muditaos

ref: 43526432f4a2f4d16e3f200b4ee704f0ba45d3ec muditaos/module-bsp/bsp/audio/bsp_audio.cpp -rw-r--r-- 1.6 KiB
43526432 — Jakub Pyszczak [EGD-5035] Fix error translation fs 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
#include "bsp_audio.hpp"

#if defined(TARGET_RT1051)

#include "board/rt1051/bsp/audio/RT1051Audiocodec.hpp"
#include "board/rt1051/bsp/audio/RT1051CellularAudio.hpp"
#include "board/rt1051/bsp/audio/RT1051BluetoothAudio.hpp"

#elif defined(TARGET_Linux)
#include "audio/linux_audiocodec.hpp"
#include "audio/LinuxCellularAudio.hpp"
#else
#error "Unsupported target"
#endif

namespace bsp{

    std::optional<std::unique_ptr<AudioDevice>> AudioDevice::Create(bsp::AudioDevice::Type type,audioCallback_t callback) {

        std::unique_ptr<AudioDevice> inst;

        switch(type){

            case Type ::Audiocodec:
            {
#if defined(TARGET_RT1051)
                inst = std::make_unique<bsp::RT1051Audiocodec>(callback);
#elif defined(TARGET_Linux)
                inst = std::make_unique<bsp::LinuxAudiocodec>(callback );
#else
                #error "Unsupported target"
#endif

            }
                break;


            case Type ::Bluetooth:
            {
#if defined(TARGET_RT1051)
                inst = std::make_unique<bsp::RT1051BluetoothAudio>(callback);

#elif defined(TARGET_Linux)

#else
#error "Unsupported target"
#endif
            }
                break;

            case Type::Cellular:
            {
#if defined(TARGET_RT1051)
                inst = std::make_unique<bsp::RT1051CellularAudio>(callback);
#elif defined(TARGET_Linux)
                inst = std::make_unique<bsp::LinuxCellularAudio>(callback );
#else
#error "Unsupported target"
#endif
            }
                break;

        }

        if(inst->isInitialized){
            return inst;
        }

        return {};
    }

}