Ring Daemon 16.0.0
Loading...
Searching...
No Matches
audio_player.h
Go to the documentation of this file.
1/*
2 * Copyright 2015 The Android Open Source Project
3 * Copyright 2015-2025 Savoir-faire Linux Inc.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18#pragma once
19
20#include "audio_common.h"
21#include "buf_manager.h"
22#include "noncopyable.h"
23
24#include <sys/types.h>
25#include <SLES/OpenSLES_Android.h>
26
27#include <mutex>
28
29namespace jami {
30namespace opensl {
31
33{
34 // buffer queue player interfaces
35 SLObjectItf outputMixObjectItf_;
36 SLObjectItf playerObjectItf_;
37 SLPlayItf playItf_;
38 SLAndroidSimpleBufferQueueItf playBufferQueueItf_;
39
40 jami::AudioFormat sampleInfo_;
41 AudioQueue* freeQueue_ {nullptr}; // user
42 AudioQueue* playQueue_ {nullptr}; // user
43 AudioQueue devShadowQueue_ {DEVICE_SHADOW_BUFFER_QUEUE_LEN}; // owner
44 sample_buf silentBuf_;
45
46 EngineCallback callback_ {};
47
48public:
49 explicit AudioPlayer(jami::AudioFormat sampleFormat,
50 size_t bufSize,
55
56 bool start();
57 void stop();
58 bool started() const;
59
62 void playAudioBuffers(unsigned count);
63 void registerCallback(EngineCallback cb) { callback_ = cb; }
64 size_t dbgGetDevBufCount();
65
66 std::mutex m_;
67};
68
69} // namespace opensl
70} // namespace jami
#define DEVICE_SHADOW_BUFFER_QUEUE_LEN
void processSLCallback(SLAndroidSimpleBufferQueueItf bq)
void registerCallback(EngineCallback cb)
void setBufQueue(AudioQueue *playQ, AudioQueue *freeQ)
void playAudioBuffers(unsigned count)
std::function< void()> EngineCallback
void emitSignal(Args... args)
Definition ring_signal.h:64
Simple macro to hide class' copy constructor and assignment operator.
Structure to hold sample rate and channel number associated with audio data.