295 Commits

Author SHA1 Message Date
Steve Block
1afd5bab4e Rename (IF_)LOGD(_IF) to (IF_)ALOGD(_IF)
Change-Id: I44f267700356967dc51e8f85ebf457dc85cfb229
2012-01-19 14:44:50 -08:00
Steve Block
06ade6ae1b Rename (IF_)LOGV(_IF) to (IF_)ALOGV(_IF)
Change-Id: I5321ebd12e9c6248a108529e82c4e1af2a4405e3
2012-01-19 14:44:31 -08:00
Eric Laurent
3562931af9 resolved conflicts for merge of 05683c85 to master
Change-Id: I7846b7da8c5813b7a9b1f3f71aede0229689ff0d
2012-01-19 10:00:02 -08:00
Glenn Kasten
6808516e8e Merge "Add units to time periods" 2012-01-19 06:09:05 -08:00
Glenn Kasten
f4a93d0965 Merge "Use const const strings for arrays and pointers to strings" 2012-01-19 06:08:53 -08:00
Glenn Kasten
22c4241a13 Add units to time periods
Change-Id: Ib980e2676cecf5d9b0c2e388da6dc8e370df8abb
2012-01-18 15:45:55 -08:00
Glenn Kasten
05d331090f Use const const strings for arrays and pointers to strings
Change-Id: I0a073e17ebf6ad59e7edbedac104c6fa4bcaf9c9
2012-01-18 15:44:48 -08:00
Glenn Kasten
b737dbb5c4 For booleans, use ! instead of == false
Change-Id: Ibc115936d2d0b0b7744ebe9b52839ea5b42c4edd
2012-01-18 15:42:59 -08:00
Glenn Kasten
ee7fea9f2f Remove dead setRingerMode(mode, mask)
Change-Id: Ia4cc8be8424a40b3dcb7ebd0264fdff4e5247f7f
2012-01-18 15:10:31 -08:00
Eric Laurent
71c4496a97 AudioFlinger: mix track only when really ready (2)
This problem due to the way audio buffers are mixed when
low power mode is active was addressed by commits 19ddf0eb
and 8a04fe03 but only partially. As a matter of fact, when more
than one audio track is playing, the problem is still present.
This is most noticeable when playing music with screen off
and a notification or navigation instruction is played: in this case,
the music or notification is likely to skip.

The fix consists in declaring the mixer ready if all active tracks
are ready. Previous behavior was to declare ready if at least one track was
ready. To avoid that one application failing to fill the track buffer blocks other
tracks indefinitely, this condition is respected only if the mixer was ready
in the previous round.

Issue 5799167.

Change-Id: Iabd4ca08d3d45f563d9824c8a03c2c68a43ae179
2012-01-18 12:27:38 -08:00
Glenn Kasten
540c35f7aa Merge "Track volume cleanup" 2012-01-18 07:46:18 -08:00
Eric Laurent
1be4afecb7 Merge "audio framework: manage stream volume per device" 2012-01-17 17:35:03 -08:00
Glenn Kasten
0632bad8ba Track volume cleanup
Always read and write track volumes atomically. In most places this was
already being done, but there were a couple places where the left and
right channels were read independently.

Changed constant MAX_GAIN_INT to be a uint32_t instead of a float.
It is always used as a uint32_t in comparisons and assignments.
Use MAX_GAIN_INT in more places.

Now that volume is always accessed atomically, removed the union
and alias for uint16_t volume[2], and kept only volumeLR.

Removed volatile as it's meaningless.

In AudioFlinger, clamp the track volumes read from shared memory
before applying master and stream volume.

Change-Id: If65e2b27e5bc3db5bf75540479843041b58433f0
2012-01-17 16:25:17 -08:00
Eric Laurent
9bc8358dda audio framework: manage stream volume per device
Improve volume management by keeping track of volume for each type
of device independently.
Volume for each stream (MUSIC, RINGTONE, VOICE_CALL...) is now maintained
per device.

The main changes are:
- AudioService now keeps tracks of stream volumes per device:
 volume indexes are kept in a HashMap < device , index>.
 active device is queried from policy manager when a volume change request
 is received
 initalization, mute and unmute happen on all device simultaneously
- Settings: suffixes is added to volume keys to store each device
volume independently.
- AudioSystem/AudioPolicyService/AudioPolicyInterface: added a device argument
to setStreamVolumeIndex() and getStreamVolumeIndex() to address each
device independently.
- AudioPolicyManagerBase: keep track of stream volumes for each device
and apply volume according to current device selection.

