diff options
| author | 2012-01-09 10:25:00 -0800 | |
|---|---|---|
| committer | 2012-01-09 10:25:00 -0800 | |
| commit | 07d7d5a22dbb0a8df5631c8014f4706dd1e449da (patch) | |
| tree | 8a1b53e723c25c1fbe6c0cdba002f03ed68193de | |
| parent | 8cf6d6f1480e760e6953bdea9fe9ab29f1e03aa8 (diff) | |
| parent | c1d810d1d0c38ba14d3f7d21d381bcbda649a0fb (diff) | |
Merge "Replace loop by __builtin_ctz"
| -rw-r--r-- | services/audioflinger/AudioMixer.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index 36cdeb859b00..bc5cb9b7aba7 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -95,16 +95,11 @@ AudioMixer::~AudioMixer() int AudioMixer::getTrackName() { - uint32_t names = mTrackNames; - uint32_t mask = 1; - int n = 0; - while (names & mask) { - mask <<= 1; - n++; - } - if (mask) { + uint32_t names = ~mTrackNames; + if (names != 0) { + int n = __builtin_ctz(names); ALOGV("add track (%d)", n); - mTrackNames |= mask; + mTrackNames |= 1 << n; return TRACK0 + n; } return -1; |