libdvr: Fail to seek to desired position [1/1]
PD#SWPL-100206
Problem:
Seek issue was found in Hisense S905Y4 project.
Enhance playback related print.
Solution:
Fixed spotted issues.
Verify:
Locally tested OK in AH212 RDK environment.
Signed-off-by: Wentao.MA <wentao.ma@amlogic.com>
Change-Id: I883b23846004d481aba45df85340669a212c4255
diff --git a/src/dvr_playback.c b/src/dvr_playback.c
index dbeb867..60cff30 100644
--- a/src/dvr_playback.c
+++ b/src/dvr_playback.c
@@ -3256,10 +3256,9 @@
int64_t cache = 0;//default es buf cache 500ms
int cur_time = 0;
pthread_mutex_lock(&player->segment_lock);
- loff_t tmp_pos = segment_tell_position(player->r_handle);
- loff_t pos = tmp_pos - player->ts_cache_len;
+ loff_t pos = segment_tell_position(player->r_handle);
uint64_t cur = 0;
- if (player->ts_cache_len > 0 && (tmp_pos < player->ts_cache_len)) {
+ if (player->ts_cache_len > 0 && (pos < 0)) {
//this case is open new segment end,but cache data is last segment.
//we need used last segment len to send play time.
cur = 0;
@@ -3302,40 +3301,16 @@
player->check_cache_flag=DVR_FALSE;
}
- DVR_PB_INFO("***get play cur time [%lld] cache:%lld cur id [%lld]"
- " last id [%lld] pb cache len [%d] pos [%lld][%lld]",
- cur,
- cache,
- player->cur_segment_id,
- player->last_send_time_id,
- player->ts_cache_len,
- pos,
- tmp_pos);
if (player->state == DVR_PLAYBACK_STATE_STOP) {
cache = 0;
}
- if (cur > cache) {
- cur_time = (int)(cur - cache);
- *id = player->cur_segment_id;
- } else if (player->last_segment_total > 0) {
- //if at fb mode,we not used last id to replace cur id if cache > cur time.
- //this case only used for normal speed or ff speed
- if (!IS_FB(player->speed) && player->last_segment_id <= player->cur_segment_id) {
- if (player->last_segment_total > (cache - cur))
- cur_time = (int)(player->last_segment_total - (cache - cur));
- else
- cur_time = (int)(player->last_segment_total - cur);
+ cur_time = (int)(cur - cache);
+ *id = player->cur_segment_id;
- *id = player->last_segment_id;
- } else {//fb mode
- cur_time = (int)(cur);
- *id = player->cur_segment_id;
- }
- DVR_PB_INFO("get play cur time[%lld][%lld][%d]", player->last_segment_id, player->cur_segment_id, player->last_segment_total);
- } else {
- cur_time = 0;
- *id = player->cur_segment_id;
- }
+ DVR_PB_INFO("***get playback slider position within segment. segment_id [%lld],"
+ " segment_slider_pos[%7d ms] = segment_read_pos[%7lld ms] - tsplayer_cache_len[%5lld ms],"
+ " last id [%lld] pos [%lld]",
+ player->cur_segment_id,cur_time,cur,cache,player->last_send_time_id,pos);
return cur_time;
}
@@ -4041,7 +4016,7 @@
player->last_cur_time = p_status->time_cur;
}
if (player->last_send_time_id == player->cur_segment_id) {
- if (player->speed > 0.0f ) {
+ if (player->speed > 1.0f ) {
//ff
if (p_status->time_cur < player->last_cur_time ) {
DVR_PB_INFO("get ff time error last[%d]cur[%d]diff[%d]",
diff --git a/src/dvr_wrapper.c b/src/dvr_wrapper.c
index 12a6a1e..af45b8b 100644
--- a/src/dvr_wrapper.c
+++ b/src/dvr_wrapper.c
@@ -2947,17 +2947,23 @@
static inline int process_notifyPlayback(DVR_WrapperCtx_t *ctx, DVR_PlaybackEvent_t evt, DVR_WrapperPlaybackStatus_t *status)
{
- DVR_WRAPPER_INFO("notify(sn:%ld) evt(0x%x) statistics:state/cur/full/obsolete(%d/%ld/%ld/%ld)\n",
- ctx->sn,
- evt,
- status->state,
- status->info_cur.time,
- status->info_full.time,
- status->info_obsolete.time);
+ DVR_RETURN_IF_FALSE(ctx->playback.event_fn != NULL);
- if (ctx->playback.event_fn)
- return ctx->playback.event_fn(evt, status, ctx->playback.event_userdata);
- return 0;
+ const time_t cur_time = status->info_cur.time;
+ const time_t full_time = status->info_full.time;
+ const time_t obsolete_time = status->info_obsolete.time;
+ const time_t origin_offset = cur_time + obsolete_time;
+ DVR_WRAPPER_INFO("playback progress notify(sn:%ld) evt(0x%x)"
+ " actual_slider_pos: %02d:%02d:%02d.%03d/%02d:%02d:%02d.%03d (%7ld ms/%7ld ms),"
+ " offset_from_origin: %02d:%02d:%02d.%03d (%7ld ms),"
+ " dump status:state/cur/full/obsolete(%d/%ld/%ld/%ld)",
+ ctx->sn,evt,cur_time/1000/3600,cur_time/1000%3600/60,cur_time/1000%60,cur_time%1000,
+ full_time/1000/3600,full_time/1000%3600/60,full_time/1000%60,full_time%1000,
+ cur_time,full_time,
+ origin_offset/1000/3600,origin_offset/1000%3600/60,origin_offset/1000%60,origin_offset%1000,
+ origin_offset,status->state,cur_time,full_time,obsolete_time);
+
+ return ctx->playback.event_fn(evt, status, ctx->playback.event_userdata);
}
/*should run periodically to update the current status*/