From fb2ab9efc3805c81521afb9ff91a58ff5097a36e Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Mon, 12 Dec 2011 09:05:55 -0800 Subject: Fix indentation and whitespace Use git diff -w to verify. Change-Id: Ib65be0a1ecf65d6cad516110604e3855bf68a638 --- core/jni/android_media_AudioTrack.cpp | 2 +- media/java/android/media/AudioTrack.java | 50 ++++++++--------- media/libmedia/AudioTrack.cpp | 1 - services/audioflinger/AudioFlinger.cpp | 12 ++-- services/audioflinger/AudioMixer.cpp | 95 ++++++++++++++++---------------- 5 files changed, 79 insertions(+), 81 deletions(-) diff --git a/core/jni/android_media_AudioTrack.cpp b/core/jni/android_media_AudioTrack.cpp index 84e7432..2573aa6 100644 --- a/core/jni/android_media_AudioTrack.cpp +++ b/core/jni/android_media_AudioTrack.cpp @@ -106,7 +106,7 @@ class AudioTrackJniStorage { #define AUDIOTRACK_ERROR_BAD_VALUE -2 #define AUDIOTRACK_ERROR_INVALID_OPERATION -3 #define AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM -16 -#define AUDIOTRACK_ERROR_SETUP_INVALIDCHANNELMASK -17 +#define AUDIOTRACK_ERROR_SETUP_INVALIDCHANNELMASK -17 #define AUDIOTRACK_ERROR_SETUP_INVALIDFORMAT -18 #define AUDIOTRACK_ERROR_SETUP_INVALIDSTREAMTYPE -19 #define AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED -20 diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java index 4f9eb2b..c5d17eb 100644 --- a/media/java/android/media/AudioTrack.java +++ b/media/java/android/media/AudioTrack.java @@ -449,7 +449,7 @@ public class AudioTrack // AudioTrack subclasses too. try { stop(); - } catch(IllegalStateException ise) { + } catch(IllegalStateException ise) { // don't raise an exception, we're releasing the resources. } native_release(); @@ -488,7 +488,7 @@ public class AudioTrack public int getSampleRate() { return mSampleRate; } - + /** * Returns the current playback rate in Hz. */ @@ -590,22 +590,22 @@ public class AudioTrack static public int getNativeOutputSampleRate(int streamType) { return native_get_output_sample_rate(streamType); } - + /** * Returns the minimum buffer size required for the successful creation of an AudioTrack * object to be created in the {@link #MODE_STREAM} mode. Note that this size doesn't * guarantee a smooth playback under load, and higher values should be chosen according to - * the expected frequency at which the buffer will be refilled with additional data to play. + * the expected frequency at which the buffer will be refilled with additional data to play. * @param sampleRateInHz the sample rate expressed in Hertz. - * @param channelConfig describes the configuration of the audio channels. + * @param channelConfig describes the configuration of the audio channels. * See {@link AudioFormat#CHANNEL_OUT_MONO} and * {@link AudioFormat#CHANNEL_OUT_STEREO} - * @param audioFormat the format in which the audio data is represented. - * See {@link AudioFormat#ENCODING_PCM_16BIT} and + * @param audioFormat the format in which the audio data is represented. + * See {@link AudioFormat#ENCODING_PCM_16BIT} and * {@link AudioFormat#ENCODING_PCM_8BIT} * @return {@link #ERROR_BAD_VALUE} if an invalid parameter was passed, - * or {@link #ERROR} if the implementation was unable to query the hardware for its output - * properties, + * or {@link #ERROR} if the implementation was unable to query the hardware for its output + * properties, * or the minimum buffer size expressed in bytes. */ static public int getMinBufferSize(int sampleRateInHz, int channelConfig, int audioFormat) { @@ -623,18 +623,18 @@ public class AudioTrack loge("getMinBufferSize(): Invalid channel configuration."); return AudioTrack.ERROR_BAD_VALUE; } - - if ((audioFormat != AudioFormat.ENCODING_PCM_16BIT) + + if ((audioFormat != AudioFormat.ENCODING_PCM_16BIT) && (audioFormat != AudioFormat.ENCODING_PCM_8BIT)) { loge("getMinBufferSize(): Invalid audio format."); return AudioTrack.ERROR_BAD_VALUE; } - + if ( (sampleRateInHz < 4000) || (sampleRateInHz > 48000) ) { loge("getMinBufferSize(): " + sampleRateInHz +"Hz is not a supported sample rate."); return AudioTrack.ERROR_BAD_VALUE; } - + int size = native_get_min_buff_size(sampleRateInHz, channelCount, audioFormat); if ((size == -1) || (size == 0)) { loge("getMinBufferSize(): error querying hardware"); @@ -667,7 +667,7 @@ public class AudioTrack public void setPlaybackPositionUpdateListener(OnPlaybackPositionUpdateListener listener) { setPlaybackPositionUpdateListener(listener, null); } - + /** * Sets the listener the AudioTrack notifies when a previously set marker is reached or * for each periodic playback head position update. @@ -676,7 +676,7 @@ public class AudioTrack * @param listener * @param handler the Handler that will receive the event notification messages. */ - public void setPlaybackPositionUpdateListener(OnPlaybackPositionUpdateListener listener, + public void setPlaybackPositionUpdateListener(OnPlaybackPositionUpdateListener listener, Handler handler) { synchronized (mPositionListenerLock) { mPositionListener = listener; @@ -684,7 +684,7 @@ public class AudioTrack if (listener != null) { mEventHandlerDelegate = new NativeEventHandlerDelegate(this, handler); } - + } @@ -917,7 +917,7 @@ public class AudioTrack return ERROR_INVALID_OPERATION; } - if ( (audioData == null) || (offsetInBytes < 0 ) || (sizeInBytes < 0) + if ( (audioData == null) || (offsetInBytes < 0 ) || (sizeInBytes < 0) || (offsetInBytes + sizeInBytes > audioData.length)) { return ERROR_BAD_VALUE; } @@ -948,12 +948,12 @@ public class AudioTrack && (sizeInShorts > 0)) { mState = STATE_INITIALIZED; } - + if (mState != STATE_INITIALIZED) { return ERROR_INVALID_OPERATION; } - if ( (audioData == null) || (offsetInShorts < 0 ) || (sizeInShorts < 0) + if ( (audioData == null) || (offsetInShorts < 0 ) || (sizeInShorts < 0) || (offsetInShorts + sizeInShorts > audioData.length)) { return ERROR_BAD_VALUE; } @@ -1047,7 +1047,7 @@ public class AudioTrack * by the playback head. */ void onMarkerReached(AudioTrack track); - + /** * Called on the listener to periodically notify it that the playback head has reached * a multiple of the notification period. @@ -1066,7 +1066,7 @@ public class AudioTrack private class NativeEventHandlerDelegate { private final AudioTrack mAudioTrack; private final Handler mHandler; - + NativeEventHandlerDelegate(AudioTrack track, Handler handler) { mAudioTrack = track; // find the looper for our new event handler @@ -1077,7 +1077,7 @@ public class AudioTrack // no given handler, use the looper the AudioTrack was created in looper = mInitializationLooper; } - + // construct the event handler with this looper if (looper != null) { // implement the event handler delegate @@ -1111,9 +1111,9 @@ public class AudioTrack }; } else { mHandler = null; - } + } } - + Handler getHandler() { return mHandler; } @@ -1133,7 +1133,7 @@ public class AudioTrack } if (track.mEventHandlerDelegate != null) { - Message m = + Message m = track.mEventHandlerDelegate.getHandler().obtainMessage(what, arg1, arg2, obj); track.mEventHandlerDelegate.getHandler().sendMessage(m); } diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index 7e55fbd..2775348 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -1469,4 +1469,3 @@ bool audio_track_cblk_t::tryLock() // ------------------------------------------------------------------------- }; // namespace android - diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index b48f23d..e2aa04e 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -1967,7 +1967,7 @@ bool AudioFlinger::MixerThread::threadLoop() // during mixing and effect process as the audio buffers could be deleted // or modified if an effect is created or deleted lockEffectChains_l(effectChains); - } + } if (LIKELY(mixerStatus == MIXER_TRACKS_READY)) { // mix buffers... @@ -2012,11 +2012,11 @@ bool AudioFlinger::MixerThread::threadLoop() } // sleepTime == 0 means we must write to audio hardware if (sleepTime == 0) { - for (size_t i = 0; i < effectChains.size(); i ++) { - effectChains[i]->process_l(); - } - // enable changes in effect chain - unlockEffectChains(effectChains); + for (size_t i = 0; i < effectChains.size(); i ++) { + effectChains[i]->process_l(); + } + // enable changes in effect chain + unlockEffectChains(effectChains); mLastWriteTime = systemTime(); mInWrite = true; mBytesWritten += mixBufferSize; diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index 7c7fa56..8011832 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -78,19 +78,19 @@ AudioMixer::AudioMixer(size_t frameCount, uint32_t sampleRate) } } - AudioMixer::~AudioMixer() - { - track_t* t = mState.tracks; - for (int i=0 ; i<32 ; i++) { - delete t->resampler; - t++; - } - delete [] mState.outputTemp; - delete [] mState.resampleTemp; - } +AudioMixer::~AudioMixer() +{ + track_t* t = mState.tracks; + for (int i=0 ; i<32 ; i++) { + delete t->resampler; + t++; + } + delete [] mState.outputTemp; + delete [] mState.resampleTemp; +} - int AudioMixer::getTrackName() - { +int AudioMixer::getTrackName() +{ uint32_t names = mTrackNames; uint32_t mask = 1; int n = 0; @@ -104,18 +104,18 @@ AudioMixer::AudioMixer(size_t frameCount, uint32_t sampleRate) return TRACK0 + n; } return -1; - } +} - void AudioMixer::invalidateState(uint32_t mask) - { +void AudioMixer::invalidateState(uint32_t mask) +{ if (mask) { mState.needsChanged |= mask; mState.hook = process__validate; } } - void AudioMixer::deleteTrackName(int name) - { +void AudioMixer::deleteTrackName(int name) +{ name -= TRACK0; if (uint32_t(name) < MAX_NUM_TRACKS) { ALOGV("deleteTrackName(%d)", name); @@ -135,7 +135,7 @@ AudioMixer::AudioMixer(size_t frameCount, uint32_t sampleRate) track.volumeInc[1] = 0; mTrackNames &= ~(1<enabledTracks, all16BitsStereoNoResample, resampling, volumeRamp); - state->hook(state); - - // Now that the volume ramp has been done, set optimal state and - // track hooks for subsequent mixer process - if (countActiveTracks) { - int allMuted = 1; - uint32_t en = state->enabledTracks; - while (en) { - const int i = 31 - __builtin_clz(en); - en &= ~(1<tracks[i]; - if (!t.doesResample() && t.volumeRL == 0) - { - t.needs |= NEEDS_MUTE_ENABLED; - t.hook = track__nop; - } else { - allMuted = 0; - } - } - if (allMuted) { - state->hook = process__nop; - } else if (all16BitsStereoNoResample) { - if (countActiveTracks == 1) { - state->hook = process__OneTrack16BitsStereoNoResampling; - } - } - } + state->hook(state); + + // Now that the volume ramp has been done, set optimal state and + // track hooks for subsequent mixer process + if (countActiveTracks) { + int allMuted = 1; + uint32_t en = state->enabledTracks; + while (en) { + const int i = 31 - __builtin_clz(en); + en &= ~(1<tracks[i]; + if (!t.doesResample() && t.volumeRL == 0) + { + t.needs |= NEEDS_MUTE_ENABLED; + t.hook = track__nop; + } else { + allMuted = 0; + } + } + if (allMuted) { + state->hook = process__nop; + } else if (all16BitsStereoNoResample) { + if (countActiveTracks == 1) { + state->hook = process__OneTrack16BitsStereoNoResampling; + } + } + } } static inline @@ -993,7 +993,7 @@ void AudioMixer::process__genericNoResampling(state_t* state) } - // generic code with resampling +// generic code with resampling void AudioMixer::process__genericResampling(state_t* state) { int32_t* const outTemp = state->outputTemp; @@ -1173,7 +1173,7 @@ void AudioMixer::process__TwoTracks16BitsStereoNoResampling(state_t* state) } in1 = buff; b1.frameCount = numFrames; - } else { + } else { in1 = b1.i16; } frameCount1 = b1.frameCount; @@ -1215,4 +1215,3 @@ void AudioMixer::process__TwoTracks16BitsStereoNoResampling(state_t* state) // ---------------------------------------------------------------------------- }; // namespace android - -- cgit v1.1