#include "Mv3d.h"
+#define MV_3D_TIMEOUT_SEC 3
namespace mediavision
{
namespace mv3d
{
Mv3d *handle = static_cast<Mv3d*>(data);
while(handle->mDfsIsLive) {
- auto queueLength = static_cast<int>(g_async_queue_length(handle->mDfsAsyncQueue));
- if (queueLength < 0)
- continue;
+ auto base = g_async_queue_timeout_pop(handle->mDfsAsyncQueue, MV_3D_TIMEOUT_SEC * G_TIME_SPAN_SECOND);
+ if (!base) {
+ LOGW("Timeout! no more items. Exit thread");
+ break;
+ }
+
+ auto queueRemaining = static_cast<int>(g_async_queue_length(handle->mDfsAsyncQueue));
+ LOGI("%d remaining", queueRemaining);
- for (int itemIndex = 0; itemIndex < queueLength; itemIndex++) {
- gpointer base = g_async_queue_try_pop(handle->mDfsAsyncQueue);
+ while (queueRemaining > 0) {
auto pItem = static_cast<std::shared_ptr<DfsInputData> *>(base);
auto item = std::move(*pItem);
delete pItem;
item.reset();
- }
- gpointer base = g_async_queue_try_pop(handle->mDfsAsyncQueue);
- if (!base) {
- continue;
+ base = g_async_queue_pop(handle->mDfsAsyncQueue);
+ queueRemaining--;
+ LOGI("%d remaining", queueRemaining);
}
auto pInput = static_cast<std::shared_ptr<DfsInputData>*>(base);