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 17 #include <stdint.h> 18 19 #include <sys/mman.h> 20 #include <aaudio/AAudio.h> 21 22 #include <binder/Parcel.h> 23 #include <binder/Parcelable.h> 24 25 #include "binding/AAudioStreamConfiguration.h" 26 27 using android::NO_ERROR; 28 using android::status_t; 29 using android::Parcel; 30 using android::Parcelable; 31 32 using namespace aaudio; 33 AAudioStreamConfiguration()34AAudioStreamConfiguration::AAudioStreamConfiguration() {} ~AAudioStreamConfiguration()35AAudioStreamConfiguration::~AAudioStreamConfiguration() {} 36 writeToParcel(Parcel * parcel) const37status_t AAudioStreamConfiguration::writeToParcel(Parcel* parcel) const { 38 status_t status; 39 status = parcel->writeInt32(getDeviceId()); 40 if (status != NO_ERROR) goto error; 41 status = parcel->writeInt32(getSampleRate()); 42 if (status != NO_ERROR) goto error; 43 status = parcel->writeInt32(getSamplesPerFrame()); 44 if (status != NO_ERROR) goto error; 45 status = parcel->writeInt32((int32_t) getSharingMode()); 46 if (status != NO_ERROR) goto error; 47 status = parcel->writeInt32((int32_t) getFormat()); 48 if (status != NO_ERROR) goto error; 49 status = parcel->writeInt32((int32_t) getDirection()); 50 if (status != NO_ERROR) goto error; 51 status = parcel->writeInt32(getBufferCapacity()); 52 if (status != NO_ERROR) goto error; 53 return NO_ERROR; 54 error: 55 ALOGE("AAudioStreamConfiguration.writeToParcel(): write failed = %d", status); 56 return status; 57 } 58 readFromParcel(const Parcel * parcel)59status_t AAudioStreamConfiguration::readFromParcel(const Parcel* parcel) { 60 int32_t value; 61 status_t status = parcel->readInt32(&value); 62 if (status != NO_ERROR) goto error; 63 setDeviceId(value); 64 status = parcel->readInt32(&value); 65 if (status != NO_ERROR) goto error; 66 setSampleRate(value); 67 status = parcel->readInt32(&value); 68 if (status != NO_ERROR) goto error; 69 setSamplesPerFrame(value); 70 status = parcel->readInt32(&value); 71 if (status != NO_ERROR) goto error; 72 setSharingMode(value); 73 status = parcel->readInt32(&value); 74 if (status != NO_ERROR) goto error; 75 setFormat(value); 76 status = parcel->readInt32(&value); 77 if (status != NO_ERROR) goto error; 78 setDirection((aaudio_direction_t) value); 79 status = parcel->readInt32(&value); 80 if (status != NO_ERROR) goto error; 81 setBufferCapacity(value); 82 return NO_ERROR; 83 error: 84 ALOGE("AAudioStreamConfiguration.readFromParcel(): read failed = %d", status); 85 return status; 86 } 87