Skip to content

Commit

Permalink
Codec2: guard the dummy work signal to lahaina only
Browse files Browse the repository at this point in the history
It seems to cause issues on Pixel's c2 codecs.

Change-Id: Iad9bbaaa9db440e49fa85368f5f1bab7d1072897
Signed-off-by: Chenyang Zhong <zhongcy95@gmail.com>
  • Loading branch information
jjpprrrr authored and whyredfire committed Jun 30, 2023
1 parent 315a1b8 commit 195f2fd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
31 changes: 20 additions & 11 deletions media/codec2/sfplugin/CCodecBufferChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ CCodecBufferChannel::CCodecBufferChannel(
mInputMetEos(false),
mLastInputBufferAvailableTs(0u),
mSendEncryptedInfoBuffer(false) {
char board_platform[PROPERTY_VALUE_MAX];
property_get("ro.board.platform", board_platform, "");
mNeedEmptyWork = false;
if (!strncmp(board_platform, "lahaina", 7)) {
mNeedEmptyWork = true;
ALOGV("CCodecBufferChannel: going to queue empty work for lahaina.");
}
mOutputSurface.lock()->maxDequeueBuffers = kSmoothnessFactor + kRenderingDepth;
{
Mutexed<Input>::Locked input(mInput);
Expand Down Expand Up @@ -730,15 +737,17 @@ void CCodecBufferChannel::feedInputBufferIfAvailable() {
// limit this WA to qc hw decoder only
// if feedInputBufferIfAvailableInternal() successfully (has available input buffer),
// mLastInputBufferAvailableTs would be updated. otherwise, not input buffer available
std::regex pattern{"c2\\.qti\\..*\\.decoder.*"};
if (std::regex_match(mComponentName, pattern)) {
std::lock_guard<std::mutex> tsLock(mTsLock);
uint64_t now = std::chrono::duration_cast<std::chrono::milliseconds>(
PipelineWatcher::Clock::now().time_since_epoch()).count();
if (now - mLastInputBufferAvailableTs > kPipelinePausedTimeoutMs) {
ALOGV("long time elapsed since last input available, let's queue a specific work to "
"HAL to notify something");
queueDummyWork();
if (mNeedEmptyWork) {
std::regex pattern{"c2\\.qti\\..*\\.decoder.*"};
if (std::regex_match(mComponentName, pattern)) {
std::lock_guard<std::mutex> tsLock(mTsLock);
uint64_t now = std::chrono::duration_cast<std::chrono::milliseconds>(
PipelineWatcher::Clock::now().time_since_epoch()).count();
if (now - mLastInputBufferAvailableTs > kPipelinePausedTimeoutMs) {
ALOGV("long time elapsed since last input available, let's queue a specific work to "
"HAL to notify something");
queueDummyWork();
}
}
}
}
Expand Down Expand Up @@ -1604,7 +1613,7 @@ status_t CCodecBufferChannel::requestInitialInputBuffers(
clientInputBuffers.erase(minIndex);
}

if (!clientInputBuffers.empty()) {
if (mNeedEmptyWork && !clientInputBuffers.empty()) {
{
std::lock_guard<std::mutex> tsLock(mTsLock);
mLastInputBufferAvailableTs = std::chrono::duration_cast<std::chrono::milliseconds>(
Expand Down Expand Up @@ -1778,7 +1787,7 @@ bool CCodecBufferChannel::handleWork(

if (work->result == C2_OK){
notifyClient = true;
} else if (work->result == C2_OMITTED) {
} else if (mNeedEmptyWork && work->result == C2_OMITTED) {
ALOGV("[%s] empty work returned; omitted.", mName);
return false; // omitted
} else if (work->result == C2_NOT_FOUND) {
Expand Down
3 changes: 3 additions & 0 deletions media/codec2/sfplugin/CCodecBufferChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ class CCodecBufferChannel
uint64_t mLastInputBufferAvailableTs;
std::mutex mTsLock;

// whether the HAL needs a dummy work
bool mNeedEmptyWork;

sp<ICrypto> mCrypto;
sp<IDescrambler> mDescrambler;

Expand Down

0 comments on commit 195f2fd

Please sign in to comment.