From 07855bdd5512ba9b8a389ec01ad17245734c6698 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Mon, 13 Nov 2006 23:14:00 +0000 Subject: [PATCH] *** empty log message *** --- command.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++++ command.h | 1 + messagequeue.h | 3 +++ player.cc | 4 ++-- 4 files changed, 53 insertions(+), 2 deletions(-) diff --git a/command.cc b/command.cc index e6ba5ee..2cbdeb5 100644 --- a/command.cc +++ b/command.cc @@ -236,6 +236,49 @@ bool Command::postMessageIfNotBusy(Message* m) #endif } +void Command::postMessageFromOuterSpace(Message* m) +{ + /* + Yet another way of getting messages into Command. This one is for events that + are not standard button presses (or UDP generated buttons). It is also not for + events that are generated as a result of other events (events that can safely + call postMessageNoLock and be guaranteed that the message will be processed + because it is known that the queue is currently being processed). + This is for events that come from outer space and can occur when the master + mutex is locked or not, they need to be queued and executed but it doesn't + matter when. + Actually so far it is for events caused by the video stream - aspect ratio + changes. These can occur when the master mutex is locked and so postMessage + doesn't work. postMessageNoLock doesn't work because if the mutex *isn't* + locked at the time then the message could be sat around a while before + being noticed. + The whole message system was at first supposed to prevent the problem of + calling a function on an object that had just been deleted, by ordering + messages such that all calls are done before object deletion. However, + because of the new centralised messaging system and the fact that ViewMan + locates the destination object before calling it, the messaging system now + allows the kind of sloppy calls it was supposed to stop. Weird huh. This + is mentioned here because the video stream might generate an event just as + the user hits stop. The mutex is locked, and by the time the message + is examined the vvideorec/live has been deleted. This doesn't matter because + viewman will drop the message if it can't find the matching object to + deliver it to. + Finally, all this is fine and dandy, except that I'm not 100% sure that + this sloppy postMessage and hope a queued signal will force it to be processed + thingy will actually work. Hmmm. + Lastly , I will consider making the naming system a little more sane + if this works. + */ + + logger->log("Command", Log::DEBUG, "PMFOS called"); + MessageQueue::postMessage(m); + kill(mainPid, SIGURG); + + // FIXME: Marten - if this actually works on the MVP then you will need + // to come up with the Windows equivalent here. + +} + void Command::processMessage(Message* m) { logger->log("Command", Log::DEBUG, "processing message %i", m->message); @@ -247,6 +290,10 @@ void Command::processMessage(Message* m) // objects deriving from messagequeues, make them derive from // messagereceiver - then one messagequeue can deliver any message to anywhere + // FIXME - a slight modification - how if messagereceivers were to register + // themselves as receivers to avoid the calling-a-deleted-object problem + // then only deliver/register/unregister would have to be protected + // deliver timer logger->log("Command", Log::DEBUG, "sending timer"); diff --git a/command.h b/command.h index c38272c..a5a6d03 100644 --- a/command.h +++ b/command.h @@ -77,6 +77,7 @@ class Command : public MessageQueue void postMessage(Message* m); // override of MessageQueue::postMessage void postMessageNoLock(Message* m); // override of MessageQueue::postMessage bool postMessageIfNotBusy(Message* m); // for timers, when masterMutex might be locked + void postMessageFromOuterSpace(Message* m); // err, read the cc comments. void sig1(); void connectionLost(); diff --git a/messagequeue.h b/messagequeue.h index 2f5a7ef..9949424 100644 --- a/messagequeue.h +++ b/messagequeue.h @@ -36,12 +36,15 @@ class MessageQueue virtual ~MessageQueue() {}; virtual void postMessage(Message* m); + virtual void postMessageNoLock(Message* m)=0; + virtual void postMessageFromOuterSpace(Message* m)=0; protected: virtual void processMessageQueue(); virtual void processMessage(Message* m)=0; + private: MQueue messages; diff --git a/player.cc b/player.cc index c36b866..173fc01 100644 --- a/player.cc +++ b/player.cc @@ -726,7 +726,7 @@ void Player::call(void* caller) m->to = messageReceiver; m->message = Message::PLAYER_EVENT; m->parameter = Player::ASPECT43; - messageQueue->postMessage(m); + messageQueue->postMessageFromOuterSpace(m); } else if (dxCurrentAspect == Demuxer::ASPECT_16_9) { @@ -738,7 +738,7 @@ void Player::call(void* caller) m->to = messageReceiver; m->message = Message::PLAYER_EVENT; m->parameter = Player::ASPECT169; - messageQueue->postMessage(m); + messageQueue->postMessageFromOuterSpace(m); } else { -- 2.39.2