Change-Id: I61ef1c45caadca04d16363bca4140e0f81901b3f
2012-01-17 15:15:04 -08:00
Glenn Kasten
8df33080f9 Remove dead setVolume() and mVolume[2]
Change-Id: I94b835434093e920432614eb5007101e87758f32
2012-01-17 13:33:33 -08:00
Glenn Kasten
fb6b5bdcea Merge "Use audio_mode_t consistently" 2012-01-17 11:32:53 -08:00
Glenn Kasten
6e987a46f4 Check stream type in AudioFlinger::createTrack
A bad parameter to AudioFlinger::createTrack could cause mediaserver to crash.

Other AudioFlinger stream type cleanup:
 - Simplify range check for audio_stream_type_t
 - Add comment about mStreamTypes array initialization.

Change-Id: Ia33aa1cce0fdd694b08d9288816ffc097a9543d0
2012-01-17 07:45:07 -08:00
Glenn Kasten
c80f407829 Merge "Fix locking for mMasterVolume and mMute" 2012-01-17 07:28:14 -08:00
Glenn Kasten
8c17a2f088 Merge "Use size_t for frame size" 2012-01-17 07:27:46 -08:00
Glenn Kasten
3c6b9cca79 Merge "Use audio_stream_type_t consistently" 2012-01-17 07:25:36 -08:00
Glenn Kasten
e6f8a425da Fix locking for mMasterVolume and mMute
mMasterVolume and mMute are both protected by mutex in AudioFlinger class, but
there were two places where they were accessed without a mutex.

Also make AudioFlinger::mMasterMute private not protected.

Change-Id: Ia3897daeb5c50313df5bcc071824357526237f3e
2012-01-13 15:53:10 -08:00
Glenn Kasten
4790bd8be8 AudioTrack and AudioFlinger send level cleanup
Add an API to control block for getting/setting send level.
This allow us to make the mSendLevel field private.

Document the lack of barriers.

Use 0.0f to initialize floating-point values (for doc only).

Change-Id: I59f83b00adeb89eeee227e7648625d9a835be7a4
2012-01-13 15:25:14 -08:00
Glenn Kasten
faf354dc7f Use size_t for frame size
except in the control block, where we don't have room.

In AudioFlinger::ThreadBase::TrackBase::getBuffer,
read the frame size from control block only once.

Change-Id: Id6c4bccd4ed3e07d91df6bbea43bae45524f9f4e
2012-01-13 14:58:44 -08:00
Glenn Kasten
bc1d77b6cb Use audio_stream_type_t consistently
At native level it was a mixture of audio_stream_type_t, int, uint32_t,
and uint8_t.  Java is still int.  Also fixed a couple of hard-coded -1
instead of AUDIO_STREAM_DEFAULT, and in startToneCommand a hard-coded 0
instead of AUDIO_STREAM_VOICE_CALL.

Change-Id: Ia33bfd70edca8c2daec9052984b369cd8eee2a83
2012-01-13 10:20:14 -08:00
Glenn Kasten
accb114e59 Use audio_mode_t consistently
It was int or uint32_t.
Also make getMode() const.

Change-Id: Ibe45aadbf413b9158e4dd17f2b3bcc6355288d37
2012-01-12 09:52:37 -08:00
Glenn Kasten
1eac460122 Merge "Simplify range check for audio_mode_t" 2012-01-11 11:38:21 -08:00
Glenn Kasten
88ef0a73fc Merge "Use correct type for hardware call state" 2012-01-11 10:25:23 -08:00
Glenn Kasten
ca61ea8499 Merge "Use consistent style of & reference for AutoMutex" 2012-01-11 10:23:04 -08:00
Glenn Kasten
482b9c2d34 Merge "AudioFlinger new can't fail" 2012-01-11 10:22:19 -08:00
Glenn Kasten
bb8d6fb4fc Merge "Fix build warning" 2012-01-11 10:01:34 -08:00
Glenn Kasten
01aaf2c401 Simplify range check for audio_mode_t
AudioSystem::setMode previously allowed negative modes, but these were
then rejected by AudioFlinger.

Now negative modes (including AUDIO_MODE_INVALID and AUDIO_MODE_CURRENT)
are explicitly disallowed.

Change-Id: I0bac8fea737c8eb1f5b6afbb893e48739f88d745
2012-01-10 15:42:32 -08:00
Steve Block
ec193dec4d Rename LOG_ASSERT to ALOG_ASSERT DO NOT MERGE
See https://android-git.corp.google.com/g/157519

