Files
MuditaOS/module-audio/Audio/StreamFactory.hpp
Marcin Smoczyński f1fc9df152 [EGD-4977] Reduce audio lag during voice call
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>
2021-02-01 22:22:12 +01:00

30 lines
788 B
C++

// 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 "Endpoint.hpp"
#include <memory>
#include <vector>
namespace audio
{
class StreamFactory
{
public:
explicit StreamFactory(Endpoint::Capabilities factoryCaps);
auto makeStream(const Source &source, const Sink &sink) -> std::unique_ptr<Stream>;
private:
auto negotiateCaps(std::vector<std::reference_wrapper<const Endpoint>> v) -> Endpoint::Capabilities;
auto getAllocator(bool usesDMA) -> Stream::Allocator &;
Endpoint::Capabilities caps;
StandardStreamAllocator stdAlloc;
NonCacheableStreamAllocator nonCacheableAlloc;
};
} // namespace audio