initted = 0;
return 0;
}
-
+#ifndef WIN32
pthread_mutex_init(&masterLock, NULL);
+#else
+ masterLock=CreateMutex(NULL,FALSE,NULL);
+#endif
return 1;
}
{
if (!initted) return;
irun = 1;
-
+#ifndef WIN32
mainPid = getpid();
+#endif
// just in case
Video::getInstance()->signalOn();
doWallpaper();
// End of startup. Lock the mutex and put the first view up
-
+#ifndef WIN32
pthread_mutex_lock(&masterLock);
-
-
+#else
+ WaitForSingleObject(masterLock, INFINITE );
+#endif
VConnect* vconnect = new VConnect();
viewman->add(vconnect);
vconnect->run();
while(irun)
{
// unlock and wait
+#ifndef WIN32
pthread_mutex_unlock(&masterLock);
+#else
+ ReleaseMutex(masterLock);
+#endif
button = remote->getButtonPress(2); // FIXME why is this set to 2 and not 0? so it can quit
// something happened, lock and process
- pthread_mutex_lock(&masterLock);
+#ifndef WIN32
+ pthread_mutex_lock(&masterLock);
+#else
+ WaitForSingleObject(masterLock, INFINITE );
+#endif
if ((button == Remote::NA_NONE) || (button == Remote::NA_UNKNOWN)) continue;
processMessageQueue();
}
- pthread_mutex_unlock(&masterLock);
+#ifndef WIN32
+ pthread_mutex_unlock(&masterLock);
+#else
+ ReleaseMutex(masterLock);
+#endif
}
void Command::postMessage(Message* m)
// locking the mutex ensures that the master thread is waiting on getButtonPress
- pthread_mutex_lock(&masterLock);
- MessageQueue::postMessage(m);
- kill(mainPid, SIGURG);
- pthread_mutex_unlock(&masterLock);
+#ifndef WIN32
+ pthread_mutex_lock(&masterLock);
+#else
+ WaitForSingleObject(masterLock, INFINITE );
+#endif
+ MessageQueue::postMessage(m);
+
+#ifndef WIN32
+ kill(mainPid, SIGURG);
+ pthread_mutex_unlock(&masterLock);
+#else
+ //TODO: send Window Message
+ ReleaseMutex(masterLock);
+#endif
}
void Command::postMessageNoLock(Message* m)
// This is for the timers module
// If the masterlock is locked then the timers module wants to
// cancel delivery
-
+#ifndef WIN32
if (pthread_mutex_trylock(&masterLock) != EBUSY)
{
MessageQueue::postMessage(m);
{
return false;
}
+#else
+ if (WaitForSingleObject(masterLock, INFINITE ) == WAIT_OBJECT_0)
+ {
+ MessageQueue::postMessage(m);
+ //TODO: send Window Message
+ ReleaseMutex(masterLock);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+#endif
}
void Command::processMessage(Message* m)
VDR::getInstance()->disconnect();
// just kill it...
logger->log("Command", Log::NOTICE, "Reboot");
+#ifndef WIN32
reboot(LINUX_REBOOT_CMD_RESTART);
+#endif //Would we support this on windows?
}
void Command::connectionLost()
while (len)
{
full = 0;
- switch (state_frametype)
+
+ if (state_frametype == 0) // Search for frame
{
- case 0: // Search for frame
- parsed = parse_find_frame(len);
- break;
- case FRAMETYPE_VID0 ... FRAMETYPE_VIDMAX:
- parsed = parse_video_frame(len, &full);
- break;
- case FRAMETYPE_AUD0 ... FRAMETYPE_AUDMAX:
- parsed = parse_audio_frame(len, &full);
- break;
- case FRAMETYPE_PRIVATE_1:
- parsed = parse_private1_frame(len, &full);
- break;
+ parsed = parse_find_frame(len);
+ }
+ else if ((state_frametype >= FRAMETYPE_VID0) && (state_frametype <= FRAMETYPE_VIDMAX))
+ {
+ parsed = parse_video_frame(len, &full);
+ }
+ else if ((state_frametype >= FRAMETYPE_AUD0) && (state_frametype <= FRAMETYPE_AUDMAX))
+ {
+ parsed = parse_audio_frame(len, &full);
}
+ else if (state_frametype == FRAMETYPE_PRIVATE_1)
+ {
+ parsed = parse_private1_frame(len, &full);
+ }
+
ret += parsed; len -= parsed;
if (full) // We have to exit early.
break; // out of while loop
break;
default:
state_framepos = 0; // Set initial state for the new frame
- switch (byte)
+
+ if (byte == 0)
+ {
+ state_framepos = 1; // Count this as a first header byte!
+ }
+ else if ( ((byte >= FRAMETYPE_VID0) && (byte <= FRAMETYPE_VIDMAX))
+ || ((byte >= FRAMETYPE_AUD0) && (byte <= FRAMETYPE_AUDMAX))
+ || byte==FRAMETYPE_PRIVATE_1 )
{
- case 0:
- state_framepos = 1; // Count this as a first header byte!
- break;
- case FRAMETYPE_VID0 ... FRAMETYPE_VIDMAX:
- case FRAMETYPE_AUD0 ... FRAMETYPE_AUDMAX:
- case FRAMETYPE_PRIVATE_1:
- state_frametype = byte;
- return ret;
+ state_frametype = byte;
+ return ret;
}
+
// Not a recognised frame type. Go back to Old Kent Road.
break;
}