blob: 9bb695a664308e70dde0cd524362b131ff99dcfd [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
17#ifndef BINDING_RINGBUFFER_PARCELABLE_H
18#define BINDING_RINGBUFFER_PARCELABLE_H
19
20#include <stdint.h>
21
22#include <binder/Parcelable.h>
23
24#include "binding/OboeServiceDefinitions.h"
25#include "binding/SharedRegionParcelable.h"
26
27namespace oboe {
28
29class RingBufferParcelable : public Parcelable {
30public:
31 RingBufferParcelable();
32 virtual ~RingBufferParcelable();
33
34 // TODO This assumes that all three use the same SharedMemoryParcelable
35 void setupMemory(int32_t sharedMemoryIndex,
36 int32_t dataMemoryOffset,
37 int32_t dataSizeInBytes,
38 int32_t readCounterOffset,
39 int32_t writeCounterOffset,
40 int32_t counterSizeBytes);
41
42 void setupMemory(int32_t sharedMemoryIndex,
43 int32_t dataMemoryOffset,
44 int32_t dataSizeInBytes);
45
46 int32_t getBytesPerFrame();
47
48 void setBytesPerFrame(int32_t bytesPerFrame);
49
50 int32_t getFramesPerBurst();
51
52 void setFramesPerBurst(int32_t framesPerBurst);
53
54 int32_t getCapacityInFrames();
55
56 void setCapacityInFrames(int32_t capacityInFrames);
57
58 /**
59 * The read and write must be symmetric.
60 */
61 virtual status_t writeToParcel(Parcel* parcel) const override;
62
63 virtual status_t readFromParcel(const Parcel* parcel) override;
64
65 oboe_result_t resolve(SharedMemoryParcelable *memoryParcels, RingBufferDescriptor *descriptor);
66
67 oboe_result_t validate();
68
69 void dump();
70
71private:
72 SharedRegionParcelable mReadCounterParcelable;
73 SharedRegionParcelable mWriteCounterParcelable;
74 SharedRegionParcelable mDataParcelable;
75 int32_t mBytesPerFrame = 0; // index is in frames
76 int32_t mFramesPerBurst = 0; // for ISOCHRONOUS queues
77 int32_t mCapacityInFrames = 0; // zero if unused
78 RingbufferFlags mFlags = RingbufferFlags::NONE;
79};
80
81} /* namespace oboe */
82
83#endif //BINDING_RINGBUFFER_PARCELABLE_H