Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <inttypes.h> | 5 #include <inttypes.h> |
| 6 #include <stddef.h> | 6 #include <stddef.h> |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 2056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2067 enum ClientState state_transitions[] = {CS_INITIALIZED, CS_ENCODING, | 2067 enum ClientState state_transitions[] = {CS_INITIALIZED, CS_ENCODING, |
| 2068 CS_FINISHED, CS_VALIDATED}; | 2068 CS_FINISHED, CS_VALIDATED}; |
| 2069 | 2069 |
| 2070 // Wait for all encoders to go through all states and finish. | 2070 // Wait for all encoders to go through all states and finish. |
| 2071 // Do this by waiting for all encoders to advance to state n before checking | 2071 // Do this by waiting for all encoders to advance to state n before checking |
| 2072 // state n+1, to verify that they are able to operate concurrently. | 2072 // state n+1, to verify that they are able to operate concurrently. |
| 2073 // It also simulates the real-world usage better, as the main thread, on which | 2073 // It also simulates the real-world usage better, as the main thread, on which |
| 2074 // encoders are created/destroyed, is a single GPU Process ChildThread. | 2074 // encoders are created/destroyed, is a single GPU Process ChildThread. |
| 2075 // Moreover, we can't have proper multithreading on X11, so this could cause | 2075 // Moreover, we can't have proper multithreading on X11, so this could cause |
| 2076 // hard to debug issues there, if there were multiple "ChildThreads". | 2076 // hard to debug issues there, if there were multiple "ChildThreads". |
| 2077 bool wrong_state = false; | |
| 2077 for (const auto& state : state_transitions) { | 2078 for (const auto& state : state_transitions) { |
| 2078 for (size_t i = 0; i < num_concurrent_encoders; i++) | 2079 for (size_t i = 0; i < num_concurrent_encoders && !wrong_state; i++) { |
| 2079 ASSERT_EQ(state, notes[i]->Wait()); | 2080 ClientState wait_state = notes[i]->Wait(); |
| 2081 EXPECT_EQ(state, wait_state); | |
| 2082 wrong_state = (state != wait_state); | |
| 2083 } | |
| 2084 if (wrong_state) { | |
|
wuchengli
2016/12/13 09:18:32
Can we use if (HasFailure())?
Same for line 2079.
| |
| 2085 break; | |
| 2086 } | |
| 2080 } | 2087 } |
| 2081 | 2088 |
| 2082 for (size_t i = 0; i < num_concurrent_encoders; ++i) { | 2089 for (size_t i = 0; i < num_concurrent_encoders; ++i) { |
| 2083 encoder_thread.task_runner()->PostTask( | 2090 encoder_thread.task_runner()->PostTask( |
| 2084 FROM_HERE, | 2091 FROM_HERE, |
| 2085 base::Bind(&VEAClient::DestroyEncoder, base::Unretained(clients[i]))); | 2092 base::Bind(&VEAClient::DestroyEncoder, base::Unretained(clients[i]))); |
| 2086 } | 2093 } |
| 2087 | 2094 |
| 2088 // This ensures all tasks have finished. | 2095 // This ensures all tasks have finished. |
| 2089 encoder_thread.Stop(); | 2096 encoder_thread.Stop(); |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2323 | 2330 |
| 2324 media::g_env = | 2331 media::g_env = |
| 2325 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( | 2332 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( |
| 2326 testing::AddGlobalTestEnvironment( | 2333 testing::AddGlobalTestEnvironment( |
| 2327 new media::VideoEncodeAcceleratorTestEnvironment( | 2334 new media::VideoEncodeAcceleratorTestEnvironment( |
| 2328 std::move(test_stream_data), log_path, run_at_fps, | 2335 std::move(test_stream_data), log_path, run_at_fps, |
| 2329 needs_encode_latency, verify_all_output))); | 2336 needs_encode_latency, verify_all_output))); |
| 2330 | 2337 |
| 2331 return RUN_ALL_TESTS(); | 2338 return RUN_ALL_TESTS(); |
| 2332 } | 2339 } |
| OLD | NEW |