summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorwjia@google.com <wjia@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-15 00:22:38 +0000
committerwjia@google.com <wjia@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-15 00:22:38 +0000
commite10bb046f38fed6fb2a328f2eb0c80a81c884045 (patch)
tree21edd23d2a7da8e5d60f03c8f57f4cbf451778f2 /media
parent2a4f9884f3b47a5af5bac0703251efa77810986e (diff)
downloadchromium_src-e10bb046f38fed6fb2a328f2eb0c80a81c884045.zip
chromium_src-e10bb046f38fed6fb2a328f2eb0c80a81c884045.tar.gz
chromium_src-e10bb046f38fed6fb2a328f2eb0c80a81c884045.tar.bz2
1. support stop mode for omx
2. make player_x11 respond to button event quickly BUG=none TEST=dev platform Review URL: http://codereview.chromium.org/2781010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/filters/omx_video_decode_engine.cc29
-rw-r--r--media/filters/omx_video_decode_engine.h1
-rw-r--r--media/tools/player_x11/player_x11.cc12
3 files changed, 32 insertions, 10 deletions
diff --git a/media/filters/omx_video_decode_engine.cc b/media/filters/omx_video_decode_engine.cc
index 4d56f56..b07e4db 100644
--- a/media/filters/omx_video_decode_engine.cc
+++ b/media/filters/omx_video_decode_engine.cc
@@ -62,7 +62,8 @@ OmxVideoDecodeEngine::OmxVideoDecodeEngine()
}
OmxVideoDecodeEngine::~OmxVideoDecodeEngine() {
- DCHECK_EQ(client_state_, kClientNotInitialized);
+ DCHECK(client_state_ == kClientNotInitialized ||
+ client_state_ == kClientStopped);
DCHECK_EQ(il_state_, kIlNone);
DCHECK_EQ(0u, input_buffers_.size());
DCHECK_EQ(0u, output_buffers_.size());
@@ -168,6 +169,7 @@ VideoDecodeEngine::State OmxVideoDecodeEngine::state() const {
return kNormal;
break;
case kClientStopping:
+ case kClientStopped:
return kStopped;
break;
case kClientError:
@@ -521,10 +523,16 @@ void OmxVideoDecodeEngine::DoneSetStateExecuting(OMX_STATETYPE state) {
// and outside allocator.
void OmxVideoDecodeEngine::FillThisBuffer(
scoped_refptr<VideoFrame> video_frame) {
+
// TODO(wjia): merge buffer recycling for EGLImage and system memory path.
if (!video_frame.get() || VideoFrame::TYPE_EGL_IMAGE != video_frame->type())
return;
+ if (!CanAcceptOutput()) {
+ fill_this_buffer_callback_->Run(video_frame);
+ return;
+ }
+
OMX_BUFFERHEADERTYPE* omx_buffer = FindOmxBuffer(video_frame);
if (omx_buffer) {
if (kClientRunning == client_state_) {
@@ -734,7 +742,10 @@ void OmxVideoDecodeEngine::DeinitFromLoaded(OMX_STATETYPE state) {
component_handle_ = NULL;
}
il_state_ = expected_il_state_ = kIlNone;
- client_state_ = kClientNotInitialized;
+
+ // kClientStopped is different from kClientNotInitialized. The former can't
+ // accept output buffers, while the latter can.
+ client_state_ = kClientStopped;
OMX_Deinit();
@@ -851,6 +862,7 @@ void OmxVideoDecodeEngine::FreeOutputBuffers() {
}
}
output_frames_.clear();
+ output_frames_allocated_ = false;
} else {
for (size_t i = 0; i < output_buffers_.size(); ++i)
OMX_FreeBuffer(component_handle_, output_port_, output_buffers_[i]);
@@ -917,14 +929,17 @@ bool OmxVideoDecodeEngine::CanFillBuffer() {
bool OmxVideoDecodeEngine::CanAcceptInput() {
// We can't take input buffer when in error state.
- return (client_state_ != kClientError &&
- !input_queue_has_eos_ &&
- kClientStopping != client_state_);
+ return (kClientError != client_state_ &&
+ kClientStopping != client_state_ &&
+ kClientStopped != client_state_ &&
+ !input_queue_has_eos_);
}
bool OmxVideoDecodeEngine::CanAcceptOutput() {
- // TODO(hclam): Reject when in stopped state.
- return client_state_ != kClientError && output_port_state_ == kPortEnabled;
+ return (kClientError != client_state_ &&
+ kClientStopping != client_state_ &&
+ kClientStopped != client_state_ &&
+ output_port_state_ == kPortEnabled);
}
// TODO(wjia): There are several things need to be done here:
diff --git a/media/filters/omx_video_decode_engine.h b/media/filters/omx_video_decode_engine.h
index d1c5619..83480d0 100644
--- a/media/filters/omx_video_decode_engine.h
+++ b/media/filters/omx_video_decode_engine.h
@@ -75,6 +75,7 @@ class OmxVideoDecodeEngine :
kClientInitializing,
kClientRunning,
kClientStopping,
+ kClientStopped,
kClientPausing,
kClientFlushing,
kClientError,
diff --git a/media/tools/player_x11/player_x11.cc b/media/tools/player_x11/player_x11.cc
index fb795c5..49ecb55 100644
--- a/media/tools/player_x11/player_x11.cc
+++ b/media/tools/player_x11/player_x11.cc
@@ -11,6 +11,7 @@
#include "base/file_path.h"
#include "base/scoped_ptr.h"
#include "base/thread.h"
+#include "base/waitable_event.h"
#include "media/base/media.h"
#include "media/base/media_switches.h"
#include "media/base/pipeline_impl.h"
@@ -141,7 +142,9 @@ void PeriodicalUpdate(MessageLoop* message_loop, bool audio_only) {
}
} else if (e.type == ButtonPress) {
g_running = false;
- message_loop->Quit();
+ // QuitNow is more responsive than Quit since renderer_base is till
+ // posting paint messages.
+ message_loop->QuitNow();
return;
}
}
@@ -181,6 +184,7 @@ int main(int argc, char** argv) {
base::AtExitManager at_exit;
scoped_ptr<base::Thread> thread;
scoped_refptr<media::PipelineImpl> pipeline;
+ MessageLoop message_loop;
thread.reset(new base::Thread("PipelineThread"));
thread->Start();
if (InitPipeline(thread->message_loop(), filename.c_str(),
@@ -191,7 +195,6 @@ int main(int argc, char** argv) {
// Check if video is present.
audio_only = !pipeline->IsRendered(media::mime_type::kMajorTypeVideo);
- MessageLoop message_loop;
if (!audio_only) {
// Tell the renderer to paint.
DCHECK(Renderer::instance());
@@ -202,7 +205,10 @@ int main(int argc, char** argv) {
NewRunnableFunction(PeriodicalUpdate, &message_loop, audio_only));
message_loop.Run();
- pipeline->Stop(NULL);
+ // Need to wait for pipeline to be fully stopped before stopping the thread.
+ base::WaitableEvent event(false, false);
+ pipeline->Stop(NewCallback(&event, &base::WaitableEvent::Signal));
+ event.Wait();
} else{
std::cout << "Pipeline initialization failed..." << std::endl;
}