1 /* 2 * Copyright 2018 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 MEGADRONE_ENGINE_H 18 #define MEGADRONE_ENGINE_H 19 20 21 #include <oboe/Oboe.h> 22 #include <vector> 23 24 #include "Synth.h" 25 #include <DefaultDataCallback.h> 26 #include <TappableAudioSource.h> 27 #include <IRestartable.h> 28 #include <DefaultErrorCallback.h> 29 30 using namespace oboe; 31 32 class MegaDroneEngine : public IRestartable { 33 34 public: 35 MegaDroneEngine(std::vector<int> cpuIds); 36 37 virtual ~MegaDroneEngine(); 38 39 void tap(bool isDown); 40 41 // from IRestartable 42 virtual void restart() override; 43 44 bool start(); 45 bool stop(); 46 47 private: 48 std::shared_ptr<AudioStream> mStream; 49 std::shared_ptr<TappableAudioSource> mAudioSource; 50 std::unique_ptr<DefaultDataCallback> mDataCallback; 51 std::unique_ptr<DefaultErrorCallback> mErrorCallback; 52 53 oboe::Result createPlaybackStream(); 54 void createCallback(std::vector<int> cpuIds); 55 }; 56 57 58 #endif //MEGADRONE_ENGINE_H 59