diff options
-rw-r--r-- | services/audioflinger/Android.mk | 1 | ||||
-rw-r--r-- | services/audioflinger/AudioBufferProvider.cpp | 28 | ||||
-rw-r--r-- | services/audioflinger/AudioBufferProvider.h | 7 | ||||
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 16 | ||||
-rw-r--r-- | services/audioflinger/AudioFlinger.h | 28 | ||||
-rw-r--r-- | services/audioflinger/AudioMixer.cpp | 4 |
6 files changed, 31 insertions, 53 deletions
diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk index 22fa752..86692e7 100644 --- a/services/audioflinger/Android.mk +++ b/services/audioflinger/Android.mk @@ -7,7 +7,6 @@ LOCAL_SRC_FILES:= \ AudioMixer.cpp.arm \ AudioResampler.cpp.arm \ AudioPolicyService.cpp \ - AudioBufferProvider.cpp \ ServiceUtilities.cpp # AudioResamplerSinc.cpp.arm # AudioResamplerCubic.cpp.arm diff --git a/services/audioflinger/AudioBufferProvider.cpp b/services/audioflinger/AudioBufferProvider.cpp deleted file mode 100644 index 678fd58..0000000 --- a/services/audioflinger/AudioBufferProvider.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#undef __STRICT_ANSI__ -#define __STDINT_LIMITS -#define __STDC_LIMIT_MACROS -#include <stdint.h> - -#include "AudioBufferProvider.h" - -namespace android { - -const int64_t AudioBufferProvider::kInvalidPTS = INT64_MAX; - -}; // namespace android diff --git a/services/audioflinger/AudioBufferProvider.h b/services/audioflinger/AudioBufferProvider.h index 62ad6bd..43e4de7 100644 --- a/services/audioflinger/AudioBufferProvider.h +++ b/services/audioflinger/AudioBufferProvider.h @@ -17,8 +17,6 @@ #ifndef ANDROID_AUDIO_BUFFER_PROVIDER_H #define ANDROID_AUDIO_BUFFER_PROVIDER_H -#include <stdint.h> -#include <sys/types.h> #include <utils/Errors.h> namespace android { @@ -29,6 +27,7 @@ class AudioBufferProvider public: struct Buffer { + Buffer() : raw(NULL), frameCount(0) { } union { void* raw; short* i16; @@ -40,12 +39,12 @@ public: virtual ~AudioBufferProvider() {} // value representing an invalid presentation timestamp - static const int64_t kInvalidPTS; + static const int64_t kInvalidPTS = 0x7FFFFFFFFFFFFFFFLL; // <stdint.h> is too painful // pts is the local time when the next sample yielded by getNextBuffer // will be rendered. // Pass kInvalidPTS if the PTS is unknown or not applicable. - virtual status_t getNextBuffer(Buffer* buffer, int64_t pts) = 0; + virtual status_t getNextBuffer(Buffer* buffer, int64_t pts = kInvalidPTS) = 0; virtual void releaseBuffer(Buffer* buffer) = 0; }; diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 6256951..fd160ab 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -2891,8 +2891,7 @@ bool AudioFlinger::DirectOutputThread::threadLoop() // output audio to hardware while (frameCount) { buffer.frameCount = frameCount; - activeTrack->getNextBuffer(&buffer, - AudioBufferProvider::kInvalidPTS); + activeTrack->getNextBuffer(&buffer); if (CC_UNLIKELY(buffer.raw == NULL)) { memset(curBuf, 0, frameCount * mFrameSize); break; @@ -3398,11 +3397,14 @@ AudioFlinger::ThreadBase::TrackBase::~TrackBase() } } +// AudioBufferProvider interface +// getNextBuffer() = 0; +// This implementation of releaseBuffer() is used by Track and RecordTrack, but not TimedTrack void AudioFlinger::ThreadBase::TrackBase::releaseBuffer(AudioBufferProvider::Buffer* buffer) { buffer->raw = NULL; mFrameCount = buffer->frameCount; - step(); + (void) step(); // ignore return value of step() buffer->frameCount = 0; } @@ -3548,6 +3550,7 @@ void AudioFlinger::PlaybackThread::Track::dump(char* buffer, size_t size) (int)mAuxBuffer); } +// AudioBufferProvider interface status_t AudioFlinger::PlaybackThread::Track::getNextBuffer( AudioBufferProvider::Buffer* buffer, int64_t pts) { @@ -4096,6 +4099,7 @@ void AudioFlinger::PlaybackThread::TimedTrack::timedYieldSilence( mTimedAudioOutputOnTime = false; } +// AudioBufferProvider interface void AudioFlinger::PlaybackThread::TimedTrack::releaseBuffer( AudioBufferProvider::Buffer* buffer) { @@ -4181,6 +4185,7 @@ AudioFlinger::RecordThread::RecordTrack::~RecordTrack() } } +// AudioBufferProvider interface status_t AudioFlinger::RecordThread::RecordTrack::getNextBuffer(AudioBufferProvider::Buffer* buffer, int64_t pts) { audio_track_cblk_t* cblk = this->cblk(); @@ -4868,8 +4873,7 @@ bool AudioFlinger::RecordThread::threadLoop() } buffer.frameCount = mFrameCount; - if (CC_LIKELY(mActiveTrack->getNextBuffer( - &buffer, AudioBufferProvider::kInvalidPTS) == NO_ERROR)) { + if (CC_LIKELY(mActiveTrack->getNextBuffer(&buffer) == NO_ERROR)) { size_t framesOut = buffer.frameCount; if (mResampler == NULL) { // no resampling @@ -5147,6 +5151,7 @@ status_t AudioFlinger::RecordThread::dump(int fd, const Vector<String16>& args) return NO_ERROR; } +// AudioBufferProvider interface status_t AudioFlinger::RecordThread::getNextBuffer(AudioBufferProvider::Buffer* buffer, int64_t pts) { size_t framesReq = buffer->frameCount; @@ -5185,6 +5190,7 @@ status_t AudioFlinger::RecordThread::getNextBuffer(AudioBufferProvider::Buffer* return NO_ERROR; } +// AudioBufferProvider interface void AudioFlinger::RecordThread::releaseBuffer(AudioBufferProvider::Buffer* buffer) { mRsmpInIndex += buffer->frameCount; diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h index 1a52de5..559d2cc 100644 --- a/services/audioflinger/AudioFlinger.h +++ b/services/audioflinger/AudioFlinger.h @@ -346,9 +346,8 @@ private: TrackBase(const TrackBase&); TrackBase& operator = (const TrackBase&); - virtual status_t getNextBuffer( - AudioBufferProvider::Buffer* buffer, - int64_t pts) = 0; + // AudioBufferProvider interface + virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer, int64_t pts) = 0; virtual void releaseBuffer(AudioBufferProvider::Buffer* buffer); audio_format_t format() const { @@ -634,9 +633,10 @@ private: Track(const Track&); Track& operator = (const Track&); - virtual status_t getNextBuffer( - AudioBufferProvider::Buffer* buffer, - int64_t pts); + // AudioBufferProvider interface + virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer, int64_t pts = kInvalidPTS); + // releaseBuffer() not overridden + virtual uint32_t framesReady() const; bool isMuted() const { return mMute; } @@ -703,9 +703,10 @@ private: virtual uint32_t framesReady() const; - virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer, - int64_t pts); + // AudioBufferProvider interface + virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer, int64_t pts); virtual void releaseBuffer(AudioBufferProvider::Buffer* buffer); + void timedYieldSamples(AudioBufferProvider::Buffer* buffer); void timedYieldSilence(uint32_t numFrames, AudioBufferProvider::Buffer* buffer); @@ -1067,9 +1068,9 @@ private: RecordTrack(const RecordTrack&); RecordTrack& operator = (const RecordTrack&); - virtual status_t getNextBuffer( - AudioBufferProvider::Buffer* buffer, - int64_t pts); + // AudioBufferProvider interface + virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer, int64_t pts = kInvalidPTS); + // releaseBuffer() not overridden bool mOverflow; }; @@ -1106,9 +1107,10 @@ private: AudioStreamIn* clearInput(); virtual audio_stream_t* stream(); - virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer, - int64_t pts); + // AudioBufferProvider interface + virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer, int64_t pts); virtual void releaseBuffer(AudioBufferProvider::Buffer* buffer); + virtual bool checkForNewParameters_l(); virtual String8 getParameters(const String8& keys); virtual void audioConfigChanged_l(int event, int param = 0); diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp index 020d62a..2cec525 100644 --- a/services/audioflinger/AudioMixer.cpp +++ b/services/audioflinger/AudioMixer.cpp @@ -332,11 +332,11 @@ size_t AudioMixer::getUnreleasedFrames(int name) const return 0; } -void AudioMixer::setBufferProvider(int name, AudioBufferProvider* buffer) +void AudioMixer::setBufferProvider(int name, AudioBufferProvider* bufferProvider) { name -= TRACK0; assert(uint32_t(name) < MAX_NUM_TRACKS); - mState.tracks[name].bufferProvider = buffer; + mState.tracks[name].bufferProvider = bufferProvider; } |