In constructors, initialize member fields in the initialization list
rather than constructor body where possible. This allows more fields
to be const, provided they are never modified.
Also initialize POD fields in constructor, unless it's obvious they
don't need to be initialized. In that case, put a comment instead.
Remove explicit clear() in destructors on fields that are now const.
Give AudioSessionRef a default constructor, so it's immutable fields can
be marked const.
Add comment about ~TrackBase() trick.
Initialize fields in declaration order to make it easier to confirm that
all fields are set.
Move initialization of mHardwareStatus from onFirstRef() to constructor.
Use NULL not 0 to initialize raw pointers in initialization list.
Rename field mClient to mAudioFlingerClient, and getter from client()
to audioFlingerClient().
Change-Id: Ib36cf6ed32f3cd19003f40a5d84046eb4c122052
EffectModule::addHandle and Client::heap() were declared incorrectly.
As a parameter, an sp<> should be & for efficiency, and for input
parameters it should also be const to protect the caller's value.
But as a return value, an sp<> should have neither const or &. The "e"
in "return e;" might be located on the stack, and if there is "&" then
the caller would see the address of a variable which no longer exists.
Also, an & would make it hard to do "return 0;".
A "const" without & is meaningless in the return type.
(In this particular case, the "e" is a member field, so it was safe.)
Change-Id: I3df5f294214eb15a9d4d596c6d5ef29de97b5c27
Don't check that pointer is non-NULL before delete.
Don't leave deleted member fields non-NULL, except in a destructor,
since it could be misleading in a dump or debugger. (mRsmpOutBuffer)
Change-Id: Ic0492a6b752f74a67f4c96dfb89ca2de4e69eecf
Also remove defaults in startToneCommand(), they're not needed and the
default for tone type was nonsense.
Change-Id: I70fa8cee4f3dbb8c66ceb3719c8d3d2f447f05b9
Was a mix of audio_source_t, uint8_t, and int.
Related fixes:
- fix comments in MediaRecorder.java
- AudioPolicyService server side was not checking source parameter at
all, so if the client wrapper was bypassed, invalid values could be
passed into audio HAL
- JNI android_media_AudioRecord_setup was checking source for positive
values, but not negative values. This test is redundant, since already
checked at Java and now checked by AudioPolicyService also, but might
as well make it correct.
Change-Id: Ie5e25d646dcd59a86d7985aa46cfcb4a1ba64a4a
Use type_t instead of int for thread types.
Initialize ThreadBase::mType in constructor and make it const.
Change-Id: I43d141388b9639e4783c30b97dbda5688bf7555f
When an AudioTrack is in underrun state, the AudioFlinger mixer will
sleep for a short period of time to give the app a chance to fill the
AudioTrack buffer. If the AudioTrack is still not ready during next mixing round,
the mixer will proceed with other tracks.
If an application keeps a steady underrun condition, the AudioFlinger mixer will
alternate between ready and not ready states. In the longer term this will cause the
audio HAL to underrun.
There is a mechanism to reduce the sleep period if the mixer is not ready several times in a
row but this mechanism is defeated by the alternating ready/not ready conditions.
The fix consists in only increasing sleep time if the mixer is ready for at least two
consecutive times.
Issue 5904527.
Change-Id: Id0139bca9be8c4e425ec6d428515c4d8f718e8c9
Was int or uint32_t.
When AudioFlinger::format can't determine the correct format,
return INVALID rather than DEFAULT.
Init mFormat to INVALID rather than DEFAULT in the constructor.
Subclass constructors will set mFormat to the correct value.
Change-Id: I9b62640aa107d24d2d27925f5563d0d7407d1b73
get() is almost always unnecessary, except in a LOG.
Also no need to check for != 0 before calling get().
Change-Id: Ib06e7a503f86cf102f09acc1ffb2ad085025516d