| 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 2057 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 for (const auto& state : state_transitions) { | 2077 for (const auto& state : state_transitions) { |
| 2078 for (size_t i = 0; i < num_concurrent_encoders; i++) | 2078 for (size_t i = 0; i < num_concurrent_encoders && !HasFailure(); i++) { |
| 2079 ASSERT_EQ(state, notes[i]->Wait()); | 2079 EXPECT_EQ(state, notes[i]->Wait()); |
| 2080 } |
| 2081 if (HasFailure()) { |
| 2082 break; |
| 2083 } |
| 2080 } | 2084 } |
| 2081 | 2085 |
| 2082 for (size_t i = 0; i < num_concurrent_encoders; ++i) { | 2086 for (size_t i = 0; i < num_concurrent_encoders; ++i) { |
| 2083 encoder_thread.task_runner()->PostTask( | 2087 encoder_thread.task_runner()->PostTask( |
| 2084 FROM_HERE, | 2088 FROM_HERE, |
| 2085 base::Bind(&VEAClient::DestroyEncoder, base::Unretained(clients[i]))); | 2089 base::Bind(&VEAClient::DestroyEncoder, base::Unretained(clients[i]))); |
| 2086 } | 2090 } |
| 2087 | 2091 |
| 2088 // This ensures all tasks have finished. | 2092 // This ensures all tasks have finished. |
| 2089 encoder_thread.Stop(); | 2093 encoder_thread.Stop(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2106 | 2110 |
| 2107 encoder_thread.task_runner()->PostTask( | 2111 encoder_thread.task_runner()->PostTask( |
| 2108 FROM_HERE, | 2112 FROM_HERE, |
| 2109 base::Bind(&TestClient::CreateEncoder, base::Unretained(client.get()))); | 2113 base::Bind(&TestClient::CreateEncoder, base::Unretained(client.get()))); |
| 2110 | 2114 |
| 2111 // Encoder must pass through states in this order. | 2115 // Encoder must pass through states in this order. |
| 2112 enum ClientState state_transitions[] = {CS_INITIALIZED, CS_ENCODING, | 2116 enum ClientState state_transitions[] = {CS_INITIALIZED, CS_ENCODING, |
| 2113 CS_FINISHED}; | 2117 CS_FINISHED}; |
| 2114 | 2118 |
| 2115 for (const auto& state : state_transitions) { | 2119 for (const auto& state : state_transitions) { |
| 2116 ClientState wait_state = note->Wait(); | 2120 EXPECT_EQ(state, note->Wait()); |
| 2117 EXPECT_EQ(state, wait_state); | 2121 if (testing::Test::HasFailure()) { |
| 2118 if (state != wait_state) { | |
| 2119 break; | 2122 break; |
| 2120 } | 2123 } |
| 2121 } | 2124 } |
| 2122 | 2125 |
| 2123 encoder_thread.task_runner()->PostTask( | 2126 encoder_thread.task_runner()->PostTask( |
| 2124 FROM_HERE, | 2127 FROM_HERE, |
| 2125 base::Bind(&TestClient::DestroyEncoder, base::Unretained(client.get()))); | 2128 base::Bind(&TestClient::DestroyEncoder, base::Unretained(client.get()))); |
| 2126 | 2129 |
| 2127 // This ensures all tasks have finished. | 2130 // This ensures all tasks have finished. |
| 2128 encoder_thread.Stop(); | 2131 encoder_thread.Stop(); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2327 | 2330 |
| 2328 media::g_env = | 2331 media::g_env = |
| 2329 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( | 2332 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( |
| 2330 testing::AddGlobalTestEnvironment( | 2333 testing::AddGlobalTestEnvironment( |
| 2331 new media::VideoEncodeAcceleratorTestEnvironment( | 2334 new media::VideoEncodeAcceleratorTestEnvironment( |
| 2332 std::move(test_stream_data), log_path, run_at_fps, | 2335 std::move(test_stream_data), log_path, run_at_fps, |
| 2333 needs_encode_latency, verify_all_output))); | 2336 needs_encode_latency, verify_all_output))); |
| 2334 | 2337 |
| 2335 return RUN_ALL_TESTS(); | 2338 return RUN_ALL_TESTS(); |
| 2336 } | 2339 } |
| OLD | NEW |