mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-06-28 02:07:08 -04:00
Reduce audio delay by reducing audio buffer size in router operation. Audio streams are now created directly in the operations, not in the audio service, which gives more flexibility. Audio Buffer size is calculated based on endpoints (source, sink) and operation capabilities. This commit also enables allocations in a non-cacheable region of OCRAM for endpoints that use DMA for data transport. Introduce power-of-two operations that use built-in functions and possibly dedicated hardware instructions of an MCU. These operations are required by the audio stream buffer size calculation algorithm. Signed-off-by: Marcin Smoczyński <smoczynski.marcin@gmail.com>
94 lines
2.9 KiB
C++
94 lines
2.9 KiB
C++
// Copyright (c) 2017-2021, 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)
|
|
: dataStreamOut(dataStreamOut), dataStreamIn(dataStreamIn), serviceCallback(std::move(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
|