blob: 1fc77e512edf475fc04ff93ab86d10cf65cbfe46 [file] [log] [blame]
Phil Burk420715b2017-12-14 12:26:38 -08001/*
2 * Copyright 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef OBOE_OUTPUT_MIXER_OPENSLES_H
18#define OBOE_OUTPUT_MIXER_OPENSLES_H
19
20#include <atomic>
21#include <mutex>
22
23#include <SLES/OpenSLES.h>
24#include <SLES/OpenSLES_Android.h>
25
26namespace oboe {
27
28/**
29 * INTERNAL USE ONLY
30 */
31
32class OutputMixerOpenSL {
33public:
Phil Burk7040a9d2017-12-15 10:54:38 -080034 static OutputMixerOpenSL &getInstance();
Phil Burk420715b2017-12-14 12:26:38 -080035
36 SLresult open();
37
38 void close();
39
40 SLresult createAudioPlayer(SLObjectItf *objectItf,
41 SLDataSource *audioSource);
42
43private:
Phil Burk7040a9d2017-12-15 10:54:38 -080044 // Make this a safe Singleton
45 OutputMixerOpenSL()= default;
46 ~OutputMixerOpenSL()= default;
47 OutputMixerOpenSL(const OutputMixerOpenSL&)= delete;
48 OutputMixerOpenSL& operator=(const OutputMixerOpenSL&)= delete;
49
Phil Burk420715b2017-12-14 12:26:38 -080050 std::mutex mLock;
Phil Burk7040a9d2017-12-15 10:54:38 -080051 int32_t mOpenCount = 0;
52
Phil Burk420715b2017-12-14 12:26:38 -080053 SLObjectItf mOutputMixObject = 0;
54};
55
56} // namespace oboe
57
58#endif //OBOE_OUTPUT_MIXER_OPENSLES_H