blob: be4bec0e7d03cc88e9ac6ae0dfb831a522829a84 [file] [log] [blame]
Dan Stoza289ade12014-02-28 11:17:17 -08001/*
2 * Copyright 2014 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
Mark Salyzyn8f515ce2014-06-09 14:32:04 -070017#include <inttypes.h>
18
Dan Stoza3e96f192014-03-03 10:16:19 -080019#define LOG_TAG "BufferQueueConsumer"
20#define ATRACE_TAG ATRACE_TAG_GRAPHICS
21//#define LOG_NDEBUG 0
22
Dan Stoza289ade12014-02-28 11:17:17 -080023#include <gui/BufferItem.h>
24#include <gui/BufferQueueConsumer.h>
25#include <gui/BufferQueueCore.h>
26#include <gui/IConsumerListener.h>
Dan Stozad1c10362014-03-28 15:19:08 -070027#include <gui/IProducerListener.h>
Dan Stoza289ade12014-02-28 11:17:17 -080028
29namespace android {
30
31BufferQueueConsumer::BufferQueueConsumer(const sp<BufferQueueCore>& core) :
32 mCore(core),
33 mSlots(core->mSlots),
34 mConsumerName() {}
35
36BufferQueueConsumer::~BufferQueueConsumer() {}
37
38status_t BufferQueueConsumer::acquireBuffer(BufferItem* outBuffer,
39 nsecs_t expectedPresent) {
40 ATRACE_CALL();
41 Mutex::Autolock lock(mCore->mMutex);
42
43 // Check that the consumer doesn't currently have the maximum number of
44 // buffers acquired. We allow the max buffer count to be exceeded by one
45 // buffer so that the consumer can successfully set up the newly acquired
46 // buffer before releasing the old one.
47 int numAcquiredBuffers = 0;
Dan Stoza3e96f192014-03-03 10:16:19 -080048 for (int s = 0; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
Dan Stoza289ade12014-02-28 11:17:17 -080049 if (mSlots[s].mBufferState == BufferSlot::ACQUIRED) {
50 ++numAcquiredBuffers;
51 }
52 }
53 if (numAcquiredBuffers >= mCore->mMaxAcquiredBufferCount + 1) {
54 BQ_LOGE("acquireBuffer: max acquired buffer count reached: %d (max %d)",
55 numAcquiredBuffers, mCore->mMaxAcquiredBufferCount);
56 return INVALID_OPERATION;
57 }
58
59 // Check if the queue is empty.
60 // In asynchronous mode the list is guaranteed to be one buffer deep,
61 // while in synchronous mode we use the oldest buffer.
62 if (mCore->mQueue.empty()) {
63 return NO_BUFFER_AVAILABLE;
64 }
65
66 BufferQueueCore::Fifo::iterator front(mCore->mQueue.begin());
67
68 // If expectedPresent is specified, we may not want to return a buffer yet.
69 // If it's specified and there's more than one buffer queued, we may want
70 // to drop a buffer.
71 if (expectedPresent != 0) {
72 const int MAX_REASONABLE_NSEC = 1000000000ULL; // 1 second
73
74 // The 'expectedPresent' argument indicates when the buffer is expected
75 // to be presented on-screen. If the buffer's desired present time is
76 // earlier (less) than expectedPresent -- meaning it will be displayed
77 // on time or possibly late if we show it as soon as possible -- we
78 // acquire and return it. If we don't want to display it until after the
79 // expectedPresent time, we return PRESENT_LATER without acquiring it.
80 //
81 // To be safe, we don't defer acquisition if expectedPresent is more
82 // than one second in the future beyond the desired present time
83 // (i.e., we'd be holding the buffer for a long time).
84 //
85 // NOTE: Code assumes monotonic time values from the system clock
86 // are positive.
87
88 // Start by checking to see if we can drop frames. We skip this check if
89 // the timestamps are being auto-generated by Surface. If the app isn't
90 // generating timestamps explicitly, it probably doesn't want frames to
91 // be discarded based on them.
92 while (mCore->mQueue.size() > 1 && !mCore->mQueue[0].mIsAutoTimestamp) {
93 // If entry[1] is timely, drop entry[0] (and repeat). We apply an
94 // additional criterion here: we only drop the earlier buffer if our
95 // desiredPresent falls within +/- 1 second of the expected present.
96 // Otherwise, bogus desiredPresent times (e.g., 0 or a small
97 // relative timestamp), which normally mean "ignore the timestamp
98 // and acquire immediately", would cause us to drop frames.
99 //
100 // We may want to add an additional criterion: don't drop the
101 // earlier buffer if entry[1]'s fence hasn't signaled yet.
102 const BufferItem& bufferItem(mCore->mQueue[1]);
103 nsecs_t desiredPresent = bufferItem.mTimestamp;
104 if (desiredPresent < expectedPresent - MAX_REASONABLE_NSEC ||
105 desiredPresent > expectedPresent) {
106 // This buffer is set to display in the near future, or
107 // desiredPresent is garbage. Either way we don't want to drop
108 // the previous buffer just to get this on the screen sooner.
Mark Salyzyn8f515ce2014-06-09 14:32:04 -0700109 BQ_LOGV("acquireBuffer: nodrop desire=%" PRId64 " expect=%"
110 PRId64 " (%" PRId64 ") now=%" PRId64,
111 desiredPresent, expectedPresent,
Dan Stoza289ade12014-02-28 11:17:17 -0800112 desiredPresent - expectedPresent,
113 systemTime(CLOCK_MONOTONIC));
114 break;
115 }
116
Mark Salyzyn8f515ce2014-06-09 14:32:04 -0700117 BQ_LOGV("acquireBuffer: drop desire=%" PRId64 " expect=%" PRId64
118 " size=%zu",
Dan Stoza289ade12014-02-28 11:17:17 -0800119 desiredPresent, expectedPresent, mCore->mQueue.size());
120 if (mCore->stillTracking(front)) {
121 // Front buffer is still in mSlots, so mark the slot as free
122 mSlots[front->mSlot].mBufferState = BufferSlot::FREE;
123 }
124 mCore->mQueue.erase(front);
125 front = mCore->mQueue.begin();
126 }
127
128 // See if the front buffer is due
129 nsecs_t desiredPresent = front->mTimestamp;
130 if (desiredPresent > expectedPresent &&
131 desiredPresent < expectedPresent + MAX_REASONABLE_NSEC) {
Mark Salyzyn8f515ce2014-06-09 14:32:04 -0700132 BQ_LOGV("acquireBuffer: defer desire=%" PRId64 " expect=%" PRId64
133 " (%" PRId64 ") now=%" PRId64,
134 desiredPresent, expectedPresent,
Dan Stoza289ade12014-02-28 11:17:17 -0800135 desiredPresent - expectedPresent,
136 systemTime(CLOCK_MONOTONIC));
137 return PRESENT_LATER;
138 }
139
Mark Salyzyn8f515ce2014-06-09 14:32:04 -0700140 BQ_LOGV("acquireBuffer: accept desire=%" PRId64 " expect=%" PRId64 " "
141 "(%" PRId64 ") now=%" PRId64, desiredPresent, expectedPresent,
Dan Stoza289ade12014-02-28 11:17:17 -0800142 desiredPresent - expectedPresent,
143 systemTime(CLOCK_MONOTONIC));
144 }
145
146 int slot = front->mSlot;
147 *outBuffer = *front;
148 ATRACE_BUFFER_INDEX(slot);
149
Mark Salyzyn8f515ce2014-06-09 14:32:04 -0700150 BQ_LOGV("acquireBuffer: acquiring { slot=%d/%" PRIu64 " buffer=%p }",
Dan Stoza289ade12014-02-28 11:17:17 -0800151 slot, front->mFrameNumber, front->mGraphicBuffer->handle);
152 // If the front buffer is still being tracked, update its slot state
153 if (mCore->stillTracking(front)) {
154 mSlots[slot].mAcquireCalled = true;
155 mSlots[slot].mNeedsCleanupOnRelease = false;
156 mSlots[slot].mBufferState = BufferSlot::ACQUIRED;
157 mSlots[slot].mFence = Fence::NO_FENCE;
158 }
159
160 // If the buffer has previously been acquired by the consumer, set
161 // mGraphicBuffer to NULL to avoid unnecessarily remapping this buffer
162 // on the consumer side
163 if (outBuffer->mAcquireCalled) {
164 outBuffer->mGraphicBuffer = NULL;
165 }
166
167 mCore->mQueue.erase(front);
Dan Stozaae3c3682014-04-18 15:43:35 -0700168
169 // We might have freed a slot while dropping old buffers, or the producer
170 // may be blocked waiting for the number of buffers in the queue to
171 // decrease.
Dan Stoza289ade12014-02-28 11:17:17 -0800172 mCore->mDequeueCondition.broadcast();
173
174 ATRACE_INT(mCore->mConsumerName.string(), mCore->mQueue.size());
175
176 return NO_ERROR;
177}
178
Dan Stozade7100a2015-03-11 16:38:47 -0700179status_t BufferQueueConsumer::acquireBuffer(android::BufferItem* outBuffer,
180 nsecs_t expectedPresent) {
181 if (outBuffer == nullptr) {
182 return BAD_VALUE;
183 }
184
185 android::BufferItem item;
186 status_t result = acquireBuffer(&item, expectedPresent);
187 if (result != NO_ERROR) {
188 return result;
189 }
190
191 *outBuffer = item;
192 return NO_ERROR;
193}
194
Dan Stoza9f3053d2014-03-06 15:14:33 -0800195status_t BufferQueueConsumer::detachBuffer(int slot) {
196 ATRACE_CALL();
197 ATRACE_BUFFER_INDEX(slot);
198 BQ_LOGV("detachBuffer(C): slot %d", slot);
199 Mutex::Autolock lock(mCore->mMutex);
200
201 if (mCore->mIsAbandoned) {
202 BQ_LOGE("detachBuffer(C): BufferQueue has been abandoned");
203 return NO_INIT;
204 }
205
206 if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS) {
207 BQ_LOGE("detachBuffer(C): slot index %d out of range [0, %d)",
208 slot, BufferQueueDefs::NUM_BUFFER_SLOTS);
209 return BAD_VALUE;
210 } else if (mSlots[slot].mBufferState != BufferSlot::ACQUIRED) {
211 BQ_LOGE("detachBuffer(C): slot %d is not owned by the consumer "
212 "(state = %d)", slot, mSlots[slot].mBufferState);
213 return BAD_VALUE;
214 }
215
216 mCore->freeBufferLocked(slot);
217 mCore->mDequeueCondition.broadcast();
218
219 return NO_ERROR;
220}
221
222status_t BufferQueueConsumer::attachBuffer(int* outSlot,
223 const sp<android::GraphicBuffer>& buffer) {
224 ATRACE_CALL();
225
226 if (outSlot == NULL) {
227 BQ_LOGE("attachBuffer(P): outSlot must not be NULL");
228 return BAD_VALUE;
229 } else if (buffer == NULL) {
230 BQ_LOGE("attachBuffer(P): cannot attach NULL buffer");
231 return BAD_VALUE;
232 }
233
234 Mutex::Autolock lock(mCore->mMutex);
235
236 // Make sure we don't have too many acquired buffers and find a free slot
237 // to put the buffer into (the oldest if there are multiple).
238 int numAcquiredBuffers = 0;
239 int found = BufferQueueCore::INVALID_BUFFER_SLOT;
240 for (int s = 0; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
241 if (mSlots[s].mBufferState == BufferSlot::ACQUIRED) {
242 ++numAcquiredBuffers;
243 } else if (mSlots[s].mBufferState == BufferSlot::FREE) {
244 if (found == BufferQueueCore::INVALID_BUFFER_SLOT ||
245 mSlots[s].mFrameNumber < mSlots[found].mFrameNumber) {
246 found = s;
247 }
248 }
249 }
250
251 if (numAcquiredBuffers >= mCore->mMaxAcquiredBufferCount + 1) {
252 BQ_LOGE("attachBuffer(P): max acquired buffer count reached: %d "
253 "(max %d)", numAcquiredBuffers,
254 mCore->mMaxAcquiredBufferCount);
255 return INVALID_OPERATION;
256 }
257 if (found == BufferQueueCore::INVALID_BUFFER_SLOT) {
258 BQ_LOGE("attachBuffer(P): could not find free buffer slot");
259 return NO_MEMORY;
260 }
261
262 *outSlot = found;
263 ATRACE_BUFFER_INDEX(*outSlot);
264 BQ_LOGV("attachBuffer(C): returning slot %d", *outSlot);
265
266 mSlots[*outSlot].mGraphicBuffer = buffer;
267 mSlots[*outSlot].mBufferState = BufferSlot::ACQUIRED;
268 mSlots[*outSlot].mAttachedByConsumer = true;
Dan Stoza9f3053d2014-03-06 15:14:33 -0800269 mSlots[*outSlot].mNeedsCleanupOnRelease = false;
270 mSlots[*outSlot].mFence = Fence::NO_FENCE;
271 mSlots[*outSlot].mFrameNumber = 0;
272
Dan Stoza99b18b42014-03-28 15:34:33 -0700273 // mAcquireCalled tells BufferQueue that it doesn't need to send a valid
274 // GraphicBuffer pointer on the next acquireBuffer call, which decreases
275 // Binder traffic by not un/flattening the GraphicBuffer. However, it
276 // requires that the consumer maintain a cached copy of the slot <--> buffer
277 // mappings, which is why the consumer doesn't need the valid pointer on
278 // acquire.
279 //
280 // The StreamSplitter is one of the primary users of the attach/detach
281 // logic, and while it is running, all buffers it acquires are immediately
282 // detached, and all buffers it eventually releases are ones that were
283 // attached (as opposed to having been obtained from acquireBuffer), so it
284 // doesn't make sense to maintain the slot/buffer mappings, which would
285 // become invalid for every buffer during detach/attach. By setting this to
286 // false, the valid GraphicBuffer pointer will always be sent with acquire
287 // for attached buffers.
288 mSlots[*outSlot].mAcquireCalled = false;
289
Dan Stoza9f3053d2014-03-06 15:14:33 -0800290 return NO_ERROR;
291}
292
Dan Stoza289ade12014-02-28 11:17:17 -0800293status_t BufferQueueConsumer::releaseBuffer(int slot, uint64_t frameNumber,
294 const sp<Fence>& releaseFence, EGLDisplay eglDisplay,
295 EGLSyncKHR eglFence) {
296 ATRACE_CALL();
297 ATRACE_BUFFER_INDEX(slot);
298
Dan Stoza9f3053d2014-03-06 15:14:33 -0800299 if (slot < 0 || slot >= BufferQueueDefs::NUM_BUFFER_SLOTS ||
300 releaseFence == NULL) {
Dan Stoza289ade12014-02-28 11:17:17 -0800301 return BAD_VALUE;
302 }
303
Dan Stozad1c10362014-03-28 15:19:08 -0700304 sp<IProducerListener> listener;
305 { // Autolock scope
306 Mutex::Autolock lock(mCore->mMutex);
Dan Stoza289ade12014-02-28 11:17:17 -0800307
Dan Stozad1c10362014-03-28 15:19:08 -0700308 // If the frame number has changed because the buffer has been reallocated,
309 // we can ignore this releaseBuffer for the old buffer
310 if (frameNumber != mSlots[slot].mFrameNumber) {
311 return STALE_BUFFER_SLOT;
312 }
Dan Stoza289ade12014-02-28 11:17:17 -0800313
Dan Stozad1c10362014-03-28 15:19:08 -0700314 // Make sure this buffer hasn't been queued while acquired by the consumer
315 BufferQueueCore::Fifo::iterator current(mCore->mQueue.begin());
316 while (current != mCore->mQueue.end()) {
317 if (current->mSlot == slot) {
318 BQ_LOGE("releaseBuffer: buffer slot %d pending release is "
319 "currently queued", slot);
320 return BAD_VALUE;
321 }
322 ++current;
323 }
324
325 if (mSlots[slot].mBufferState == BufferSlot::ACQUIRED) {
326 mSlots[slot].mEglDisplay = eglDisplay;
327 mSlots[slot].mEglFence = eglFence;
328 mSlots[slot].mFence = releaseFence;
329 mSlots[slot].mBufferState = BufferSlot::FREE;
330 listener = mCore->mConnectedProducerListener;
331 BQ_LOGV("releaseBuffer: releasing slot %d", slot);
332 } else if (mSlots[slot].mNeedsCleanupOnRelease) {
333 BQ_LOGV("releaseBuffer: releasing a stale buffer slot %d "
334 "(state = %d)", slot, mSlots[slot].mBufferState);
335 mSlots[slot].mNeedsCleanupOnRelease = false;
336 return STALE_BUFFER_SLOT;
337 } else {
338 BQ_LOGV("releaseBuffer: attempted to release buffer slot %d "
339 "but its state was %d", slot, mSlots[slot].mBufferState);
Dan Stoza9f3053d2014-03-06 15:14:33 -0800340 return BAD_VALUE;
Dan Stoza289ade12014-02-28 11:17:17 -0800341 }
Dan Stoza289ade12014-02-28 11:17:17 -0800342
Dan Stozad1c10362014-03-28 15:19:08 -0700343 mCore->mDequeueCondition.broadcast();
344 } // Autolock scope
Dan Stoza289ade12014-02-28 11:17:17 -0800345
Dan Stozad1c10362014-03-28 15:19:08 -0700346 // Call back without lock held
347 if (listener != NULL) {
348 listener->onBufferReleased();
349 }
Dan Stoza289ade12014-02-28 11:17:17 -0800350
351 return NO_ERROR;
352}
353
354status_t BufferQueueConsumer::connect(
355 const sp<IConsumerListener>& consumerListener, bool controlledByApp) {
356 ATRACE_CALL();
357
358 if (consumerListener == NULL) {
359 BQ_LOGE("connect(C): consumerListener may not be NULL");
360 return BAD_VALUE;
361 }
362
363 BQ_LOGV("connect(C): controlledByApp=%s",
364 controlledByApp ? "true" : "false");
365
366 Mutex::Autolock lock(mCore->mMutex);
367
368 if (mCore->mIsAbandoned) {
369 BQ_LOGE("connect(C): BufferQueue has been abandoned");
370 return NO_INIT;
371 }
372
373 mCore->mConsumerListener = consumerListener;
374 mCore->mConsumerControlledByApp = controlledByApp;
375
376 return NO_ERROR;
377}
378
379status_t BufferQueueConsumer::disconnect() {
380 ATRACE_CALL();
381
382 BQ_LOGV("disconnect(C)");
383
384 Mutex::Autolock lock(mCore->mMutex);
385
386 if (mCore->mConsumerListener == NULL) {
387 BQ_LOGE("disconnect(C): no consumer is connected");
Dan Stoza9f3053d2014-03-06 15:14:33 -0800388 return BAD_VALUE;
Dan Stoza289ade12014-02-28 11:17:17 -0800389 }
390
391 mCore->mIsAbandoned = true;
392 mCore->mConsumerListener = NULL;
393 mCore->mQueue.clear();
394 mCore->freeAllBuffersLocked();
395 mCore->mDequeueCondition.broadcast();
396 return NO_ERROR;
397}
398
Dan Stozafebd4f42014-04-09 16:14:51 -0700399status_t BufferQueueConsumer::getReleasedBuffers(uint64_t *outSlotMask) {
Dan Stoza289ade12014-02-28 11:17:17 -0800400 ATRACE_CALL();
401
402 if (outSlotMask == NULL) {
403 BQ_LOGE("getReleasedBuffers: outSlotMask may not be NULL");
404 return BAD_VALUE;
405 }
406
407 Mutex::Autolock lock(mCore->mMutex);
408
409 if (mCore->mIsAbandoned) {
410 BQ_LOGE("getReleasedBuffers: BufferQueue has been abandoned");
411 return NO_INIT;
412 }
413
Dan Stozafebd4f42014-04-09 16:14:51 -0700414 uint64_t mask = 0;
Dan Stoza3e96f192014-03-03 10:16:19 -0800415 for (int s = 0; s < BufferQueueDefs::NUM_BUFFER_SLOTS; ++s) {
Dan Stoza289ade12014-02-28 11:17:17 -0800416 if (!mSlots[s].mAcquireCalled) {
Dan Stozafebd4f42014-04-09 16:14:51 -0700417 mask |= (1ULL << s);
Dan Stoza289ade12014-02-28 11:17:17 -0800418 }
419 }
420
421 // Remove from the mask queued buffers for which acquire has been called,
422 // since the consumer will not receive their buffer addresses and so must
423 // retain their cached information
424 BufferQueueCore::Fifo::iterator current(mCore->mQueue.begin());
425 while (current != mCore->mQueue.end()) {
426 if (current->mAcquireCalled) {
Dan Stozafebd4f42014-04-09 16:14:51 -0700427 mask &= ~(1ULL << current->mSlot);
Dan Stoza289ade12014-02-28 11:17:17 -0800428 }
429 ++current;
430 }
431
Dan Stozafebd4f42014-04-09 16:14:51 -0700432 BQ_LOGV("getReleasedBuffers: returning mask %#" PRIx64, mask);
Dan Stoza289ade12014-02-28 11:17:17 -0800433 *outSlotMask = mask;
434 return NO_ERROR;
435}
436
437status_t BufferQueueConsumer::setDefaultBufferSize(uint32_t width,
438 uint32_t height) {
439 ATRACE_CALL();
440
441 if (width == 0 || height == 0) {
442 BQ_LOGV("setDefaultBufferSize: dimensions cannot be 0 (width=%u "
443 "height=%u)", width, height);
444 return BAD_VALUE;
445 }
446
447 BQ_LOGV("setDefaultBufferSize: width=%u height=%u", width, height);
448
449 Mutex::Autolock lock(mCore->mMutex);
450 mCore->mDefaultWidth = width;
451 mCore->mDefaultHeight = height;
452 return NO_ERROR;
453}
454
455status_t BufferQueueConsumer::setDefaultMaxBufferCount(int bufferCount) {
456 ATRACE_CALL();
457 Mutex::Autolock lock(mCore->mMutex);
458 return mCore->setDefaultMaxBufferCountLocked(bufferCount);
459}
460
461status_t BufferQueueConsumer::disableAsyncBuffer() {
462 ATRACE_CALL();
463
464 Mutex::Autolock lock(mCore->mMutex);
465
466 if (mCore->mConsumerListener != NULL) {
467 BQ_LOGE("disableAsyncBuffer: consumer already connected");
468 return INVALID_OPERATION;
469 }
470
471 BQ_LOGV("disableAsyncBuffer");
472 mCore->mUseAsyncBuffer = false;
473 return NO_ERROR;
474}
475
476status_t BufferQueueConsumer::setMaxAcquiredBufferCount(
477 int maxAcquiredBuffers) {
478 ATRACE_CALL();
479
480 if (maxAcquiredBuffers < 1 ||
481 maxAcquiredBuffers > BufferQueueCore::MAX_MAX_ACQUIRED_BUFFERS) {
482 BQ_LOGE("setMaxAcquiredBufferCount: invalid count %d",
483 maxAcquiredBuffers);
484 return BAD_VALUE;
485 }
486
487 Mutex::Autolock lock(mCore->mMutex);
488
489 if (mCore->mConnectedApi != BufferQueueCore::NO_CONNECTED_API) {
490 BQ_LOGE("setMaxAcquiredBufferCount: producer is already connected");
491 return INVALID_OPERATION;
492 }
493
494 BQ_LOGV("setMaxAcquiredBufferCount: %d", maxAcquiredBuffers);
495 mCore->mMaxAcquiredBufferCount = maxAcquiredBuffers;
496 return NO_ERROR;
497}
498
499void BufferQueueConsumer::setConsumerName(const String8& name) {
500 ATRACE_CALL();
501 BQ_LOGV("setConsumerName: '%s'", name.string());
502 Mutex::Autolock lock(mCore->mMutex);
503 mCore->mConsumerName = name;
504 mConsumerName = name;
505}
506
Dan Stozad723bd72014-11-18 10:24:03 -0800507status_t BufferQueueConsumer::setDefaultBufferFormat(PixelFormat defaultFormat) {
Dan Stoza289ade12014-02-28 11:17:17 -0800508 ATRACE_CALL();
509 BQ_LOGV("setDefaultBufferFormat: %u", defaultFormat);
510 Mutex::Autolock lock(mCore->mMutex);
511 mCore->mDefaultBufferFormat = defaultFormat;
512 return NO_ERROR;
513}
514
Eino-Ville Talvala5b75a512015-02-19 16:10:43 -0800515status_t BufferQueueConsumer::setDefaultBufferDataSpace(
516 android_dataspace defaultDataSpace) {
517 ATRACE_CALL();
518 BQ_LOGV("setDefaultBufferDataSpace: %u", defaultDataSpace);
519 Mutex::Autolock lock(mCore->mMutex);
520 mCore->mDefaultBufferDataSpace = defaultDataSpace;
521 return NO_ERROR;
522}
523
Dan Stoza289ade12014-02-28 11:17:17 -0800524status_t BufferQueueConsumer::setConsumerUsageBits(uint32_t usage) {
525 ATRACE_CALL();
526 BQ_LOGV("setConsumerUsageBits: %#x", usage);
527 Mutex::Autolock lock(mCore->mMutex);
528 mCore->mConsumerUsageBits = usage;
529 return NO_ERROR;
530}
531
532status_t BufferQueueConsumer::setTransformHint(uint32_t hint) {
533 ATRACE_CALL();
534 BQ_LOGV("setTransformHint: %#x", hint);
535 Mutex::Autolock lock(mCore->mMutex);
536 mCore->mTransformHint = hint;
537 return NO_ERROR;
538}
539
Jesse Hall399184a2014-03-03 15:42:54 -0800540sp<NativeHandle> BufferQueueConsumer::getSidebandStream() const {
541 return mCore->mSidebandStream;
542}
543
Dan Stoza289ade12014-02-28 11:17:17 -0800544void BufferQueueConsumer::dump(String8& result, const char* prefix) const {
545 mCore->dump(result, prefix);
546}
547
548} // namespace android