4 Commits

Author SHA1 Message Date
Andy Hung
4474c3f82c SoundPool: Implement generic garbage collection
Move audio tracks to a gc mechanism for release outside of lock.

Test: soundpool_stress
Test: atest SoundPoolAacTest
Test: atest SoundPoolHapticTest
Test: atest SoundPoolMidiTest
Test: atest SoundPoolOggTest
Bug: 203193643
Change-Id: I5babd4f3fa73cca25579fde2194123bf62cf53b4
2021-12-02 11:32:28 -08:00
Andy Hung
ce8e6daa9a SoundPool: Fix verbose logging compilation
Make compatible with clang warning / thread safety.

Test: build verbose and logcat
Bug: 157618660
Change-Id: I773f446561b86a0f3a8b5ddc355cfe6adf0d4294
2020-06-01 09:51:46 -07:00
Andy Hung
77eb2bda0e SoundPool: Add clang-tidy and fix
Test: soundpool_stress
Test: SoundPoolAacTest
Test: SoundPoolHapticTest
Test: SoundPoolMidiTest
Test: SoundPoolOggTest
Bug: 157501605
Change-Id: I7bba857a8b44b6255d423086127da0e2df4ce1c4
2020-05-27 10:47:41 -07:00
Andy Hung
e7937b9882 SoundPool: Refactor class
Make class names fit the Java API and documentation.

Rename Channel -> Stream.
Rename Sample -> Sound.
Rename SoundPoolThread -> SoundDecoder.

Move track start and stop to worker thread.

Fix up types to ensure future compatibility with Java ints
which are 32 bits always. Upgrade 16 bit types to
32 bits (e.g. sample id, sample rate, etc.)

Move sound related code into the SoundManager class.
Move stream related code into the StreamManager class.

Clean up locking, split SoundPool lock into the following locks
1) mApiLock
2) mStreamManagerLock
3) mSoundManagerLock
4) per Stream mLock.
5) mCallbackLock

Group locked data and make private in associated classes to ensure
restricted access, yet maximum concurrency.

Fix race conditions waiting for next event to play in stream.

Ensure track commands are handled consistently when stream is stolen.

Test: SoundPoolOggTest
Bug: 140807581
Change-Id: I8fcb374ee6329eb5474b973624584ca5080da862
2019-10-22 16:26:58 -07:00