Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 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 | |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_BINDING_AUDIO_ENDPOINT_PARCELABLE_H |
| 18 | #define ANDROID_BINDING_AUDIO_ENDPOINT_PARCELABLE_H |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 19 | |
| 20 | #include <stdint.h> |
| 21 | |
| 22 | //#include <sys/mman.h> |
Phil Burk | e72481c | 2017-08-08 13:20:45 -0700 | [diff] [blame^] | 23 | #include <android-base/unique_fd.h> |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 24 | #include <binder/Parcel.h> |
| 25 | #include <binder/Parcelable.h> |
| 26 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 27 | #include "binding/AAudioServiceDefinitions.h" |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 28 | #include "binding/RingBufferParcelable.h" |
| 29 | |
| 30 | using android::status_t; |
| 31 | using android::Parcel; |
| 32 | using android::Parcelable; |
| 33 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 34 | namespace aaudio { |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 35 | |
| 36 | /** |
| 37 | * Container for information about the message queues plus |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 38 | * general stream information needed by AAudio clients. |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 39 | * It contains no addresses, just sizes, offsets and file descriptors for |
| 40 | * shared memory that can be passed through Binder. |
| 41 | */ |
| 42 | class AudioEndpointParcelable : public Parcelable { |
| 43 | public: |
| 44 | AudioEndpointParcelable(); |
| 45 | virtual ~AudioEndpointParcelable(); |
| 46 | |
| 47 | /** |
| 48 | * Add the file descriptor to the table. |
| 49 | * @return index in table or negative error |
| 50 | */ |
Phil Burk | e72481c | 2017-08-08 13:20:45 -0700 | [diff] [blame^] | 51 | int32_t addFileDescriptor(const android::base::unique_fd& fd, int32_t sizeInBytes); |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 52 | |
| 53 | virtual status_t writeToParcel(Parcel* parcel) const override; |
| 54 | |
| 55 | virtual status_t readFromParcel(const Parcel* parcel) override; |
| 56 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 57 | aaudio_result_t resolve(EndpointDescriptor *descriptor); |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 58 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 59 | aaudio_result_t validate(); |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 60 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 61 | aaudio_result_t close(); |
| 62 | |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 63 | void dump(); |
| 64 | |
| 65 | public: // TODO add getters |
| 66 | // Set capacityInFrames to zero if Queue is unused. |
| 67 | RingBufferParcelable mUpMessageQueueParcelable; // server to client |
| 68 | RingBufferParcelable mDownMessageQueueParcelable; // to server |
| 69 | RingBufferParcelable mUpDataQueueParcelable; // eg. record, could share same queue |
| 70 | RingBufferParcelable mDownDataQueueParcelable; // eg. playback |
| 71 | |
| 72 | private: |
| 73 | int32_t mNumSharedMemories = 0; |
| 74 | SharedMemoryParcelable mSharedMemories[MAX_SHARED_MEMORIES]; |
| 75 | }; |
| 76 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 77 | } /* namespace aaudio */ |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 78 | |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 79 | #endif //ANDROID_BINDING_AUDIO_ENDPOINT_PARCELABLE_H |