m->tag = info->lindex >> 32LL;
}
- MessageQueue::getInstance()->postMessage(m); // inform command about new picture
+ MessageQueue::getInstance()->postMessage(m); // inform control about new picture
delete info;
break;
info->handle = handle;
info->reference = eglCreateImageKHR(egl_display, egl_context, EGL_VG_PARENT_IMAGE_KHR, reinterpret_cast<EGLClientBuffer>(handle), NULL);
-
if (info->reference) return true;
- else
- {
- Log::getInstance()->log("OSD", Log::DEBUG, "TVMedia OVGcreateEGLImage %d %d %x Fail!", info->width, info->height, handle);
- if (handle) vgDestroyImage(handle);
- return false;
- }
- break;
+
+ Log::getInstance()->log("OSD", Log::DEBUG, "TVMedia OVGcreateEGLImage %d %d %x Fail!", info->width, info->height, handle);
+ if (handle) vgDestroyImage(handle);
+ return false;
}
case OVGreadyEGLImage:
{
return worked;
}
-bool OsdOpenVG::haveOpenVGResponse(unsigned int id, unsigned int* resp)
-{
- taskmutex.lock();
-
- if (vgresponses.size() > 0)
- {
- std::deque<OpenVGResponse>::iterator itty = vgresponses.begin();
-
- while (itty != vgresponses.end())
- {
- if ((*itty).id == id)
- {
- *resp = (*itty).result;
- taskmutex.unlock();
- return true;
- }
-
- itty++;
- }
- }
-
- taskmutex.unlock();
- return false;
-}
-
unsigned int OsdOpenVG::putOpenVGCommand(OpenVGCommand& comm, bool wait)
{
taskmutex.lock();
if (wait)
- {
- comm.id = wait_id;
- wait_id++;
- }
+ comm.id = wait_id++;
else
- {
comm.id = 0; // we are not waiting
- }
vgcommands.push_back(comm);
taskmutex.unlock();
+
threadSignal();
- while (wait)
- {
- unsigned int resp;
+ if (!wait) return 0;
- if (!haveOpenVGResponse(comm.id, &resp))
+ while(1)
+ {
+ // Is there a response now?
+ taskmutex.lock();
+ for (auto& vgresponse : vgresponses)
{
-
- // Log::getInstance()->log("OsdOpenVG", Log::DEBUG, "putOpenVGCommand wait_for");
- std::unique_lock<std::mutex> ul(vgTaskSignalMutex);
- /*auto a = */ vgTaskSignal.wait_for(ul, std::chrono::milliseconds(100));
- ul.unlock();
- /*
- if (a == std::cv_status::timeout)
- Log::getInstance()->log("OsdOpenVG", Log::DEBUG, "putOpenVGCommand timeout");
- else
- Log::getInstance()->log("OsdOpenVG", Log::DEBUG, "putOpenVGCommand no timeout");
- */
- /*
- struct timespec target_time;
- clock_gettime(CLOCK_REALTIME,&target_time);
- target_time.tv_nsec+=1000000LL*100;
- if (target_time.tv_nsec>999999999) {
- target_time.tv_nsec-=1000000000L;
- target_time.tv_sec+=1;
+ if (vgresponse.id == comm.id)
+ {
+ UINT resp = vgresponse.result;
+ taskmutex.unlock();
+ return resp;
}
- vgtaskSignal.waitForSignalTimed(&target_time);
- */
}
- else
- {
- return resp;
- }
- }
+ // No.
+ taskmutex.unlock();
- return 0;
+ std::unique_lock<std::mutex> ul(vgTaskSignalMutex);
+ vgTaskSignal.wait_for(ul, std::chrono::milliseconds(100));
+ ul.unlock();
+ }
}
void OsdOpenVG::destroyImageRef(ImageIndex index)
#include <vector>
#include <deque>
#include <mutex>
+#include <thread>
#include <condition_variable>
#include <EGL/egl.h>
std::deque<OpenVGCommand> vgcommands;
std::deque<OpenVGResponse> vgresponses;
bool processTasks();
- bool haveOpenVGResponse(unsigned int id, unsigned int* resp);
unsigned int putOpenVGCommand(OpenVGCommand& comm, bool wait);
unsigned int handleTask(OpenVGCommand& command);
//void purgeAllReferences();
ImageOMX* imageomx;
#endif
+ // future
+ //std::thread renderThread;
+ //std::mutex threadStartProtect;
+
};
#endif