mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-07-04 05:06:58 -04:00
80 lines
1.6 KiB
C++
80 lines
1.6 KiB
C++
/*
|
|
* @file bsp_audio.cpp
|
|
* @author Mateusz Piesta (mateusz.piesta@mudita.com)
|
|
* @date 22.07.19
|
|
* @brief
|
|
* @copyright Copyright (C) 2019 mudita.com
|
|
* @details
|
|
*/
|
|
|
|
|
|
|
|
#include "bsp_audio.hpp"
|
|
|
|
#if defined(TARGET_RT1051)
|
|
|
|
#include "board/rt1051/bsp/audio/RT1051Audiocodec.hpp"
|
|
#include "board/rt1051/bsp/audio/RT1051CellularAudio.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)
|
|
|
|
#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 {};
|
|
}
|
|
|
|
} |