Reland "codec2: fix build by assigning absolute namespace path ::base"
This reverts commit 7acf8892969e8f2d6a0bca3bbd1a939e894227a6.
ag/4009937 produces compile error after C2VDAComponent includes
"v4l2/C2VDABQBlockPool.h", there is "namespace android::base" which misleads
compiler to find the correct "namespace base" in libchrome.
To solve this, change to use absolute namespace "::base".
Bug: 79239042
Test: build image
Change-Id: Ib9d179131c4bc9c5c0f7b5fc411318b497d7e2eb
diff --git a/C2VDAComponent.cpp b/C2VDAComponent.cpp
index 2e8f9d3..1f15e2d 100644
--- a/C2VDAComponent.cpp
+++ b/C2VDAComponent.cpp
@@ -224,7 +224,7 @@
if (mThread.IsRunning()) {
mTaskRunner->PostTask(FROM_HERE,
- base::Bind(&C2VDAComponent::onDestroy, base::Unretained(this)));
+ ::base::Bind(&C2VDAComponent::onDestroy, ::base::Unretained(this)));
mThread.Stop();
}
}
@@ -239,7 +239,7 @@
stopDequeueThread();
}
-void C2VDAComponent::onStart(media::VideoCodecProfile profile, base::WaitableEvent* done) {
+void C2VDAComponent::onStart(media::VideoCodecProfile profile, ::base::WaitableEvent* done) {
DCHECK(mTaskRunner->BelongsToCurrentThread());
ALOGV("onStart");
CHECK_EQ(mComponentState, ComponentState::UNINITIALIZED);
@@ -276,7 +276,7 @@
// TODO(johnylin): set a maximum size of mQueue and check if mQueue is already full.
mTaskRunner->PostTask(FROM_HERE,
- base::Bind(&C2VDAComponent::onDequeueWork, base::Unretained(this)));
+ ::base::Bind(&C2VDAComponent::onDequeueWork, ::base::Unretained(this)));
}
void C2VDAComponent::onDequeueWork() {
@@ -325,8 +325,8 @@
mPendingWorks.emplace_back(std::move(work));
if (!mQueue.empty()) {
- mTaskRunner->PostTask(FROM_HERE,
- base::Bind(&C2VDAComponent::onDequeueWork, base::Unretained(this)));
+ mTaskRunner->PostTask(FROM_HERE, ::base::Bind(&C2VDAComponent::onDequeueWork,
+ ::base::Unretained(this)));
}
}
@@ -401,7 +401,7 @@
C2Fence())));
// TODO: this does not work for timestamps as they can wrap around
- int64_t currentTimestamp = base::checked_cast<int64_t>(work->input.ordinal.timestamp.peek());
+ int64_t currentTimestamp = ::base::checked_cast<int64_t>(work->input.ordinal.timestamp.peek());
CHECK_GE(currentTimestamp, mLastOutputTimestamp);
mLastOutputTimestamp = currentTimestamp;
@@ -461,7 +461,7 @@
// Work dequeueing was stopped while component draining. Restart it.
mTaskRunner->PostTask(FROM_HERE,
- base::Bind(&C2VDAComponent::onDequeueWork, base::Unretained(this)));
+ ::base::Bind(&C2VDAComponent::onDequeueWork, ::base::Unretained(this)));
}
void C2VDAComponent::onFlush() {
@@ -481,7 +481,7 @@
mComponentState = ComponentState::FLUSHING;
}
-void C2VDAComponent::onStop(base::WaitableEvent* done) {
+void C2VDAComponent::onStop(::base::WaitableEvent* done) {
DCHECK(mTaskRunner->BelongsToCurrentThread());
ALOGV("onStop");
EXPECT_RUNNING_OR_RETURN_ON_ERROR();
@@ -781,7 +781,7 @@
#endif
ALOGV("HAL pixel format: 0x%x", static_cast<uint32_t>(info.mPixelFormat));
- base::ScopedFD passedHandle(dup(info.mGraphicBlock->handle()->data[0]));
+ ::base::ScopedFD passedHandle(dup(info.mGraphicBlock->handle()->data[0]));
if (!passedHandle.is_valid()) {
ALOGE("Failed to dup(%d), errno=%d", info.mGraphicBlock->handle()->data[0], errno);
reportError(C2_CORRUPTED);
@@ -839,8 +839,8 @@
}
while (!items->empty()) {
mTaskRunner->PostTask(FROM_HERE,
- base::Bind(&C2VDAComponent::onQueueWork, base::Unretained(this),
- base::Passed(&items->front())));
+ ::base::Bind(&C2VDAComponent::onQueueWork, ::base::Unretained(this),
+ ::base::Passed(&items->front())));
items->pop_front();
}
return C2_OK;
@@ -859,7 +859,8 @@
if (mState.load() != State::RUNNING) {
return C2_BAD_STATE;
}
- mTaskRunner->PostTask(FROM_HERE, base::Bind(&C2VDAComponent::onFlush, base::Unretained(this)));
+ mTaskRunner->PostTask(FROM_HERE, ::base::Bind(&C2VDAComponent::onFlush,
+ ::base::Unretained(this)));
// Instead of |flushedWork|, abandoned works will be returned via onWorkDone_nb() callback.
return C2_OK;
}
@@ -871,8 +872,9 @@
if (mState.load() != State::RUNNING) {
return C2_BAD_STATE;
}
- mTaskRunner->PostTask(FROM_HERE, base::Bind(&C2VDAComponent::onDrain, base::Unretained(this),
- static_cast<uint32_t>(mode)));
+ mTaskRunner->PostTask(FROM_HERE,
+ ::base::Bind(&C2VDAComponent::onDrain, ::base::Unretained(this),
+ static_cast<uint32_t>(mode)));
return C2_OK;
}
@@ -887,10 +889,11 @@
mCodecProfile = mIntfImpl->getCodecProfile();
ALOGI("get parameter: mCodecProfile = %d", static_cast<int>(mCodecProfile));
- base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC,
- base::WaitableEvent::InitialState::NOT_SIGNALED);
- mTaskRunner->PostTask(FROM_HERE, base::Bind(&C2VDAComponent::onStart, base::Unretained(this),
- mCodecProfile, &done));
+ ::base::WaitableEvent done(::base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ ::base::WaitableEvent::InitialState::NOT_SIGNALED);
+ mTaskRunner->PostTask(FROM_HERE,
+ ::base::Bind(&C2VDAComponent::onStart, ::base::Unretained(this),
+ mCodecProfile, &done));
done.Wait();
if (mVDAInitResult != VideoDecodeAcceleratorAdaptor::Result::SUCCESS) {
ALOGE("Failed to start component due to VDA error: %d", static_cast<int>(mVDAInitResult));
@@ -909,10 +912,10 @@
return C2_OK; // Component is already in stopped state.
}
- base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC,
- base::WaitableEvent::InitialState::NOT_SIGNALED);
+ ::base::WaitableEvent done(::base::WaitableEvent::ResetPolicy::AUTOMATIC,
+ ::base::WaitableEvent::InitialState::NOT_SIGNALED);
mTaskRunner->PostTask(FROM_HERE,
- base::Bind(&C2VDAComponent::onStop, base::Unretained(this), &done));
+ ::base::Bind(&C2VDAComponent::onStop, ::base::Unretained(this), &done));
done.Wait();
mState.store(State::LOADED);
return C2_OK;
@@ -941,8 +944,9 @@
// Set mRequestedVisibleRect to default.
mRequestedVisibleRect = media::Rect();
- mTaskRunner->PostTask(FROM_HERE, base::Bind(&C2VDAComponent::onOutputFormatChanged,
- base::Unretained(this), base::Passed(&format)));
+ mTaskRunner->PostTask(FROM_HERE, ::base::Bind(&C2VDAComponent::onOutputFormatChanged,
+ ::base::Unretained(this),
+ ::base::Passed(&format)));
}
void C2VDAComponent::dismissPictureBuffer(int32_t pictureBufferId) {
@@ -957,28 +961,28 @@
if (mRequestedVisibleRect != cropRect) {
mRequestedVisibleRect = cropRect;
- mTaskRunner->PostTask(FROM_HERE, base::Bind(&C2VDAComponent::onVisibleRectChanged,
- base::Unretained(this), cropRect));
+ mTaskRunner->PostTask(FROM_HERE, ::base::Bind(&C2VDAComponent::onVisibleRectChanged,
+ ::base::Unretained(this), cropRect));
}
- mTaskRunner->PostTask(FROM_HERE,
- base::Bind(&C2VDAComponent::onOutputBufferDone, base::Unretained(this),
- pictureBufferId, bitstreamId));
+ mTaskRunner->PostTask(FROM_HERE, ::base::Bind(&C2VDAComponent::onOutputBufferDone,
+ ::base::Unretained(this),
+ pictureBufferId, bitstreamId));
}
void C2VDAComponent::notifyEndOfBitstreamBuffer(int32_t bitstreamId) {
- mTaskRunner->PostTask(FROM_HERE, base::Bind(&C2VDAComponent::onInputBufferDone,
- base::Unretained(this), bitstreamId));
+ mTaskRunner->PostTask(FROM_HERE, ::base::Bind(&C2VDAComponent::onInputBufferDone,
+ ::base::Unretained(this), bitstreamId));
}
void C2VDAComponent::notifyFlushDone() {
mTaskRunner->PostTask(FROM_HERE,
- base::Bind(&C2VDAComponent::onDrainDone, base::Unretained(this)));
+ ::base::Bind(&C2VDAComponent::onDrainDone, ::base::Unretained(this)));
}
void C2VDAComponent::notifyResetDone() {
mTaskRunner->PostTask(FROM_HERE,
- base::Bind(&C2VDAComponent::onResetDone, base::Unretained(this)));
+ ::base::Bind(&C2VDAComponent::onResetDone, ::base::Unretained(this)));
}
void C2VDAComponent::notifyError(VideoDecodeAcceleratorAdaptor::Result error) {
@@ -1110,8 +1114,8 @@
mDequeueLoopStop.store(false);
mBuffersInClient.store(0u);
mDequeueThread.task_runner()->PostTask(
- FROM_HERE, base::Bind(&C2VDAComponent::dequeueThreadLoop, base::Unretained(this),
- size, pixelFormat));
+ FROM_HERE, ::base::Bind(&C2VDAComponent::dequeueThreadLoop, ::base::Unretained(this),
+ size, pixelFormat));
return true;
}
@@ -1140,8 +1144,8 @@
}
if (err == C2_OK) {
auto slot = getSlotFromGraphicBlockHandle(block->handle());
- mTaskRunner->PostTask(FROM_HERE, base::Bind(&C2VDAComponent::onOutputBufferReturned,
- base::Unretained(this), slot));
+ mTaskRunner->PostTask(FROM_HERE, ::base::Bind(&C2VDAComponent::onOutputBufferReturned,
+ ::base::Unretained(this), slot));
mBuffersInClient--;
} else {
ALOGE("dequeueThreadLoop got error: %d", err);
diff --git a/include/C2VDAComponent.h b/include/C2VDAComponent.h
index 4eb7453..53fcf4e 100644
--- a/include/C2VDAComponent.h
+++ b/include/C2VDAComponent.h
@@ -159,7 +159,7 @@
// HAL pixel format used while importing to VDA.
HalPixelFormat mPixelFormat;
// The handle dupped from graphic block for importing to VDA.
- base::ScopedFD mHandle;
+ ::base::ScopedFD mHandle;
// VideoFramePlane information for importing to VDA.
std::vector<VideoFramePlane> mPlanes;
};
@@ -177,7 +177,7 @@
// These tasks should be run on the component thread |mThread|.
void onDestroy();
- void onStart(media::VideoCodecProfile profile, base::WaitableEvent* done);
+ void onStart(media::VideoCodecProfile profile, ::base::WaitableEvent* done);
void onQueueWork(std::unique_ptr<C2Work> work);
void onDequeueWork();
void onInputBufferDone(int32_t bitstreamId);
@@ -185,7 +185,7 @@
void onDrain(uint32_t drainMode);
void onDrainDone();
void onFlush();
- void onStop(base::WaitableEvent* done);
+ void onStop(::base::WaitableEvent* done);
void onResetDone();
void onFlushDone();
void onStopDone();
@@ -238,12 +238,12 @@
std::shared_ptr<Listener> mListener;
// The main component thread.
- base::Thread mThread;
+ ::base::Thread mThread;
// The task runner on component thread.
- scoped_refptr<base::SingleThreadTaskRunner> mTaskRunner;
+ scoped_refptr<::base::SingleThreadTaskRunner> mTaskRunner;
// The dequeue buffer loop thread.
- base::Thread mDequeueThread;
+ ::base::Thread mDequeueThread;
// The stop signal for dequeue loop which should be atomic (toggled by main thread).
std::atomic<bool> mDequeueLoopStop;
// The count of buffers owned by client which should be atomic.
@@ -257,7 +257,7 @@
std::unique_ptr<VideoDecodeAcceleratorAdaptor> mVDAAdaptor;
// The done event pointer of stop procedure. It should be restored in onStop() and signaled in
// onStopDone().
- base::WaitableEvent* mStopDoneEvent;
+ ::base::WaitableEvent* mStopDoneEvent;
// The state machine on component thread.
ComponentState mComponentState;
// The indicator of drain mode (true for draining with EOS). This should be always set along
@@ -295,7 +295,7 @@
std::mutex mStartStopLock;
// The WeakPtrFactory for getting weak pointer of this.
- base::WeakPtrFactory<C2VDAComponent> mWeakThisFactory;
+ ::base::WeakPtrFactory<C2VDAComponent> mWeakThisFactory;
DISALLOW_COPY_AND_ASSIGN(C2VDAComponent);
};