1 /* 2 * Copyright 2020 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 MEGA_COMMON_OBOESTREAM_H 18 #define MEGA_COMMON_OBOESTREAM_H 19 20 #include <cstdint> 21 #include <mutex> 22 23 #include <StreamBase.h> 24 25 class OboeStream: public StreamBase { 26 public: 27 static Result OboeErrorToMegaAudioError(oboe::Result oboeError); 28 29 virtual Result teardownStream() override; 30 31 virtual Result startStream() override; 32 virtual Result stopStream() override; 33 34 StreamBase::Result getTimeStamp(oboe::FrameTimestamp* timeStamp); 35 36 protected: OboeStream(int32_t subtype)37 OboeStream(int32_t subtype) : mSubtype(subtype), mStreamStarted(false) {} 38 39 // determine native back-end to use. 40 // either SUB_TYPE_OBOE_DEFAULT, SUB_TYPE_OBOE_AAUDIO or SUB_TYPE_OBOE_OPENSL_ES 41 int32_t mSubtype; 42 43 // Oboe Audio Stream 44 std::shared_ptr<oboe::AudioStream> mAudioStream; 45 bool mStreamStarted; 46 47 std::mutex mStreamLock; 48 49 Result teardownStream_l(); 50 }; 51 52 #endif //MEGA_COMMON_OBOESTREAM_H 53