summaryrefslogtreecommitdiffstats
path: root/ppapi/examples
diff options
context:
space:
mode:
authorfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 19:36:51 +0000
committerfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-26 19:36:51 +0000
commit3a65d92d7c52770a197ba7abe8ea4600e1201a36 (patch)
treeea8f61a93404c16a681287c36f4c96d7aecc2bbc /ppapi/examples
parent5efb5e31a219214f9c468f15ee24e92ceb8b7086 (diff)
downloadchromium_src-3a65d92d7c52770a197ba7abe8ea4600e1201a36.zip
chromium_src-3a65d92d7c52770a197ba7abe8ea4600e1201a36.tar.gz
chromium_src-3a65d92d7c52770a197ba7abe8ea4600e1201a36.tar.bz2
Made Destroy() followup more aggressive to test for races.
In particular we now free output textures and input bitstream buffers as soon as Destroy() returns, in an attempt to trip up race conditions between OVDA::Destroy() returning and the openmax libs/drivers/hardware attempting to use no-longer-valid memory. Also made DestroyVideoDecoder a SYNChronous IPC message again to match VideoDecodeAccelerator::Destroy()'s contract. Also explicitly set to NULL pointers that are made invalid or no-longer useful by Destroy(), in the pepper glue code, to make crashes more obvious if they happen. [No crashes have been observed in gles2 or ovdatest; this CL is just to increase (currently manual) test coverage] BUG=none TEST=gles2 mid-decode reload works, ovdatest passes Review URL: http://codereview.chromium.org/7467037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94148 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/examples')
-rw-r--r--ppapi/examples/gles2/gles2.cc23
1 files changed, 22 insertions, 1 deletions
diff --git a/ppapi/examples/gles2/gles2.cc b/ppapi/examples/gles2/gles2.cc
index 24a9727..e46f02d 100644
--- a/ppapi/examples/gles2/gles2.cc
+++ b/ppapi/examples/gles2/gles2.cc
@@ -86,6 +86,7 @@ class GLES2DemoInstance : public pp::Instance,
void DecodeNextNALU();
void GetNextNALUBoundary(size_t start_pos, size_t* end_pos);
void Render(const PP_PictureBuffer_Dev& buffer);
+ void DeleteOutstandingBitstreamBuffers();
// GL-related functions.
void InitGL();
@@ -93,6 +94,7 @@ class GLES2DemoInstance : public pp::Instance,
void CreateGLObjects();
void CreateShader(GLuint program, GLenum type, const char* source, int size);
void DeleteTexture(GLuint id);
+ void DeleteOutstandingTextures();
void PaintFinished(int32_t result, int picture_buffer_id);
// Log an error to the developer console and stderr (though the latter may be
@@ -173,10 +175,28 @@ GLES2DemoInstance::GLES2DemoInstance(PP_Instance instance, pp::Module* module)
GLES2DemoInstance::~GLES2DemoInstance() {
delete video_decoder_; // May be NULL, which is fine.
+ DeleteOutstandingBitstreamBuffers();
+ DeleteOutstandingTextures();
delete surface_;
delete context_;
}
+void GLES2DemoInstance::DeleteOutstandingTextures() {
+ for (PictureBufferMap::iterator it = buffers_by_id_.begin();
+ it != buffers_by_id_.end(); ++it) {
+ DeleteTexture(it->second.texture_id);
+ }
+ buffers_by_id_.clear();
+}
+
+void GLES2DemoInstance::DeleteOutstandingBitstreamBuffers() {
+ for (BitstreamBufferMap::iterator it = bitstream_buffers_by_id_.begin();
+ it != bitstream_buffers_by_id_.end(); ++it) {
+ delete it->second;
+ }
+ bitstream_buffers_by_id_.clear();
+}
+
void GLES2DemoInstance::DidChangeView(
const pp::Rect& position, const pp::Rect& clip_ignored) {
if (position.width() == 0 || position.height() == 0)
@@ -213,6 +233,7 @@ void GLES2DemoInstance::DecoderBitstreamDone(
bitstream_buffers_by_id_.find(bitstream_buffer_id);
assert(it != bitstream_buffers_by_id_.end());
delete it->second;
+ bitstream_buffers_by_id_.erase(it);
DecodeNextNALUs();
}
@@ -263,7 +284,7 @@ void GLES2DemoInstance::DecodeNextNALU() {
size_t start_pos = encoded_data_next_pos_to_decode_;
size_t end_pos;
GetNextNALUBoundary(start_pos, &end_pos);
- pp::Buffer_Dev* buffer = new pp::Buffer_Dev (this, end_pos - start_pos);
+ pp::Buffer_Dev* buffer = new pp::Buffer_Dev(this, end_pos - start_pos);
PP_VideoBitstreamBuffer_Dev bitstream_buffer;
int id = ++next_bitstream_buffer_id_;
bitstream_buffer.id = id;