#include <stdio.h>
#include <time.h>
-#include <signal.h>
#include <list>
#include <stack>
#include <mutex>
along with VOMP. If not, see <https://www.gnu.org/licenses/>.
*/
+#include <chrono>
+#include <sys/syscall.h>
+#include <fontconfig/fontconfig.h>
+#include <vector>
+#include <math.h>
+#include <bcm_host.h>
-#include "osdopenvg.h"
#include "videoomx.h"
#include "surface.h"
-
#include "message.h"
#include "command.h"
#include "teletxt/txtfont.h"
-#include <sys/syscall.h>
-#include <fontconfig/fontconfig.h>
-#include <vector>
-#include <math.h>
-#include <bcm_host.h>
-
+#include "osdopenvg.h"
#define EXTERNALPICTURE(name, fname, fileextension) extern uint8_t name ## _data[] asm("_binary_other_"#fname"_"#fileextension"_start"); \
taskmutex.unlock();
vgmutex.unlock();
//threadCheckExit();
- vgtaskSignal.signal();
+
+ /* Getting rid of Signal class. As with VideoOMX, just replicate what Signal did here
+ * and figure out if any of this can be simplified later. e.g. taskmutex sounds
+ * like it should be the mutex being used. 3 mutexes here???
+ */
+
+ vgTaskSignalMutex.lock();
+ vgTaskSignal.notify_one();
+ vgTaskSignalMutex.unlock();
+
taskmutex.lock();
vgmutex.lock();
worked=true;
while (wait) {
unsigned int resp;
if (!haveOpenVGResponse(comm.id,&resp)) {
+
+// 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;
target_time.tv_sec+=1;
}
vgtaskSignal.waitForSignalTimed(&target_time);
+ */
+
+
} else {
return resp;
}
#include <stdio.h>
#include <mutex>
+#include <condition_variable>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include "defines.h"
#include "log.h"
#include "threadp.h"
-#include "signal.h"
#include "videoomx.h"
#include "staticartwork.h"
#ifdef PICTURE_DECODER_OMX
std::mutex vgmutex;
std::mutex taskmutex;
- Signal vgtaskSignal;
+
+ std::mutex vgTaskSignalMutex;
+ std::condition_variable vgTaskSignal;
+
std::deque<OpenVGCommand> vgcommands;
std::deque<OpenVGResponse> vgresponses;
bool processTasks();
+++ /dev/null
-/*
- Copyright 2004-2005 Chris Tallon
-
- This file is part of VOMP.
-
- VOMP is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- VOMP is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-#include "signal.h"
-
-// FIXME
-// well, I say fix... Delete me.
-
-
-Signal::Signal()
-{
- pthread_cond_init(&cond, NULL);
- pthread_mutex_init(&condMutex, NULL);
-}
-
-Signal::~Signal()
-{
- pthread_cond_destroy(&cond);
- pthread_mutex_destroy(&condMutex);
-}
-
-
-
-void Signal::signal()
-{
-#ifndef WIN32
- pthread_mutex_lock(&condMutex);
- pthread_cond_signal(&cond);
- pthread_mutex_unlock(&condMutex);
-#else
-#error "Not ported yet"
-#endif
-}
-
-void Signal::waitForSignal()
-{
-#ifndef WIN32
- pthread_mutex_lock(&condMutex);
- pthread_cond_wait(&cond, &condMutex);
- pthread_mutex_unlock(&condMutex);
-#else
-#error "Not ported yet"
-#endif
-}
-
-void Signal::waitForSignalTimed(struct timespec* ts)
-{
-#ifndef WIN32
- pthread_mutex_lock(&condMutex);
- pthread_cond_timedwait(&cond, &condMutex, ts);
- pthread_mutex_unlock(&condMutex);
-#else
-#error "Not ported yet"
-#endif
-}
-
-void Signal::waitForSignalTimed(unsigned int ts)
-{
- struct timespec target_time;
- clock_gettime(CLOCK_REALTIME,&target_time);
- target_time.tv_nsec+=1000000LL*ts;
- if (target_time.tv_nsec>999999999) {
- target_time.tv_nsec-=1000000000L;
- target_time.tv_sec+=1;
- }
- waitForSignalTimed(&target_time);
-}
+++ /dev/null
-/*
- Copyright 2004-2005 Chris Tallon
-
- This file is part of VOMP.
-
- VOMP is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- VOMP is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#ifndef SIGNAL_H
-#define SIGNAL_H
-
-#ifndef WIN32
-#include <pthread.h>
-#include <signal.h>
-#else
-#include <winsock2.h>
-#include <windows.h>
-#endif
-
-
-class Signal {
-public:
- Signal();
- ~Signal();
- void signal(); // releases a thread that has called threadWaitForSignal
- void waitForSignal(); // pauses thread until dignal() is called
- void waitForSignalTimed(struct timespec*); // pauses thread until signal() is called or timer expires
- void waitForSignalTimed(unsigned int ts);
-
-protected:
-#ifndef WIN32
- pthread_cond_t cond;
- pthread_mutex_t condMutex;
-#else
-#error "Not ported yet"
-#endif
-
-};
-
-
-#endif
along with VOMP. If not, see <https://www.gnu.org/licenses/>.
*/
-#include "videoomx.h"
+#include <bcm_host.h>
+#include <linux/fb.h>
+
+#include <chrono>
+
+#include "log.h"
#include "audioomx.h"
#include "demuxer.h"
#include "vdr.h"
#include "boxstack.h"
#include "inputman.h"
-#include <bcm_host.h>
-
-#include <linux/fb.h>
-
-// temp
-#include "log.h"
+#include "videoomx.h"
//A lot of parts of this file are heavily inspired by xbmc omx implementations
}
+void VideoOMX::signalOmx()
+{
+ /*
+ * Getting rid of Signal class. It looks like VideoOMX uses a wait-on-condition-variable in WaitForEvent()
+ * and CommandFinished(). These methods both use timed waits and don't use exact thread synchronisation -
+ * i.e. a caught signal will end the wait early but a missed signal doesn't matter. So, I'm just copying
+ * in what the Signal class used to do here and I'll sort it out later.
+ * Q: Are the found places the only synchronisation points? Would it be possible to change this to use
+ * exact sychronisation and remove the wait spin loops? Unknown.
+ *
+ * This omx_event_mutex - is this exactly locking the very thing the condition variable is being used
+ * for? i.e. is omx_event_mutex really the mutex that should be being used with the cond var?
+ *
+ * Callers of signalOmx:
+ *
+ * VideoOMX::AddOmxEvent, VideoOMX::ReturnEmptyOMXBuffer
+ * ImageOMX::ReturnEmptyOMXBuffer, ImageOMX::ReturnFillOMXBuffer
+ * AudioOMX::ReturnEmptyOMXBuffer, AudioOMX::FillBufferDone_OMX
+ *
+ * Surprise: WaitForEvent isn't a long running loop while video is playing.
+ */
+
+ omx_event_ready_signal_mutex.lock();
+ omx_event_ready_signal.notify_one(); // Signal called pthread_cond_signal - unblock one
+ omx_event_ready_signal_mutex.unlock();
+};
+
void VideoOMX::AddOmxEvent(VPE_OMX_EVENT new_event)
{
- omx_event_mutex.lock();
- omx_events.push_back(new_event);
- omx_event_mutex.unlock();
- omx_event_ready_signal.signal();
-}
+ omx_event_mutex.lock();
+ omx_events.push_back(new_event);
+ omx_event_mutex.unlock();
+ signalOmx();
+}
OMX_ERRORTYPE VideoOMX::EmptyBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp,OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* buffer){
input_bufs_omx_free.push_back(buffer);
//Log::getInstance()->log("Video", Log::NOTICE, "ReturnEmptyOMXBuffer %d",input_bufs_omx_free.size());
input_bufs_omx_mutex.unlock();
- omx_event_ready_signal.signal();
+
+ signalOmx();
}
OMX_ERRORTYPE VideoOMX::FillBufferDone_OMX(OMX_IN OMX_HANDLETYPE hcomp, OMX_IN OMX_PTR appdata,OMX_IN OMX_BUFFERHEADERTYPE* buffer) {
}
omx_event_mutex.unlock();
- omx_event_ready_signal.waitForSignalTimed(10);
- //MILLISLEEP(2);
- i++;
+
+ //Log::getInstance()->log("Video", Log::DEBUG, "WaitForEvent");
+ std::unique_lock<std::mutex> ul(omx_event_ready_signal_mutex);
+ omx_event_ready_signal.wait_for(ul, std::chrono::milliseconds(10));
+ ul.unlock();
+
+ i++;
}
Log::getInstance()->log("Video", Log::DEBUG, "WaitForEvent waited too long %x %x",handle,event);
}
omx_event_mutex.unlock();
- omx_event_ready_signal.waitForSignalTimed(10);
- //MILLISLEEP(2);
+
+ std::unique_lock<std::mutex> ul(omx_event_ready_signal_mutex);
+ omx_event_ready_signal.wait_for(ul, std::chrono::milliseconds(10));
+ ul.unlock();
+
i++;
}
#include <list>
#include <vector>
#include <mutex>
-
-#include "signal.h"
+#include <condition_variable>
#include "defines.h"
#include "video.h"
-#include "threadsystem.h"
-
#define OMX_SKIP64BIT
void clockUnpause();
bool isClockPaused() {return clockpaused;};
- void signalOmx() {omx_event_ready_signal.signal();};
+ void signalOmx();
+ std::condition_variable omx_event_ready_signal;
+ std::mutex omx_event_ready_signal_mutex;
+
+
void interlaceSwitch4Demux();
bool omx_first_frame;
std::mutex omx_event_mutex;
- Signal omx_event_ready_signal;
std::list<VPE_OMX_EVENT> omx_events;