Ticket #13444: 20190418-android-suspend-pause-bookmark.patch

File 20190418-android-suspend-pause-bookmark.patch, 2.9 KB (added by gigem, 8 months ago)
  • mythtv/libs/libmythtv/tv_play.cpp

    diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp
    index 740b658b9f..2b554dc6ef 100644
    a b TV::TV(void) 
    10031003
    10041004    InitFromDB();
    10051005
     1006#ifdef Q_OS_ANDROID
     1007    connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
     1008            this, SLOT(onApplicationStateChange(Qt::ApplicationState)));
     1009#endif
     1010
    10061011    LOG(VB_PLAYBACK, LOG_INFO, LOC + "Finished creating TV object");
    10071012}
    10081013
    QString TV::GetLiveTVIndex(const PlayerContext *ctx) const 
    1342013425#endif
    1342113426}
    1342213427
     13428void TV::onApplicationStateChange(Qt::ApplicationState state)
     13429{
     13430    switch (state)
     13431    {
     13432        case Qt::ApplicationState::ApplicationActive:
     13433        {
     13434            LOG(VB_GENERAL, LOG_NOTICE, "Resuming playback");
     13435            PlayerContext *ctx = GetPlayerReadLock(-1, __FILE__, __LINE__);
     13436            SetBookmark(ctx, true);
     13437            DoSetPauseState(ctx, m_suspendedPause);
     13438            ReturnPlayerLock(ctx);
     13439            m_suspended = false;
     13440            break;
     13441        }
     13442        case Qt::ApplicationState::ApplicationSuspended:
     13443        {
     13444            LOG(VB_GENERAL, LOG_NOTICE, "Suspending playback");
     13445            m_suspended = true;
     13446            PlayerContext *ctx = GetPlayerReadLock(-1, __FILE__, __LINE__);
     13447            vector<bool> do_pause;
     13448            for (uint i = 0; i < m_player.size(); i++)
     13449                do_pause.push_back(true);
     13450            m_suspendedPause = DoSetPauseState(ctx, do_pause);
     13451            SetBookmark(ctx, false);
     13452            ReturnPlayerLock(ctx);
     13453            break;
     13454        }
     13455        default:
     13456            break;
     13457    }
     13458}
     13459
    1342313460/* vim: set expandtab tabstop=4 shiftwidth=4: */
  • mythtv/libs/libmythtv/tv_play.h

    diff --git a/mythtv/libs/libmythtv/tv_play.h b/mythtv/libs/libmythtv/tv_play.h
    index 5102810ff5..8a56e2fae9 100644
    a b class MTV_PUBLIC TV : public QObject, public MenuItemDisplayer 
    346346    static EMBEDRETURNVOIDFINDER RunProgramFinderPtr;
    347347    static EMBEDRETURNVOIDSCHEDIT RunScheduleEditorPtr;
    348348
     349  protected slots:
     350    void onApplicationStateChange(Qt::ApplicationState state);
     351
    349352  private:
    350353    TV();
    351354   ~TV();
    class MTV_PUBLIC TV : public QObject, public MenuItemDisplayer 
    932935    /// true if video chromakey and frame should not be drawn
    933936    bool          m_disableDrawUnusedRects {false};
    934937
    935     // embedded status
     938    // embedded and suspended status
    936939    bool         m_isEmbedded {false};       ///< are we currently embedded
    937940    bool         m_ignoreKeyPresses {false}; ///< should we ignore keypresses
    938941    vector<bool> m_savedPause;      ///< saved pause state before embedding
     942    bool         m_suspended {false};///< are we currently suspended
     943    vector<bool> m_suspendedPause;  ///< saved pause state before suspending
    939944
    940945    // Channel group stuff
    941946    /// \brief Lock necessary when modifying channel group variables.