• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 "oboe/Oboe.h"
22 #include "EngineOpenSLES.h"
23 #include "AudioStreamOpenSLES.h"
24 
25 namespace oboe {
26 
27 /**
28  * INTERNAL USE ONLY
29  */
30 class AudioOutputStreamOpenSLES : public AudioStreamOpenSLES {
31 public:
32     AudioOutputStreamOpenSLES();
33     explicit AudioOutputStreamOpenSLES(const AudioStreamBuilder &builder);
34 
35     virtual ~AudioOutputStreamOpenSLES() = default;
36 
37     Result open() override;
38     Result close() override;
39 
40     Result requestStart() override;
41     Result requestPause() override;
42     Result requestFlush() override;
43     Result requestStop() override;
44 
45 protected:
46     Result requestPause_l();
47 
48     void setFramesRead(int64_t framesRead);
49 
50     Result updateServiceFrameCounter() override;
51 
52     void updateFramesRead() override;
53 
54 private:
55 
56     SLuint32 channelCountToChannelMask(int chanCount) const;
57 
58     Result onAfterDestroy() override;
59 
60     Result requestFlush_l();
61 
62     Result requestStop_l();
63 
64     /**
65      * Set OpenSL ES PLAYSTATE.
66      *
67      * @param newState SL_PLAYSTATE_PAUSED, SL_PLAYSTATE_PLAYING, SL_PLAYSTATE_STOPPED
68      * @return
69      */
70     Result setPlayState_l(SLuint32 newState);
71 
72     SLPlayItf      mPlayInterface = nullptr;
73 
74 };
75 
76 } // namespace oboe
77 
78 #endif //AUDIO_OUTPUT_STREAM_OPENSL_ES_H_
79