blob: e7639347e97a587bcb8e0bbb30c2d7e2a27492ff [file] [log] [blame]
Phil Burk5ed503c2017-02-01 09:38:15 -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#include <stdint.h>
18
19#include <sys/mman.h>
Phil Burka4eb0d82017-04-12 15:44:06 -070020#include <aaudio/AAudio.h>
21
Phil Burk5ed503c2017-02-01 09:38:15 -080022#include <binder/Parcel.h>
23#include <binder/Parcelable.h>
24
Phil Burk5ed503c2017-02-01 09:38:15 -080025#include "binding/AAudioStreamConfiguration.h"
26
27using android::NO_ERROR;
28using android::status_t;
29using android::Parcel;
30using android::Parcelable;
31
32using namespace aaudio;
33
34AAudioStreamConfiguration::AAudioStreamConfiguration() {}
35AAudioStreamConfiguration::~AAudioStreamConfiguration() {}
36
37status_t AAudioStreamConfiguration::writeToParcel(Parcel* parcel) const {
Phil Burkc0c70e32017-02-09 13:18:38 -080038 status_t status;
jiabin901f65d2017-07-12 17:56:35 -070039 status = parcel->writeInt32(getDeviceId());
Phil Burkc0c70e32017-02-09 13:18:38 -080040 if (status != NO_ERROR) goto error;
jiabin901f65d2017-07-12 17:56:35 -070041 status = parcel->writeInt32(getSampleRate());
Phil Burkc0c70e32017-02-09 13:18:38 -080042 if (status != NO_ERROR) goto error;
jiabin901f65d2017-07-12 17:56:35 -070043 status = parcel->writeInt32(getSamplesPerFrame());
Phil Burkc0c70e32017-02-09 13:18:38 -080044 if (status != NO_ERROR) goto error;
jiabin901f65d2017-07-12 17:56:35 -070045 status = parcel->writeInt32((int32_t) getSharingMode());
Phil Burkc0c70e32017-02-09 13:18:38 -080046 if (status != NO_ERROR) goto error;
jiabin901f65d2017-07-12 17:56:35 -070047 status = parcel->writeInt32((int32_t) getFormat());
Phil Burkc0c70e32017-02-09 13:18:38 -080048 if (status != NO_ERROR) goto error;
jiabin901f65d2017-07-12 17:56:35 -070049 status = parcel->writeInt32(getBufferCapacity());
Phil Burkc0c70e32017-02-09 13:18:38 -080050 if (status != NO_ERROR) goto error;
51 return NO_ERROR;
52error:
53 ALOGE("AAudioStreamConfiguration.writeToParcel(): write failed = %d", status);
54 return status;
Phil Burk5ed503c2017-02-01 09:38:15 -080055}
56
57status_t AAudioStreamConfiguration::readFromParcel(const Parcel* parcel) {
jiabin901f65d2017-07-12 17:56:35 -070058 int32_t value;
59 status_t status = parcel->readInt32(&value);
Phil Burkc0c70e32017-02-09 13:18:38 -080060 if (status != NO_ERROR) goto error;
jiabin901f65d2017-07-12 17:56:35 -070061 setDeviceId(value);
62 status = parcel->readInt32(&value);
Phil Burkc0c70e32017-02-09 13:18:38 -080063 if (status != NO_ERROR) goto error;
jiabin901f65d2017-07-12 17:56:35 -070064 setSampleRate(value);
65 status = parcel->readInt32(&value);
Phil Burkc0c70e32017-02-09 13:18:38 -080066 if (status != NO_ERROR) goto error;
jiabin901f65d2017-07-12 17:56:35 -070067 setSamplesPerFrame(value);
68 status = parcel->readInt32(&value);
Phil Burkc0c70e32017-02-09 13:18:38 -080069 if (status != NO_ERROR) goto error;
jiabin901f65d2017-07-12 17:56:35 -070070 setSharingMode(value);
71 status = parcel->readInt32(&value);
Phil Burkc0c70e32017-02-09 13:18:38 -080072 if (status != NO_ERROR) goto error;
jiabin901f65d2017-07-12 17:56:35 -070073 setFormat(value);
74 status = parcel->readInt32(&value);
Phil Burkc0c70e32017-02-09 13:18:38 -080075 if (status != NO_ERROR) goto error;
jiabin901f65d2017-07-12 17:56:35 -070076 setBufferCapacity(value);
Phil Burkc0c70e32017-02-09 13:18:38 -080077 return NO_ERROR;
78error:
79 ALOGE("AAudioStreamConfiguration.readFromParcel(): read failed = %d", status);
80 return status;
jiabin901f65d2017-07-12 17:56:35 -070081}