status_t VideoThread::waitForAndExecuteMessage() { LOG2("@%s", __FUNCTION__); status_t status = NO_ERROR; Message msg; mMessageQueue.receive(&msg); switch (msg.id) { case MESSAGE_ID_EXIT: status = handleMessageExit(); break; case MESSAGE_ID_VIDEO: status = handleMessageVideo(&msg.data.video); break; case MESSAGE_ID_FLUSH: status = handleMessageFlush(); break; case MESSAGE_ID_SET_SLOWMOTION_RATE: status = handleMessageSetSlowMotionRate(&msg.data.setSlowMotionRate); break; default: ALOGE("Invalid message"); status = BAD_VALUE; break; }; return status; }
status_t PictureThread::waitForAndExecuteMessage() { LOG2("@%s", __FUNCTION__); status_t status = NO_ERROR; Message msg; mMessageQueue.receive(&msg); switch (msg.id) { case MESSAGE_ID_EXIT: status = handleMessageExit(); break; case MESSAGE_ID_ENCODE: status = handleMessageEncode(&msg.data.encode); break; case MESSAGE_ID_FLUSH: status = handleMessageFlush(); break; default: status = BAD_VALUE; break; }; return status; }
status_t VideoThread::waitForAndExecuteMessage() { LOG2("@%s", __FUNCTION__); status_t status = NO_ERROR; Message msg; mMessageQueue.receive(&msg); switch (msg.id) { case MESSAGE_ID_EXIT: status = handleMessageExit(); break; case MESSAGE_ID_FLUSH: status = handleMessageFlush(); break; case MESSAGE_ID_RELEASE_RECORDING_FRAME: status = handleMessageReleaseRecordingFrame(&msg.data.releaseRecordingFrame); break; case MESSAGE_ID_SET_SLOWMOTION_RATE: status = handleMessageSetSlowMotionRate(&msg.data.setSlowMotionRate); break; case MESSAGE_ID_DEQUEUE_RECORDING: status = handleMessageDequeueRecording(&msg.data.dequeueRecording); break; case MESSAGE_ID_START_RECORDING: status = handleMessageStartRecording(); break; case MESSAGE_ID_PUSH_FRAME: status = handleMessagePushFrame(&msg.data.pushFrame); break; case MESSAGE_ID_STOP_RECORDING: status = handleMessageStopRecording(); break; default: ALOGE("Invalid message"); status = BAD_VALUE; break; }; return status; }
status_t PanoramaThread::waitForAndExecuteMessage() { LOG2("@%s", __FUNCTION__); status_t status = NO_ERROR; Message msg; mMessageQueue.receive(&msg); switch (msg.id) { case MESSAGE_ID_STITCH: status = handleStitch(msg.data.stitch); break; case MESSAGE_ID_EXIT: status = handleExit(); break; case MESSAGE_ID_FRAME: status = handleFrame(msg.data.frame); break; case MESSAGE_ID_FINALIZE: status = handleMessageFinalize(); break; case MESSAGE_ID_START_PANORAMA: status = handleMessageStartPanorama(); break; case MESSAGE_ID_STOP_PANORAMA: status = handleMessageStopPanorama(msg.data.stop); break; case MESSAGE_ID_START_PANORAMA_CAPTURE: status = handleMessageStartPanoramaCapture(); break; case MESSAGE_ID_STOP_PANORAMA_CAPTURE: status = handleMessageStopPanoramaCapture(); break; case MESSAGE_ID_THUMBNAILSIZE: status = handleMessageThumbnailSize(msg.data.thumbnail); break; case MESSAGE_ID_FLUSH: status = handleMessageFlush(); break; default: status = INVALID_OPERATION; break; } if (status != NO_ERROR) { LOGE("operation failed, ID = %d, status = %d", msg.id, status); } return status; }
void CaptureStream::messageThreadLoop(void) { LOG2("@%s, name:%s, Start", __FUNCTION__, getName()); mThreadRunning = true; while (mThreadRunning) { status_t status = NO_ERROR; Message msg; mMessageQueue.receive(&msg); PERFORMANCE_HAL_ATRACE_PARAM1("msg", msg.id); bool replyImmediately = true; switch (msg.id) { case MESSAGE_ID_EXIT: mThreadRunning = false; status = NO_ERROR; break; case MESSAGE_ID_POLL: status = handleMessagePoll(msg); break; case MESSAGE_ID_FLUSH: status = handleMessageFlush(msg); replyImmediately = false; break; default: LOGE("ERROR @%s: Unknow message %d", __FUNCTION__, msg.id); status = BAD_VALUE; break; } if (status != NO_ERROR) LOGE(" error %d in handling message: %d", status, (int)msg.id); if (replyImmediately) mMessageQueue.reply(msg.id, status); } LOG2("%s: Exit", __FUNCTION__); }