OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // The bulk of this file is support code; sorry about that. Here's an overview | 5 // The bulk of this file is support code; sorry about that. Here's an overview |
6 // to hopefully help readers of this code: | 6 // to hopefully help readers of this code: |
7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or | 7 // - RenderingHelper is charged with interacting with X11/{EGL/GLES2,GLX/GL} or |
8 // Win/EGL. | 8 // Win/EGL. |
9 // - ClientState is an enum for the state of the decode client used by the test. | 9 // - ClientState is an enum for the state of the decode client used by the test. |
10 // - ClientStateNotification is a barrier abstraction that allows the test code | 10 // - ClientStateNotification is a barrier abstraction that allows the test code |
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 next_fragment_size, profile_); | 1078 next_fragment_size, profile_); |
1079 if (reset_here) | 1079 if (reset_here) |
1080 reset_after_frame_num_ = END_OF_STREAM_RESET; | 1080 reset_after_frame_num_ = END_OF_STREAM_RESET; |
1081 } | 1081 } |
1082 | 1082 |
1083 // Populate the shared memory buffer w/ the fragment, duplicate its handle, | 1083 // Populate the shared memory buffer w/ the fragment, duplicate its handle, |
1084 // and hand it off to the decoder. | 1084 // and hand it off to the decoder. |
1085 base::SharedMemory shm; | 1085 base::SharedMemory shm; |
1086 LOG_ASSERT(shm.CreateAndMapAnonymous(next_fragment_size)); | 1086 LOG_ASSERT(shm.CreateAndMapAnonymous(next_fragment_size)); |
1087 memcpy(shm.memory(), next_fragment_bytes.data(), next_fragment_size); | 1087 memcpy(shm.memory(), next_fragment_bytes.data(), next_fragment_size); |
1088 base::SharedMemoryHandle dup_handle; | 1088 base::SharedMemoryHandle dup_handle = shm.handle().Duplicate(); |
1089 bool result = | 1089 LOG_ASSERT(dup_handle.IsValid()); |
1090 shm.ShareToProcess(base::GetCurrentProcessHandle(), &dup_handle); | 1090 |
1091 LOG_ASSERT(result); | 1091 // TODO(erikchen): This may leak the SharedMemoryHandle. |
| 1092 // https://crbug.com/640840. |
1092 BitstreamBuffer bitstream_buffer(next_bitstream_buffer_id_, dup_handle, | 1093 BitstreamBuffer bitstream_buffer(next_bitstream_buffer_id_, dup_handle, |
1093 next_fragment_size); | 1094 next_fragment_size); |
1094 decode_start_time_[next_bitstream_buffer_id_] = base::TimeTicks::Now(); | 1095 decode_start_time_[next_bitstream_buffer_id_] = base::TimeTicks::Now(); |
1095 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer. | 1096 // Mask against 30 bits, to avoid (undefined) wraparound on signed integer. |
1096 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF; | 1097 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF; |
1097 decoder_->Decode(bitstream_buffer); | 1098 decoder_->Decode(bitstream_buffer); |
1098 ++outstanding_decodes_; | 1099 ++outstanding_decodes_; |
1099 if (!remaining_play_throughs_ && | 1100 if (!remaining_play_throughs_ && |
1100 -delete_decoder_state_ == next_bitstream_buffer_id_) { | 1101 -delete_decoder_state_ == next_bitstream_buffer_id_) { |
1101 DeleteDecoder(); | 1102 DeleteDecoder(); |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1915 media::g_thumbnail_output_dir = base::FilePath(it->second.c_str()); | 1916 media::g_thumbnail_output_dir = base::FilePath(it->second.c_str()); |
1916 } | 1917 } |
1917 } | 1918 } |
1918 | 1919 |
1919 base::ShadowingAtExitManager at_exit_manager; | 1920 base::ShadowingAtExitManager at_exit_manager; |
1920 | 1921 |
1921 return base::LaunchUnitTestsSerially( | 1922 return base::LaunchUnitTestsSerially( |
1922 argc, argv, | 1923 argc, argv, |
1923 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); | 1924 base::Bind(&media::VDATestSuite::Run, base::Unretained(&test_suite))); |
1924 } | 1925 } |
OLD | NEW |