1828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk/*
2828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * Copyright 2016 The Android Open Source Project
3828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk *
4828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * Licensed under the Apache License, Version 2.0 (the "License");
5828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * you may not use this file except in compliance with the License.
6828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * You may obtain a copy of the License at
7828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk *
8828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk *      http://www.apache.org/licenses/LICENSE-2.0
9828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk *
10828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * Unless required by applicable law or agreed to in writing, software
11828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * distributed under the License is distributed on an "AS IS" BASIS,
12828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * See the License for the specific language governing permissions and
14828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * limitations under the License.
15828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk */
16828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
175204d315c6c6f53188f8d1414dd1b55b6c90142bPhil Burk#ifndef ANDROID_BINDING_AUDIO_ENDPOINT_PARCELABLE_H
185204d315c6c6f53188f8d1414dd1b55b6c90142bPhil Burk#define ANDROID_BINDING_AUDIO_ENDPOINT_PARCELABLE_H
19828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
20828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk#include <stdint.h>
21828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
22828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk//#include <sys/mman.h>
23e72481c5c16d401c776e0ba49b84b80223769b91Phil Burk#include <android-base/unique_fd.h>
24828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk#include <binder/Parcel.h>
25828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk#include <binder/Parcelable.h>
26828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
275ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk#include "binding/AAudioServiceDefinitions.h"
28828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk#include "binding/RingBufferParcelable.h"
29828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
30828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkusing android::status_t;
31828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkusing android::Parcel;
32828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkusing android::Parcelable;
33828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
345ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burknamespace aaudio {
35828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
36828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk/**
37828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * Container for information about the message queues plus
385ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk * general stream information needed by AAudio clients.
39828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * It contains no addresses, just sizes, offsets and file descriptors for
40828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * shared memory that can be passed through Binder.
41828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk */
42828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkclass AudioEndpointParcelable : public Parcelable {
43828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkpublic:
44828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    AudioEndpointParcelable();
45828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    virtual ~AudioEndpointParcelable();
46828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
47828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    /**
48828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk     * Add the file descriptor to the table.
49828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk     * @return index in table or negative error
50828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk     */
51e72481c5c16d401c776e0ba49b84b80223769b91Phil Burk    int32_t addFileDescriptor(const android::base::unique_fd& fd, int32_t sizeInBytes);
52828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
53828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    virtual status_t writeToParcel(Parcel* parcel) const override;
54828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
55828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    virtual status_t readFromParcel(const Parcel* parcel) override;
56828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
575ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    aaudio_result_t resolve(EndpointDescriptor *descriptor);
58828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
59c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    aaudio_result_t close();
60c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
61828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    void dump();
62828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
63828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkpublic: // TODO add getters
64828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    // Set capacityInFrames to zero if Queue is unused.
65828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RingBufferParcelable    mUpMessageQueueParcelable;   // server to client
66828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RingBufferParcelable    mDownMessageQueueParcelable; // to server
67828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RingBufferParcelable    mUpDataQueueParcelable;      // eg. record, could share same queue
68828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RingBufferParcelable    mDownDataQueueParcelable;    // eg. playback
69828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
70828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkprivate:
71a5891f427bbd57914090f3260430b82f6879ec8dPhil Burk    aaudio_result_t         validate() const;
72a5891f427bbd57914090f3260430b82f6879ec8dPhil Burk
73828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    int32_t                 mNumSharedMemories = 0;
74828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    SharedMemoryParcelable  mSharedMemories[MAX_SHARED_MEMORIES];
75828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk};
76828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
775ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk} /* namespace aaudio */
78828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
795204d315c6c6f53188f8d1414dd1b55b6c90142bPhil Burk#endif //ANDROID_BINDING_AUDIO_ENDPOINT_PARCELABLE_H
80