| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2010 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 | #include <sys/types.h> | 
|  | 19 |  | 
|  | 20 | #include <utils/Errors.h> | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 21 | #include <utils/NativeHandle.h> | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 22 | #include <utils/RefBase.h> | 
| Brian Anderson | 175a720 | 2016-10-10 16:52:56 -0700 | [diff] [blame] | 23 | #include <utils/String8.h> | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 24 | #include <utils/Timers.h> | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 25 | #include <utils/Vector.h> | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 26 |  | 
|  | 27 | #include <binder/Parcel.h> | 
|  | 28 | #include <binder/IInterface.h> | 
|  | 29 |  | 
| Jiwen 'Steve' Cai | c90a77f | 2018-01-14 15:42:29 -0800 | [diff] [blame] | 30 | #include <gui/BufferHubProducer.h> | 
| Chia-I Wu | c79a296 | 2017-05-15 10:32:27 -0700 | [diff] [blame] | 31 | #include <gui/BufferQueueDefs.h> | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 32 | #include <gui/IGraphicBufferProducer.h> | 
| Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 33 | #include <gui/IProducerListener.h> | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 34 |  | 
| Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 35 | #include <gui/bufferqueue/1.0/H2BGraphicBufferProducer.h> | 
|  | 36 |  | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 37 | namespace android { | 
|  | 38 | // ---------------------------------------------------------------------------- | 
|  | 39 |  | 
| Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 40 | using ::android::hardware::graphics::bufferqueue::V1_0::utils:: | 
|  | 41 | H2BGraphicBufferProducer; | 
|  | 42 |  | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 43 | enum { | 
|  | 44 | REQUEST_BUFFER = IBinder::FIRST_CALL_TRANSACTION, | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 45 | DEQUEUE_BUFFER, | 
| Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 46 | DETACH_BUFFER, | 
| Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 47 | DETACH_NEXT_BUFFER, | 
| Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 48 | ATTACH_BUFFER, | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 49 | QUEUE_BUFFER, | 
|  | 50 | CANCEL_BUFFER, | 
| Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 51 | QUERY, | 
| Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 52 | CONNECT, | 
|  | 53 | DISCONNECT, | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 54 | SET_SIDEBAND_STREAM, | 
| Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 55 | ALLOCATE_BUFFERS, | 
| Dan Stoza | 9de7293 | 2015-04-16 17:28:43 -0700 | [diff] [blame] | 56 | ALLOW_ALLOCATION, | 
| Dan Stoza | 812ed06 | 2015-06-02 15:45:22 -0700 | [diff] [blame] | 57 | SET_GENERATION_NUMBER, | 
| Dan Stoza | c6f30bd | 2015-06-08 09:32:50 -0700 | [diff] [blame] | 58 | GET_CONSUMER_NAME, | 
| Pablo Ceballos | fa45535 | 2015-08-12 17:47:47 -0700 | [diff] [blame] | 59 | SET_MAX_DEQUEUED_BUFFER_COUNT, | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 60 | SET_ASYNC_MODE, | 
| Pablo Ceballos | 3559fbf | 2016-03-17 15:50:23 -0700 | [diff] [blame] | 61 | SET_SHARED_BUFFER_MODE, | 
| Pablo Ceballos | ff95aab | 2016-01-13 17:09:58 -0800 | [diff] [blame] | 62 | SET_AUTO_REFRESH, | 
| Dan Stoza | 127fc63 | 2015-06-30 13:43:32 -0700 | [diff] [blame] | 63 | SET_DEQUEUE_TIMEOUT, | 
| Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 64 | GET_LAST_QUEUED_BUFFER, | 
| Pablo Ceballos | fc35258 | 2016-06-30 17:22:20 -0700 | [diff] [blame] | 65 | GET_FRAME_TIMESTAMPS, | 
| Chia-I Wu | e2786ea | 2017-08-07 10:36:08 -0700 | [diff] [blame] | 66 | GET_UNIQUE_ID, | 
|  | 67 | GET_CONSUMER_USAGE, | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 68 | }; | 
|  | 69 |  | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 70 | class BpGraphicBufferProducer : public BpInterface<IGraphicBufferProducer> | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 71 | { | 
|  | 72 | public: | 
| Chih-Hung Hsieh | e2347b7 | 2016-04-25 15:41:05 -0700 | [diff] [blame] | 73 | explicit BpGraphicBufferProducer(const sp<IBinder>& impl) | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 74 | : BpInterface<IGraphicBufferProducer>(impl) | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 75 | { | 
|  | 76 | } | 
|  | 77 |  | 
| Yi Kong | ca03851 | 2017-05-02 16:55:24 -0700 | [diff] [blame] | 78 | ~BpGraphicBufferProducer() override; | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 79 |  | 
| Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 80 | virtual status_t requestBuffer(int bufferIdx, sp<GraphicBuffer>* buf) { | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 81 | Parcel data, reply; | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 82 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 83 | data.writeInt32(bufferIdx); | 
| Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 84 | status_t result =remote()->transact(REQUEST_BUFFER, data, &reply); | 
|  | 85 | if (result != NO_ERROR) { | 
|  | 86 | return result; | 
|  | 87 | } | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 88 | bool nonNull = reply.readInt32(); | 
|  | 89 | if (nonNull) { | 
| Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 90 | *buf = new GraphicBuffer(); | 
| Lingyun Zhu | 2aff702 | 2012-11-20 19:24:35 +0800 | [diff] [blame] | 91 | result = reply.read(**buf); | 
|  | 92 | if(result != NO_ERROR) { | 
|  | 93 | (*buf).clear(); | 
|  | 94 | return result; | 
|  | 95 | } | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 96 | } | 
| Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 97 | result = reply.readInt32(); | 
| Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 98 | return result; | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 99 | } | 
|  | 100 |  | 
| Pablo Ceballos | fa45535 | 2015-08-12 17:47:47 -0700 | [diff] [blame] | 101 | virtual status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers) { | 
|  | 102 | Parcel data, reply; | 
|  | 103 | data.writeInterfaceToken( | 
|  | 104 | IGraphicBufferProducer::getInterfaceDescriptor()); | 
|  | 105 | data.writeInt32(maxDequeuedBuffers); | 
|  | 106 | status_t result = remote()->transact(SET_MAX_DEQUEUED_BUFFER_COUNT, | 
|  | 107 | data, &reply); | 
|  | 108 | if (result != NO_ERROR) { | 
|  | 109 | return result; | 
|  | 110 | } | 
|  | 111 | result = reply.readInt32(); | 
|  | 112 | return result; | 
|  | 113 | } | 
|  | 114 |  | 
|  | 115 | virtual status_t setAsyncMode(bool async) { | 
|  | 116 | Parcel data, reply; | 
|  | 117 | data.writeInterfaceToken( | 
|  | 118 | IGraphicBufferProducer::getInterfaceDescriptor()); | 
|  | 119 | data.writeInt32(async); | 
|  | 120 | status_t result = remote()->transact(SET_ASYNC_MODE, | 
|  | 121 | data, &reply); | 
|  | 122 | if (result != NO_ERROR) { | 
|  | 123 | return result; | 
|  | 124 | } | 
|  | 125 | result = reply.readInt32(); | 
|  | 126 | return result; | 
|  | 127 | } | 
|  | 128 |  | 
| Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 129 | virtual status_t dequeueBuffer(int* buf, sp<Fence>* fence, uint32_t width, uint32_t height, | 
|  | 130 | PixelFormat format, uint64_t usage, uint64_t* outBufferAge, | 
|  | 131 | FrameEventHistoryDelta* outTimestamps) { | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 132 | Parcel data, reply; | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 133 | bool getFrameTimestamps = (outTimestamps != nullptr); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 134 |  | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 135 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 136 | data.writeUint32(width); | 
|  | 137 | data.writeUint32(height); | 
|  | 138 | data.writeInt32(static_cast<int32_t>(format)); | 
| Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 139 | data.writeUint64(usage); | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 140 | data.writeBool(getFrameTimestamps); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 141 |  | 
| Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 142 | status_t result = remote()->transact(DEQUEUE_BUFFER, data, &reply); | 
|  | 143 | if (result != NO_ERROR) { | 
|  | 144 | return result; | 
|  | 145 | } | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 146 |  | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 147 | *buf = reply.readInt32(); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 148 | *fence = new Fence(); | 
|  | 149 | result = reply.read(**fence); | 
|  | 150 | if (result != NO_ERROR) { | 
|  | 151 | fence->clear(); | 
|  | 152 | return result; | 
| Jesse Hall | f785754 | 2012-06-14 15:26:33 -0700 | [diff] [blame] | 153 | } | 
| Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 154 | if (outBufferAge) { | 
|  | 155 | result = reply.readUint64(outBufferAge); | 
|  | 156 | } else { | 
|  | 157 | // Read the value even if outBufferAge is nullptr: | 
|  | 158 | uint64_t bufferAge; | 
|  | 159 | result = reply.readUint64(&bufferAge); | 
|  | 160 | } | 
|  | 161 | if (result != NO_ERROR) { | 
|  | 162 | ALOGE("IGBP::dequeueBuffer failed to read buffer age: %d", result); | 
|  | 163 | return result; | 
|  | 164 | } | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 165 | if (getFrameTimestamps) { | 
|  | 166 | result = reply.read(*outTimestamps); | 
|  | 167 | if (result != NO_ERROR) { | 
|  | 168 | ALOGE("IGBP::dequeueBuffer failed to read timestamps: %d", | 
|  | 169 | result); | 
|  | 170 | return result; | 
|  | 171 | } | 
|  | 172 | } | 
| Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 173 | result = reply.readInt32(); | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 174 | return result; | 
|  | 175 | } | 
|  | 176 |  | 
| Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 177 | virtual status_t detachBuffer(int slot) { | 
|  | 178 | Parcel data, reply; | 
|  | 179 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
|  | 180 | data.writeInt32(slot); | 
|  | 181 | status_t result = remote()->transact(DETACH_BUFFER, data, &reply); | 
|  | 182 | if (result != NO_ERROR) { | 
|  | 183 | return result; | 
|  | 184 | } | 
|  | 185 | result = reply.readInt32(); | 
|  | 186 | return result; | 
|  | 187 | } | 
|  | 188 |  | 
| Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 189 | virtual status_t detachNextBuffer(sp<GraphicBuffer>* outBuffer, | 
|  | 190 | sp<Fence>* outFence) { | 
|  | 191 | if (outBuffer == NULL) { | 
|  | 192 | ALOGE("detachNextBuffer: outBuffer must not be NULL"); | 
|  | 193 | return BAD_VALUE; | 
|  | 194 | } else if (outFence == NULL) { | 
|  | 195 | ALOGE("detachNextBuffer: outFence must not be NULL"); | 
|  | 196 | return BAD_VALUE; | 
|  | 197 | } | 
|  | 198 | Parcel data, reply; | 
|  | 199 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
|  | 200 | status_t result = remote()->transact(DETACH_NEXT_BUFFER, data, &reply); | 
|  | 201 | if (result != NO_ERROR) { | 
|  | 202 | return result; | 
|  | 203 | } | 
|  | 204 | result = reply.readInt32(); | 
|  | 205 | if (result == NO_ERROR) { | 
|  | 206 | bool nonNull = reply.readInt32(); | 
|  | 207 | if (nonNull) { | 
|  | 208 | *outBuffer = new GraphicBuffer; | 
| Pablo Ceballos | 70636b3 | 2016-07-06 15:24:54 -0700 | [diff] [blame] | 209 | result = reply.read(**outBuffer); | 
|  | 210 | if (result != NO_ERROR) { | 
|  | 211 | outBuffer->clear(); | 
|  | 212 | return result; | 
|  | 213 | } | 
| Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 214 | } | 
|  | 215 | nonNull = reply.readInt32(); | 
|  | 216 | if (nonNull) { | 
|  | 217 | *outFence = new Fence; | 
| Pablo Ceballos | 70636b3 | 2016-07-06 15:24:54 -0700 | [diff] [blame] | 218 | result = reply.read(**outFence); | 
|  | 219 | if (result != NO_ERROR) { | 
|  | 220 | outBuffer->clear(); | 
|  | 221 | outFence->clear(); | 
|  | 222 | return result; | 
|  | 223 | } | 
| Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 224 | } | 
|  | 225 | } | 
|  | 226 | return result; | 
|  | 227 | } | 
|  | 228 |  | 
| Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 229 | virtual status_t attachBuffer(int* slot, const sp<GraphicBuffer>& buffer) { | 
|  | 230 | Parcel data, reply; | 
|  | 231 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
|  | 232 | data.write(*buffer.get()); | 
|  | 233 | status_t result = remote()->transact(ATTACH_BUFFER, data, &reply); | 
|  | 234 | if (result != NO_ERROR) { | 
|  | 235 | return result; | 
|  | 236 | } | 
| Chia-I Wu | c79a296 | 2017-05-15 10:32:27 -0700 | [diff] [blame] | 237 |  | 
| Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 238 | *slot = reply.readInt32(); | 
|  | 239 | result = reply.readInt32(); | 
| Chia-I Wu | c79a296 | 2017-05-15 10:32:27 -0700 | [diff] [blame] | 240 | if (result == NO_ERROR && | 
|  | 241 | (*slot < 0 || *slot >= BufferQueueDefs::NUM_BUFFER_SLOTS)) { | 
|  | 242 | ALOGE("attachBuffer returned invalid slot %d", *slot); | 
|  | 243 | android_errorWriteLog(0x534e4554, "37478824"); | 
|  | 244 | return UNKNOWN_ERROR; | 
|  | 245 | } | 
|  | 246 |  | 
| Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 247 | return result; | 
|  | 248 | } | 
|  | 249 |  | 
| Mathias Agopian | f0bc2f1 | 2012-04-09 16:14:01 -0700 | [diff] [blame] | 250 | virtual status_t queueBuffer(int buf, | 
|  | 251 | const QueueBufferInput& input, QueueBufferOutput* output) { | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 252 | Parcel data, reply; | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 253 |  | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 254 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 255 | data.writeInt32(buf); | 
| Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 256 | data.write(input); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 257 |  | 
| Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 258 | status_t result = remote()->transact(QUEUE_BUFFER, data, &reply); | 
|  | 259 | if (result != NO_ERROR) { | 
|  | 260 | return result; | 
|  | 261 | } | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 262 |  | 
|  | 263 | result = reply.read(*output); | 
|  | 264 | if (result != NO_ERROR) { | 
|  | 265 | return result; | 
|  | 266 | } | 
|  | 267 |  | 
| Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 268 | result = reply.readInt32(); | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 269 | return result; | 
|  | 270 | } | 
|  | 271 |  | 
| Pablo Ceballos | 583b1b3 | 2015-09-03 18:23:52 -0700 | [diff] [blame] | 272 | virtual status_t cancelBuffer(int buf, const sp<Fence>& fence) { | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 273 | Parcel data, reply; | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 274 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 275 | data.writeInt32(buf); | 
| Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame] | 276 | data.write(*fence.get()); | 
| Pablo Ceballos | 583b1b3 | 2015-09-03 18:23:52 -0700 | [diff] [blame] | 277 | status_t result = remote()->transact(CANCEL_BUFFER, data, &reply); | 
|  | 278 | if (result != NO_ERROR) { | 
|  | 279 | return result; | 
|  | 280 | } | 
|  | 281 | result = reply.readInt32(); | 
|  | 282 | return result; | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 283 | } | 
|  | 284 |  | 
| Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 285 | virtual int query(int what, int* value) { | 
|  | 286 | Parcel data, reply; | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 287 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
| Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 288 | data.writeInt32(what); | 
| Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 289 | status_t result = remote()->transact(QUERY, data, &reply); | 
|  | 290 | if (result != NO_ERROR) { | 
|  | 291 | return result; | 
|  | 292 | } | 
| Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 293 | value[0] = reply.readInt32(); | 
| Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 294 | result = reply.readInt32(); | 
| Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 295 | return result; | 
|  | 296 | } | 
|  | 297 |  | 
| Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 298 | virtual status_t connect(const sp<IProducerListener>& listener, | 
| Mathias Agopian | 365857d | 2013-09-11 19:35:45 -0700 | [diff] [blame] | 299 | int api, bool producerControlledByApp, QueueBufferOutput* output) { | 
| Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 300 | Parcel data, reply; | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 301 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
| Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 302 | if (listener != NULL) { | 
|  | 303 | data.writeInt32(1); | 
| Marco Nelissen | 097ca27 | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 304 | data.writeStrongBinder(IInterface::asBinder(listener)); | 
| Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 305 | } else { | 
|  | 306 | data.writeInt32(0); | 
|  | 307 | } | 
| Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 308 | data.writeInt32(api); | 
| Mathias Agopian | 595264f | 2013-07-16 22:56:09 -0700 | [diff] [blame] | 309 | data.writeInt32(producerControlledByApp); | 
| Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 310 | status_t result = remote()->transact(CONNECT, data, &reply); | 
|  | 311 | if (result != NO_ERROR) { | 
|  | 312 | return result; | 
|  | 313 | } | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 314 | reply.read(*output); | 
| Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 315 | result = reply.readInt32(); | 
| Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 316 | return result; | 
|  | 317 | } | 
| Mathias Agopian | 8072711 | 2011-05-02 19:51:12 -0700 | [diff] [blame] | 318 |  | 
| Robert Carr | 97b9c86 | 2016-09-08 13:54:35 -0700 | [diff] [blame] | 319 | virtual status_t disconnect(int api, DisconnectMode mode) { | 
| Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 320 | Parcel data, reply; | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 321 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
| Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 322 | data.writeInt32(api); | 
| Robert Carr | 97b9c86 | 2016-09-08 13:54:35 -0700 | [diff] [blame] | 323 | data.writeInt32(static_cast<int32_t>(mode)); | 
| Jamie Gennis | 8a29ff2 | 2011-10-14 15:03:17 -0700 | [diff] [blame] | 324 | status_t result =remote()->transact(DISCONNECT, data, &reply); | 
|  | 325 | if (result != NO_ERROR) { | 
|  | 326 | return result; | 
|  | 327 | } | 
|  | 328 | result = reply.readInt32(); | 
| Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 329 | return result; | 
|  | 330 | } | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 331 |  | 
|  | 332 | virtual status_t setSidebandStream(const sp<NativeHandle>& stream) { | 
|  | 333 | Parcel data, reply; | 
|  | 334 | status_t result; | 
|  | 335 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
|  | 336 | if (stream.get()) { | 
|  | 337 | data.writeInt32(true); | 
|  | 338 | data.writeNativeHandle(stream->handle()); | 
|  | 339 | } else { | 
|  | 340 | data.writeInt32(false); | 
|  | 341 | } | 
|  | 342 | if ((result = remote()->transact(SET_SIDEBAND_STREAM, data, &reply)) == NO_ERROR) { | 
|  | 343 | result = reply.readInt32(); | 
|  | 344 | } | 
|  | 345 | return result; | 
|  | 346 | } | 
| Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 347 |  | 
| Pablo Ceballos | 567dbbb | 2015-08-26 18:59:08 -0700 | [diff] [blame] | 348 | virtual void allocateBuffers(uint32_t width, uint32_t height, | 
| Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 349 | PixelFormat format, uint64_t usage) { | 
| Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 350 | Parcel data, reply; | 
|  | 351 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 352 | data.writeUint32(width); | 
|  | 353 | data.writeUint32(height); | 
| Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 354 | data.writeInt32(static_cast<int32_t>(format)); | 
| Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 355 | data.writeUint64(usage); | 
| Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 356 | status_t result = remote()->transact(ALLOCATE_BUFFERS, data, &reply); | 
|  | 357 | if (result != NO_ERROR) { | 
|  | 358 | ALOGE("allocateBuffers failed to transact: %d", result); | 
|  | 359 | } | 
|  | 360 | } | 
| Dan Stoza | 9de7293 | 2015-04-16 17:28:43 -0700 | [diff] [blame] | 361 |  | 
|  | 362 | virtual status_t allowAllocation(bool allow) { | 
|  | 363 | Parcel data, reply; | 
|  | 364 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
|  | 365 | data.writeInt32(static_cast<int32_t>(allow)); | 
|  | 366 | status_t result = remote()->transact(ALLOW_ALLOCATION, data, &reply); | 
|  | 367 | if (result != NO_ERROR) { | 
|  | 368 | return result; | 
|  | 369 | } | 
|  | 370 | result = reply.readInt32(); | 
|  | 371 | return result; | 
|  | 372 | } | 
| Dan Stoza | 812ed06 | 2015-06-02 15:45:22 -0700 | [diff] [blame] | 373 |  | 
|  | 374 | virtual status_t setGenerationNumber(uint32_t generationNumber) { | 
|  | 375 | Parcel data, reply; | 
|  | 376 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
|  | 377 | data.writeUint32(generationNumber); | 
|  | 378 | status_t result = remote()->transact(SET_GENERATION_NUMBER, data, &reply); | 
|  | 379 | if (result == NO_ERROR) { | 
|  | 380 | result = reply.readInt32(); | 
|  | 381 | } | 
|  | 382 | return result; | 
|  | 383 | } | 
| Dan Stoza | c6f30bd | 2015-06-08 09:32:50 -0700 | [diff] [blame] | 384 |  | 
|  | 385 | virtual String8 getConsumerName() const { | 
|  | 386 | Parcel data, reply; | 
|  | 387 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
|  | 388 | status_t result = remote()->transact(GET_CONSUMER_NAME, data, &reply); | 
|  | 389 | if (result != NO_ERROR) { | 
|  | 390 | ALOGE("getConsumerName failed to transact: %d", result); | 
|  | 391 | return String8("TransactFailed"); | 
|  | 392 | } | 
|  | 393 | return reply.readString8(); | 
|  | 394 | } | 
| Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 395 |  | 
| Pablo Ceballos | 3559fbf | 2016-03-17 15:50:23 -0700 | [diff] [blame] | 396 | virtual status_t setSharedBufferMode(bool sharedBufferMode) { | 
| Pablo Ceballos | ccdfd60 | 2015-10-07 15:05:45 -0700 | [diff] [blame] | 397 | Parcel data, reply; | 
|  | 398 | data.writeInterfaceToken( | 
|  | 399 | IGraphicBufferProducer::getInterfaceDescriptor()); | 
| Pablo Ceballos | 3559fbf | 2016-03-17 15:50:23 -0700 | [diff] [blame] | 400 | data.writeInt32(sharedBufferMode); | 
|  | 401 | status_t result = remote()->transact(SET_SHARED_BUFFER_MODE, data, | 
| Pablo Ceballos | ccdfd60 | 2015-10-07 15:05:45 -0700 | [diff] [blame] | 402 | &reply); | 
|  | 403 | if (result == NO_ERROR) { | 
|  | 404 | result = reply.readInt32(); | 
|  | 405 | } | 
|  | 406 | return result; | 
|  | 407 | } | 
| Dan Stoza | 127fc63 | 2015-06-30 13:43:32 -0700 | [diff] [blame] | 408 |  | 
| Pablo Ceballos | ff95aab | 2016-01-13 17:09:58 -0800 | [diff] [blame] | 409 | virtual status_t setAutoRefresh(bool autoRefresh) { | 
|  | 410 | Parcel data, reply; | 
|  | 411 | data.writeInterfaceToken( | 
|  | 412 | IGraphicBufferProducer::getInterfaceDescriptor()); | 
|  | 413 | data.writeInt32(autoRefresh); | 
|  | 414 | status_t result = remote()->transact(SET_AUTO_REFRESH, data, &reply); | 
|  | 415 | if (result == NO_ERROR) { | 
|  | 416 | result = reply.readInt32(); | 
|  | 417 | } | 
|  | 418 | return result; | 
|  | 419 | } | 
|  | 420 |  | 
| Dan Stoza | 127fc63 | 2015-06-30 13:43:32 -0700 | [diff] [blame] | 421 | virtual status_t setDequeueTimeout(nsecs_t timeout) { | 
|  | 422 | Parcel data, reply; | 
|  | 423 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
|  | 424 | data.writeInt64(timeout); | 
|  | 425 | status_t result = remote()->transact(SET_DEQUEUE_TIMEOUT, data, &reply); | 
|  | 426 | if (result != NO_ERROR) { | 
|  | 427 | ALOGE("setDequeueTimeout failed to transact: %d", result); | 
|  | 428 | return result; | 
|  | 429 | } | 
|  | 430 | return reply.readInt32(); | 
|  | 431 | } | 
| Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 432 |  | 
|  | 433 | virtual status_t getLastQueuedBuffer(sp<GraphicBuffer>* outBuffer, | 
| John Reck | 1a61da5 | 2016-04-28 13:18:15 -0700 | [diff] [blame] | 434 | sp<Fence>* outFence, float outTransformMatrix[16]) override { | 
| Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 435 | Parcel data, reply; | 
|  | 436 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
|  | 437 | status_t result = remote()->transact(GET_LAST_QUEUED_BUFFER, data, | 
|  | 438 | &reply); | 
|  | 439 | if (result != NO_ERROR) { | 
|  | 440 | ALOGE("getLastQueuedBuffer failed to transact: %d", result); | 
|  | 441 | return result; | 
|  | 442 | } | 
|  | 443 | result = reply.readInt32(); | 
|  | 444 | if (result != NO_ERROR) { | 
|  | 445 | return result; | 
|  | 446 | } | 
| John Reck | ce8e5df | 2016-04-28 10:12:47 -0700 | [diff] [blame] | 447 | bool hasBuffer = reply.readBool(); | 
|  | 448 | sp<GraphicBuffer> buffer; | 
|  | 449 | if (hasBuffer) { | 
|  | 450 | buffer = new GraphicBuffer(); | 
|  | 451 | result = reply.read(*buffer); | 
| John Reck | 1a61da5 | 2016-04-28 13:18:15 -0700 | [diff] [blame] | 452 | if (result == NO_ERROR) { | 
|  | 453 | result = reply.read(outTransformMatrix, sizeof(float) * 16); | 
|  | 454 | } | 
| John Reck | ce8e5df | 2016-04-28 10:12:47 -0700 | [diff] [blame] | 455 | } | 
| Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 456 | if (result != NO_ERROR) { | 
|  | 457 | ALOGE("getLastQueuedBuffer failed to read buffer: %d", result); | 
|  | 458 | return result; | 
|  | 459 | } | 
|  | 460 | sp<Fence> fence(new Fence); | 
|  | 461 | result = reply.read(*fence); | 
|  | 462 | if (result != NO_ERROR) { | 
|  | 463 | ALOGE("getLastQueuedBuffer failed to read fence: %d", result); | 
|  | 464 | return result; | 
|  | 465 | } | 
|  | 466 | *outBuffer = buffer; | 
|  | 467 | *outFence = fence; | 
|  | 468 | return result; | 
|  | 469 | } | 
| Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 470 |  | 
| Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 471 | virtual void getFrameTimestamps(FrameEventHistoryDelta* outDelta) { | 
| Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 472 | Parcel data, reply; | 
|  | 473 | status_t result = data.writeInterfaceToken( | 
|  | 474 | IGraphicBufferProducer::getInterfaceDescriptor()); | 
|  | 475 | if (result != NO_ERROR) { | 
| Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 476 | ALOGE("IGBP::getFrameTimestamps failed to write token: %d", result); | 
|  | 477 | return; | 
| Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 478 | } | 
|  | 479 | result = remote()->transact(GET_FRAME_TIMESTAMPS, data, &reply); | 
|  | 480 | if (result != NO_ERROR) { | 
| Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 481 | ALOGE("IGBP::getFrameTimestamps failed to transact: %d", result); | 
|  | 482 | return; | 
| Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 483 | } | 
| Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 484 | result = reply.read(*outDelta); | 
| Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 485 | if (result != NO_ERROR) { | 
| Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 486 | ALOGE("IGBP::getFrameTimestamps failed to read timestamps: %d", | 
|  | 487 | result); | 
| Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 488 | } | 
| Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 489 | } | 
| Pablo Ceballos | 6155b40 | 2016-06-30 17:01:49 -0700 | [diff] [blame] | 490 |  | 
| Pablo Ceballos | 8e3e92b | 2016-06-27 17:56:53 -0700 | [diff] [blame] | 491 | virtual status_t getUniqueId(uint64_t* outId) const { | 
|  | 492 | Parcel data, reply; | 
|  | 493 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
|  | 494 | status_t result = remote()->transact(GET_UNIQUE_ID, data, &reply); | 
|  | 495 | if (result != NO_ERROR) { | 
|  | 496 | ALOGE("getUniqueId failed to transact: %d", result); | 
|  | 497 | } | 
|  | 498 | status_t actualResult = NO_ERROR; | 
|  | 499 | result = reply.readInt32(&actualResult); | 
|  | 500 | if (result != NO_ERROR) { | 
|  | 501 | return result; | 
|  | 502 | } | 
|  | 503 | result = reply.readUint64(outId); | 
|  | 504 | if (result != NO_ERROR) { | 
|  | 505 | return result; | 
|  | 506 | } | 
|  | 507 | return actualResult; | 
|  | 508 | } | 
| Chia-I Wu | e2786ea | 2017-08-07 10:36:08 -0700 | [diff] [blame] | 509 |  | 
|  | 510 | virtual status_t getConsumerUsage(uint64_t* outUsage) const { | 
|  | 511 | Parcel data, reply; | 
|  | 512 | data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor()); | 
|  | 513 | status_t result = remote()->transact(GET_CONSUMER_USAGE, data, &reply); | 
|  | 514 | if (result != NO_ERROR) { | 
|  | 515 | ALOGE("getConsumerUsage failed to transact: %d", result); | 
|  | 516 | } | 
|  | 517 | status_t actualResult = NO_ERROR; | 
|  | 518 | result = reply.readInt32(&actualResult); | 
|  | 519 | if (result != NO_ERROR) { | 
|  | 520 | return result; | 
|  | 521 | } | 
|  | 522 | result = reply.readUint64(outUsage); | 
|  | 523 | if (result != NO_ERROR) { | 
|  | 524 | return result; | 
|  | 525 | } | 
|  | 526 | return actualResult; | 
|  | 527 | } | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 528 | }; | 
|  | 529 |  | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 530 | // Out-of-line virtual method definition to trigger vtable emission in this | 
|  | 531 | // translation unit (see clang warning -Wweak-vtables) | 
|  | 532 | BpGraphicBufferProducer::~BpGraphicBufferProducer() {} | 
|  | 533 |  | 
| Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 534 | class HpGraphicBufferProducer : public HpInterface< | 
|  | 535 | BpGraphicBufferProducer, H2BGraphicBufferProducer> { | 
|  | 536 | public: | 
|  | 537 | HpGraphicBufferProducer(const sp<IBinder>& base) : PBase(base) {} | 
|  | 538 |  | 
|  | 539 | status_t requestBuffer(int slot, sp<GraphicBuffer>* buf) override { | 
|  | 540 | return mBase->requestBuffer(slot, buf); | 
|  | 541 | } | 
|  | 542 |  | 
|  | 543 | status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers) override { | 
|  | 544 | return mBase->setMaxDequeuedBufferCount(maxDequeuedBuffers); | 
|  | 545 | } | 
|  | 546 |  | 
|  | 547 | status_t setAsyncMode(bool async) override { | 
|  | 548 | return mBase->setAsyncMode(async); | 
|  | 549 | } | 
|  | 550 |  | 
| Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 551 | status_t dequeueBuffer(int* slot, sp<Fence>* fence, uint32_t w, uint32_t h, PixelFormat format, | 
|  | 552 | uint64_t usage, uint64_t* outBufferAge, | 
|  | 553 | FrameEventHistoryDelta* outTimestamps) override { | 
|  | 554 | return mBase->dequeueBuffer(slot, fence, w, h, format, usage, outBufferAge, outTimestamps); | 
| Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 555 | } | 
|  | 556 |  | 
|  | 557 | status_t detachBuffer(int slot) override { | 
|  | 558 | return mBase->detachBuffer(slot); | 
|  | 559 | } | 
|  | 560 |  | 
|  | 561 | status_t detachNextBuffer( | 
|  | 562 | sp<GraphicBuffer>* outBuffer, sp<Fence>* outFence) override { | 
|  | 563 | return mBase->detachNextBuffer(outBuffer, outFence); | 
|  | 564 | } | 
|  | 565 |  | 
|  | 566 | status_t attachBuffer( | 
|  | 567 | int* outSlot, const sp<GraphicBuffer>& buffer) override { | 
|  | 568 | return mBase->attachBuffer(outSlot, buffer); | 
|  | 569 | } | 
|  | 570 |  | 
|  | 571 | status_t queueBuffer( | 
|  | 572 | int slot, | 
|  | 573 | const QueueBufferInput& input, | 
|  | 574 | QueueBufferOutput* output) override { | 
|  | 575 | return mBase->queueBuffer(slot, input, output); | 
|  | 576 | } | 
|  | 577 |  | 
|  | 578 | status_t cancelBuffer(int slot, const sp<Fence>& fence) override { | 
|  | 579 | return mBase->cancelBuffer(slot, fence); | 
|  | 580 | } | 
|  | 581 |  | 
|  | 582 | int query(int what, int* value) override { | 
|  | 583 | return mBase->query(what, value); | 
|  | 584 | } | 
|  | 585 |  | 
|  | 586 | status_t connect( | 
|  | 587 | const sp<IProducerListener>& listener, | 
|  | 588 | int api, bool producerControlledByApp, | 
|  | 589 | QueueBufferOutput* output) override { | 
|  | 590 | return mBase->connect(listener, api, producerControlledByApp, output); | 
|  | 591 | } | 
|  | 592 |  | 
|  | 593 | status_t disconnect( | 
|  | 594 | int api, DisconnectMode mode = DisconnectMode::Api) override { | 
|  | 595 | return mBase->disconnect(api, mode); | 
|  | 596 | } | 
|  | 597 |  | 
|  | 598 | status_t setSidebandStream(const sp<NativeHandle>& stream) override { | 
|  | 599 | return mBase->setSidebandStream(stream); | 
|  | 600 | } | 
|  | 601 |  | 
|  | 602 | void allocateBuffers(uint32_t width, uint32_t height, | 
| Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 603 | PixelFormat format, uint64_t usage) override { | 
| Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 604 | return mBase->allocateBuffers(width, height, format, usage); | 
|  | 605 | } | 
|  | 606 |  | 
|  | 607 | status_t allowAllocation(bool allow) override { | 
|  | 608 | return mBase->allowAllocation(allow); | 
|  | 609 | } | 
|  | 610 |  | 
|  | 611 | status_t setGenerationNumber(uint32_t generationNumber) override { | 
|  | 612 | return mBase->setGenerationNumber(generationNumber); | 
|  | 613 | } | 
|  | 614 |  | 
|  | 615 | String8 getConsumerName() const override { | 
|  | 616 | return mBase->getConsumerName(); | 
|  | 617 | } | 
|  | 618 |  | 
|  | 619 | status_t setSharedBufferMode(bool sharedBufferMode) override { | 
|  | 620 | return mBase->setSharedBufferMode(sharedBufferMode); | 
|  | 621 | } | 
|  | 622 |  | 
|  | 623 | status_t setAutoRefresh(bool autoRefresh) override { | 
|  | 624 | return mBase->setAutoRefresh(autoRefresh); | 
|  | 625 | } | 
|  | 626 |  | 
|  | 627 | status_t setDequeueTimeout(nsecs_t timeout) override { | 
|  | 628 | return mBase->setDequeueTimeout(timeout); | 
|  | 629 | } | 
|  | 630 |  | 
|  | 631 | status_t getLastQueuedBuffer( | 
|  | 632 | sp<GraphicBuffer>* outBuffer, | 
|  | 633 | sp<Fence>* outFence, | 
|  | 634 | float outTransformMatrix[16]) override { | 
|  | 635 | return mBase->getLastQueuedBuffer( | 
|  | 636 | outBuffer, outFence, outTransformMatrix); | 
|  | 637 | } | 
|  | 638 |  | 
|  | 639 | void getFrameTimestamps(FrameEventHistoryDelta* outDelta) override { | 
|  | 640 | return mBase->getFrameTimestamps(outDelta); | 
|  | 641 | } | 
|  | 642 |  | 
|  | 643 | status_t getUniqueId(uint64_t* outId) const override { | 
|  | 644 | return mBase->getUniqueId(outId); | 
|  | 645 | } | 
| Chia-I Wu | e2786ea | 2017-08-07 10:36:08 -0700 | [diff] [blame] | 646 |  | 
|  | 647 | status_t getConsumerUsage(uint64_t* outUsage) const override { | 
|  | 648 | return mBase->getConsumerUsage(outUsage); | 
|  | 649 | } | 
| Pawin Vongmasa | 6e1193a | 2017-03-07 13:08:40 -0800 | [diff] [blame] | 650 | }; | 
|  | 651 |  | 
|  | 652 | IMPLEMENT_HYBRID_META_INTERFACE(GraphicBufferProducer, HGraphicBufferProducer, | 
|  | 653 | "android.gui.IGraphicBufferProducer"); | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 654 |  | 
|  | 655 | // ---------------------------------------------------------------------- | 
|  | 656 |  | 
| Jiwen 'Steve' Cai | c90a77f | 2018-01-14 15:42:29 -0800 | [diff] [blame] | 657 | status_t IGraphicBufferProducer::exportToParcel(Parcel* parcel) { | 
|  | 658 | status_t res = OK; | 
|  | 659 | res = parcel->writeUint32(USE_BUFFER_QUEUE); | 
|  | 660 | if (res != NO_ERROR) { | 
|  | 661 | ALOGE("exportToParcel: Cannot write magic, res=%d.", res); | 
|  | 662 | return res; | 
|  | 663 | } | 
|  | 664 |  | 
|  | 665 | return parcel->writeStrongBinder(IInterface::asBinder(this)); | 
|  | 666 | } | 
|  | 667 |  | 
|  | 668 | /* static */ | 
|  | 669 | status_t IGraphicBufferProducer::exportToParcel(const sp<IGraphicBufferProducer>& producer, | 
|  | 670 | Parcel* parcel) { | 
|  | 671 | if (parcel == nullptr) { | 
|  | 672 | ALOGE("exportToParcel: Invalid parcel object."); | 
|  | 673 | return BAD_VALUE; | 
|  | 674 | } | 
|  | 675 |  | 
|  | 676 | if (producer == nullptr) { | 
|  | 677 | status_t res = OK; | 
|  | 678 | res = parcel->writeUint32(IGraphicBufferProducer::USE_BUFFER_QUEUE); | 
|  | 679 | if (res != NO_ERROR) return res; | 
|  | 680 | return parcel->writeStrongBinder(nullptr); | 
|  | 681 | } else { | 
|  | 682 | return producer->exportToParcel(parcel); | 
|  | 683 | } | 
|  | 684 | } | 
|  | 685 |  | 
|  | 686 | /* static */ | 
|  | 687 | sp<IGraphicBufferProducer> IGraphicBufferProducer::createFromParcel(const Parcel* parcel) { | 
|  | 688 | uint32_t outMagic = 0; | 
|  | 689 | status_t res = NO_ERROR; | 
|  | 690 |  | 
|  | 691 | res = parcel->readUint32(&outMagic); | 
|  | 692 | if (res != NO_ERROR) { | 
|  | 693 | ALOGE("createFromParcel: Failed to read magic, error=%d.", res); | 
|  | 694 | return nullptr; | 
|  | 695 | } | 
|  | 696 |  | 
|  | 697 | switch (outMagic) { | 
|  | 698 | case USE_BUFFER_QUEUE: { | 
|  | 699 | sp<IBinder> binder; | 
|  | 700 | res = parcel->readNullableStrongBinder(&binder); | 
|  | 701 | if (res != NO_ERROR) { | 
|  | 702 | ALOGE("createFromParcel: Can't read strong binder."); | 
|  | 703 | return nullptr; | 
|  | 704 | } | 
|  | 705 | return interface_cast<IGraphicBufferProducer>(binder); | 
|  | 706 | } | 
|  | 707 | case USE_BUFFER_HUB: { | 
|  | 708 | ALOGE("createFromParcel: BufferHub not implemented."); | 
|  | 709 | dvr::ProducerQueueParcelable producerParcelable; | 
|  | 710 | res = producerParcelable.readFromParcel(parcel); | 
|  | 711 | if (res != NO_ERROR) { | 
|  | 712 | ALOGE("createFromParcel: Failed to read from parcel, error=%d", res); | 
|  | 713 | return nullptr; | 
|  | 714 | } | 
|  | 715 | return BufferHubProducer::Create(std::move(producerParcelable)); | 
|  | 716 | } | 
|  | 717 | default: { | 
|  | 718 | ALOGE("createFromParcel: Unexpected mgaic: 0x%x.", outMagic); | 
|  | 719 | return nullptr; | 
|  | 720 | } | 
|  | 721 | } | 
|  | 722 | } | 
|  | 723 |  | 
|  | 724 | // ---------------------------------------------------------------------------- | 
|  | 725 |  | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 726 | status_t BnGraphicBufferProducer::onTransact( | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 727 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) | 
|  | 728 | { | 
|  | 729 | switch(code) { | 
|  | 730 | case REQUEST_BUFFER: { | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 731 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 732 | int bufferIdx   = data.readInt32(); | 
| Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 733 | sp<GraphicBuffer> buffer; | 
|  | 734 | int result = requestBuffer(bufferIdx, &buffer); | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 735 | reply->writeInt32(buffer != 0); | 
|  | 736 | if (buffer != 0) { | 
|  | 737 | reply->write(*buffer); | 
|  | 738 | } | 
| Jamie Gennis | 7b305ff | 2011-07-19 12:08:33 -0700 | [diff] [blame] | 739 | reply->writeInt32(result); | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 740 | return NO_ERROR; | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 741 | } | 
| Pablo Ceballos | fa45535 | 2015-08-12 17:47:47 -0700 | [diff] [blame] | 742 | case SET_MAX_DEQUEUED_BUFFER_COUNT: { | 
|  | 743 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
|  | 744 | int maxDequeuedBuffers = data.readInt32(); | 
|  | 745 | int result = setMaxDequeuedBufferCount(maxDequeuedBuffers); | 
|  | 746 | reply->writeInt32(result); | 
|  | 747 | return NO_ERROR; | 
|  | 748 | } | 
|  | 749 | case SET_ASYNC_MODE: { | 
|  | 750 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
|  | 751 | bool async = data.readInt32(); | 
|  | 752 | int result = setAsyncMode(async); | 
|  | 753 | reply->writeInt32(result); | 
|  | 754 | return NO_ERROR; | 
|  | 755 | } | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 756 | case DEQUEUE_BUFFER: { | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 757 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 758 | uint32_t width = data.readUint32(); | 
|  | 759 | uint32_t height = data.readUint32(); | 
|  | 760 | PixelFormat format = static_cast<PixelFormat>(data.readInt32()); | 
| Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 761 | uint64_t usage = data.readUint64(); | 
| Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 762 | uint64_t bufferAge = 0; | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 763 | bool getTimestamps = data.readBool(); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 764 |  | 
| Naveen Leekha | 12ba0f5 | 2015-09-21 17:28:04 -0700 | [diff] [blame] | 765 | int buf = 0; | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 766 | sp<Fence> fence = Fence::NO_FENCE; | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 767 | FrameEventHistoryDelta frameTimestamps; | 
| Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 768 | int result = dequeueBuffer(&buf, &fence, width, height, format, usage, &bufferAge, | 
|  | 769 | getTimestamps ? &frameTimestamps : nullptr); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 770 |  | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 771 | reply->writeInt32(buf); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 772 | reply->write(*fence); | 
| Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 773 | reply->writeUint64(bufferAge); | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 774 | if (getTimestamps) { | 
|  | 775 | reply->write(frameTimestamps); | 
|  | 776 | } | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 777 | reply->writeInt32(result); | 
|  | 778 | return NO_ERROR; | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 779 | } | 
| Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 780 | case DETACH_BUFFER: { | 
|  | 781 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
|  | 782 | int slot = data.readInt32(); | 
|  | 783 | int result = detachBuffer(slot); | 
|  | 784 | reply->writeInt32(result); | 
|  | 785 | return NO_ERROR; | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 786 | } | 
| Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 787 | case DETACH_NEXT_BUFFER: { | 
|  | 788 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
|  | 789 | sp<GraphicBuffer> buffer; | 
|  | 790 | sp<Fence> fence; | 
|  | 791 | int32_t result = detachNextBuffer(&buffer, &fence); | 
|  | 792 | reply->writeInt32(result); | 
|  | 793 | if (result == NO_ERROR) { | 
|  | 794 | reply->writeInt32(buffer != NULL); | 
|  | 795 | if (buffer != NULL) { | 
|  | 796 | reply->write(*buffer); | 
|  | 797 | } | 
|  | 798 | reply->writeInt32(fence != NULL); | 
|  | 799 | if (fence != NULL) { | 
|  | 800 | reply->write(*fence); | 
|  | 801 | } | 
|  | 802 | } | 
|  | 803 | return NO_ERROR; | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 804 | } | 
| Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 805 | case ATTACH_BUFFER: { | 
|  | 806 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
|  | 807 | sp<GraphicBuffer> buffer = new GraphicBuffer(); | 
| Pablo Ceballos | 70636b3 | 2016-07-06 15:24:54 -0700 | [diff] [blame] | 808 | status_t result = data.read(*buffer.get()); | 
| Naveen Leekha | 12ba0f5 | 2015-09-21 17:28:04 -0700 | [diff] [blame] | 809 | int slot = 0; | 
| Pablo Ceballos | 70636b3 | 2016-07-06 15:24:54 -0700 | [diff] [blame] | 810 | if (result == NO_ERROR) { | 
|  | 811 | result = attachBuffer(&slot, buffer); | 
|  | 812 | } | 
| Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 813 | reply->writeInt32(slot); | 
|  | 814 | reply->writeInt32(result); | 
|  | 815 | return NO_ERROR; | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 816 | } | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 817 | case QUEUE_BUFFER: { | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 818 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 819 |  | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 820 | int buf = data.readInt32(); | 
| Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 821 | QueueBufferInput input(data); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 822 | QueueBufferOutput output; | 
|  | 823 | status_t result = queueBuffer(buf, input, &output); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 824 | reply->write(output); | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 825 | reply->writeInt32(result); | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 826 |  | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 827 | return NO_ERROR; | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 828 | } | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 829 | case CANCEL_BUFFER: { | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 830 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 831 | int buf = data.readInt32(); | 
| Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame] | 832 | sp<Fence> fence = new Fence(); | 
| Pablo Ceballos | 70636b3 | 2016-07-06 15:24:54 -0700 | [diff] [blame] | 833 | status_t result = data.read(*fence.get()); | 
|  | 834 | if (result == NO_ERROR) { | 
|  | 835 | result = cancelBuffer(buf, fence); | 
|  | 836 | } | 
| Pablo Ceballos | 583b1b3 | 2015-09-03 18:23:52 -0700 | [diff] [blame] | 837 | reply->writeInt32(result); | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 838 | return NO_ERROR; | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 839 | } | 
| Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 840 | case QUERY: { | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 841 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
| Naveen Leekha | 12ba0f5 | 2015-09-21 17:28:04 -0700 | [diff] [blame] | 842 | int value = 0; | 
| Mathias Agopian | eafabcd | 2011-04-20 14:20:59 -0700 | [diff] [blame] | 843 | int what = data.readInt32(); | 
|  | 844 | int res = query(what, &value); | 
|  | 845 | reply->writeInt32(value); | 
|  | 846 | reply->writeInt32(res); | 
|  | 847 | return NO_ERROR; | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 848 | } | 
| Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 849 | case CONNECT: { | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 850 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
| Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 851 | sp<IProducerListener> listener; | 
|  | 852 | if (data.readInt32() == 1) { | 
|  | 853 | listener = IProducerListener::asInterface(data.readStrongBinder()); | 
|  | 854 | } | 
| Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 855 | int api = data.readInt32(); | 
| Mathias Agopian | 595264f | 2013-07-16 22:56:09 -0700 | [diff] [blame] | 856 | bool producerControlledByApp = data.readInt32(); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 857 | QueueBufferOutput output; | 
|  | 858 | status_t res = connect(listener, api, producerControlledByApp, &output); | 
|  | 859 | reply->write(output); | 
| Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 860 | reply->writeInt32(res); | 
|  | 861 | return NO_ERROR; | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 862 | } | 
| Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 863 | case DISCONNECT: { | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 864 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
| Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 865 | int api = data.readInt32(); | 
| Robert Carr | 97b9c86 | 2016-09-08 13:54:35 -0700 | [diff] [blame] | 866 | DisconnectMode mode = static_cast<DisconnectMode>(data.readInt32()); | 
|  | 867 | status_t res = disconnect(api, mode); | 
| Jamie Gennis | fe0a87b | 2011-07-13 19:12:20 -0700 | [diff] [blame] | 868 | reply->writeInt32(res); | 
|  | 869 | return NO_ERROR; | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 870 | } | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 871 | case SET_SIDEBAND_STREAM: { | 
|  | 872 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
|  | 873 | sp<NativeHandle> stream; | 
|  | 874 | if (data.readInt32()) { | 
| Wonsik Kim | 0ec54e1 | 2014-03-21 10:46:24 +0900 | [diff] [blame] | 875 | stream = NativeHandle::create(data.readNativeHandle(), true); | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 876 | } | 
|  | 877 | status_t result = setSidebandStream(stream); | 
|  | 878 | reply->writeInt32(result); | 
|  | 879 | return NO_ERROR; | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 880 | } | 
| Dan Stoza | 9de7293 | 2015-04-16 17:28:43 -0700 | [diff] [blame] | 881 | case ALLOCATE_BUFFERS: { | 
| Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 882 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
| Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 883 | uint32_t width = data.readUint32(); | 
|  | 884 | uint32_t height = data.readUint32(); | 
|  | 885 | PixelFormat format = static_cast<PixelFormat>(data.readInt32()); | 
| Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 886 | uint64_t usage = data.readUint64(); | 
| Pablo Ceballos | 567dbbb | 2015-08-26 18:59:08 -0700 | [diff] [blame] | 887 | allocateBuffers(width, height, format, usage); | 
| Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 888 | return NO_ERROR; | 
| Dan Stoza | 9de7293 | 2015-04-16 17:28:43 -0700 | [diff] [blame] | 889 | } | 
|  | 890 | case ALLOW_ALLOCATION: { | 
|  | 891 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
|  | 892 | bool allow = static_cast<bool>(data.readInt32()); | 
|  | 893 | status_t result = allowAllocation(allow); | 
|  | 894 | reply->writeInt32(result); | 
|  | 895 | return NO_ERROR; | 
|  | 896 | } | 
| Dan Stoza | 812ed06 | 2015-06-02 15:45:22 -0700 | [diff] [blame] | 897 | case SET_GENERATION_NUMBER: { | 
|  | 898 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
|  | 899 | uint32_t generationNumber = data.readUint32(); | 
|  | 900 | status_t result = setGenerationNumber(generationNumber); | 
|  | 901 | reply->writeInt32(result); | 
|  | 902 | return NO_ERROR; | 
|  | 903 | } | 
| Dan Stoza | c6f30bd | 2015-06-08 09:32:50 -0700 | [diff] [blame] | 904 | case GET_CONSUMER_NAME: { | 
|  | 905 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
|  | 906 | reply->writeString8(getConsumerName()); | 
|  | 907 | return NO_ERROR; | 
|  | 908 | } | 
| Pablo Ceballos | 3559fbf | 2016-03-17 15:50:23 -0700 | [diff] [blame] | 909 | case SET_SHARED_BUFFER_MODE: { | 
| Pablo Ceballos | ccdfd60 | 2015-10-07 15:05:45 -0700 | [diff] [blame] | 910 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
| Pablo Ceballos | 3559fbf | 2016-03-17 15:50:23 -0700 | [diff] [blame] | 911 | bool sharedBufferMode = data.readInt32(); | 
|  | 912 | status_t result = setSharedBufferMode(sharedBufferMode); | 
| Pablo Ceballos | ccdfd60 | 2015-10-07 15:05:45 -0700 | [diff] [blame] | 913 | reply->writeInt32(result); | 
|  | 914 | return NO_ERROR; | 
|  | 915 | } | 
| Pablo Ceballos | ff95aab | 2016-01-13 17:09:58 -0800 | [diff] [blame] | 916 | case SET_AUTO_REFRESH: { | 
|  | 917 | CHECK_INTERFACE(IGraphicBuffer, data, reply); | 
|  | 918 | bool autoRefresh = data.readInt32(); | 
|  | 919 | status_t result = setAutoRefresh(autoRefresh); | 
|  | 920 | reply->writeInt32(result); | 
|  | 921 | return NO_ERROR; | 
|  | 922 | } | 
| Dan Stoza | 127fc63 | 2015-06-30 13:43:32 -0700 | [diff] [blame] | 923 | case SET_DEQUEUE_TIMEOUT: { | 
|  | 924 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
|  | 925 | nsecs_t timeout = data.readInt64(); | 
|  | 926 | status_t result = setDequeueTimeout(timeout); | 
|  | 927 | reply->writeInt32(result); | 
|  | 928 | return NO_ERROR; | 
|  | 929 | } | 
| Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 930 | case GET_LAST_QUEUED_BUFFER: { | 
|  | 931 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
|  | 932 | sp<GraphicBuffer> buffer(nullptr); | 
|  | 933 | sp<Fence> fence(Fence::NO_FENCE); | 
| John Reck | 1a61da5 | 2016-04-28 13:18:15 -0700 | [diff] [blame] | 934 | float transform[16] = {}; | 
|  | 935 | status_t result = getLastQueuedBuffer(&buffer, &fence, transform); | 
| Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 936 | reply->writeInt32(result); | 
|  | 937 | if (result != NO_ERROR) { | 
|  | 938 | return result; | 
|  | 939 | } | 
| John Reck | ce8e5df | 2016-04-28 10:12:47 -0700 | [diff] [blame] | 940 | if (!buffer.get()) { | 
|  | 941 | reply->writeBool(false); | 
|  | 942 | } else { | 
|  | 943 | reply->writeBool(true); | 
|  | 944 | result = reply->write(*buffer); | 
| John Reck | 1a61da5 | 2016-04-28 13:18:15 -0700 | [diff] [blame] | 945 | if (result == NO_ERROR) { | 
|  | 946 | reply->write(transform, sizeof(float) * 16); | 
|  | 947 | } | 
| John Reck | ce8e5df | 2016-04-28 10:12:47 -0700 | [diff] [blame] | 948 | } | 
| Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 949 | if (result != NO_ERROR) { | 
|  | 950 | ALOGE("getLastQueuedBuffer failed to write buffer: %d", result); | 
|  | 951 | return result; | 
|  | 952 | } | 
|  | 953 | result = reply->write(*fence); | 
|  | 954 | if (result != NO_ERROR) { | 
|  | 955 | ALOGE("getLastQueuedBuffer failed to write fence: %d", result); | 
|  | 956 | return result; | 
|  | 957 | } | 
|  | 958 | return NO_ERROR; | 
|  | 959 | } | 
| Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 960 | case GET_FRAME_TIMESTAMPS: { | 
|  | 961 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
| Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 962 | FrameEventHistoryDelta frameTimestamps; | 
|  | 963 | getFrameTimestamps(&frameTimestamps); | 
|  | 964 | status_t result = reply->write(frameTimestamps); | 
| Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 965 | if (result != NO_ERROR) { | 
| Brian Anderson | 3890c39 | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 966 | ALOGE("BnGBP::GET_FRAME_TIMESTAMPS failed to write buffer: %d", | 
|  | 967 | result); | 
| Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 968 | return result; | 
|  | 969 | } | 
| Pablo Ceballos | ce796e7 | 2016-02-04 19:10:51 -0800 | [diff] [blame] | 970 | return NO_ERROR; | 
|  | 971 | } | 
| Pablo Ceballos | 8e3e92b | 2016-06-27 17:56:53 -0700 | [diff] [blame] | 972 | case GET_UNIQUE_ID: { | 
|  | 973 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
|  | 974 | uint64_t outId = 0; | 
|  | 975 | status_t actualResult = getUniqueId(&outId); | 
|  | 976 | status_t result = reply->writeInt32(actualResult); | 
|  | 977 | if (result != NO_ERROR) { | 
|  | 978 | return result; | 
|  | 979 | } | 
|  | 980 | result = reply->writeUint64(outId); | 
|  | 981 | if (result != NO_ERROR) { | 
|  | 982 | return result; | 
|  | 983 | } | 
|  | 984 | return NO_ERROR; | 
|  | 985 | } | 
| Chia-I Wu | e2786ea | 2017-08-07 10:36:08 -0700 | [diff] [blame] | 986 | case GET_CONSUMER_USAGE: { | 
|  | 987 | CHECK_INTERFACE(IGraphicBufferProducer, data, reply); | 
|  | 988 | uint64_t outUsage = 0; | 
|  | 989 | status_t actualResult = getConsumerUsage(&outUsage); | 
|  | 990 | status_t result = reply->writeInt32(actualResult); | 
|  | 991 | if (result != NO_ERROR) { | 
|  | 992 | return result; | 
|  | 993 | } | 
|  | 994 | result = reply->writeUint64(outUsage); | 
|  | 995 | if (result != NO_ERROR) { | 
|  | 996 | return result; | 
|  | 997 | } | 
|  | 998 | return NO_ERROR; | 
|  | 999 | } | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1000 | } | 
|  | 1001 | return BBinder::onTransact(code, data, reply, flags); | 
|  | 1002 | } | 
|  | 1003 |  | 
|  | 1004 | // ---------------------------------------------------------------------------- | 
|  | 1005 |  | 
| Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 1006 | IGraphicBufferProducer::QueueBufferInput::QueueBufferInput(const Parcel& parcel) { | 
| Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 1007 | parcel.read(*this); | 
|  | 1008 | } | 
|  | 1009 |  | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1010 | constexpr size_t IGraphicBufferProducer::QueueBufferInput::minFlattenedSize() { | 
|  | 1011 | return sizeof(timestamp) + | 
|  | 1012 | sizeof(isAutoTimestamp) + | 
|  | 1013 | sizeof(dataSpace) + | 
|  | 1014 | sizeof(crop) + | 
|  | 1015 | sizeof(scalingMode) + | 
|  | 1016 | sizeof(transform) + | 
|  | 1017 | sizeof(stickyTransform) + | 
|  | 1018 | sizeof(getFrameTimestamps); | 
|  | 1019 | } | 
|  | 1020 |  | 
| Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 1021 | size_t IGraphicBufferProducer::QueueBufferInput::getFlattenedSize() const { | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1022 | return minFlattenedSize() + | 
|  | 1023 | fence->getFlattenedSize() + | 
| Courtney Goeltzenleuchter | 9bad0d7 | 2017-12-19 12:34:34 -0700 | [diff] [blame] | 1024 | surfaceDamage.getFlattenedSize() + | 
|  | 1025 | hdrMetadata.getFlattenedSize(); | 
| Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 1026 | } | 
|  | 1027 |  | 
| Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 1028 | size_t IGraphicBufferProducer::QueueBufferInput::getFdCount() const { | 
| Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame] | 1029 | return fence->getFdCount(); | 
| Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 1030 | } | 
|  | 1031 |  | 
| Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 1032 | status_t IGraphicBufferProducer::QueueBufferInput::flatten( | 
|  | 1033 | void*& buffer, size_t& size, int*& fds, size_t& count) const | 
| Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 1034 | { | 
| Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 1035 | if (size < getFlattenedSize()) { | 
|  | 1036 | return NO_MEMORY; | 
|  | 1037 | } | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1038 |  | 
| Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 1039 | FlattenableUtils::write(buffer, size, timestamp); | 
| Andy McFadden | 3c25621 | 2013-08-16 14:55:39 -0700 | [diff] [blame] | 1040 | FlattenableUtils::write(buffer, size, isAutoTimestamp); | 
| Eino-Ville Talvala | 82c6bcc | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 1041 | FlattenableUtils::write(buffer, size, dataSpace); | 
| Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 1042 | FlattenableUtils::write(buffer, size, crop); | 
|  | 1043 | FlattenableUtils::write(buffer, size, scalingMode); | 
|  | 1044 | FlattenableUtils::write(buffer, size, transform); | 
| Ruben Brunk | 1681d95 | 2014-06-27 15:51:55 -0700 | [diff] [blame] | 1045 | FlattenableUtils::write(buffer, size, stickyTransform); | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1046 | FlattenableUtils::write(buffer, size, getFrameTimestamps); | 
|  | 1047 |  | 
| Dan Stoza | 5065a55 | 2015-03-17 16:23:42 -0700 | [diff] [blame] | 1048 | status_t result = fence->flatten(buffer, size, fds, count); | 
|  | 1049 | if (result != NO_ERROR) { | 
|  | 1050 | return result; | 
|  | 1051 | } | 
| Courtney Goeltzenleuchter | 9bad0d7 | 2017-12-19 12:34:34 -0700 | [diff] [blame] | 1052 | result = surfaceDamage.flatten(buffer, size); | 
|  | 1053 | if (result != NO_ERROR) { | 
|  | 1054 | return result; | 
|  | 1055 | } | 
|  | 1056 | FlattenableUtils::advance(buffer, size, surfaceDamage.getFlattenedSize()); | 
|  | 1057 | return hdrMetadata.flatten(buffer, size); | 
| Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 1058 | } | 
|  | 1059 |  | 
| Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 1060 | status_t IGraphicBufferProducer::QueueBufferInput::unflatten( | 
|  | 1061 | void const*& buffer, size_t& size, int const*& fds, size_t& count) | 
| Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 1062 | { | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1063 | if (size < minFlattenedSize()) { | 
| Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 1064 | return NO_MEMORY; | 
|  | 1065 | } | 
|  | 1066 |  | 
|  | 1067 | FlattenableUtils::read(buffer, size, timestamp); | 
| Andy McFadden | 3c25621 | 2013-08-16 14:55:39 -0700 | [diff] [blame] | 1068 | FlattenableUtils::read(buffer, size, isAutoTimestamp); | 
| Eino-Ville Talvala | 82c6bcc | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 1069 | FlattenableUtils::read(buffer, size, dataSpace); | 
| Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 1070 | FlattenableUtils::read(buffer, size, crop); | 
|  | 1071 | FlattenableUtils::read(buffer, size, scalingMode); | 
|  | 1072 | FlattenableUtils::read(buffer, size, transform); | 
| Ruben Brunk | 1681d95 | 2014-06-27 15:51:55 -0700 | [diff] [blame] | 1073 | FlattenableUtils::read(buffer, size, stickyTransform); | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1074 | FlattenableUtils::read(buffer, size, getFrameTimestamps); | 
| Mathias Agopian | e142428 | 2013-07-29 21:24:40 -0700 | [diff] [blame] | 1075 |  | 
| Jamie Gennis | 1df8c34 | 2012-12-20 14:05:45 -0800 | [diff] [blame] | 1076 | fence = new Fence(); | 
| Dan Stoza | 5065a55 | 2015-03-17 16:23:42 -0700 | [diff] [blame] | 1077 | status_t result = fence->unflatten(buffer, size, fds, count); | 
|  | 1078 | if (result != NO_ERROR) { | 
|  | 1079 | return result; | 
|  | 1080 | } | 
| Courtney Goeltzenleuchter | 9bad0d7 | 2017-12-19 12:34:34 -0700 | [diff] [blame] | 1081 | result = surfaceDamage.unflatten(buffer, size); | 
|  | 1082 | if (result != NO_ERROR) { | 
|  | 1083 | return result; | 
|  | 1084 | } | 
|  | 1085 | FlattenableUtils::advance(buffer, size, surfaceDamage.getFlattenedSize()); | 
|  | 1086 | return hdrMetadata.unflatten(buffer, size); | 
| Jesse Hall | c777b0b | 2012-06-28 12:52:05 -0700 | [diff] [blame] | 1087 | } | 
|  | 1088 |  | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1089 | // ---------------------------------------------------------------------------- | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1090 | constexpr size_t IGraphicBufferProducer::QueueBufferOutput::minFlattenedSize() { | 
|  | 1091 | return sizeof(width) + | 
|  | 1092 | sizeof(height) + | 
|  | 1093 | sizeof(transformHint) + | 
|  | 1094 | sizeof(numPendingBuffers) + | 
| Shuzhen Wang | 22f842b | 2017-01-18 23:02:36 -0800 | [diff] [blame] | 1095 | sizeof(nextFrameNumber) + | 
|  | 1096 | sizeof(bufferReplaced); | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1097 | } | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1098 |  | 
|  | 1099 | size_t IGraphicBufferProducer::QueueBufferOutput::getFlattenedSize() const { | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1100 | return minFlattenedSize() + frameTimestamps.getFlattenedSize(); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1101 | } | 
|  | 1102 |  | 
|  | 1103 | size_t IGraphicBufferProducer::QueueBufferOutput::getFdCount() const { | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1104 | return frameTimestamps.getFdCount(); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1105 | } | 
|  | 1106 |  | 
|  | 1107 | status_t IGraphicBufferProducer::QueueBufferOutput::flatten( | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1108 | void*& buffer, size_t& size, int*& fds, size_t& count) const | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1109 | { | 
|  | 1110 | if (size < getFlattenedSize()) { | 
|  | 1111 | return NO_MEMORY; | 
|  | 1112 | } | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1113 |  | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1114 | FlattenableUtils::write(buffer, size, width); | 
|  | 1115 | FlattenableUtils::write(buffer, size, height); | 
|  | 1116 | FlattenableUtils::write(buffer, size, transformHint); | 
|  | 1117 | FlattenableUtils::write(buffer, size, numPendingBuffers); | 
|  | 1118 | FlattenableUtils::write(buffer, size, nextFrameNumber); | 
| Shuzhen Wang | 22f842b | 2017-01-18 23:02:36 -0800 | [diff] [blame] | 1119 | FlattenableUtils::write(buffer, size, bufferReplaced); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1120 |  | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1121 | return frameTimestamps.flatten(buffer, size, fds, count); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1122 | } | 
|  | 1123 |  | 
|  | 1124 | status_t IGraphicBufferProducer::QueueBufferOutput::unflatten( | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1125 | void const*& buffer, size_t& size, int const*& fds, size_t& count) | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1126 | { | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1127 | if (size < minFlattenedSize()) { | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1128 | return NO_MEMORY; | 
|  | 1129 | } | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1130 |  | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1131 | FlattenableUtils::read(buffer, size, width); | 
|  | 1132 | FlattenableUtils::read(buffer, size, height); | 
|  | 1133 | FlattenableUtils::read(buffer, size, transformHint); | 
|  | 1134 | FlattenableUtils::read(buffer, size, numPendingBuffers); | 
|  | 1135 | FlattenableUtils::read(buffer, size, nextFrameNumber); | 
| Shuzhen Wang | 22f842b | 2017-01-18 23:02:36 -0800 | [diff] [blame] | 1136 | FlattenableUtils::read(buffer, size, bufferReplaced); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1137 |  | 
| Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 1138 | return frameTimestamps.unflatten(buffer, size, fds, count); | 
| Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 1139 | } | 
|  | 1140 |  | 
| Jamie Gennis | 8ba32fa | 2010-12-20 11:27:26 -0800 | [diff] [blame] | 1141 | }; // namespace android |