Refactor and unit test CastAudioOutputStream
CAOS was refactored to simplify the logic for the service connector, multithreading, and unit tests. The CAOS::Backend object was renamed to CAOS::CmaWrapper, and much of the implementation was moved out into CAOS to simplify the object. The service connector is created in CastAudioManager and passed to CAOS's audio thread. Instead of passing this then to the media thread as done previously, we only utilize the connector in the audio thread. The connector can be easily overriden for tests. CAOS runs on two threads. It is constructed and controlled from CastAudioManager in the audio thread. All CMA construction and control happens in the media thread in the CAOS::CmaWrapper object. The thread usage in the unit tests has been significantly simplified. Instead of using RunLoops and multiple threads, we use a single thread retrieved from a ScopedTaskEnvironment in CAM, CAOS:audio, and CAOS:media. This means that everything in the unit tests are running on a single thread, and the tests are far less flaky. In order to allow everything to run on a single thread, the usages of WaitableEvent were removed. WaitableEvent was previously used to allow the synchronous behavior of the audio thread to work with the asynchronous thread hopping. To compensate for this, certain task postings between threads can be cached or cancelled, and errors are returned late. The following unit tests were added to verify the above behavior and fill in untested implementation: - CastAudioManagerTest .HasValidOutputStreamParameters .CanMakeStream .CanMakeMixerStream - CastAudioOutputStreamTest .CloseWithoutStart .CloseWithoutStop .CloseCancelsOpen .CloseCancelsStart .CloseCancelsStop .StartImmediatelyAfterOpen .SetVolumeImmediatelyAfterOpen .StopCancelsStart .StopDoesNotCancelSetVolume .PushFrameAfterStop .PushFrameAfterClose .MultiroomInfo .SessionId Bug: b/111993375 Test: cast_media_unittests, udon build Change-Id: Ib7dce8df8a36a2311e13d6a0062b7e56d4928995 Reviewed-on: https://chromium-review.googlesource.com/1159824 Commit-Queue: Aidan Wolter <awolter@chromium.org> Reviewed-by:Luke Halliwell <halliwell@chromium.org> Reviewed-by:
Kenneth MacKay <kmackay@chromium.org> Cr-Commit-Position: refs/heads/master@{#586096}
Showing
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Please register or sign in to comment