Phil Burk | 64c55f4 | 2017-12-13 18:36:53 -0800 | [diff] [blame] | 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_INPUT_STREAM_OPENSL_ES_H_ |
| 18 | #define AUDIO_INPUT_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 | |
| 27 | namespace oboe { |
| 28 | |
Phil Burk | 420715b | 2017-12-14 12:26:38 -0800 | [diff] [blame] | 29 | /** |
| 30 | * INTERNAL USE ONLY |
| 31 | */ |
| 32 | |
Phil Burk | 64c55f4 | 2017-12-13 18:36:53 -0800 | [diff] [blame] | 33 | class AudioInputStreamOpenSLES : public AudioStreamOpenSLES { |
| 34 | public: |
| 35 | AudioInputStreamOpenSLES(); |
| 36 | explicit AudioInputStreamOpenSLES(const AudioStreamBuilder &builder); |
| 37 | |
| 38 | virtual ~AudioInputStreamOpenSLES(); |
Phil Burk | 9a147a1 | 2017-12-13 20:23:25 -0800 | [diff] [blame] | 39 | |
| 40 | Result open() override; |
| 41 | Result close() override; |
| 42 | |
| 43 | Result requestStart() override; |
| 44 | Result requestPause() override; |
| 45 | Result requestFlush() override; |
| 46 | Result requestStop() override; |
| 47 | |
| 48 | Result waitForStateChange(StreamState currentState, |
| 49 | StreamState *nextState, |
| 50 | int64_t timeoutNanoseconds) override; |
| 51 | |
Phil Burk | 9b1c2ce | 2017-12-15 11:47:56 -0800 | [diff] [blame] | 52 | int chanCountToChanMask(int chanCount); |
| 53 | |
Phil Burk | f2a7053 | 2018-05-09 18:36:21 -0700 | [diff] [blame] | 54 | int64_t getFramesWritten() const override; |
| 55 | |
| 56 | protected: |
| 57 | |
| 58 | Result updateServiceFrameCounter() override; |
| 59 | |
Phil Burk | 6d95291 | 2017-12-14 10:10:00 -0800 | [diff] [blame] | 60 | private: |
Phil Burk | 9a147a1 | 2017-12-13 20:23:25 -0800 | [diff] [blame] | 61 | |
Phil Burk | 6d95291 | 2017-12-14 10:10:00 -0800 | [diff] [blame] | 62 | Result setRecordState(SLuint32 newState); |
| 63 | |
Phil Burk | 0cb67a6 | 2018-03-26 09:42:22 -0700 | [diff] [blame] | 64 | SLRecordItf mRecordInterface = nullptr; |
Phil Burk | 64c55f4 | 2017-12-13 18:36:53 -0800 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | } // namespace oboe |
| 68 | |
| 69 | #endif //AUDIO_INPUT_STREAM_OPENSL_ES_H_ |