blob: 67cba5fa38181666fffa965bfa5e958637aef875 [file] [log] [blame]
Phil Burk64c55f42017-12-13 18:36:53 -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 AUDIO_OUTPUT_STREAM_OPENSL_ES_H_
18#define AUDIO_OUTPUT_STREAM_OPENSL_ES_H_
19
20
21#include <SLES/OpenSLES.h>
22#include <SLES/OpenSLES_Android.h>
23
24#include "oboe/Oboe.h"
25#include "AudioStreamOpenSLES.h"
26
27namespace oboe {
28
Phil Burk420715b2017-12-14 12:26:38 -080029/**
30 * INTERNAL USE ONLY
31 */
Phil Burk64c55f42017-12-13 18:36:53 -080032class AudioOutputStreamOpenSLES : public AudioStreamOpenSLES {
33public:
34 AudioOutputStreamOpenSLES();
35 explicit AudioOutputStreamOpenSLES(const AudioStreamBuilder &builder);
36
37 virtual ~AudioOutputStreamOpenSLES();
Phil Burk9a147a12017-12-13 20:23:25 -080038
39 Result open() override;
40 Result close() override;
41
42 Result requestStart() override;
43 Result requestPause() override;
44 Result requestFlush() override;
45 Result requestStop() override;
46
47 Result waitForStateChange(StreamState currentState,
48 StreamState *nextState,
49 int64_t timeoutNanoseconds) override;
50
Phil Burk9b1c2ce2017-12-15 11:47:56 -080051 int chanCountToChanMask(int chanCount);
Phil Burk9a147a12017-12-13 20:23:25 -080052
Phil Burkf2a70532018-05-09 18:36:21 -070053 int64_t getFramesRead() const override;
54
55protected:
56
57 void setFramesRead(int64_t framesRead);
58
59 Result updateServiceFrameCounter() override;
60
Phil Burk64c55f42017-12-13 18:36:53 -080061private:
Phil Burk9a147a12017-12-13 20:23:25 -080062
63 /**
64 * Set OpenSL ES PLAYSTATE.
65 *
66 * @param newState SL_PLAYSTATE_PAUSED, SL_PLAYSTATE_PLAYING, SL_PLAYSTATE_STOPPED
67 * @return
68 */
69 Result setPlayState(SLuint32 newState);
70
Phil Burk6d952912017-12-14 10:10:00 -080071 SLPlayItf mPlayInterface = nullptr;
72
Phil Burk64c55f42017-12-13 18:36:53 -080073};
74
75} // namespace oboe
76
77#endif //AUDIO_OUTPUT_STREAM_OPENSL_ES_H_