~aleteoryx/muditaos

ref: 428cd660ffdb064a11644abae3a34553ffcaa2d4 muditaos/module-services/service-cellular/call/CallAudio.cpp -rw-r--r-- 1.1 KiB
428cd660 — Maciej Janicki [MOS-153] Fix quotes too log copies 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
// 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);
}