Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Unified Diff: content/common/gpu/media/gpu_video_decode_accelerator.cc

Issue 185403020: Make VEA client of command buffer; move sync. IPC to VDA/VEA::Initialize() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: f2a9ccb5 Rebase, posciak@ comments. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/media/gpu_video_decode_accelerator.cc
diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.cc b/content/common/gpu/media/gpu_video_decode_accelerator.cc
index 9ec813983645bef94c86d0470861d9c00ce2ecae..e76608fc826769e176c72c68c7202884c8da0fd1 100644
--- a/content/common/gpu/media/gpu_video_decode_accelerator.cc
+++ b/content/common/gpu/media/gpu_video_decode_accelerator.cc
@@ -130,8 +130,7 @@ GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator(
int32 host_route_id,
GpuCommandBufferStub* stub,
const scoped_refptr<base::MessageLoopProxy>& io_message_loop)
- : init_done_msg_(NULL),
- host_route_id_(host_route_id),
+ : host_route_id_(host_route_id),
stub_(stub),
texture_target_(0),
filter_removed_(true, false),
@@ -139,7 +138,6 @@ GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator(
weak_factory_for_io_(this) {
DCHECK(stub_);
stub_->AddDestructionObserver(this);
- stub_->channel()->AddRoute(host_route_id_, this);
child_message_loop_ = base::MessageLoopProxy::current();
make_context_current_ =
base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr());
@@ -148,7 +146,7 @@ GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator(
GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() {
// This class can only be self-deleted from OnWillDestroyStub(), which means
// the VDA has already been destroyed in there.
- CHECK(!video_decode_accelerator_.get());
+ DCHECK(!video_decode_accelerator_);
}
bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) {
@@ -229,16 +227,6 @@ void GpuVideoDecodeAccelerator::PictureReady(
void GpuVideoDecodeAccelerator::NotifyError(
media::VideoDecodeAccelerator::Error error) {
- if (init_done_msg_) {
- // If we get an error while we're initializing, NotifyInitializeDone won't
- // be called, so we need to send the reply (with an error) here.
- GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(
- init_done_msg_, -1);
- if (!Send(init_done_msg_))
- DLOG(ERROR) << "Send(init_done_msg_) failed";
- init_done_msg_ = NULL;
- return;
- }
if (!Send(new AcceleratedVideoDecoderHostMsg_ErrorNotification(
host_route_id_, error))) {
DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ErrorNotification) "
@@ -246,19 +234,22 @@ void GpuVideoDecodeAccelerator::NotifyError(
}
}
+#define WRITE_REPLY_AND_SEND(msg, route_id) \
+ do { \
+ GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(msg, route_id); \
+ Send(init_done_msg); \
Ami GONE FROM CHROMIUM 2014/03/17 03:17:54 s/init_done_msg/msg/ but why not just a helper met
sheu 2014/03/18 22:38:35 Done.
+ } while (0)
+
void GpuVideoDecodeAccelerator::Initialize(
const media::VideoCodecProfile profile,
IPC::Message* init_done_msg) {
DCHECK(!video_decode_accelerator_.get());
- DCHECK(!init_done_msg_);
- DCHECK(init_done_msg);
- init_done_msg_ = init_done_msg;
#if !defined(OS_WIN)
// Ensure we will be able to get a GL context at all before initializing
// non-Windows VDAs.
if (!make_context_current_.Run()) {
- NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
+ WRITE_REPLY_AND_SEND(init_done_msg, -1);
Ami GONE FROM CHROMIUM 2014/03/17 03:17:54 I thought route ID of "0" was error. But here I s
sheu 2014/03/18 22:38:35 On the renderer side it checks " < 0 " for error.
return;
}
#endif
@@ -266,7 +257,7 @@ void GpuVideoDecodeAccelerator::Initialize(
#if defined(OS_WIN)
if (base::win::GetVersion() < base::win::VERSION_WIN7) {
NOTIMPLEMENTED() << "HW video decode acceleration not available.";
- NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
+ WRITE_REPLY_AND_SEND(init_done_msg, -1);
return;
}
DVLOG(0) << "Initializing DXVA HW decoder for windows.";
@@ -275,7 +266,7 @@ void GpuVideoDecodeAccelerator::Initialize(
#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11)
scoped_ptr<V4L2Device> device = V4L2Device::Create();
if (!device.get()) {
- NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
+ WRITE_REPLY_AND_SEND(init_done_msg, -1);
return;
}
video_decode_accelerator_.reset(
@@ -288,7 +279,7 @@ void GpuVideoDecodeAccelerator::Initialize(
if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) {
VLOG(1) << "HW video decode acceleration not available without "
"DesktopGL (GLX).";
- NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
+ WRITE_REPLY_AND_SEND(init_done_msg, -1);
return;
}
gfx::GLContextGLX* glx_context =
@@ -301,7 +292,7 @@ void GpuVideoDecodeAccelerator::Initialize(
make_context_current_));
#else
NOTIMPLEMENTED() << "HW video decode acceleration not available.";
- NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
+ WRITE_REPLY_AND_SEND(init_done_msg, -1);
return;
#endif
@@ -310,10 +301,16 @@ void GpuVideoDecodeAccelerator::Initialize(
stub_->channel()->AddFilter(filter_.get());
}
- if (!video_decode_accelerator_->Initialize(profile, this))
- NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE);
+ if (!video_decode_accelerator_->Initialize(profile, this)) {
+ WRITE_REPLY_AND_SEND(init_done_msg, -1);
+ return;
+ }
+
+ WRITE_REPLY_AND_SEND(init_done_msg, host_route_id_);
}
+#undef WRITE_REPLY_AND_SEND
+
// Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is
// true, otherwise on the main thread.
void GpuVideoDecodeAccelerator::OnDecode(
@@ -448,14 +445,6 @@ void GpuVideoDecodeAccelerator::NotifyEndOfBitstreamBuffer(
}
}
-void GpuVideoDecodeAccelerator::NotifyInitializeDone() {
- GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(
- init_done_msg_, host_route_id_);
- if (!Send(init_done_msg_))
- DLOG(ERROR) << "Send(init_done_msg_) failed";
- init_done_msg_ = NULL;
-}
-
void GpuVideoDecodeAccelerator::NotifyFlushDone() {
if (!Send(new AcceleratedVideoDecoderHostMsg_FlushDone(host_route_id_)))
DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_FlushDone) failed";

Powered by Google App Engine
This is Rietveld 408576698