Skip to content

VPLAY-12875#1207

Open
Gnanesha wants to merge 1 commit intosupport/2.11.1_8.4from
feature/VPLAY-12875_8.4
Open

VPLAY-12875#1207
Gnanesha wants to merge 1 commit intosupport/2.11.1_8.4from
feature/VPLAY-12875_8.4

Conversation

@Gnanesha
Copy link
Copy Markdown
Contributor

Change the MonitorAV log line to single log line by combining beginning of issue started log

Reason for Change: combine two log lines to one to reduce the flooding
Test Guidance: updated in ticket
Risk: Low

Change the MonitorAV log line to single log line by combining beginning of issue started log

Reason for Change: combine two log lines to one to reduce the flooding
Test Guidance: updated in ticket
Risk: Low
@Gnanesha Gnanesha requested a review from a team as a code owner March 19, 2026 20:15
Copilot AI review requested due to automatic review settings March 19, 2026 20:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to reduce MonitorAV log flooding by collapsing the previous “state ended” + “state started” pair of log lines into a single combined log line, adding a human-readable UTC timestamp.

Changes:

  • Added a UTC timestamp formatter (MS_TO_UTC_STRING) and related includes in InterfacePlayerRDK.cpp.
  • Modified MonitorAV() logging to emit a single combined log line on AV state transitions, and added tracking variables for timestamp/positions.
  • Added a NOW_SYSTEM_TS_MS macro (system clock milliseconds) to InterfacePlayerPriv.h.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
middleware/InterfacePlayerRDK.cpp Introduces timestamp formatting and changes MonitorAV transition logging into a single line.
middleware/InterfacePlayerPriv.h Adds a system-clock timestamp macro used by the new MonitorAV logging.

Comment on lines +727 to +731
std::string humanReadbletime = MS_TO_UTC_STRING(time_now_ms);

