Pawin Vongmasa | 95674af | 2018-09-06 04:40:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | package android.hardware.graphics.bufferqueue@2.0; |
| 18 | |
| 19 | import android.hardware.graphics.common@1.2::HardwareBuffer; |
| 20 | import android.hardware.graphics.common@1.2::HardwareBufferDescription; |
| 21 | import android.hardware.graphics.common@1.2::Rect; |
| 22 | |
| 23 | import IProducerListener; |
| 24 | |
| 25 | /** |
| 26 | * Ref: frameworks/native/include/gui/IGraphicBufferProducer.h: |
| 27 | * IGraphicBufferProducer |
| 28 | * This is a wrapper/wrapped HAL interface for the actual binder interface. |
| 29 | */ |
| 30 | interface IGraphicBufferProducer { |
| 31 | /** |
| 32 | * Sets the maximum number of buffers that can be dequeued at one time. If |
| 33 | * this method succeeds, any new buffer slots shall be both unallocated and |
| 34 | * owned by the buffer queue, i.e., they are not owned by the producer or |
| 35 | * the consumer. Calling this may cause some buffer slots to be emptied. If |
| 36 | * the caller is caching the contents of the buffer slots, it must empty |
| 37 | * that cache after calling this method. |
| 38 | * |
| 39 | * @p maxDequeuedBuffers must not be less than the number of currently |
| 40 | * dequeued buffer slots; otherwise, the returned @p status shall be |
| 41 | * `BAD_VALUE`. |
| 42 | * |
| 43 | * @p maxDequeuedBuffers must be at least 1 (inclusive), but at most |
| 44 | * (`NUM_BUFFER_SLOTS` - the minimum undequeued buffer count) (exclusive). |
| 45 | * The minimum undequeued buffer count can be obtained by calling |
| 46 | * `query(ANATIVEWINDOW_QUERY_MIN_UNDEQUEUED_BUFFERS)`. |
| 47 | * |
| 48 | * Before calling setMaxDequeuedBufferCount(), the caller must make sure |
| 49 | * that |
| 50 | * - @p maxDequeuedBuffers is greater than or equal to 1. |
| 51 | * - @p maxDequeuedBuffers is greater than or equal to the number of |
| 52 | * currently dequeued buffer slots. |
| 53 | * If any of these conditions do not hold, or if the request to set the new |
| 54 | * maximum number of dequeued buffers cannot be accomplished for any other |
| 55 | * reasons, `BAD_VALUE` shall be returned in @p status. |
| 56 | * |
| 57 | * @param maxDequeuedBuffers The desired number of buffers that can be |
| 58 | * dequeued at one time. |
| 59 | * @return status Status of the call. |
| 60 | */ |
| 61 | setMaxDequeuedBufferCount( |
| 62 | int32_t maxDequeuedBuffers |
| 63 | ) generates ( |
| 64 | Status status |
| 65 | ); |
| 66 | |
| 67 | /** |
| 68 | * Assigns a newly created buffer to the given slot index. The client is |
| 69 | * expected to mirror the slot-to-buffer mapping so that it is not necessary |
| 70 | * to transfer a `HardwareBuffer` object for every dequeue operation. |
| 71 | * |
| 72 | * If @p slot is not a valid slot index corresponding to a dequeued buffer, |
| 73 | * the call shall fail with @p status set to `BAD_VALUE`. |
| 74 | * |
| 75 | * @param slot Slot index. |
| 76 | * @return status Status of the call. |
| 77 | * @return buffer New buffer associated to the given slot index. |
| 78 | */ |
| 79 | requestBuffer( |
| 80 | int32_t slot |
| 81 | ) generates ( |
| 82 | Status status, |
| 83 | HardwareBuffer buffer |
| 84 | ); |
| 85 | |
| 86 | /** |
| 87 | * Sets the async flag: whether the producer intends to asynchronously queue |
| 88 | * buffers without blocking. Typically this is used for triple-buffering |
| 89 | * and/or when the swap interval is set to zero. |
| 90 | * |
| 91 | * Enabling async mode may internally allocate an additional buffer to allow |
| 92 | * for the asynchronous behavior. If it is not enabled, queue/dequeue calls |
| 93 | * may block. |
| 94 | * |
| 95 | * Changing the async flag may affect the number of available slots. If the |
| 96 | * adjustment to the number of slots cannot be made, @p status shall be set |
| 97 | * to `BAD_VALUE`. |
| 98 | * |
| 99 | * @param async True if the asynchronous operation is desired; false |
| 100 | * otherwise. |
| 101 | * @return status Status of the call. |
| 102 | */ |
| 103 | setAsyncMode( |
| 104 | bool async |
| 105 | ) generates ( |
| 106 | Status status |
| 107 | ); |
| 108 | |
| 109 | /** |
| 110 | * Input data for dequeueBuffer() specifying desired attributes of a buffer |
| 111 | * to dequeue. |
| 112 | * |
| 113 | * This structure contains 4 fields from |
| 114 | * +llndk libnativewindow#AHardwareBuffer_Desc. |
| 115 | * |
| 116 | * The `width` and `height` parameters must be no greater than the minimum |
| 117 | * of `GL_MAX_VIEWPORT_DIMS` and `GL_MAX_TEXTURE_SIZE` (see: |
| 118 | * glGetIntegerv()). An error due to invalid dimensions may not be reported |
| 119 | * until updateTexImage() is called. |
| 120 | * |
| 121 | * If `width` and `height` are both zero, the default dimensions shall be |
| 122 | * used. If only one of `width` and `height` is zero, dequeueBuffer() shall |
| 123 | * return `BAD_VALUE` in `status`. |
| 124 | * |
| 125 | * If `format` is zero, the default format shall be used. |
| 126 | * |
| 127 | * `usage` shall be merged with the usage flags set from the consumer side. |
| 128 | * |
| 129 | * @sa +llndk libnativewindow#AHardwareBuffer_Desc. |
| 130 | */ |
| 131 | struct DequeueBufferInput { |
| 132 | uint32_t width; |
| 133 | uint32_t height; |
| 134 | uint32_t format; |
| 135 | uint64_t usage; |
| 136 | }; |
| 137 | |
| 138 | /** |
| 139 | * Output data for dequeueBuffer(). |
| 140 | * |
| 141 | * A `DequeueBufferOutput` object returned from dequeueBuffer() shall be |
| 142 | * valid if and only if `status` returned from the same call is `OK`. |
| 143 | */ |
| 144 | struct DequeueBufferOutput { |
| 145 | /** |
| 146 | * The number of frames that have elapsed since the buffer was last |
| 147 | * queued. |
| 148 | */ |
| 149 | uint64_t bufferAge; |
| 150 | /** |
| 151 | * Whether the client must call requestBuffer(). |
| 152 | */ |
| 153 | bool bufferNeedsReallocation; |
| 154 | /** |
| 155 | * Whether the client must discard the mirrored slot-to-buffer |
| 156 | * mapping. |
| 157 | */ |
| 158 | bool releaseAllBuffers; |
| 159 | /** |
| 160 | * Fence associated with the buffer. |
| 161 | * |
| 162 | * If this is an empty fence, the buffer may be written immediately; |
| 163 | * otherwise, the buffer must not be written to until the fence signals. |
| 164 | */ |
| 165 | Fence fence; |
| 166 | }; |
| 167 | |
| 168 | /** |
| 169 | * Requests a new buffer slot for the client to use. Ownership of the slot |
| 170 | * is transfered to the client, meaning that the server shall not use the |
| 171 | * contents of the buffer associated with that slot. |
| 172 | * |
| 173 | * On success, @p status shall be `OK`, and @p output shall contain valid |
| 174 | * information of the call. Otherwise, the contents of @p output are |
| 175 | * meaningless. |
| 176 | * |
| 177 | * The slot index returned in @p slot may or may not contain a buffer |
| 178 | * (client-side). If the slot is empty, the client must call |
| 179 | * requestBuffer() to assign a new buffer to that slot. |
| 180 | * |
| 181 | * Once the client is done filling this buffer, it is expected to transfer |
| 182 | * buffer ownership back to the server with either cancelBuffer() on |
| 183 | * the dequeued slot or to fill in the contents of its associated buffer |
| 184 | * contents and call queueBuffer(). |
| 185 | * |
| 186 | * If dequeueBuffer() returns with `output.releaseAllBuffers` set to `true`, |
| 187 | * the client is expected to release all of the mirrored slot-to-buffer |
| 188 | * mappings. |
| 189 | * |
| 190 | * If dequeueBuffer() returns with `output.bufferNeedsReallocation` set to |
| 191 | * `true`, the client is expected to call requestBuffer() immediately. |
| 192 | * |
| 193 | * The returned `output.fence` shall be updated to hold the fence associated |
| 194 | * with the buffer. The contents of the buffer must not be overwritten until |
| 195 | * the fence signals. If the fence is an empty fence, the buffer may be |
| 196 | * written immediately. |
| 197 | * |
| 198 | * This call shall block until a buffer is available to be dequeued. If |
| 199 | * both the producer and consumer are controlled by the app, then this call |
| 200 | * can never block and shall return `WOULD_BLOCK` in @p status if no buffer |
| 201 | * is available. |
| 202 | * |
| 203 | * If a dequeue operation shall cause certain conditions on the number of |
| 204 | * buffers to be violated (such as the maximum number of dequeued buffers), |
| 205 | * @p status shall be set to `INVALID_OPERATION` to indicate failure. |
| 206 | * |
| 207 | * If a dequeue operation cannot be completed within the time period |
| 208 | * previously set by setDequeueTimeout(), the return @p status shall |
| 209 | * `TIMED_OUT`. |
| 210 | * |
| 211 | * See @ref DequeueBufferInput for more information on the @p input |
| 212 | * parameter. |
| 213 | * |
| 214 | * @param input See #DequeueBufferInput for more information. |
| 215 | * @param status Status of the call. |
| 216 | * @param slot Slot index. |
| 217 | * @param output See #DequeueBufferOutput for more information. |
| 218 | * |
| 219 | * @sa queueBuffer(), requestBuffer(). |
| 220 | */ |
| 221 | dequeueBuffer( |
| 222 | DequeueBufferInput input |
| 223 | ) generates ( |
| 224 | Status status, |
| 225 | int32_t slot, |
| 226 | DequeueBufferOutput output |
| 227 | ); |
| 228 | |
| 229 | /** |
| 230 | * Attempts to remove all ownership of the buffer in the given slot from the |
| 231 | * buffer queue. |
| 232 | * |
| 233 | * If this call succeeds, the slot shall be freed, and there shall be no way |
| 234 | * to obtain the buffer from this interface. The freed slot shall remain |
| 235 | * unallocated until either it is selected to hold a freshly allocated |
| 236 | * buffer in dequeueBuffer() or a buffer is attached to the slot. The buffer |
| 237 | * must have already been dequeued, and the caller must already possesses |
| 238 | * the buffer (i.e., must have called requestBuffer()). |
| 239 | * |
| 240 | * @param slot Slot index. |
| 241 | * @return status Status of the call. |
| 242 | */ |
| 243 | detachBuffer( |
| 244 | int32_t slot |
| 245 | ) generates ( |
| 246 | Status status |
| 247 | ); |
| 248 | |
| 249 | /** |
| 250 | * Dequeues a buffer slot, requests the buffer associated to the slot, and |
| 251 | * detaches it from the buffer queue. This is equivalent to calling |
| 252 | * dequeueBuffer(), requestBuffer(), and detachBuffer() in succession except |
| 253 | * for two things: |
| 254 | * 1. It is unnecessary to provide a #DequeueBufferInput object. |
| 255 | * 2. The call shall not block, since if it cannot find an appropriate |
| 256 | * buffer to return, it shall return an error instead. |
| 257 | * |
| 258 | * Only slots that are free but still contain a buffer shall be considered, |
| 259 | * and the oldest of those shall be returned. @p buffer is equivalent to the |
| 260 | * buffer that would be returned from requestBuffer(), and @p fence is |
| 261 | * equivalent to the fence that would be returned from dequeueBuffer(). |
| 262 | * |
| 263 | * @return status Status of the call. |
| 264 | * @return buffer Buffer just released from the buffer queue. |
| 265 | * @return fence Fence associated to @p buffer. |
| 266 | * |
| 267 | * @sa dequeueBuffer(), requestBuffer(), detachBuffer(). |
| 268 | */ |
| 269 | detachNextBuffer( |
| 270 | ) generates ( |
| 271 | Status status, |
| 272 | HardwareBuffer buffer, |
| 273 | Fence fence |
| 274 | ); |
| 275 | |
| 276 | /** |
| 277 | * Attempts to transfer ownership of a buffer to the buffer queue. |
| 278 | * |
| 279 | * If this call succeeds, it shall be as if this buffer was dequeued from the |
| 280 | * returned slot index. As such, this call shall fail if attaching this |
| 281 | * buffer would cause too many buffers to be simultaneously dequeued. |
| 282 | * |
| 283 | * If the returned @p releaseAllBuffers is `true`, the caller is expected to |
| 284 | * release all of the mirrored slot-to-buffer mappings. |
| 285 | * |
| 286 | * See dequeueBuffer() for conditions that may cause the call to fail. |
| 287 | * |
| 288 | * @param buffer Buffer to attach to the buffer queue. |
| 289 | * @return status Status of the call. |
| 290 | * @return slot Slot index assigned to @p buffer. |
| 291 | * @return releaseAllBuffers Whether the caller is expected to release all |
| 292 | * of the mirrored slot-to-buffer mappings. |
| 293 | * |
| 294 | * @sa dequeueBuffer(). |
| 295 | */ |
| 296 | attachBuffer( |
| 297 | HardwareBuffer buffer |
| 298 | ) generates ( |
| 299 | Status status, |
| 300 | int32_t slot, |
| 301 | bool releaseAllBuffers |
| 302 | ); |
| 303 | |
| 304 | struct QueueBufferInput { |
| 305 | /** |
| 306 | * Timestamp in nanoseconds. |
| 307 | */ |
| 308 | int64_t timestamp; |
| 309 | /** |
| 310 | * Whether the timestamp was synthesized at queue time. |
| 311 | */ |
| 312 | bool isAutoTimestamp; |
| 313 | /** |
| 314 | * Dataspace of the contents. |
| 315 | * |
| 316 | * @sa +ndk libnativewindow#ADataSpace. |
| 317 | */ |
| 318 | int32_t dataSpace; |
| 319 | /** |
| 320 | * Crop rectangle that is used as a hint to the consumer. |
| 321 | */ |
| 322 | Rect crop; |
| 323 | /** |
| 324 | * Transformation flags. |
| 325 | * |
| 326 | * @sa +ndk libnativewindow#ANativeWindowTransform. |
| 327 | */ |
| 328 | int32_t transform; |
| 329 | /** |
| 330 | * The sticky transform set in Surface (only used by the LEGACY camera |
| 331 | * mode). |
| 332 | * |
| 333 | * @sa +ndk libnativewindow#ANativeWindowTransform. |
| 334 | */ |
| 335 | int32_t stickyTransform; |
| 336 | /** |
| 337 | * Fence that the consumer must wait on before reading the buffer. An |
| 338 | * empty fence indicates that the buffer is ready immediately. |
| 339 | */ |
| 340 | Fence fence; |
| 341 | /** |
| 342 | * List of rectangular pieces covering the damage region. |
| 343 | */ |
| 344 | vec<Rect> surfaceDamage; |
| 345 | }; |
| 346 | |
| 347 | /** |
| 348 | * Information about the queued buffer. `QueueBufferOutput` is used in both |
| 349 | * queueBuffer() and connect(). |
| 350 | */ |
| 351 | struct QueueBufferOutput { |
| 352 | /** |
| 353 | * Default width of a buffer in the buffer queue. |
| 354 | */ |
| 355 | uint32_t width; |
| 356 | /** |
| 357 | * Default height of a buffer in the buffer queue. |
| 358 | */ |
| 359 | uint32_t height; |
| 360 | /** |
| 361 | * The transform hint of the buffer queue. |
| 362 | * |
| 363 | * @sa +ndk libnativewindow#ANativeWindowTransform. |
| 364 | */ |
| 365 | int32_t transformHint; |
| 366 | /** |
| 367 | * The number of pending buffers in the buffer queue. If this is |
| 368 | * returned from queueBuffer(), the number shall include the buffer that |
| 369 | * has just been queued. |
| 370 | */ |
| 371 | uint32_t numPendingBuffers; |
| 372 | /** |
| 373 | * The frame number of the next frame. The buffer queue maintains this |
| 374 | * number and makes sure that it is increasing for every successful |
| 375 | * queueBuffer() call. |
| 376 | */ |
| 377 | uint64_t nextFrameNumber; |
| 378 | /** |
| 379 | * After a successful queueBuffer() call, #bufferReplaced shall be set to |
| 380 | * true if the queued buffer replaced a previously queued buffer that |
| 381 | * has not been consumed. |
| 382 | */ |
| 383 | bool bufferReplaced; |
| 384 | }; |
| 385 | |
| 386 | /** |
| 387 | * Indicates that the client has finished filling in the contents of the |
| 388 | * buffer associated with slot and transfers ownership of that slot back to |
| 389 | * the buffer queue. |
| 390 | * |
| 391 | * @p status may be set to `BAD_VALUE` if any of the following conditions |
| 392 | * hold: |
| 393 | * - The buffer queue is operating in the asynchronous mode, and the |
| 394 | * buffer count was smaller than the maximum number of buffers that can |
| 395 | * be allocated at once. |
| 396 | * - @p slot is an invalid slot index, i.e., the slot is not owned by the |
| 397 | * client by previously calling dequeueBuffer(), requestBuffer() or |
| 398 | * attachBuffer(). |
| 399 | * - The crop rectangle is not contained in the buffer. |
| 400 | * |
| 401 | * Upon success, the output shall be filled with meaningful values |
| 402 | * (refer to the documentation of @ref QueueBufferOutput). |
| 403 | * |
| 404 | * @param slot Slot index. |
| 405 | * @param input See @ref QueueBufferInput. |
| 406 | * @return status Status of the call. |
| 407 | * @return output See @ref QueueBufferOutput. |
| 408 | * |
| 409 | * @sa #QueueBufferInput, #QueueBufferOutput, dequeueBuffer(). |
| 410 | */ |
| 411 | queueBuffer( |
| 412 | int32_t slot, |
| 413 | QueueBufferInput input |
| 414 | ) generates ( |
| 415 | Status status, |
| 416 | QueueBufferOutput output |
| 417 | ); |
| 418 | |
| 419 | /** |
| 420 | * Indicates that the client does not wish to fill in the buffer associated |
| 421 | * with the slot and transfers ownership of the slot back to the server. The |
| 422 | * buffer is not queued for use by the consumer. |
| 423 | * |
| 424 | * If @p fence is not an empty fence, the buffer shall not be overwritten |
| 425 | * until the fence signals. @p fence is usually obtained from |
| 426 | * dequeueBuffer(). |
| 427 | * |
| 428 | * @param slot Slot index. |
| 429 | * @param fence Fence for the canceled buffer. |
| 430 | * @return status Status of the call. |
| 431 | */ |
| 432 | cancelBuffer( |
| 433 | int32_t slot, |
| 434 | Fence fence |
| 435 | ) generates ( |
| 436 | Status status |
| 437 | ); |
| 438 | |
| 439 | /** |
| 440 | * Retrieves information for this surface. |
| 441 | * |
| 442 | * @param what What to query. @p what must be one of the values in |
| 443 | * +llndk libnativewindow#ANativeWindowQuery. |
| 444 | * @return status Status of the call. |
| 445 | * @return value The value queried. The set of possible values depends on |
| 446 | * the value of @p what. |
| 447 | * |
| 448 | * @sa +llndk libnativewindow#ANativeWindowQuery. |
| 449 | */ |
| 450 | query( |
| 451 | int32_t what |
| 452 | ) generates ( |
| 453 | int32_t result, |
| 454 | int32_t value |
| 455 | ); |
| 456 | |
| 457 | /** |
| 458 | * Attempts to connect the client as a producer of the buffer queue. |
| 459 | * This method must be called before any other methods in this interface. |
| 460 | * |
| 461 | * If the buffer queue does not have a consumer ready (connected), the |
| 462 | * return @p status shall be `NO_INIT`. |
| 463 | * |
| 464 | * If any of the following conditions hold, the error code `BAD_VALUE` shall |
| 465 | * be reported in @p status: |
| 466 | * - The producer is already connected. |
| 467 | * - The number of available slots cannot be adjusted to accommodate the |
| 468 | * supplied value of @p producerControlledByApp. |
| 469 | * |
| 470 | * @param listener An optional callback object that can be provided if the |
| 471 | * client wants to be notified when the consumer releases a buffer back |
| 472 | * to the buffer queue. |
| 473 | * @param api How the client shall write to buffers. |
| 474 | * @param producerControlledByApp `true` if the producer is hosted by an |
| 475 | * untrusted process (typically application-forked processes). If both |
| 476 | * the producer and the consumer are controlled by app, the buffer queue |
| 477 | * shall operate in the asynchronous mode regardless of the async flag |
| 478 | * set by setAsyncMode(). |
| 479 | * @return status Status of the call. |
| 480 | * @return output See #QueueBufferOutput for more information. |
| 481 | * |
| 482 | * @sa #QueueBufferOutput, disconnect(), setAsyncMode(). |
| 483 | */ |
| 484 | connect( |
| 485 | IProducerListener listener, |
| 486 | ConnectionType api, |
| 487 | bool producerControlledByApp |
| 488 | ) generates ( |
| 489 | Status status, |
| 490 | QueueBufferOutput output |
| 491 | ); |
| 492 | |
| 493 | /** |
| 494 | * Attempts to disconnect the client from the producer end of the buffer |
| 495 | * queue. |
| 496 | * |
| 497 | * Calling this method shall cause any subsequent calls to other |
| 498 | * @ref IGraphicBufferProducer methods apart from connect() to fail. |
| 499 | * A successful connect() call afterwards may allow other methods to succeed |
| 500 | * again. |
| 501 | * |
| 502 | * Disconnecting from an abandoned buffer queue is legal and is considered a |
| 503 | * no-op. |
| 504 | * |
| 505 | * @param api The type of connection to disconnect. Supplying the value of |
| 506 | * `CURRENTLY_CONNECTED` to @p api has the same effect as supplying the |
| 507 | * current connection type. If the producer end is not connected, |
| 508 | * supplying `CURRENTLY_CONNECTED` shall result in a successful no-op |
| 509 | * call. |
| 510 | * @return status Status of the call. |
| 511 | * |
| 512 | * @sa connect(). |
| 513 | */ |
| 514 | disconnect( |
| 515 | ConnectionType api |
| 516 | ) generates ( |
| 517 | Status status |
| 518 | ); |
| 519 | |
| 520 | /** |
| 521 | * Allocates buffers based on the given dimensions, format and usage. |
| 522 | * |
| 523 | * This function shall allocate up to the maximum number of buffers |
| 524 | * permitted by the current buffer queue configuration. It shall use the |
| 525 | * given format, dimensions, and usage bits, which are interpreted in the |
| 526 | * same way as for dequeueBuffer(), and the async flag must be set the same |
| 527 | * way as for dequeueBuffer() to ensure that the correct number of buffers |
| 528 | * are allocated. This is most useful to avoid an allocation delay during |
| 529 | * dequeueBuffer(). If there are already the maximum number of buffers |
| 530 | * allocated, this function has no effect. |
| 531 | * |
| 532 | * A value of 0 in @p width, @p height or @p format indicates that the |
| 533 | * buffer queue can pick the default value. |
| 534 | * |
| 535 | * @param width Width of buffers to allocate. |
| 536 | * @param height Height of buffers to allocate. |
| 537 | * @param format Format of buffers to allocate. |
| 538 | * @param usage Usage of bufferes to allocate. |
| 539 | * @return status Status of the call. |
| 540 | */ |
| 541 | allocateBuffers( |
| 542 | uint32_t width, |
| 543 | uint32_t height, |
| 544 | uint32_t format, |
| 545 | uint64_t usage |
| 546 | ) generates ( |
| 547 | Status status |
| 548 | ); |
| 549 | |
| 550 | /** |
| 551 | * Sets whether dequeueBuffer() is allowed to allocate new buffers. |
| 552 | * |
| 553 | * Normally dequeueBuffer() does not discriminate between free slots which |
| 554 | * already have an allocated buffer and those which do not, and shall |
| 555 | * allocate a new buffer if the slot doesn't have a buffer or if the slot's |
| 556 | * buffer doesn't match the requested size, format, or usage. This method |
| 557 | * allows the producer to restrict the eligible slots to those which already |
| 558 | * have an allocated buffer of the correct size, format, and usage. If no |
| 559 | * eligible slot is available, dequeueBuffer() shall block or return an |
| 560 | * error. |
| 561 | * |
| 562 | * @param allow Whether to allow new buffers to be allocated in |
| 563 | * dequeueBuffer(). |
| 564 | * @return status Status of the call. |
| 565 | */ |
| 566 | allowAllocation( |
| 567 | bool allow |
| 568 | ) generates ( |
| 569 | Status status |
| 570 | ); |
| 571 | |
| 572 | /** |
| 573 | * Sets the current generation number of the buffer queue. |
| 574 | * |
| 575 | * This generation number shall be inserted into any buffers allocated by the |
| 576 | * buffer queue, and any attempts to attach a buffer with a different |
| 577 | * generation number shall fail. Buffers already in the queue are not |
| 578 | * affected and shall retain their current generation number. The generation |
| 579 | * number defaults to 0, i.e., buffers allocated before the first call to |
| 580 | * setGenerationNumber() shall be given 0 as their generation numbers. |
| 581 | * |
| 582 | * @param generationNumber New generation number. The client must make sure |
| 583 | * that @p generationNumber is different from the previous generation |
| 584 | * number if it wants to deprecate old buffers. |
| 585 | * @return status Status of the call. |
| 586 | */ |
| 587 | setGenerationNumber( |
| 588 | uint32_t generationNumber |
| 589 | ) generates ( |
| 590 | Status status |
| 591 | ); |
| 592 | |
| 593 | /** |
| 594 | * Sets how long dequeueBuffer() shall wait for a buffer to become available |
| 595 | * before returning an error `TIMED_OUT`. |
| 596 | * |
| 597 | * This timeout also affects the attachBuffer() call, which shall block if |
| 598 | * there is not a free slot available into which the attached buffer can be |
| 599 | * placed. |
| 600 | * |
| 601 | * By default, the buffer queue shall wait forever, which is equivalent to |
| 602 | * setting @p timeoutNs equal to any negative number (such as `-1`). If |
| 603 | * @p timeoutNs is non-negative, setDequeueTimeout() shall disable |
| 604 | * non-blocking mode and its corresponding spare buffer (which is used to |
| 605 | * ensure a buffer is always available). |
| 606 | * |
| 607 | * Changing the dequeue timeout may affect the number of buffers. (See |
| 608 | * setAsyncMode().) If the adjustment to the number of buffers inside the |
| 609 | * buffer queue is not feasible, @p status shall be set to `BAD_VALUE`. |
| 610 | * |
| 611 | * @param timeoutNs Amount of time dequeueBuffer() is allowed to block |
| 612 | * before returning `TIMED_OUT`. If @p timeoutNs is negative, |
| 613 | * dequeueBuffer() shall not be able to return `TIMED_OUT`. Instead, it |
| 614 | * may block forever or return `WOULD_BLOCK`. |
| 615 | * @return status Status of the call. |
| 616 | * |
| 617 | * @sa dequeueBuffer(), setAsyncMode(), query(). |
| 618 | */ |
| 619 | setDequeueTimeout( |
| 620 | int64_t timeoutNs |
| 621 | ) generates ( |
| 622 | Status status |
| 623 | ); |
| 624 | |
| 625 | /** |
| 626 | * Returns a unique id for this buffer queue. |
| 627 | * |
| 628 | * @return id System-wide unique id of the buffer queue. |
| 629 | */ |
| 630 | getUniqueId( |
| 631 | ) generates ( |
| 632 | uint64_t id |
| 633 | ); |
| 634 | |
| 635 | /** |
| 636 | * Returns the name of the connected consumer. |
| 637 | * |
| 638 | * \note This is used for debugging only. |
| 639 | * |
| 640 | * @return name Name of the consumer. |
| 641 | */ |
| 642 | getConsumerName( |
| 643 | ) generates ( |
| 644 | string name |
| 645 | ); |
| 646 | |
| 647 | }; |
| 648 | |