Phil Burk | 2355edb | 2016-12-26 13:54:02 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 OBOE_OBOE_AUDIO_SERVICE_H |
| 18 | #define OBOE_OBOE_AUDIO_SERVICE_H |
| 19 | |
| 20 | #include <time.h> |
| 21 | #include <pthread.h> |
| 22 | |
| 23 | #include <binder/BinderService.h> |
| 24 | |
| 25 | #include <oboe/OboeDefinitions.h> |
| 26 | #include <oboe/OboeAudio.h> |
| 27 | #include "HandleTracker.h" |
| 28 | #include "IOboeAudioService.h" |
| 29 | #include "OboeService.h" |
| 30 | #include "OboeServiceStreamBase.h" |
| 31 | |
| 32 | using namespace android; |
| 33 | namespace oboe { |
| 34 | |
| 35 | class OboeAudioService : |
| 36 | public BinderService<OboeAudioService>, |
| 37 | public BnOboeAudioService |
| 38 | { |
| 39 | friend class BinderService<OboeAudioService>; // for OboeAudioService() |
| 40 | public: |
| 41 | // TODO why does this fail? static const char* getServiceName() ANDROID_API { return "media.audio_oboe"; } |
| 42 | static const char* getServiceName() { return "media.audio_oboe"; } |
| 43 | |
| 44 | virtual oboe_handle_t openStream(OboeStreamRequest &request, |
| 45 | OboeStreamConfiguration &configuration); |
| 46 | |
| 47 | virtual oboe_result_t closeStream(oboe_handle_t streamHandle); |
| 48 | |
| 49 | virtual oboe_result_t getStreamDescription( |
| 50 | oboe_handle_t streamHandle, |
| 51 | AudioEndpointParcelable &parcelable); |
| 52 | |
| 53 | virtual oboe_result_t startStream(oboe_handle_t streamHandle); |
| 54 | |
| 55 | virtual oboe_result_t pauseStream(oboe_handle_t streamHandle); |
| 56 | |
| 57 | virtual oboe_result_t flushStream(oboe_handle_t streamHandle); |
| 58 | |
| 59 | virtual oboe_result_t registerAudioThread(oboe_handle_t streamHandle, |
| 60 | pid_t pid, oboe_nanoseconds_t periodNanoseconds) ; |
| 61 | |
| 62 | virtual oboe_result_t unregisterAudioThread(oboe_handle_t streamHandle, pid_t pid); |
| 63 | |
| 64 | virtual void tickle(); |
| 65 | |
| 66 | private: |
| 67 | |
| 68 | OboeServiceStreamBase *convertHandleToServiceStream(oboe_handle_t streamHandle) const; |
| 69 | |
| 70 | HandleTracker mHandleTracker; |
| 71 | oboe_handle_t mLatestHandle = OBOE_ERROR_INVALID_HANDLE; // TODO until we have service threads |
| 72 | }; |
| 73 | |
| 74 | } /* namespace oboe */ |
| 75 | |
| 76 | #endif //OBOE_OBOE_AUDIO_SERVICE_H |