Files
MuditaOS/module-audio/Audio/Endpoint.cpp
Marcin Smoczyński 871b250d86 [EGD-4534] Change audio data path synchronization
Refactor audio data path to fix several synchronization issues and
excessive copy operations on large memory blocks. Introduce
audio::Stream data structure to allow connecting audio source and sink
with a zero-copy capability.

Introduce system mechanisms:
 - critical section guard lock needed for stream synchronization
 - non-cacheable memory allocator to allocate memory for DMA safe
   buffers

Update the Googletest CMake template to match the capabilities of the
Catch2 template.

Signed-off-by: Marcin Smoczyński <smoczynski.marcin@gmail.com>
Signed-off-by: Hubert Chrzaniuk <hubert.chrzaniuk@mudita.com>
2020-12-17 12:20:40 +01:00

45 lines
815 B
C++

// Copyright (c) 2017-2020, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "Endpoint.hpp"
#include <cassert> // assert
using namespace audio;
void Endpoint::setStream(Stream &stream)
{
assert(_stream == nullptr);
_stream = &stream;
}
Stream *Endpoint::getStream() const noexcept
{
return _stream;
}
void Endpoint::unsetStream()
{
assert(_stream != nullptr);
_stream = nullptr;
}
bool Endpoint::isConnected() const noexcept
{
return _stream != nullptr;
}
void Source::connect(Sink &sink, Stream &stream)
{
connectedSink = &sink;
connectedSink->setStream(stream);
setStream(stream);
}
void Source::disconnectStream()
{
unsetStream();
connectedSink->unsetStream();
connectedSink = nullptr;
}