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

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

Issue 7467037: Made Destroy() followup more aggressive to test for races. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/common/gpu/gpu_messages.h ('k') | content/renderer/pepper_platform_video_decoder_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/gpu/media/omx_video_decode_accelerator_unittest.cc
diff --git a/content/common/gpu/media/omx_video_decode_accelerator_unittest.cc b/content/common/gpu/media/omx_video_decode_accelerator_unittest.cc
index 160e75cd7be02b7c46e6782b837608c99cda5bd6..c4ac3a2ff1cbf7c686c47a153a3163c6ead2c0c4 100644
--- a/content/common/gpu/media/omx_video_decode_accelerator_unittest.cc
+++ b/content/common/gpu/media/omx_video_decode_accelerator_unittest.cc
@@ -445,7 +445,7 @@ class EglRenderingVDAClient : public VideoDecodeAccelerator::Client {
EglRenderingVDAClient(RenderingHelper* rendering_helper,
int rendering_window_id,
ClientStateNotification* note,
- std::string* encoded_data,
+ const std::string& encoded_data,
int num_NALUs_per_decode,
int delete_decoder_state);
virtual ~EglRenderingVDAClient();
@@ -492,12 +492,13 @@ class EglRenderingVDAClient : public VideoDecodeAccelerator::Client {
RenderingHelper* rendering_helper_;
int rendering_window_id_;
- const std::string* encoded_data_;
+ std::string encoded_data_;
const int num_NALUs_per_decode_;
size_t encoded_data_next_pos_to_decode_;
int next_bitstream_buffer_id_;
ClientStateNotification* note_;
scoped_refptr<OmxVideoDecodeAccelerator> decoder_;
+ std::set<int> outstanding_texture_ids_;
int delete_decoder_state_;
ClientState state_;
int num_decoded_frames_;
@@ -510,7 +511,7 @@ class EglRenderingVDAClient : public VideoDecodeAccelerator::Client {
EglRenderingVDAClient::EglRenderingVDAClient(RenderingHelper* rendering_helper,
int rendering_window_id,
ClientStateNotification* note,
- std::string* encoded_data,
+ const std::string& encoded_data,
int num_NALUs_per_decode,
int delete_decoder_state)
: rendering_helper_(rendering_helper),
@@ -562,6 +563,8 @@ void EglRenderingVDAClient::ProvidePictureBuffers(
base::WaitableEvent done(false, false);
rendering_helper_->CreateTexture(rendering_window_id_, &texture_id, &done);
done.Wait();
+ bool inserted = outstanding_texture_ids_.insert(texture_id).second;
+ DCHECK(inserted);
vrk (LEFT CHROMIUM) 2011/07/26 17:33:20 nit: change DCHECK to CHECK here and elsewhere.
Ami GONE FROM CHROMIUM 2011/07/26 18:05:09 Done.
media::PictureBuffer* buffer =
new media::PictureBuffer(id, dimensions, texture_id);
CHECK(picture_buffers_by_id_.insert(std::make_pair(id, buffer)).second);
@@ -576,6 +579,8 @@ void EglRenderingVDAClient::DismissPictureBuffer(int32 picture_buffer_id) {
PictureBufferById::iterator it =
picture_buffers_by_id_.find(picture_buffer_id);
DCHECK(it != picture_buffers_by_id_.end());
+ int removed = outstanding_texture_ids_.erase(it->second->texture_id());
+ DCHECK_EQ(removed, 1);
rendering_helper_->DeleteTexture(it->second->texture_id());
delete it->second;
picture_buffers_by_id_.erase(it);
@@ -662,6 +667,12 @@ void EglRenderingVDAClient::DeleteDecoder() {
return;
decoder_->Destroy();
decoder_ = NULL;
+ STLClearObject(&encoded_data_);
+ for (std::set<int>::iterator it = outstanding_texture_ids_.begin();
+ it != outstanding_texture_ids_.end(); ++it) {
+ rendering_helper_->DeleteTexture(*it);
+ }
+ outstanding_texture_ids_.clear();
// Cascade through the rest of the states to simplify test code below.
for (int i = state_ + 1; i < CS_MAX; ++i)
SetState(static_cast<ClientState>(i));
@@ -670,15 +681,15 @@ void EglRenderingVDAClient::DeleteDecoder() {
void EglRenderingVDAClient::GetRangeForNextNALUs(
size_t start_pos, size_t* end_pos) {
*end_pos = start_pos;
- CHECK(LookingAtNAL(*encoded_data_, start_pos));
+ CHECK(LookingAtNAL(encoded_data_, start_pos));
for (int i = 0; i < num_NALUs_per_decode_; ++i) {
*end_pos += 4;
- while (*end_pos + 3 < encoded_data_->size() &&
- !LookingAtNAL(*encoded_data_, *end_pos)) {
+ while (*end_pos + 3 < encoded_data_.size() &&
+ !LookingAtNAL(encoded_data_, *end_pos)) {
++*end_pos;
}
- if (*end_pos + 3 >= encoded_data_->size()) {
- *end_pos = encoded_data_->size();
+ if (*end_pos + 3 >= encoded_data_.size()) {
+ *end_pos = encoded_data_.size();
return;
}
}
@@ -687,7 +698,7 @@ void EglRenderingVDAClient::GetRangeForNextNALUs(
void EglRenderingVDAClient::DecodeNextNALUs() {
if (decoder_deleted())
return;
- if (encoded_data_next_pos_to_decode_ == encoded_data_->size()) {
+ if (encoded_data_next_pos_to_decode_ == encoded_data_.size()) {
decoder_->Flush();
return;
}
@@ -700,7 +711,7 @@ void EglRenderingVDAClient::DecodeNextNALUs() {
base::SharedMemory shm;
CHECK(shm.CreateAndMapAnonymous(end_pos - start_pos))
<< start_pos << ", " << end_pos;
- memcpy(shm.memory(), encoded_data_->data() + start_pos, end_pos - start_pos);
+ memcpy(shm.memory(), encoded_data_.data() + start_pos, end_pos - start_pos);
base::SharedMemoryHandle dup_handle;
CHECK(shm.ShareToProcess(base::Process::Current().handle(), &dup_handle));
media::BitstreamBuffer bitstream_buffer(
@@ -797,7 +808,7 @@ TEST_P(OmxVideoDecodeAcceleratorTest, TestSimpleDecode) {
notes[index] = note;
EglRenderingVDAClient* client = new EglRenderingVDAClient(
&rendering_helper, index,
- note, &data_str, num_NALUs_per_decode,
+ note, data_str, num_NALUs_per_decode,
delete_decoder_state);
clients[index] = client;
« no previous file with comments | « content/common/gpu/gpu_messages.h ('k') | content/renderer/pepper_platform_video_decoder_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698