TEST_F(BufferQueueTest, AcquireBuffer_ExceedsMaxAcquireCount_Fails) { createBufferQueue(); sp<DummyConsumer> dc(new DummyConsumer); mConsumer->consumerConnect(dc, false); IGraphicBufferProducer::QueueBufferOutput qbo; mProducer->connect(new DummyProducerListener, NATIVE_WINDOW_API_CPU, false, &qbo); mProducer->setBufferCount(4); int slot; sp<Fence> fence; sp<GraphicBuffer> buf; IGraphicBufferProducer::QueueBufferInput qbi(0, false, HAL_DATASPACE_UNKNOWN, Rect(0, 0, 1, 1), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, false, Fence::NO_FENCE); BufferItem item; for (int i = 0; i < 2; i++) { ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION, mProducer->dequeueBuffer(&slot, &fence, false, 1, 1, 0, GRALLOC_USAGE_SW_READ_OFTEN)); ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buf)); ASSERT_EQ(OK, mProducer->queueBuffer(slot, qbi, &qbo)); ASSERT_EQ(OK, mConsumer->acquireBuffer(&item, 0)); } ASSERT_EQ(IGraphicBufferProducer::BUFFER_NEEDS_REALLOCATION, mProducer->dequeueBuffer(&slot, &fence, false, 1, 1, 0, GRALLOC_USAGE_SW_READ_OFTEN)); ASSERT_EQ(OK, mProducer->requestBuffer(slot, &buf)); ASSERT_EQ(OK, mProducer->queueBuffer(slot, qbi, &qbo)); // Acquire the third buffer, which should fail. ASSERT_EQ(INVALID_OPERATION, mConsumer->acquireBuffer(&item, 0)); }
TEST_F(BufferQueueTest, AcquireBuffer_ExceedsMaxAcquireCount_Fails) { sp<DummyConsumer> dc(new DummyConsumer); mBQ->consumerConnect(dc); ISurfaceTexture::QueueBufferOutput qbo; mBQ->connect(NATIVE_WINDOW_API_CPU, &qbo); mBQ->setBufferCount(4); int slot; sp<Fence> fence; sp<GraphicBuffer> buf; ISurfaceTexture::QueueBufferInput qbi(0, Rect(0, 0, 1, 1), NATIVE_WINDOW_SCALING_MODE_FREEZE, 0, fence); BufferQueue::BufferItem item; for (int i = 0; i < 2; i++) { ASSERT_EQ(ISurfaceTexture::BUFFER_NEEDS_REALLOCATION, mBQ->dequeueBuffer(&slot, fence, 1, 1, 0, GRALLOC_USAGE_SW_READ_OFTEN)); ASSERT_EQ(OK, mBQ->requestBuffer(slot, &buf)); ASSERT_EQ(OK, mBQ->queueBuffer(slot, qbi, &qbo)); ASSERT_EQ(OK, mBQ->acquireBuffer(&item)); } ASSERT_EQ(ISurfaceTexture::BUFFER_NEEDS_REALLOCATION, mBQ->dequeueBuffer(&slot, fence, 1, 1, 0, GRALLOC_USAGE_SW_READ_OFTEN)); ASSERT_EQ(OK, mBQ->requestBuffer(slot, &buf)); ASSERT_EQ(OK, mBQ->queueBuffer(slot, qbi, &qbo)); // Acquire the third buffer, which should fail. ASSERT_EQ(INVALID_OPERATION, mBQ->acquireBuffer(&item)); }
int main(void) { BL_OUTPUT; // DS_OUTPUT; BL_ON; GLCD_Initalize(); // Initalize LCD GLCD_ClearText(); // Clear text area GLCD_ClearCG(); // Clear character generator area GLCD_ClearGraphic(); // Clear graphic area GLCD_TextGoTo(0,0);// set text coordinates GLCD_WriteString("Hello"); // write text GLCD_Circle(32,32,20); // draw circle GLCD_Rectangle(8,8,24, 48); // draw rectangle // GLCD_FillRectangle(0, 0, 96, 8); USART_Init(MYUBRR); USART_Transmit_string("Hi\n"); LED_OUTPUT; BLINK3; GLCD_ClearText(); GLCD_TextGoTo(0,0);// set text coordinates ADCSRA = 0b10000111; data_flag=0; sei(); uint16_t T = 0; uint8_t i; while(1) { if (data_flag == 1) { //BLINK00; // Heh nasty error when it is here, if 'g' followed by newline comes, because it rewrites data here :D if (data == 't') { T = DS_get(6); GLCD_TextGoTo(0,0); i = (uint8_t)(T>>8); USART_Transmit_num(i); GLCD_WriteChar(i/10 + '0'); GLCD_WriteChar(i%10 + '0'); USART_Transmit('.'); GLCD_WriteChar('.'); i = (uint8_t)(T); USART_Transmit_num(i); GLCD_WriteChar(i/10 + '0'); GLCD_WriteChar(i%10 + '0'); USART_Transmit('C'); GLCD_WriteChar('C'); USART_Transmit('\n'); } if (data == 'g') { ADMUX = 0x00; sbi(ADCSRA, ADSC); while (qbi(ADCSRA, ADSC)) ; uint16_t val = ADC; GLCD_TextGoTo(0,0); } data_flag=0; } }