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_SERVICE_STREAM_FAKE_HAL_H |
| 18 | #define OBOE_OBOE_SERVICE_STREAM_FAKE_HAL_H |
| 19 | |
| 20 | #include "OboeService.h" |
| 21 | #include "OboeServiceStreamBase.h" |
| 22 | #include "FakeAudioHal.h" |
| 23 | #include "MonotonicCounter.h" |
| 24 | #include "AudioEndpointParcelable.h" |
| 25 | |
| 26 | namespace oboe { |
| 27 | |
| 28 | class OboeServiceStreamFakeHal : public OboeServiceStreamBase { |
| 29 | |
| 30 | public: |
| 31 | OboeServiceStreamFakeHal(); |
| 32 | virtual ~OboeServiceStreamFakeHal(); |
| 33 | |
| 34 | virtual oboe_result_t getDescription(AudioEndpointParcelable &parcelable) override; |
| 35 | |
| 36 | virtual oboe_result_t open(oboe::OboeStreamRequest &request, |
| 37 | oboe::OboeStreamConfiguration &configuration) override; |
| 38 | |
| 39 | /** |
| 40 | * Start the flow of data. |
| 41 | */ |
| 42 | virtual oboe_result_t start() override; |
| 43 | |
| 44 | /** |
| 45 | * Stop the flow of data such that start() can resume with loss of data. |
| 46 | */ |
| 47 | virtual oboe_result_t pause() override; |
| 48 | |
| 49 | /** |
| 50 | * Discard any data held by the underlying HAL or Service. |
| 51 | */ |
| 52 | virtual oboe_result_t flush() override; |
| 53 | |
| 54 | virtual oboe_result_t close() override; |
| 55 | |
| 56 | virtual void tickle() override; |
| 57 | |
| 58 | protected: |
| 59 | |
| 60 | void sendCurrentTimestamp(); |
| 61 | |
| 62 | private: |
| 63 | fake_hal_stream_ptr mStreamId; // Move to HAL |
| 64 | |
| 65 | MonotonicCounter mFramesWritten; |
| 66 | MonotonicCounter mFramesRead; |
| 67 | int mHalFileDescriptor = -1; |
| 68 | int mPreviousFrameCounter = 0; // from HAL |
| 69 | |
| 70 | oboe_stream_state_t mState = OBOE_STREAM_STATE_UNINITIALIZED; |
| 71 | }; |
| 72 | |
| 73 | } // namespace oboe |
| 74 | |
| 75 | #endif //OBOE_OBOE_SERVICE_STREAM_FAKE_HAL_H |