Bug: 5449033
Change-Id: I8ceb2dba1b031a0fd68d15d146960d9ced62bbf3
2012-01-09 21:36:22 +00:00
Glenn Kasten
4e7191448d Merge "By convention const goes before the type specifier" 2012-01-09 11:59:17 -08:00
Glenn Kasten
26f260a167 Use cached reference to media.player service
This save unnecessary binder calls

Change-Id: I93a60efc54d9c8fb8fab706cd4477bbfd00ffec8
2012-01-09 11:57:07 -08:00
Glenn Kasten
07d7d5a22d Merge "Replace loop by __builtin_ctz" 2012-01-09 10:25:00 -08:00
Glenn Kasten
f5c491651f Merge "suspended() and isSuspended() are const" 2012-01-09 10:24:09 -08:00
Steve Block
3762c31172 Rename (IF_)LOGE(_IF) to (IF_)ALOGE(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/#/c/157220

Bug: 5449033
Change-Id: Ic9c19d30693bd56755f55906127cd6bd7126096c
2012-01-08 13:19:13 +00:00
Glenn Kasten
c95ca2c26d AudioFlinger new can't fail
Change-Id: I7dae05a5ea1c962a9975386eab1fedbbe106ffba
2012-01-06 15:12:25 -08:00
Glenn Kasten
325ee1c69d Use consistent style of & reference for AutoMutex
AutoMutex, which is a typedef for Mutex::Autolock, is overloaded for
either a reference (&) or pointer (*) parameter, but we prefer to use
the reference form when the mutex is known at compile time.

Change-Id: I3515e6d6ab7959b2356a27fa3b04fd49e42cb31e
2012-01-06 13:33:41 -08:00
Glenn Kasten
a934c2cd2d Use correct type for hardware call state
Change-Id: Ic6d98b129e3ec653df1d8f7e829adf8dccb4f378
2012-01-06 13:29:47 -08:00
Glenn Kasten
99c2fd36dc By convention const goes before the type specifier
Change-Id: I70203abd6a6f54e5bd9f1412800cc01212157e58
2012-01-06 08:00:59 -08:00
Glenn Kasten
adda27acae Fix build warning
Change-Id: Ic99608d0c14ed56c02f036e0bbaaae1b16bab8ba
2012-01-06 07:49:34 -08:00
Steve Block
8564c8da81 Rename (IF_)LOGW(_IF) to (IF_)ALOGW(_IF) DO NOT MERGE
See https://android-git.corp.google.com/g/157065

Bug: 5449033
Change-Id: I00a4b904f9449e6f93b7fd35eac28640d7929e69
2012-01-06 10:07:54 +00:00
Glenn Kasten
c1d810d1d0 Replace loop by __builtin_ctz
Using the builtin is faster on some platforms, for example on ARM it's
19 instructions instead of 13, and is O(1) instead of O(n).  Of course,
track creation is an inherently slow operation, so this doesn't matter
much now.  But if we add support for virtual tracks, then physical tracks
will be allocated/freed more frequently.  Also just on principle ...

Change-Id: I3f590934092bd7a1869cbedbc7357928aa5cc8ff
2012-01-05 15:31:19 -08:00
Steve Block
bd47cac4df Merge "Rename (IF_)LOGI(_IF) to (IF_)ALOGI(_IF) DO NOT MERGE" 2012-01-05 14:07:02 -08:00
Glenn Kasten
1dce841996 suspended() and isSuspended() are const
Change-Id: I04b95970b5a645b64e7e64fffd46d868354dda66
2012-01-05 10:51:02 -08:00
Glenn Kasten
6b14d58580 Merge "Remove the notion of "active track" from mixer" 2012-01-05 08:20:10 -08:00
Glenn Kasten
a8719ad9d5 Merge "Use the standard CC_LIKELY and CC_UNLIKELY macros" 2012-01-05 07:38:29 -08:00
Glenn Kasten
e80a4ccd2b Use the standard CC_LIKELY and CC_UNLIKELY macros
Several source files privately defined macros LIKELY and UNLIKELY in terms
of __builtin_expect. But <cutils/compiler.h> already has CC_LIKELY and
CC_UNLIKELY which are intended for this purpose.  So rename the private
uses to use the standard names.

In addition, AudioFlinger was relying on the macro expanding to extra ( ).

Change-Id: I2494e087a0c0cac0ac998335f5e9c8ad02955873
2012-01-05 07:33:45 -08:00
Eric Laurent
dc8627e7dc resolved conflicts for merge of 1a4b9939 to master
Change-Id: I0c910d391a38a916d8431f7d1f5b82e39e1a66c2
2012-01-04 17:39:12 -08:00