~aleteoryx/muditaos

ref: 17f64cb3e4865ec85d4cb5a7f8a2bb9db68d023c muditaos/module-audio/Audio/Endpoint.cpp -rw-r--r-- 815 bytes
17f64cb3 — Lucjan Bryndza [EGD-5022] Fix invalid open flags in vfscore 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
// 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;
}