1 //
2 //  Copyright (C) 2017 Google, Inc.
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 "android/bluetooth/bluetooth_a2dp_codec_config.h"
18 
19 #include <utils/String16.h>
20 #include <utils/String8.h>
21 
22 using android::OK;
23 using android::String16;
24 using android::String8;
25 
26 namespace android {
27 namespace bluetooth {
28 
writeToParcel(Parcel * parcel) const29 status_t BluetoothA2dpCodecConfig::writeToParcel(Parcel* parcel) const {
30   status_t status = parcel->writeInt32(codec_type_);
31   if (status != OK) return status;
32 
33   status = parcel->writeInt32(codec_priority_);
34   if (status != OK) return status;
35 
36   status = parcel->writeInt32(sample_rate_);
37   if (status != OK) return status;
38 
39   status = parcel->writeInt32(bits_per_sample_);
40   if (status != OK) return status;
41 
42   status = parcel->writeInt32(channel_mode_);
43   if (status != OK) return status;
44 
45   status = parcel->writeInt64(codec_specific_1_);
46   if (status != OK) return status;
47 
48   status = parcel->writeInt64(codec_specific_2_);
49   if (status != OK) return status;
50 
51   status = parcel->writeInt64(codec_specific_3_);
52   if (status != OK) return status;
53 
54   status = parcel->writeInt64(codec_specific_4_);
55   if (status != OK) return status;
56 
57   return status;
58 }
59 
readFromParcel(const Parcel * parcel)60 status_t BluetoothA2dpCodecConfig::readFromParcel(const Parcel* parcel) {
61   int32_t tmp;
62   status_t status = parcel->readInt32(&tmp);
63   if (status != OK) return status;
64   codec_type_ = tmp;
65 
66   status = parcel->readInt32(&tmp);
67   if (status != OK) return status;
68   codec_priority_ = tmp;
69 
70   status = parcel->readInt32(&tmp);
71   if (status != OK) return status;
72   sample_rate_ = tmp;
73 
74   status = parcel->readInt32(&tmp);
75   if (status != OK) return status;
76   bits_per_sample_ = tmp;
77 
78   status = parcel->readInt32(&tmp);
79   if (status != OK) return status;
80   channel_mode_ = tmp;
81 
82   int64_t tmp64;
83   status = parcel->readInt64(&tmp64);
84   if (status != OK) return status;
85   codec_specific_1_ = tmp64;
86 
87   status = parcel->readInt64(&tmp64);
88   if (status != OK) return status;
89   codec_specific_2_ = tmp64;
90 
91   status = parcel->readInt64(&tmp64);
92   if (status != OK) return status;
93   codec_specific_3_ = tmp64;
94 
95   status = parcel->readInt64(&tmp64);
96   if (status != OK) return status;
97   codec_specific_4_ = tmp64;
98 
99   return status;
100 }
101 
102 }  // namespace bluetooth
103 }  // namespace android
104