Ticket #7994: clear_bookmark_at_end_8.patch

File clear_bookmark_at_end_8.patch, 5.5 KB (added by Jim Stichnoth <stichnot@…>, 14 years ago)
  • libs/libmythtv/mythplayer.cpp

     
    31603160 *  \param margin minimum number of frames we want before being near end,
    31613161 *                defaults to 2 seconds of video.
    31623162 */
    3163 bool MythPlayer::IsNearEnd(int64_t margin)
     3163bool MythPlayer::IsNearEnd(int64_t margin, bool allowVideo)
    31643164{
    31653165    uint64_t framesRead, framesLeft = 0;
    31663166
     
    31683168        return false;
    31693169
    31703170    player_ctx->LockPlayingInfo(__FILE__, __LINE__);
    3171     if (!player_ctx->playingInfo || player_ctx->playingInfo->IsVideo() ||
     3171    if (!player_ctx->playingInfo || (player_ctx->playingInfo->IsVideo() && !allowVideo) ||
    31723172        !GetDecoder())
    31733173    {
    31743174        player_ctx->UnlockPlayingInfo(__FILE__, __LINE__);
     
    31843184    framesRead = GetDecoder()->GetFramesRead();
    31853185
    31863186    if (!player_ctx->IsPIP() &&
    3187         player_ctx->GetState() == kState_WatchingPreRecorded)
     3187        (player_ctx->GetState() == kState_WatchingPreRecorded ||
     3188         player_ctx->GetState() == kState_WatchingVideo ||
     3189         player_ctx->GetState() == kState_WatchingBD ||
     3190         player_ctx->GetState() == kState_WatchingDVD))
    31883191    {
    31893192        framesLeft = margin;
    31903193        if (framesRead >= deleteMap.GetLastFrame(totalFrames))
  • libs/libmythtv/tv_play.h

     
    337337    void SetErrored(PlayerContext*);
    338338    void PrepToSwitchToRecordedProgram(PlayerContext*,
    339339                                       const ProgramInfo &);
     340    enum BookmarkAction {
     341        kBookmarkAlways,
     342        kBookmarkNever,
     343        kBookmarkAuto // set iff db_playback_exit_prompt==2
     344    };
    340345    void PrepareToExitPlayer(PlayerContext*, int line,
    341                              bool bookmark = true) const;
     346                             BookmarkAction bookmark = kBookmarkAuto) const;
    342347    void SetExitPlayer(bool set_it, bool wants_to) const;
    343348    void SetUpdateOSDPosition(bool set_it);
    344349
  • libs/libmythtv/mythplayer.h

     
    219219    bool    IsPlaying(uint wait_ms = 0, bool wait_for = true) const;
    220220    bool    AtNormalSpeed(void) const         { return next_normal_speed; }
    221221    bool    IsReallyNearEnd(void) const;
    222     bool    IsNearEnd(int64_t framesRemaining = -1);
     222    bool    IsNearEnd(int64_t framesRemaining = -1, bool allowVideo = false);
    223223    bool    HasAudioOut(void) const           { return audio.HasAudioOut(); }
    224224    bool    IsPIPActive(void) const           { return pip_active; }
    225225    bool    IsPIPVisible(void) const          { return pip_visible; }
  • libs/libmythtv/tv_play.cpp

     
    30373037    SetExitPlayer(true, true);
    30383038}
    30393039
    3040 void TV::PrepareToExitPlayer(PlayerContext *ctx, int line, bool bookmark) const
     3040void TV::PrepareToExitPlayer(PlayerContext *ctx, int line, BookmarkAction bookmark) const
    30413041{
    3042     bool bookmark_it = bookmark && IsBookmarkAllowed(ctx);
     3042    bool bm_basic = (bookmark == kBookmarkAlways ||
     3043                     (bookmark == kBookmarkAuto && db_playback_exit_prompt == 2));
     3044    bool bookmark_it = bm_basic && IsBookmarkAllowed(ctx);
    30433045    ctx->LockDeletePlayer(__FILE__, line);
    30443046    if (ctx->player)
    30453047    {
    3046         if (bookmark_it && !(ctx->player->IsNearEnd()))
    3047             ctx->player->SetBookmark();
     3048        if (bookmark_it)
     3049        {
     3050            if (ctx->player->IsNearEnd(-1, true))
     3051                ctx->player->ClearBookmark();
     3052            else
     3053                ctx->player->SetBookmark();
     3054        }
    30483055        if (db_auto_set_watched)
    30493056            ctx->player->SetWatched();
    30503057    }
     
    31123119        if (mctx == ctx)
    31133120        {
    31143121            endOfRecording = true;
    3115             PrepareToExitPlayer(mctx, __LINE__, false);
     3122            PrepareToExitPlayer(mctx, __LINE__);
    31163123            SetExitPlayer(true, true);
    31173124        }
    31183125    }
     
    41074114                ShowOSDStopWatchingRecording(ctx);
    41084115                return handled;
    41094116            }
    4110             PrepareToExitPlayer(ctx, __LINE__, db_playback_exit_prompt == 2);
     4117            PrepareToExitPlayer(ctx, __LINE__);
    41114118            requestDelete = false;
    41124119            do_exit = true;
    41134120        }
     
    83908397        for (uint i = 0; mctx && (i < player.size()); i++)
    83918398        {
    83928399            PlayerContext *ctx = GetPlayer(mctx, i);
    8393             PrepareToExitPlayer(ctx, __LINE__, db_playback_exit_prompt == 1 ||
    8394                                                db_playback_exit_prompt == 2);
     8400            PrepareToExitPlayer(ctx, __LINE__);
    83958401        }
    83968402
    83978403        SetExitPlayer(true, true);
     
    1158211588    }
    1158311589    else if (action == "SAVEPOSITIONANDEXIT" && bookmark_ok)
    1158411590    {
    11585         PrepareToExitPlayer(ctx, __LINE__);
     11591        PrepareToExitPlayer(ctx, __LINE__, kBookmarkAlways);
    1158611592        SetExitPlayer(true, true);
    1158711593    }
    1158811594    else if (action == "KEEPWATCHING" && !near_end)
     
    1159111597    }
    1159211598    else/* (action == "JUSTEXIT")*/
    1159311599    {
    11594         PrepareToExitPlayer(ctx, __LINE__, false);
     11600        PrepareToExitPlayer(ctx, __LINE__, kBookmarkNever);
    1159511601        SetExitPlayer(true, true);
    1159611602    }
    1159711603