Skip to content

Commit

Permalink
Fix problem with GetStatus API call while playing video.
Browse files Browse the repository at this point in the history
This bug was introduced while fixing a problem where all the network
control "play" commands were duplicated by MythTV.  Most of the "play"
commands are idempotent, so the only place the duplication was visible
was the "play speed pause" command.

Fixing that problem using a different method restores the
functionality of the GetStatus API call.

Fixes #545.

(cherry picked from commit 0751111)
  • Loading branch information
linuxdude42 committed May 27, 2022
1 parent b6286af commit 98c82d5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
14 changes: 7 additions & 7 deletions mythtv/libs/libmythtv/tv_play.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2905,11 +2905,12 @@ void TV::HandleSpeedChangeTimerEvent()
/// 2021, this filter is only used to redirect some events from the
/// MythMainWindow object to the TV object.
///
/// \warning If an event will be received by both the MythMainWindow object
/// and the TV object, block it instead of redirecting it. Redirecting it
/// just causes the event to be handled twice, once in the direct call from
/// Qt to TV::event and once in the call from Qt to this function to
/// TV::event.
/// \warning Be careful if an event is broadcast to all objects
/// instead of being set directly to a specific object. For a
/// broadcast event, Qt will: 1) call TV::customEvent, and 2) call
/// this function to find out whether it should call
/// MythMainWindow::customEvent. If this function calls
/// TV::customEvent, then the same event gets processed twice.
///
/// \param Object The QObject whose events are being filtered.
/// \param Event The QEvent that is about to be passed to Object->event().
Expand Down Expand Up @@ -2944,8 +2945,7 @@ bool TV::eventFilter(QObject* Object, QEvent* Event)
Event->type() == MythEvent::kUpdateTvProgressEventType ||
Event->type() == MythMediaEvent::kEventType)
{
// DO NOT call TV::customEvent here!
// customEvent(Event);
customEvent(Event);
return true;
}

Expand Down
13 changes: 11 additions & 2 deletions mythtv/programs/mythfrontend/networkcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -912,8 +912,17 @@ QString NetworkControl::processPlay(NetworkCommand *nc, int clientID)

if (!message.isEmpty())
{
MythEvent me(message);
gCoreContext->dispatch(me);
// Don't broadcast this event as the TV object will see it
// twice: once directly from the Qt event system, and once
// because its filtering all events before they are sent to
// the main window. Its much easier to get a pointer to the
// MainWindow object than is is to a pointer to the TV object,
// so send the event directly there. The TV object will get
// it anyway because because of the filter hook. (The last
// third of this function requires you to be in playback mode
// so the TV object is guaranteed to exist.)
auto *me = new MythEvent(message);
qApp->postEvent(GetMythMainWindow(), me);
}

return result;
Expand Down

0 comments on commit 98c82d5

Please sign in to comment.