MW_LOG_MIL( "MonitorAV_%s: (%s - %" G_GINT64_FORMAT ",%" G_GINT64_FORMAT ",%d,0) %" G_GINT64_FORMAT ",%" G_GINT64_FORMAT ",%d,%" G_GINT64_FORMAT "",
description,
humanReadbletime.c_str(),
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: variable name humanReadbletime appears misspelled (likely humanReadableTime). Consider correcting for readability/maintainability.

Suggested change
std::string humanReadbletime = MS_TO_UTC_STRING(time_now_ms);
MW_LOG_MIL( "MonitorAV_%s: (%s - %" G_GINT64_FORMAT ",%" G_GINT64_FORMAT ",%d,0) %" G_GINT64_FORMAT ",%" G_GINT64_FORMAT ",%d,%" G_GINT64_FORMAT "",
description,
humanReadbletime.c_str(),
std::string humanReadableTime = MS_TO_UTC_STRING(time_now_ms);
MW_LOG_MIL( "MonitorAV_%s: (%s - %" G_GINT64_FORMAT ",%" G_GINT64_FORMAT ",%d,0) %" G_GINT64_FORMAT ",%" G_GINT64_FORMAT ",%d,%" G_GINT64_FORMAT "",
description,
humanReadableTime.c_str(),

Copilot uses AI. Check for mistakes.
Comment on lines +631 to +633
static long long time_now_ms = 0;
static gint64 videoPos = 0;
static gint64 audioPos = 0;
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new static locals (time_now_ms, videoPos, audioPos) are shared across all MonitorAV() calls, so multiple InterfacePlayerRDK instances will overwrite each other’s values and produce incorrect/merged logs. Please store this per-player (e.g., in MonitorAVState or the player’s private context) instead of function-level statics.

Suggested change
static long long time_now_ms = 0;
static gint64 videoPos = 0;
static gint64 audioPos = 0;
long long time_now_ms = 0;
gint64 videoPos = 0;
gint64 audioPos = 0;

Copilot uses AI. Check for mistakes.
Comment on lines +729 to +737
MW_LOG_MIL( "MonitorAV_%s: (%s - %" G_GINT64_FORMAT ",%" G_GINT64_FORMAT ",%d,0) %" G_GINT64_FORMAT ",%" G_GINT64_FORMAT ",%d,%" G_GINT64_FORMAT "",
description,
humanReadbletime.c_str(),
videoPos,
audioPos,
(int)(videoPos - audioPos),
(gint64)monitorAVState->av_position[eGST_MEDIATYPE_VIDEO],
(gint64)monitorAVState->av_position[eGST_MEDIATYPE_AUDIO],
(int)(monitorAVState->av_position[eGST_MEDIATYPE_VIDEO] - monitorAVState->av_position[eGST_MEDIATYPE_AUDIO]),
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The combined log line labels the message with description (the new AV state), but the “previous state” section no longer includes the old state name (monitorAVState->description). This loses information compared to the previous two-line logging and makes transitions ambiguous. Include both old and new state descriptions in the single line (e.g., old -> new).

Copilot uses AI. Check for mistakes.
Comment on lines 723 to 739
{ // log only when interpretation of AV state has changed
if( monitorAVState->description )
{ // avoid logging for initial NULL description
MW_LOG_MIL( "MonitorAV_%s: %" G_GINT64_FORMAT ",%" G_GINT64_FORMAT ",%d, %" G_GINT64_FORMAT "",
monitorAVState->description,
(gint64)monitorAVState->av_position[eGST_MEDIATYPE_VIDEO],
(gint64)monitorAVState->av_position[eGST_MEDIATYPE_AUDIO],
(int)(monitorAVState->av_position[eGST_MEDIATYPE_VIDEO] - monitorAVState->av_position[eGST_MEDIATYPE_AUDIO]),
(gint64)monitorAVState->tLastSampled - monitorAVState->tLastReported );

std::string humanReadbletime = MS_TO_UTC_STRING(time_now_ms);

MW_LOG_MIL( "MonitorAV_%s: (%s - %" G_GINT64_FORMAT ",%" G_GINT64_FORMAT ",%d,0) %" G_GINT64_FORMAT ",%" G_GINT64_FORMAT ",%d,%" G_GINT64_FORMAT "",
description,
humanReadbletime.c_str(),
videoPos,
audioPos,
(int)(videoPos - audioPos),
(gint64)monitorAVState->av_position[eGST_MEDIATYPE_VIDEO],
(gint64)monitorAVState->av_position[eGST_MEDIATYPE_AUDIO],
(int)(monitorAVState->av_position[eGST_MEDIATYPE_VIDEO] - monitorAVState->av_position[eGST_MEDIATYPE_AUDIO]),
(gint64)monitorAVState->tLastSampled - monitorAVState->tLastReported );
}
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change suppresses logging for the first transition from nullptr to the initial state because logging now only happens inside if (monitorAVState->description). Previously, the code always emitted the “new state started” line on every transition. If the intent is to combine two lines into one (not drop the initial one), consider emitting a single line even when monitorAVState->description is null (with an explicit marker for "initial").

Copilot uses AI. Check for mistakes.
Comment on lines +727 to +742
std::string humanReadbletime = MS_TO_UTC_STRING(time_now_ms);

MW_LOG_MIL( "MonitorAV_%s: (%s - %" G_GINT64_FORMAT ",%" G_GINT64_FORMAT ",%d,0) %" G_GINT64_FORMAT ",%" G_GINT64_FORMAT ",%d,%" G_GINT64_FORMAT "",
description,
humanReadbletime.c_str(),
videoPos,
audioPos,
(int)(videoPos - audioPos),
(gint64)monitorAVState->av_position[eGST_MEDIATYPE_VIDEO],
(gint64)monitorAVState->av_position[eGST_MEDIATYPE_AUDIO],
(int)(monitorAVState->av_position[eGST_MEDIATYPE_VIDEO] - monitorAVState->av_position[eGST_MEDIATYPE_AUDIO]),
(gint64)monitorAVState->tLastSampled - monitorAVState->tLastReported );
}
MW_LOG_MIL( "MonitorAV_%s: %" G_GINT64_FORMAT ",%" G_GINT64_FORMAT ",%d,0",
description,
av_position[eGST_MEDIATYPE_VIDEO],
av_position[eGST_MEDIATYPE_AUDIO],
(int)(av_position[eGST_MEDIATYPE_VIDEO] - av_position[eGST_MEDIATYPE_AUDIO]) );
time_now_ms = NOW_SYSTEM_TS_MS;
videoPos = av_position[eGST_MEDIATYPE_VIDEO];
audioPos = av_position[eGST_MEDIATYPE_AUDIO];
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

humanReadbletime is derived from time_now_ms, but time_now_ms is only updated after the log line. As a result the timestamp shown corresponds to the previous transition (or 0/epoch until the first update), not the current event being logged. If the timestamp is meant to represent when the new issue/state started, set it before logging (or log both previous and current timestamps explicitly).

Copilot uses AI. Check for mistakes.
Comment on lines +73 to +81
#define MS_TO_UTC_STRING(ms) ([&](){ \
std::time_t t = (ms) / 1000; \
std::tm tm = *std::gmtime(&t); /* UTC instead of localtime */ \
std::ostringstream oss; \
oss << std::put_time(&tm, "%Y-%m-%d %H:%M:%S") \
<< '.' << std::setw(3) << std::setfill('0') << ((ms) % 1000); \
return oss.str(); \
}())

Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MS_TO_UTC_STRING uses std::gmtime(), which returns a pointer to a shared static tm and is not thread-safe; dereferencing it also assumes it never returns null. Since MonitorAV can be invoked from different threads/contexts, consider using gmtime_r (POSIX) or an equivalent thread-safe conversion, and prefer an inline helper function over a macro to avoid multiple evaluations of the ms argument.

Suggested change
#define MS_TO_UTC_STRING(ms) ([&](){ \
std::time_t t = (ms) / 1000; \
std::tm tm = *std::gmtime(&t); /* UTC instead of localtime */ \
std::ostringstream oss; \
oss << std::put_time(&tm, "%Y-%m-%d %H:%M:%S") \
<< '.' << std::setw(3) << std::setfill('0') << ((ms) % 1000); \
return oss.str(); \
}())
static inline std::string msToUtcString(int64_t ms)
{
std::time_t t = static_cast<std::time_t>(ms / 1000);
std::tm tm{};
#if defined(_POSIX_VERSION)
if (gmtime_r(&t, &tm) == nullptr)
{
return std::string();
}
#else
std::tm *tmp = std::gmtime(&t); /* UTC instead of localtime */
if (tmp == nullptr)
{
return std::string();
}
tm = *tmp;
#endif
std::ostringstream oss;
oss << std::put_time(&tm, "%Y-%m-%d %H:%M:%S")
<< '.' << std::setw(3) << std::setfill('0') << (ms % 1000);
return oss.str();
}
#define MS_TO_UTC_STRING(ms) msToUtcString(ms)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants