~aleteoryx/muditaos

ref: 3454dade997baa5a0391700aa1d8f789ff4b0b65 muditaos/module-services/service-cellular/call/CallAudio.cpp -rw-r--r-- 1.5 KiB
3454dade — Kuba [MOS-325] AudioServiceAPI removed from Call app 3 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "CallAudio.hpp"
#include "Service/Message.hpp"
#include "log/log.hpp"
#include <limits>
#include <service-audio/AudioMessage.hpp>
#include "service-audio/AudioServiceName.hpp"
#include <service-audio/AudioServiceAPI.hpp>
#include <Timers/TimerFactory.hpp>

struct CallRingAudio::CallMeta
{
    sys::Async<AudioStartPlaybackRequest, AudioStartPlaybackResponse> async;
};

CallRingAudio::CallRingAudio(sys::Service &s) : owner(s), meta(new CallRingAudio::CallMeta)
{}

CallRingAudio::~CallRingAudio()
{
    delete meta;
}

void CallRingAudio::play()
{
    started         = true;
    const auto file = AudioServiceAPI::GetSound(&owner, audio::PlaybackType::CallRingtone);
    meta->async     = owner.async_call<AudioStartPlaybackRequest, AudioStartPlaybackResponse>(
        service::name::audio, file, audio::PlaybackType::CallRingtone);
}

void CallRingAudio::stop()
{
    if (not started) {
        return;
    }
    owner.sync(meta->async);
    AudioServiceAPI::StopAll(&owner);
}

void CallRingAudio::muteCall()
{
    AudioServiceAPI::SendEvent(&owner, audio::EventType::CallMute);
}

void CallRingAudio::unmuteCall()
{
    AudioServiceAPI::SendEvent(&owner, audio::EventType::CallUnmute);
}

void CallRingAudio::setLaudspeakerOn()
{
    AudioServiceAPI::SendEvent(&owner, audio::EventType::CallLoudspeakerOn);
}

void CallRingAudio::setLaudspeakerOff()
{
    AudioServiceAPI::SendEvent(&owner, audio::EventType::CallLoudspeakerOff);
}