frameworks/av: Add ifdefs for QCOM_HARDWARE features
Change-Id: Iebe0da91f0b761bba8eb8c0e181c47bbd0d0703d
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index cef551c..092f512 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -154,8 +154,12 @@
mBtNrecIsOff(false),
mIsLowRamDevice(true),
mIsDeviceTypeKnown(false),
+#ifdef QCOM_HARDWARE
mGlobalEffectEnableTime(0),
mAllChainsLocked(false)
+#else
+ mGlobalEffectEnableTime(0)
+#endif
{
getpid_cached = getpid();
char value[PROPERTY_VALUE_MAX];
@@ -570,6 +574,7 @@
return trackHandle;
}
+#ifdef QCOM_HARDWARE
sp<IDirectTrack> AudioFlinger::createDirectTrack(
pid_t pid,
uint32_t sampleRate,
@@ -676,16 +681,19 @@
mLPAEffectChain = NULL;
}
}
+#endif
uint32_t AudioFlinger::sampleRate(audio_io_handle_t output) const
{
Mutex::Autolock _l(mLock);
+#ifdef QCOM_HARDWARE
if (!mDirectAudioTracks.isEmpty()) {
AudioSessionDescriptor *desc = mDirectAudioTracks.valueFor(output);
if(desc != NULL) {
return desc->stream->common.get_sample_rate(&desc->stream->common);
}
}
+#endif
PlaybackThread *thread = checkPlaybackThread_l(output);
if (thread == NULL) {
ALOGW("sampleRate() unknown thread %d", output);
@@ -697,10 +705,12 @@
int AudioFlinger::channelCount(audio_io_handle_t output) const
{
Mutex::Autolock _l(mLock);
+#ifdef QCOM_HARDWARE
AudioSessionDescriptor *desc = mDirectAudioTracks.valueFor(output);
if(desc != NULL) {
return desc->stream->common.get_channels(&desc->stream->common);
}
+#endif
PlaybackThread *thread = checkPlaybackThread_l(output);
if (thread == NULL) {
ALOGW("channelCount() unknown thread %d", output);
@@ -723,10 +733,12 @@
size_t AudioFlinger::frameCount(audio_io_handle_t output) const
{
Mutex::Autolock _l(mLock);
+#ifdef QCOM_HARDWARE
AudioSessionDescriptor *desc = mDirectAudioTracks.valueFor(output);
if(desc != NULL) {
return desc->stream->common.get_buffer_size(&desc->stream->common);
}
+#endif
PlaybackThread *thread = checkPlaybackThread_l(output);
if (thread == NULL) {
ALOGW("frameCount() unknown thread %d", output);
@@ -740,12 +752,14 @@
uint32_t AudioFlinger::latency(audio_io_handle_t output) const
{
Mutex::Autolock _l(mLock);
+#ifdef QCOM_HARDWARE
if (!mDirectAudioTracks.isEmpty()) {
AudioSessionDescriptor *desc = mDirectAudioTracks.valueFor(output);
if (desc != NULL) {
return desc->stream->get_latency(desc->stream);
}
}
+#endif
PlaybackThread *thread = checkPlaybackThread_l(output);
if (thread == NULL) {
@@ -937,6 +951,7 @@
}
AutoMutex lock(mLock);
+#ifdef QCOM_HARDWARE
ALOGV("setStreamVolume stream %d, output %d, value %f",stream, output, value);
AudioSessionDescriptor *desc = NULL;
if (!mDirectAudioTracks.isEmpty()) {
@@ -953,13 +968,16 @@
}
}
}
+#endif
PlaybackThread *thread = NULL;
if (output) {
thread = checkPlaybackThread_l(output);
if (thread == NULL) {
+#ifdef QCOM_HARDWARE
if (desc != NULL) {
return NO_ERROR;
}
+#endif
return BAD_VALUE;
}
}
@@ -1094,6 +1112,7 @@
return final_result;
}
+#ifdef QCOM_HARDWARE
AudioSessionDescriptor *desc = NULL;
if (!mDirectAudioTracks.isEmpty()) {
desc = mDirectAudioTracks.valueFor(ioHandle);
@@ -1116,6 +1135,7 @@
}
}
}
+#endif
// hold a strong ref on thread in case closeOutput() or closeInput() is called
// and the thread is exited once the lock is released
@@ -1284,6 +1304,7 @@
}
}
+#ifdef QCOM_HARDWARE
status_t AudioFlinger::deregisterClient(const sp<IAudioFlingerClient>& client)
{
ALOGV("deregisterClient() %p, tid %d, calling tid %d", client.get(), gettid(), IPCThreadState::self()->getCallingPid());
@@ -1298,6 +1319,7 @@
return false;
}
+#endif
void AudioFlinger::removeNotificationClient(pid_t pid)
{
@@ -1329,16 +1351,19 @@
// audioConfigChanged_l() must be called with AudioFlinger::mLock held
void AudioFlinger::audioConfigChanged_l(int event, audio_io_handle_t ioHandle, const void *param2)
{
+#ifdef QCOM_HARDWARE
ALOGV("AudioFlinger::audioConfigChanged_l: event %d", event);
if (event == AudioSystem::EFFECT_CONFIG_CHANGED) {
mIsEffectConfigChanged = true;
}
if (!mNotificationClients.isEmpty()){
+#endif
size_t size = mNotificationClients.size();
for (size_t i = 0; i < size; i++) {
mNotificationClients.valueAt(i)->audioFlingerClient()->ioConfigChanged(event, ioHandle,
param2);
}
+#ifdef QCOM_HARDWARE
}
if ((!mDirectAudioTracks.isEmpty())&& (event == AudioSystem::EFFECT_CONFIG_CHANGED)){
size_t dsize = mDirectAudioTracks.size();
@@ -1352,6 +1377,7 @@
}
}
}
+#endif
}
// removeClient_l() must be called with AudioFlinger::mLock held
@@ -1472,8 +1498,10 @@
RecordThread *thread;
size_t inFrameCount;
int lSessionId;
+#ifdef QCOM_HARDWARE
size_t inputBufferSize = 0;
uint32_t channelCount = popcount(channelMask);
+#endif
// check calling permissions
if (!recordingAllowed()) {
@@ -1482,6 +1510,7 @@
goto Exit;
}
+#ifdef QCOM_HARDWARE
// Check that audio input stream accepts requested audio parameters
inputBufferSize = getInputBufferSize(sampleRate, format, channelCount);
if (inputBufferSize == 0) {
@@ -1489,6 +1518,13 @@
ALOGE("Bad audio input parameters: sampling rate %u, format %d, channels %d", sampleRate, format, channelCount);
goto Exit;
}
+#else
+ if (format != AUDIO_FORMAT_PCM_16_BIT) {
+ ALOGE("openRecord() invalid format %d", format);
+ lStatus = BAD_VALUE;
+ goto Exit;
+ }
+#endif
// add client to list
{ // scope for mLock
@@ -1520,6 +1556,7 @@
}
}
+#ifdef QCOM_HARDWARE
// frameCount must be a multiple of input buffer size
// Change for Codec type
uint8_t channelCount = popcount(channelMask);
@@ -1542,6 +1579,7 @@
}
}
frameCount = ((frameCount - 1)/inFrameCount + 1) * inFrameCount;
+#endif
// create new record track.
// The record track uses one track in mHardwareMixerThread by convention.
@@ -1779,6 +1817,7 @@
if (flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
thread = new OffloadThread(this, output, id, *pDevices);
ALOGV("openOutput() created offload output: ID %d thread %p", id, thread);
+#ifdef QCOM_HARDWARE
}
if (flags & AUDIO_OUTPUT_FLAG_LPA || flags & AUDIO_OUTPUT_FLAG_TUNNEL ) {
AudioSessionDescriptor *desc = new AudioSessionDescriptor(hwDevHal, outStream, flags);
@@ -1791,6 +1830,7 @@
desc->trackRefPtr = NULL;
mDirectAudioTracks.add(id, desc);
mDirectDevice = desc->device;
+#endif
} else if ((flags & AUDIO_OUTPUT_FLAG_DIRECT) ||
(config.format != AUDIO_FORMAT_PCM_16_BIT) ||
(config.channel_mask != AUDIO_CHANNEL_OUT_STEREO)) {
@@ -1818,6 +1858,7 @@
// notify client processes of the new output creation
thread->audioConfigChanged_l(AudioSystem::OUTPUT_OPENED);
}
+#ifdef QCOM_HARDWARE
else {
*pLatencyMs = 0;
if ((flags & AUDIO_OUTPUT_FLAG_LPA) || (flags & AUDIO_OUTPUT_FLAG_TUNNEL)) {
@@ -1825,6 +1866,7 @@
*pLatencyMs = desc->stream->get_latency(desc->stream);
}
}
+#endif
// the first primary output opened designates the primary hw device
@@ -1877,6 +1919,7 @@
{
// keep strong reference on the playback thread so that
// it is not destroyed while exit() is executed
+#ifdef QCOM_HARDWARE
AudioSessionDescriptor *desc = mDirectAudioTracks.valueFor(output);
if (desc) {
ALOGV("Closing DirectTrack output %d", output);
@@ -1890,6 +1933,7 @@
delete desc;
return NO_ERROR;
}
+#endif
sp<PlaybackThread> thread;
{
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 6392bed..9844659 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -29,8 +29,10 @@
#include <media/IAudioFlinger.h>
#include <media/IAudioFlingerClient.h>
+#ifdef QCOM_HARDWARE
#include <media/IDirectTrack.h>
#include <media/IDirectTrackClient.h>
+#endif
#include <media/IAudioTrack.h>
#include <media/IAudioRecord.h>
#include <media/AudioSystem.h>
@@ -91,7 +93,11 @@
static uint32_t getInputChannelCount(uint32_t channels) {
// only mono, stereo, and 5.1 are supported for input sources
+#ifdef QCOM_HARDWARE
return popcount((channels)&(AUDIO_CHANNEL_IN_STEREO|AUDIO_CHANNEL_IN_MONO|AUDIO_CHANNEL_IN_5POINT1));
+#else
+ return popcount(channels);
+#endif
}
class AudioFlinger :
public BinderService<AudioFlinger>,
@@ -117,6 +123,7 @@
int *sessionId,
String8& name,
status_t *status);
+#ifdef QCOM_HARDWARE
virtual sp<IDirectTrack> createDirectTrack(
pid_t pid,
uint32_t sampleRate,
@@ -127,6 +134,7 @@
audio_stream_type_t streamType,
status_t *status);
virtual void deleteEffectSession();
+#endif
virtual sp<IAudioRecord> openRecord(
audio_io_handle_t input,
uint32_t sampleRate,
@@ -167,7 +175,9 @@
virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const;
virtual void registerClient(const sp<IAudioFlingerClient>& client);
- virtual status_t deregisterClient(const sp<IAudioFlingerClient>& client);
+#ifdef QCOM_HARDWARE
+ virtual status_t deregisterClient(const sp<IAudioFlingerClient>& client);
+#endif
virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
audio_channel_mask_t channelMask) const;
@@ -245,11 +255,13 @@
Parcel* reply,
uint32_t flags);
+#ifdef QCOM_HARDWARE
bool applyEffectsOn(void *token,
int16_t *buffer1,
int16_t *buffer2,
int size,
bool force);
+#endif
// end of IAudioFlinger interface
@@ -396,7 +408,9 @@
class EffectModule;
class EffectHandle;
class EffectChain;
+#ifdef QCOM_HARDWARE
struct AudioSessionDescriptor;
+#endif
struct AudioStreamOut;
struct AudioStreamIn;
@@ -486,6 +500,7 @@
sp<PlaybackThread> getEffectThread_l(int sessionId, int EffectId);
+#ifdef QCOM_HARDWARE
// server side of the client's IAudioTrack
class DirectAudioTrack : public android::BnDirectTrack,
public AudioEventObserver
@@ -596,6 +611,7 @@
sp<IBinder> mWakeLockToken;
sp<PMDeathRecipient> mDeathRecipient;
};
+#endif
void removeClient_l(pid_t pid);
void removeNotificationClient(pid_t pid);
@@ -657,6 +673,7 @@
AudioStreamIn(AudioHwDevice *dev, audio_stream_in_t *in) :
audioHwDev(dev), stream(in) {}
};
+#ifdef QCOM_HARDWARE
struct AudioSessionDescriptor {
bool mActive;
int mStreamType;
@@ -671,6 +688,7 @@
AudioSessionDescriptor(audio_hw_device_t *dev, audio_stream_out_t *out, audio_output_flags_t outflag) :
hwDev(dev), stream(out), flag(outflag) {}
};
+#endif
// for mAudioSessionRefs only
struct AudioSessionRef {
@@ -735,16 +753,20 @@
volatile int32_t mNextUniqueId; // updated by android_atomic_inc
audio_mode_t mMode;
bool mBtNrecIsOff;
+#ifdef QCOM_HARDWARE
DefaultKeyedVector<audio_io_handle_t, AudioSessionDescriptor *> mDirectAudioTracks;
// protected by mLock
volatile bool mIsEffectConfigChanged;
+#endif
Vector<AudioSessionRef*> mAudioSessionRefs;
+#ifdef QCOM_HARDWARE
sp<EffectChain> mLPAEffectChain;
int mLPASessionId;
audio_devices_t mDirectDevice;//device for directTrack,used for effects
int mLPASampleRate;
int mLPANumChannels;
volatile bool mAllChainsLocked;
+#endif
float masterVolume_l() const;
bool masterMute_l() const;
audio_module_handle_t loadHwModule_l(const char *name);
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index f45476c..95f7381 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -561,7 +561,11 @@
(value == 48000 && devSampleRate == 44100))) {
quality = AudioResampler::LOW_QUALITY;
} else {
+#ifdef QCOM_HARDWARE
quality = AudioResampler::VERY_HIGH_QUALITY;
+#else
+ quality = AudioResampler::DEFAULT_QUALITY;
+#endif
}
resampler = AudioResampler::create(
format,
diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp
index f916dfc..a8f0511 100644
--- a/services/audioflinger/Effects.cpp
+++ b/services/audioflinger/Effects.cpp
@@ -72,7 +72,11 @@
mStatus(NO_INIT), mState(IDLE),
// mMaxDisableWaitCnt is set by configure() and not used before then
// mDisableWaitCnt is set by process() and updateState() and not used before then
+#ifdef QCOM_HARDWARE
mSuspended(false), mIsForLPA(false)
+#else
+ mSuspended(false)
+#endif
{
ALOGV("Constructor %p", this);
int lStatus;
@@ -307,14 +311,20 @@
(*mEffectInterface)->command(mEffectInterface, EFFECT_CMD_RESET, 0, NULL, 0, NULL);
}
+#ifdef QCOM_HARDWARE
status_t AudioFlinger::EffectModule::configure(bool isForLPA, int sampleRate, int channelCount, int frameCount)
+#else
+status_t AudioFlinger::EffectModule::configure()
+#endif
{
status_t status;
status_t cmdStatus = 0;
sp<ThreadBase> thread;
uint32_t size;
audio_channel_mask_t channelMask;
+#ifdef QCOM_HARDWARE
uint32_t channels;
+#endif
if (mEffectInterface == NULL) {
status = NO_INIT;
@@ -329,6 +339,7 @@
// TODO: handle configuration of effects replacing track process
channelMask = thread->channelMask();
+#ifdef QCOM_HARDWARE
if(popcount(channelMask) > 2) {
ALOGE("Error: Trying to apply effect on %d channel content",popcount(channelMask));
return INVALID_OPERATION;
@@ -347,6 +358,7 @@
channels = AUDIO_CHANNEL_OUT_STEREO;
}
}
+#endif
if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) {
mConfig.inputCfg.channels = AUDIO_CHANNEL_OUT_MONO;
@@ -356,11 +368,15 @@
mConfig.outputCfg.channels = channelMask;
mConfig.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
mConfig.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
+#ifdef QCOM_HARDWARE
if(isForLPA){
mConfig.inputCfg.samplingRate = sampleRate;
} else {
+#endif
mConfig.inputCfg.samplingRate = thread->sampleRate();
+#ifdef QCOM_HARDWARE
}
+#endif
mConfig.outputCfg.samplingRate = mConfig.inputCfg.samplingRate;
mConfig.inputCfg.bufferProvider.cookie = NULL;
mConfig.inputCfg.bufferProvider.getBuffer = NULL;
@@ -385,11 +401,15 @@
}
mConfig.inputCfg.mask = EFFECT_CONFIG_ALL;
mConfig.outputCfg.mask = EFFECT_CONFIG_ALL;
+#ifdef QCOM_HARDWARE
if(isForLPA) {
mConfig.inputCfg.buffer.frameCount = frameCount;
} else {
+#endif
mConfig.inputCfg.buffer.frameCount = thread->frameCount();
+#ifdef QCOM_HARDWARE
}
+#endif
mConfig.outputCfg.buffer.frameCount = mConfig.inputCfg.buffer.frameCount;
ALOGV("configure() %p thread %p buffer %p framecount %d",
@@ -586,11 +606,15 @@
// must be called with EffectModule::mLock held
status_t AudioFlinger::EffectModule::setEnabled_l(bool enabled)
{
+#ifdef QCOM_HARDWARE
bool effectStateChanged = false;
+#endif
ALOGV("setEnabled %p enabled %d", this, enabled);
if (enabled != isEnabled()) {
+#ifdef QCOM_HARDWARE
effectStateChanged = true;
+#endif
status_t status = AudioSystem::setEffectEnabled(mId, enabled);
if (enabled && status != NO_ERROR) {
return status;
@@ -628,6 +652,7 @@
}
}
}
+#ifdef QCOM_HARDWARE
/*
Send notification event to LPA Player when an effect for
LPA output is enabled or disabled.
@@ -639,6 +664,7 @@
thread->effectConfigChanged();
lock();
}
+#endif
return NO_ERROR;
}
@@ -1182,6 +1208,7 @@
return disable();
}
+#ifdef QCOM_HARDWARE
if(mEffect->isOnLPA() &&
((cmdCode == EFFECT_CMD_SET_PARAM) || (cmdCode == EFFECT_CMD_SET_PARAM_DEFERRED) ||
(cmdCode == EFFECT_CMD_SET_PARAM_COMMIT) || (cmdCode == EFFECT_CMD_SET_DEVICE) ||
@@ -1191,6 +1218,7 @@
ALOGV("Notifying Direct Track for the change in effect config %d", cmdCode);
mClient->audioFlinger()->audioConfigChanged_l(AudioSystem::EFFECT_CONFIG_CHANGED, 0, NULL);
}
+#endif
return mEffect->command(cmdCode, cmdSize, pCmdData, replySize, pReplyData);
}
@@ -1258,7 +1286,11 @@
int sessionId)
: mThread(thread), mSessionId(sessionId), mActiveTrackCnt(0), mTrackCnt(0), mTailBufferCount(0),
mOwnInBuffer(false), mVolumeCtrlIdx(-1), mLeftVolume(UINT_MAX), mRightVolume(UINT_MAX),
+#ifdef QCOM_HARDWARE
mNewLeftVolume(UINT_MAX), mNewRightVolume(UINT_MAX), mIsForLPATrack(false)
+#else
+ mNewLeftVolume(UINT_MAX), mNewRightVolume(UINT_MAX)
+#endif
{
mStrategy = AudioSystem::getStrategyForStream(AUDIO_STREAM_MUSIC);
if (thread == NULL) {
@@ -1304,6 +1336,7 @@
return 0;
}
+#ifdef QCOM_HARDWARE
sp<AudioFlinger::EffectModule> AudioFlinger::EffectChain::getEffectFromIndex_l(int idx)
{
sp<EffectModule> effect = NULL;
@@ -1315,6 +1348,7 @@
}
return effect;
}
+#endif
// getEffectFromType_l() must be called with ThreadBase::mLock held
sp<AudioFlinger::EffectModule> AudioFlinger::EffectChain::getEffectFromType_l(
@@ -1381,7 +1415,11 @@
}
size_t size = mEffects.size();
+#ifdef QCOM_HARDWARE
if (doProcess || isForLPATrack()) {
+#else
+ if (doProcess) {
+#endif
for (size_t i = 0; i < size; i++) {
mEffects[i]->process();
}
@@ -1859,6 +1897,7 @@
return false;
}
+#ifdef QCOM_HARDWARE
#define DEAFULT_FRAME_COUNT 1200
bool AudioFlinger::applyEffectsOn(void *token, int16_t *inBuffer,
int16_t *outBuffer, int size, bool force)
@@ -2033,5 +2072,6 @@
ALOGV("Creating Effects Thread");
pthread_create(&mEffectsThread, &attr, EffectsThreadWrapper, this);
}
+#endif
}; // namespace android
diff --git a/services/audioflinger/Effects.h b/services/audioflinger/Effects.h
index 10c2227..5ad312b 100644
--- a/services/audioflinger/Effects.h
+++ b/services/audioflinger/Effects.h
@@ -69,10 +69,14 @@
void *pReplyData);
void reset_l();
+#ifdef QCOM_HARDWARE
status_t configure(bool isForLPA = false,
int sampleRate = 0,
int channelCount = 0,
int frameCount = 0);
+#else
+ status_t configure();
+#endif
status_t init();
effect_state state() const {
return mState;
@@ -123,8 +127,10 @@
{ return (mDescriptor.flags & EFFECT_FLAG_OFFLOAD_SUPPORTED) != 0; }
status_t setOffloaded(bool offloaded, audio_io_handle_t io);
bool isOffloaded() const;
+#ifdef QCOM_HARDWARE
bool isOnLPA() { return mIsForLPA;}
void setLPAFlag(bool isForLPA) {mIsForLPA = isForLPA; }
+#endif
void dump(int fd, const Vector<String16>& args);
@@ -159,7 +165,9 @@
uint32_t mDisableWaitCnt; // current process() calls count during disable period.
bool mSuspended; // effect is suspended: temporarily disabled by framework
bool mOffloaded; // effect is currently offloaded to the audio DSP
+#ifdef QCOM_HARDWARE
bool mIsForLPA;
+#endif
};
// The EffectHandle class implements the IEffect interface. It provides resources
@@ -269,14 +277,18 @@
status_t addEffect_l(const sp<EffectModule>& handle);
size_t removeEffect_l(const sp<EffectModule>& handle);
+#ifdef QCOM_HARDWARE
size_t getNumEffects() { return mEffects.size(); }
+#endif
int sessionId() const { return mSessionId; }
void setSessionId(int sessionId) { mSessionId = sessionId; }
sp<EffectModule> getEffectFromDesc_l(effect_descriptor_t *descriptor);
sp<EffectModule> getEffectFromId_l(int id);
+#ifdef QCOM_HARDWARE
sp<EffectModule> getEffectFromIndex_l(int idx);
+#endif
sp<EffectModule> getEffectFromType_l(const effect_uuid_t *type);
bool setVolume_l(uint32_t *left, uint32_t *right);
void setDevice_l(audio_devices_t device);
@@ -326,8 +338,10 @@
void dump(int fd, const Vector<String16>& args);
+#ifdef QCOM_HARDWARE
bool isForLPATrack() {return mIsForLPATrack; }
void setLPAFlag(bool flag) {mIsForLPATrack = flag;}
+#endif
protected:
friend class AudioFlinger; // for mThread, mEffects
@@ -376,7 +390,9 @@
uint32_t mNewLeftVolume; // new volume on left channel
uint32_t mNewRightVolume; // new volume on right channel
uint32_t mStrategy; // strategy for this effect chain
+#ifdef QCOM_HARDWARE
bool mIsForLPATrack;
+#endif
// mSuspendedEffects lists all effects currently suspended in the chain.
// Use effect type UUID timelow field as key. There is no real risk of identical
// timeLow fields among effect type UUIDs.
diff --git a/services/audioflinger/RecordTracks.h b/services/audioflinger/RecordTracks.h
index cb54348..4b0c4d8 100644
--- a/services/audioflinger/RecordTracks.h
+++ b/services/audioflinger/RecordTracks.h
@@ -28,7 +28,9 @@
audio_format_t format,
audio_channel_mask_t channelMask,
size_t frameCount,
+#ifdef QCOM_HARDWARE
uint32_t flags,
+#endif
int sessionId);
virtual ~RecordTrack();
@@ -58,7 +60,9 @@
int64_t pts = kInvalidPTS);
// releaseBuffer() not overridden
+#ifdef QCOM_HARDWARE
track_flags_t mFlags;
+#endif
bool mOverflow; // overflow on most recent attempt to fill client buffer
AudioRecordServerProxy* mAudioRecordServerProxy;
};
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 568329f..aa9097b 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -85,9 +85,11 @@
#define ALOGVV(a...) do { } while(0)
#endif
+#ifdef QCOM_HARDWARE
#define DIRECT_TRACK_EOS 1
#define DIRECT_TRACK_HW_FAIL 6
static const char lockName[] = "DirectTrack";
+#endif
namespace android {
// retry counts for buffer fill timeout
@@ -349,10 +351,12 @@
return status;
}
+#ifdef QCOM_HARDWARE
void AudioFlinger::ThreadBase::effectConfigChanged() {
ALOGV("New effect is being added to LPA chain, Notifying LPA Direct Track");
mAudioFlinger->audioConfigChanged_l(AudioSystem::EFFECT_CONFIG_CHANGED, 0, NULL);
}
+#endif
void AudioFlinger::ThreadBase::sendIoConfigEvent(int event, int param)
{
@@ -782,6 +786,7 @@
addEffectChain_l(chain);
chain->setStrategy(getStrategyForSession_l(sessionId));
chainCreated = true;
+#ifdef QCOM_HARDWARE
if(sessionId == mAudioFlinger->mLPASessionId) {
// Clear reference to previous effect chain if any
if(mAudioFlinger->mLPAEffectChain.get()) {
@@ -795,6 +800,7 @@
uint32_t volume = 0x1000000; // Equals to 1.0 in 8.24 format
chain->setVolume_l(&volume,&volume);
}
+#endif
} else {
effect = chain->getEffectFromDesc_l(desc);
}
@@ -823,7 +829,11 @@
}
effectCreated = true;
+#ifdef QCOM_HARDWARE
effect->setDevice(mAudioFlinger->mLPASessionId == sessionId ? mAudioFlinger->mDirectDevice:mOutDevice);
+#else
+ effect->setDevice(mOutDevice);
+#endif
effect->setDevice(mInDevice);
effect->setMode(mAudioFlinger->getMode());
effect->setAudioSource(mAudioSource);
@@ -938,13 +948,20 @@
Vector< sp<AudioFlinger::EffectChain> >& effectChains)
{
effectChains = mEffectChains;
+#ifdef QCOM_HARDWARE
mAudioFlinger->mAllChainsLocked = true;
+#endif
for (size_t i = 0; i < mEffectChains.size(); i++) {
+#ifdef QCOM_HARDWARE
if (mEffectChains[i] != mAudioFlinger->mLPAEffectChain) {
+#else
mEffectChains[i]->lock();
+#endif
+#ifdef QCOM_HARDWARE
} else {
mAudioFlinger-> mAllChainsLocked = false;
}
+#endif
}
}
@@ -952,7 +969,9 @@
const Vector< sp<AudioFlinger::EffectChain> >& effectChains)
{
for (size_t i = 0; i < effectChains.size(); i++) {
+#ifdef QCOM_HARDWARE
if (mAudioFlinger->mAllChainsLocked || effectChains[i] != mAudioFlinger->mLPAEffectChain)
+#endif
effectChains[i]->unlock();
}
}
@@ -1268,6 +1287,7 @@
}
if (mType == DIRECT) {
+#ifdef QCOM_HARDWARE
if (((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM)
||((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_AMR_NB)
||((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_AMR_WB)
@@ -1275,6 +1295,9 @@
||((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_EVRCB)
||((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_EVRCWB)
||((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_EVRCNW)) {
+#else
+ if ((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM) {
+#endif
if (sampleRate != mSampleRate || format != mFormat || channelMask != mChannelMask) {
ALOGE("createTrack_l() Bad parameter: sampleRate %u format %d, channelMask 0x%08x "
"for output %p with format %d",
@@ -2317,9 +2340,13 @@
// only process effects if we're going to write
if (sleepTime == 0 && mType != OFFLOAD) {
for (size_t i = 0; i < effectChains.size(); i ++) {
+#ifdef QCOM_HARDWARE
if (effectChains[i] != mAudioFlinger->mLPAEffectChain) {
+#endif
effectChains[i]->process_l();
+#ifdef QCOM_HARDWARE
}
+#endif
}
}
}
@@ -4530,6 +4557,7 @@
}
if (framesOut && (mFrameCount == mRsmpInIndex)) {
void *readInto;
+#ifdef QCOM_HARDWARE
int InputBytes;
/*Fix me: How does framesOut become 0 in this condition */
if (( framesOut != mFrameCount) &&
@@ -4549,8 +4577,21 @@
mRsmpInIndex = 0;
InputBytes = mBufferSize;
}
+#else
+ if (framesOut == mFrameCount && mChannelCount == mReqChannelCount) {
+ readInto = buffer.raw;
+ framesOut = 0;
+ } else {
+ readInto = mRsmpInBuffer;
+ mRsmpInIndex = 0;
+ }
+#endif
mBytesRead = mInput->stream->read(mInput->stream, readInto,
+#ifdef QCOM_HARDWARE
InputBytes);
+#else
+ mBufferSize);
+#endif
if (mBytesRead <= 0) {
if ((mBytesRead < 0) && (mActiveTrack->mState == TrackBase::ACTIVE))
{
@@ -4750,7 +4791,11 @@
Mutex::Autolock _l(mLock);
track = new RecordTrack(this, client, sampleRate,
+#ifdef QCOM_HARDWARE
format, channelMask, frameCount, *flags, sessionId);
+#else
+ format, channelMask, frameCount, sessionId);
+#endif
if (track->getCblk() == 0) {
ALOGE("createRecordTrack_l() no control block");
@@ -5226,6 +5271,11 @@
mChannelMask = mInput->stream->common.get_channels(&mInput->stream->common);
mChannelCount = (uint16_t)getInputChannelCount(mChannelMask);
mFormat = mInput->stream->common.get_format(&mInput->stream->common);
+#ifndef QCOM_HARDWARE
+ if (mFormat != AUDIO_FORMAT_PCM_16_BIT) {
+ ALOGE("HAL format %d not supported; must be AUDIO_FORMAT_PCM_16_BIT", mFormat);
+ }
+#endif
mFrameSize = audio_stream_frame_size(&mInput->stream->common);
mBufferSize = mInput->stream->common.get_buffer_size(&mInput->stream->common);
mFrameCount = mBufferSize / mFrameSize;
@@ -5345,6 +5395,7 @@
return 0;
}
+#ifdef QCOM_HARDWARE
// ----------------------------------------------------------------------------
AudioFlinger::DirectAudioTrack::DirectAudioTrack(const sp<AudioFlinger>& audioFlinger,
@@ -5659,5 +5710,6 @@
}
// ----------------------------------------------------------------------------
+#endif
}; // namespace android
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index eff4bb7..0d01d05 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -138,7 +138,9 @@
virtual status_t setParameters(const String8& keyValuePairs);
virtual String8 getParameters(const String8& keys) = 0;
virtual void audioConfigChanged_l(int event, int param = 0) = 0;
+#ifdef QCOM_HARDWARE
void effectConfigChanged();
+#endif
void sendIoConfigEvent(int event, int param = 0);
void sendIoConfigEvent_l(int event, int param = 0);
void sendPrioConfigEvent_l(pid_t pid, pid_t tid, int32_t prio);
diff --git a/services/audioflinger/TrackBase.h b/services/audioflinger/TrackBase.h
index 065e020..358d74a 100644
--- a/services/audioflinger/TrackBase.h
+++ b/services/audioflinger/TrackBase.h
@@ -43,7 +43,9 @@
audio_format_t format,
audio_channel_mask_t channelMask,
size_t frameCount,
+#ifdef QCOM_HARDWARE
uint32_t flags,
+#endif
const sp<IMemory>& sharedBuffer,
int sessionId,
bool isOut);
@@ -131,7 +133,9 @@
// 8-bit PCM samples are stored as 16-bit
const size_t mFrameCount;// size of track buffer given at createTrack() or
// openRecord(), and then adjusted as needed
+#ifdef QCOM_HARDWARE
uint32_t mFlags;
+#endif
const int mSessionId;
Vector < sp<SyncEvent> >mSyncEvents;
const bool mIsOut;
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 436d4de..dfae5d9 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -66,7 +66,9 @@
audio_format_t format,
audio_channel_mask_t channelMask,
size_t frameCount,
+#ifdef QCOM_HARDWARE
uint32_t flags,
+#endif
const sp<IMemory>& sharedBuffer,
int sessionId,
bool isOut)
@@ -80,10 +82,17 @@
mFormat(format),
mChannelMask(channelMask),
mChannelCount(popcount(channelMask)),
+#ifdef QCOM_HARDWARE
mFrameSize((audio_is_linear_pcm(format) || audio_is_supported_compressed(format)) ?
((flags & IAudioFlinger::TRACK_VOICE_COMMUNICATION)? mChannelCount * sizeof(int16_t) : mChannelCount * audio_bytes_per_sample(format)) : sizeof(int8_t)),
+#else
+ mFrameSize(audio_is_linear_pcm(format) ?
+ mChannelCount * audio_bytes_per_sample(format) : sizeof(int8_t)),
+#endif
mFrameCount(frameCount),
+#ifdef QCOM_HARDWARE
mFlags(0),
+#endif
mSessionId(sessionId),
mIsOut(isOut),
mServerProxy(NULL),
@@ -98,6 +107,7 @@
// ALOGD("Creating track with %d buffers @ %d bytes", bufferCount, bufferSize);
size_t size = sizeof(audio_track_cblk_t);
+#ifdef QCOM_HARDWARE
uint8_t channelCount = popcount(channelMask);
size_t bufferSize = 0;
if (flags & IAudioFlinger::TRACK_VOICE_COMMUNICATION) {
@@ -118,6 +128,9 @@
bufferSize = frameCount * channelCount * AMR_WB_FRAMESIZE; // full rate frame size
}
}
+#else
+ size_t bufferSize = (sharedBuffer == 0 ? roundup(frameCount) : frameCount) * mFrameSize;
+#endif
if (sharedBuffer == 0) {
size += bufferSize;
@@ -146,6 +159,7 @@
mCblk->frameCount_ = frameCount;
if (sharedBuffer == 0) {
mBuffer = (char*)mCblk + sizeof(audio_track_cblk_t);
+#ifdef QCOM_HARDWARE
if (flags & IAudioFlinger::TRACK_VOICE_COMMUNICATION) {
memset(mBuffer, 0, bufferSize);
} else {
@@ -169,6 +183,9 @@
memset(mBuffer, 0, frameCount * channelCount * AMR_WB_FRAMESIZE);
}
}
+#else
+ memset(mBuffer, 0, bufferSize);
+#endif
} else {
mBuffer = sharedBuffer->pointer();
#if 0
@@ -358,9 +375,14 @@
const sp<IMemory>& sharedBuffer,
int sessionId,
IAudioFlinger::track_flags_t flags)
+#ifdef QCOM_HARDWARE
: TrackBase(thread, client, sampleRate, format, channelMask, frameCount,
((audio_stream_type_t)streamType == AUDIO_STREAM_VOICE_CALL)? IAudioFlinger::TRACK_VOICE_COMMUNICATION:0x0,
sharedBuffer, sessionId, true /*isOut*/),
+#else
+ : TrackBase(thread, client, sampleRate, format, channelMask, frameCount, sharedBuffer,
+ sessionId, true /*isOut*/),
+#endif
mFillingUpStatus(FS_INVALID),
// mRetryCount initialized later when needed
mSharedBuffer(sharedBuffer),
@@ -1783,14 +1805,23 @@
audio_format_t format,
audio_channel_mask_t channelMask,
size_t frameCount,
+#ifdef QCOM_HARDWARE
uint32_t flags,
+#endif
int sessionId)
+#ifdef QCOM_HARDWARE
: TrackBase(thread, client, sampleRate, format, channelMask, frameCount,
flags, 0 /*sharedBuffer*/, sessionId, false /*isOut*/),
+#else
+ : TrackBase(thread, client, sampleRate, format,
+ channelMask, frameCount, 0 /*sharedBuffer*/, sessionId, false /*isOut*/),
+#endif
mOverflow(false)
{
ALOGV("RecordTrack constructor");
+#ifdef QCOM_HARDWARE
mFlags = flags;
+#endif
if (mCblk != NULL) {
mAudioRecordServerProxy = new AudioRecordServerProxy(mCblk, mBuffer, frameCount,
mFrameSize);