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

Side by Side Diff: content/renderer/gpu/gpu_video_service_host.cc

Issue 7260008: Implement proper synchronization between HW video decode IPC and CommandBuffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/gpu/gpu_video_service_host.h" 5 #include "content/renderer/gpu/gpu_video_service_host.h"
6 6
7 #include "content/common/gpu/gpu_messages.h" 7 #include "content/common/gpu/gpu_messages.h"
8 #include "content/renderer/gpu/gpu_video_decode_accelerator_host.h" 8 #include "content/renderer/gpu/gpu_video_decode_accelerator_host.h"
9 #include "content/renderer/render_thread.h" 9 #include "content/renderer/render_thread.h"
10 #include "media/video/video_decode_accelerator.h" 10 #include "media/video/video_decode_accelerator.h"
11 11
12 GpuVideoServiceHost::GpuVideoServiceHost() 12 GpuVideoServiceHost::GpuVideoServiceHost()
scherkus (not reviewing) 2011/06/28 22:02:07 nit: if the object is created/destroyed on same th
Ami GONE FROM CHROMIUM 2011/06/28 22:25:06 Done.
13 : channel_(NULL), 13 : channel_(NULL),
14 next_decoder_host_id_(0) { 14 next_decoder_host_id_(0) {
15 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
scherkus (not reviewing) 2011/06/28 22:02:07 ditto
Ami GONE FROM CHROMIUM 2011/06/28 22:25:06 Done.
15 } 16 }
16 17
17 GpuVideoServiceHost::~GpuVideoServiceHost() { 18 GpuVideoServiceHost::~GpuVideoServiceHost() {
18 } 19 }
19 20
20 void GpuVideoServiceHost::OnFilterAdded(IPC::Channel* channel) { 21 void GpuVideoServiceHost::set_channel(IPC::SyncChannel* channel) {
21 base::Closure on_initialized; 22 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
22 { 23 DCHECK(!channel_);
23 base::AutoLock auto_lock(lock_); 24 channel_ = channel;
24 DCHECK(!channel_); 25 if (!on_initialized_.is_null())
25 channel_ = channel; 26 on_initialized_.Run();
26 on_initialized = on_initialized_;
27 }
28 if (!on_initialized.is_null())
29 on_initialized.Run();
30 }
31
32 void GpuVideoServiceHost::OnFilterRemoved() {
33 // TODO(hclam): Implement.
34 }
35
36 void GpuVideoServiceHost::OnChannelClosing() {
37 // TODO(hclam): Implement.
38 } 27 }
39 28
40 bool GpuVideoServiceHost::OnMessageReceived(const IPC::Message& msg) { 29 bool GpuVideoServiceHost::OnMessageReceived(const IPC::Message& msg) {
30 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
31 if (!channel_)
32 return false;
41 switch (msg.type()) { 33 switch (msg.type()) {
42 case AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed::ID: 34 case AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed::ID:
43 case AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers::ID: 35 case AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers::ID:
44 case AcceleratedVideoDecoderHostMsg_CreateDone::ID: 36 case AcceleratedVideoDecoderHostMsg_CreateDone::ID:
45 case AcceleratedVideoDecoderHostMsg_InitializeDone::ID: 37 case AcceleratedVideoDecoderHostMsg_InitializeDone::ID:
46 case AcceleratedVideoDecoderHostMsg_DismissPictureBuffer::ID: 38 case AcceleratedVideoDecoderHostMsg_DismissPictureBuffer::ID:
47 case AcceleratedVideoDecoderHostMsg_PictureReady::ID: 39 case AcceleratedVideoDecoderHostMsg_PictureReady::ID:
48 case AcceleratedVideoDecoderHostMsg_FlushDone::ID: 40 case AcceleratedVideoDecoderHostMsg_FlushDone::ID:
49 case AcceleratedVideoDecoderHostMsg_AbortDone::ID: 41 case AcceleratedVideoDecoderHostMsg_AbortDone::ID:
50 case AcceleratedVideoDecoderHostMsg_EndOfStream::ID: 42 case AcceleratedVideoDecoderHostMsg_EndOfStream::ID:
51 case AcceleratedVideoDecoderHostMsg_ErrorNotification::ID: 43 case AcceleratedVideoDecoderHostMsg_ErrorNotification::ID:
52 if (router_.RouteMessage(msg)) 44 if (router_.RouteMessage(msg))
53 return true; 45 return true;
54 LOG(ERROR) << "AcceleratedVideoDecoderHostMsg cannot be dispatched."; 46 LOG(ERROR) << "AcceleratedVideoDecoderHostMsg cannot be dispatched.";
55 default: 47 default:
56 return false; 48 return false;
57 } 49 }
58 } 50 }
59 51
52 void GpuVideoServiceHost::OnChannelError() {
53 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
54 channel_ = NULL;
55 }
56
60 void GpuVideoServiceHost::SetOnInitialized( 57 void GpuVideoServiceHost::SetOnInitialized(
61 const base::Closure& on_initialized) { 58 const base::Closure& on_initialized) {
62 IPC::Channel* channel; 59 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
63 { 60 DCHECK(on_initialized_.is_null());
64 base::AutoLock auto_lock(lock_); 61 on_initialized_ = on_initialized;
65 DCHECK(on_initialized_.is_null()); 62 if (channel_)
66 on_initialized_ = on_initialized;
67 channel = channel_;
68 }
69 if (channel)
70 on_initialized.Run(); 63 on_initialized.Run();
71 } 64 }
72 65
73 GpuVideoDecodeAcceleratorHost* GpuVideoServiceHost::CreateVideoAccelerator( 66 GpuVideoDecodeAcceleratorHost* GpuVideoServiceHost::CreateVideoAccelerator(
74 media::VideoDecodeAccelerator::Client* client, 67 media::VideoDecodeAccelerator::Client* client,
75 int command_buffer_route_id) { 68 int32 command_buffer_route_id,
76 base::AutoLock auto_lock(lock_); 69 gpu::CommandBufferHelper* cmd_buffer_helper) {
70 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current());
77 DCHECK(channel_); 71 DCHECK(channel_);
78 return new GpuVideoDecodeAcceleratorHost( 72 return new GpuVideoDecodeAcceleratorHost(
79 &router_, channel_, next_decoder_host_id_++, 73 &router_, channel_, next_decoder_host_id_++,
80 command_buffer_route_id, client); 74 command_buffer_route_id, cmd_buffer_helper, client);
81 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698