blob: 993075c7022ae8262e3fd8a1a8a7f6940dc63777 [file] [log] [blame]
Phil Burk828bea52017-01-03 17:22:09 -08001/*
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 Burk5204d312017-05-04 17:16:13 -070017#ifndef ANDROID_BINDING_AUDIO_ENDPOINT_PARCELABLE_H
18#define ANDROID_BINDING_AUDIO_ENDPOINT_PARCELABLE_H
Phil Burk828bea52017-01-03 17:22:09 -080019
20#include <stdint.h>
21
22//#include <sys/mman.h>
23#include <binder/Parcel.h>
24#include <binder/Parcelable.h>
25
Phil Burk5ed503c2017-02-01 09:38:15 -080026#include "binding/AAudioServiceDefinitions.h"
Phil Burk828bea52017-01-03 17:22:09 -080027#include "binding/RingBufferParcelable.h"
28
29using android::status_t;
30using android::Parcel;
31using android::Parcelable;
32
Phil Burk5ed503c2017-02-01 09:38:15 -080033namespace aaudio {
Phil Burk828bea52017-01-03 17:22:09 -080034
35/**
36 * Container for information about the message queues plus
Phil Burk5ed503c2017-02-01 09:38:15 -080037 * general stream information needed by AAudio clients.
Phil Burk828bea52017-01-03 17:22:09 -080038 * It contains no addresses, just sizes, offsets and file descriptors for
39 * shared memory that can be passed through Binder.
40 */
41class AudioEndpointParcelable : public Parcelable {
42public:
43 AudioEndpointParcelable();
44 virtual ~AudioEndpointParcelable();
45
46 /**
47 * Add the file descriptor to the table.
48 * @return index in table or negative error
49 */
50 int32_t addFileDescriptor(int fd, int32_t sizeInBytes);
51
52 virtual status_t writeToParcel(Parcel* parcel) const override;
53
54 virtual status_t readFromParcel(const Parcel* parcel) override;
55
Phil Burk5ed503c2017-02-01 09:38:15 -080056 aaudio_result_t resolve(EndpointDescriptor *descriptor);
Phil Burk828bea52017-01-03 17:22:09 -080057
Phil Burk5ed503c2017-02-01 09:38:15 -080058 aaudio_result_t validate();
Phil Burk828bea52017-01-03 17:22:09 -080059
Phil Burkc0c70e32017-02-09 13:18:38 -080060 aaudio_result_t close();
61
Phil Burk828bea52017-01-03 17:22:09 -080062 void dump();
63
64public: // TODO add getters
65 // Set capacityInFrames to zero if Queue is unused.
66 RingBufferParcelable mUpMessageQueueParcelable; // server to client
67 RingBufferParcelable mDownMessageQueueParcelable; // to server
68 RingBufferParcelable mUpDataQueueParcelable; // eg. record, could share same queue
69 RingBufferParcelable mDownDataQueueParcelable; // eg. playback
70
71private:
72 int32_t mNumSharedMemories = 0;
73 SharedMemoryParcelable mSharedMemories[MAX_SHARED_MEMORIES];
74};
75
Phil Burk5ed503c2017-02-01 09:38:15 -080076} /* namespace aaudio */
Phil Burk828bea52017-01-03 17:22:09 -080077
Phil Burk5204d312017-05-04 17:16:13 -070078#endif //ANDROID_BINDING_AUDIO_ENDPOINT_PARCELABLE_H