Ticket #7994: clear_bookmark_at_end_5.patch

File clear_bookmark_at_end_5.patch, 6.6 KB (added by Jim Stichnoth <stichnot@…>, 16 years ago)
  • libs/libmythtv/NuppelVideoPlayer.cpp

     
    45254525 *  \param margin minimum number of frames we want before being near end,
    45264526 *                defaults to 2 seconds of video.
    45274527 */
    4528 bool NuppelVideoPlayer::IsNearEnd(int64_t margin) const
     4528bool NuppelVideoPlayer::IsNearEnd(int64_t margin, bool allowVideo) const
    45294529{
    45304530    uint64_t framesRead, framesLeft = 0;
    45314531
     
    45334533        return false;
    45344534
    45354535    player_ctx->LockPlayingInfo(__FILE__, __LINE__);
    4536     if (!player_ctx->playingInfo || player_ctx->playingInfo->IsVideo() ||
     4536    if (!player_ctx->playingInfo || (player_ctx->playingInfo->IsVideo() && !allowVideo) ||
    45374537        !GetDecoder())
    45384538    {
    45394539        player_ctx->UnlockPlayingInfo(__FILE__, __LINE__);
     
    45494549    framesRead = GetDecoder()->GetFramesRead();
    45504550
    45514551    if (!player_ctx->IsPIP() &&
    4552         player_ctx->GetState() == kState_WatchingPreRecorded)
     4552        (player_ctx->GetState() == kState_WatchingPreRecorded ||
     4553         player_ctx->GetState() == kState_WatchingVideo ||
     4554         player_ctx->GetState() == kState_WatchingDVD))
    45534555    {
    45544556        framesLeft = margin;
    45554557        if (!editmode && hasdeletetable && IsInDelete(framesRead))
     
    45644566            }
    45654567        }
    45664568        else
    4567             framesLeft = totalFrames - framesRead;
     4569            framesLeft = totalFrames < framesRead ? 0 : totalFrames - framesRead;
    45684570        return (framesLeft < (uint64_t)margin);
    45694571    }
    45704572
  • libs/libmythtv/tv_play.h

     
    346346    void SetErrored(PlayerContext*);
    347347    void PrepToSwitchToRecordedProgram(PlayerContext*,
    348348                                       const ProgramInfo &);
     349    enum BookmarkAction {
     350        kBookmarkAlways,
     351        kBookmarkNever,
     352        kBookmarkAuto // set iff db_playback_exit_prompt==2
     353    };
    349354    void PrepareToExitPlayer(PlayerContext*, int line,
    350                              bool bookmark = true) const;
     355                             BookmarkAction bookmark = kBookmarkAuto) const;
    351356    void SetExitPlayer(bool set_it, bool wants_to) const;
    352357    void SetUpdateOSDPosition(bool set_it);
    353358
  • libs/libmythtv/NuppelVideoPlayer.h

     
    206206    bool    AtNormalSpeed(void) const         { return next_normal_speed; }
    207207    bool    IsDecoderThreadAlive(void) const  { return decoder_thread_alive; }
    208208    bool    IsReallyNearEnd(void) const;
    209     bool    IsNearEnd(int64_t framesRemaining = -1) const;
     209    bool    IsNearEnd(int64_t framesRemaining = -1, bool allowVideo = false) const;
    210210    bool    PlayingSlowForPrebuffer(void) const { return m_playing_slower; }
    211211    bool    HasAudioIn(void) const            { return !no_audio_in; }
    212212    bool    HasAudioOut(void) const           { return !no_audio_out; }
  • libs/libmythtv/tv_play.cpp

     
    31093109    SetExitPlayer(true, true);
    31103110}
    31113111
    3112 void TV::PrepareToExitPlayer(PlayerContext *ctx, int line, bool bookmark) const
     3112void TV::PrepareToExitPlayer(PlayerContext *ctx, int line, BookmarkAction bookmark) const
    31133113{
    3114     bool bookmark_it = bookmark && IsBookmarkAllowed(ctx);
     3114    bool bm_basic = (bookmark == kBookmarkAlways ||
     3115                     (bookmark == kBookmarkAuto && db_playback_exit_prompt == 2));
     3116    bool bookmark_it = bm_basic && IsBookmarkAllowed(ctx);
    31153117    ctx->LockDeleteNVP(__FILE__, line);
    31163118    if (ctx->nvp)
    31173119    {
    3118         if (bookmark_it && !(ctx->nvp->IsNearEnd()))
    3119             ctx->nvp->SetBookmark();
     3120        if (bookmark_it)
     3121        {
     3122            if (ctx->nvp->IsNearEnd(-1, true))
     3123                ctx->nvp->ClearBookmark();
     3124            else
     3125                ctx->nvp->SetBookmark();
     3126        }
    31203127        if (db_auto_set_watched)
    31213128            ctx->nvp->SetWatched();
    31223129    }
     
    31843191        if (mctx == ctx)
    31853192        {
    31863193            endOfRecording = true;
    3187             PrepareToExitPlayer(mctx, __LINE__, false);
     3194            PrepareToExitPlayer(mctx, __LINE__);
    31883195            SetExitPlayer(true, true);
    31893196        }
    31903197    }
     
    38913898    else if (has_action("ESCAPE", actions) && isnearend)
    38923899    {
    38933900        requestDelete = false;
    3894         PrepareToExitPlayer(actx, __LINE__, false);
     3901        PrepareToExitPlayer(actx, __LINE__);
    38953902        SetExitPlayer(true, true);
    38963903    }
    38973904    else if (has_action("SELECT", actions)  ||
     
    39563963                    DoTogglePause(actx, true);
    39573964                    break;
    39583965                case 1:
    3959                     PrepareToExitPlayer(actx, __LINE__);
     3966                    PrepareToExitPlayer(actx, __LINE__, kBookmarkAlways);
    39603967                    SetExitPlayer(true, true);
    39613968                    break;
    39623969                case 3:
     
    39653972                        actx, tr("Delete this recording?"));
    39663973                    return handled;
    39673974                default:
    3968                     PrepareToExitPlayer(actx, __LINE__, false);
     3975                    PrepareToExitPlayer(actx, __LINE__, kBookmarkNever);
    39693976                    SetExitPlayer(true, true);
    39703977                    break;
    39713978            }
     
    39903997                default:
    39913998                    if (isnearend)
    39923999                    {
    3993                         PrepareToExitPlayer(actx, __LINE__, false);
     4000                        PrepareToExitPlayer(actx, __LINE__);
    39944001                        SetExitPlayer(true, true);
    39954002                    }
    39964003                    else
     
    44124419                PromptStopWatchingRecording(ctx);
    44134420                return handled;
    44144421            }
    4415             PrepareToExitPlayer(ctx, __LINE__, db_playback_exit_prompt == 2);
     4422            PrepareToExitPlayer(ctx, __LINE__);
    44164423            requestDelete = false;
    44174424            do_exit = true;
    44184425        }
     
    87728779        for (uint i = 0; mctx && (i < player.size()); i++)
    87738780        {
    87748781            PlayerContext *ctx = GetPlayer(mctx, i);
    8775             PrepareToExitPlayer(ctx, __LINE__, db_playback_exit_prompt == 1 ||
    8776                                                db_playback_exit_prompt == 2);
     8782            PrepareToExitPlayer(ctx, __LINE__);
    87778783        }
    87788784
    87798785        SetExitPlayer(true, true);