diff options
author | Glenn Kasten <gkasten@google.com> | 2012-01-17 12:20:54 -0800 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2012-01-17 16:25:17 -0800 |
commit | b1cf75c4935001f61057989ee3cf27bbf09ecd9c (patch) | |
tree | e3daaea6160475e36dedfccaabf5d8b94406d05e /include/private | |
parent | f237a30e9344d43f832ba11db6f62c6ad2084444 (diff) | |
download | frameworks_av-b1cf75c4935001f61057989ee3cf27bbf09ecd9c.zip frameworks_av-b1cf75c4935001f61057989ee3cf27bbf09ecd9c.tar.gz frameworks_av-b1cf75c4935001f61057989ee3cf27bbf09ecd9c.tar.bz2 |
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
Diffstat (limited to 'include/private')
-rw-r--r-- | include/private/media/AudioTrackShared.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h index 33a92cd..ffc546e 100644 --- a/include/private/media/AudioTrackShared.h +++ b/include/private/media/AudioTrackShared.h @@ -71,10 +71,13 @@ struct audio_track_cblk_t uint32_t loopStart; uint32_t loopEnd; int loopCount; - volatile union { - uint16_t volume[2]; - uint32_t volumeLR; - }; + + // Channel volumes are fixed point U4.12, so 0x1000 means 1.0. + // Left channel is in [0:15], right channel is in [16:31]. + // Always read and write the combined pair atomically. + // For AudioTrack only, not used by AudioRecord. + uint32_t volumeLR; + uint32_t sampleRate; // NOTE: audio_track_cblk_t::frameSize is not equal to AudioTrack::frameSize() for // 8 bit PCM data: in this case, mCblk->frameSize is based on a sample size of |