Merge "Keep AACEncoder around for a bit longer to have more time fix issues related to video editor engine"
diff --git a/include/media/AudioEffect.h b/include/media/AudioEffect.h
index 1417416..7b0b443 100644
--- a/include/media/AudioEffect.h
+++ b/include/media/AudioEffect.h
@@ -226,8 +226,8 @@
AudioEffect(const effect_uuid_t *type,
const effect_uuid_t *uuid = NULL,
int32_t priority = 0,
- effect_callback_t cbf = 0,
- void* user = 0,
+ effect_callback_t cbf = NULL,
+ void* user = NULL,
int sessionId = 0,
audio_io_handle_t io = 0
);
@@ -238,8 +238,8 @@
AudioEffect(const char *typeStr,
const char *uuidStr = NULL,
int32_t priority = 0,
- effect_callback_t cbf = 0,
- void* user = 0,
+ effect_callback_t cbf = NULL,
+ void* user = NULL,
int sessionId = 0,
audio_io_handle_t io = 0
);
@@ -260,8 +260,8 @@
status_t set(const effect_uuid_t *type,
const effect_uuid_t *uuid = NULL,
int32_t priority = 0,
- effect_callback_t cbf = 0,
- void* user = 0,
+ effect_callback_t cbf = NULL,
+ void* user = NULL,
int sessionId = 0,
audio_io_handle_t io = 0
);
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index 76ec3b1..c8c5dba 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -155,8 +155,8 @@
uint32_t channelMask = AUDIO_CHANNEL_IN_MONO,
int frameCount = 0,
uint32_t flags = 0,
- callback_t cbf = 0,
- void* user = 0,
+ callback_t cbf = NULL,
+ void* user = NULL,
int notificationFrames = 0,
int sessionId = 0);
@@ -181,8 +181,8 @@
uint32_t channelMask = AUDIO_CHANNEL_IN_MONO,
int frameCount = 0,
uint32_t flags = 0,
- callback_t cbf = 0,
- void* user = 0,
+ callback_t cbf = NULL,
+ void* user = NULL,
int notificationFrames = 0,
bool threadCanCallJava = false,
int sessionId = 0);
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index 98abfbd..02c85cd 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -148,8 +148,8 @@
int channelMask = 0,
int frameCount = 0,
uint32_t flags = 0,
- callback_t cbf = 0,
- void* user = 0,
+ callback_t cbf = NULL,
+ void* user = NULL,
int notificationFrames = 0,
int sessionId = 0);
@@ -180,8 +180,8 @@
int channelMask = 0,
const sp<IMemory>& sharedBuffer = 0,
uint32_t flags = 0,
- callback_t cbf = 0,
- void* user = 0,
+ callback_t cbf = NULL,
+ void* user = NULL,
int notificationFrames = 0,
int sessionId = 0);
@@ -204,8 +204,8 @@
int channelMask = 0,
int frameCount = 0,
uint32_t flags = 0,
- callback_t cbf = 0,
- void* user = 0,
+ callback_t cbf = NULL,
+ void* user = NULL,
int notificationFrames = 0,
const sp<IMemory>& sharedBuffer = 0,
bool threadCanCallJava = false,
diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h
index 7c0d886..760595c 100644
--- a/include/media/IAudioFlinger.h
+++ b/include/media/IAudioFlinger.h
@@ -126,7 +126,7 @@
uint32_t *pSamplingRate,
audio_format_t *pFormat,
uint32_t *pChannels,
- uint32_t acoustics) = 0;
+ audio_in_acoustics_t acoustics) = 0;
virtual status_t closeInput(int input) = 0;
virtual status_t setStreamOutput(audio_stream_type_t stream, int output) = 0;
diff --git a/include/media/ToneGenerator.h b/include/media/ToneGenerator.h
index 7d890bd..df0c97e 100644
--- a/include/media/ToneGenerator.h
+++ b/include/media/ToneGenerator.h
@@ -154,7 +154,7 @@
ToneGenerator(audio_stream_type_t streamType, float volume, bool threadCanCallJava = false);
~ToneGenerator();
- bool startTone(int toneType, int durationMs = -1);
+ bool startTone(tone_type toneType, int durationMs = -1);
void stopTone();
bool isInited() { return (mState == TONE_IDLE)?false:true;}
@@ -274,7 +274,7 @@
bool prepareWave();
unsigned int numWaves(unsigned int segmentIdx);
void clearWaveGens();
- int getToneForRegion(int toneType);
+ tone_type getToneForRegion(tone_type toneType);
// WaveGenerator generates a single sine wave
class WaveGenerator {
diff --git a/include/media/Visualizer.h b/include/media/Visualizer.h
index 1a4cbca..60fa15b 100644
--- a/include/media/Visualizer.h
+++ b/include/media/Visualizer.h
@@ -66,8 +66,8 @@
* See AudioEffect constructor for details on parameters.
*/
Visualizer(int32_t priority = 0,
- effect_callback_t cbf = 0,
- void* user = 0,
+ effect_callback_t cbf = NULL,
+ void* user = NULL,
int sessionId = 0);
~Visualizer();
diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h
index ffc546e..dd97ce4 100644
--- a/include/private/media/AudioTrackShared.h
+++ b/include/private/media/AudioTrackShared.h
@@ -76,7 +76,9 @@
// 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;
+private:
+ uint32_t mVolumeLR;
+public:
uint32_t sampleRate;
// NOTE: audio_track_cblk_t::frameSize is not equal to AudioTrack::frameSize() for
@@ -116,6 +118,17 @@
uint16_t getSendLevel_U4_12() const {
return mSendLevel;
}
+
+ // for AudioTrack client only, caller must limit to 0 <= volumeLR <= 0x10001000
+ void setVolumeLR(uint32_t volumeLR) {
+ mVolumeLR = volumeLR;
+ }
+
+ // for AudioFlinger only; the return value must be validated by the caller
+ uint32_t getVolumeLR() const {
+ return mVolumeLR;
+ }
+
};
diff --git a/media/libmedia/AudioEffect.cpp b/media/libmedia/AudioEffect.cpp
index 6639d06..a242846 100644
--- a/media/libmedia/AudioEffect.cpp
+++ b/media/libmedia/AudioEffect.cpp
@@ -342,7 +342,7 @@
{
ALOGW("IEffect died");
mStatus = NO_INIT;
- if (mCbf) {
+ if (mCbf != NULL) {
status_t status = DEAD_OBJECT;
mCbf(EVENT_ERROR, mUserData, &status);
}
@@ -363,7 +363,7 @@
mStatus = ALREADY_EXISTS;
}
}
- if (mCbf) {
+ if (mCbf != NULL) {
mCbf(EVENT_CONTROL_STATUS_CHANGED, mUserData, &controlGranted);
}
}
@@ -373,7 +373,7 @@
ALOGV("enableStatusChanged %p enabled %d mCbf %p", this, enabled, mCbf);
if (mStatus == ALREADY_EXISTS) {
mEnabled = enabled;
- if (mCbf) {
+ if (mCbf != NULL) {
mCbf(EVENT_ENABLE_STATUS_CHANGED, mUserData, &enabled);
}
}
@@ -389,7 +389,7 @@
return;
}
- if (mCbf && cmdCode == EFFECT_CMD_SET_PARAM) {
+ if (mCbf != NULL && cmdCode == EFFECT_CMD_SET_PARAM) {
effect_param_t *cmd = (effect_param_t *)cmdData;
cmd->status = *(int32_t *)replyData;
mCbf(EVENT_PARAMETER_CHANGED, mUserData, cmd);
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 2b3ea38..c96bc76 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -206,7 +206,7 @@
return status;
}
- if (cbf != 0) {
+ if (cbf != NULL) {
mClientRecordThread = new ClientRecordThread(*this, threadCanCallJava);
}
@@ -387,7 +387,7 @@
status_t AudioRecord::setMarkerPosition(uint32_t marker)
{
- if (mCbf == 0) return INVALID_OPERATION;
+ if (mCbf == NULL) return INVALID_OPERATION;
mMarkerPosition = marker;
mMarkerReached = false;
@@ -397,7 +397,7 @@
status_t AudioRecord::getMarkerPosition(uint32_t *marker)
{
- if (marker == 0) return BAD_VALUE;
+ if (marker == NULL) return BAD_VALUE;
*marker = mMarkerPosition;
@@ -406,7 +406,7 @@
status_t AudioRecord::setPositionUpdatePeriod(uint32_t updatePeriod)
{
- if (mCbf == 0) return INVALID_OPERATION;
+ if (mCbf == NULL) return INVALID_OPERATION;
uint32_t curPosition;
getPosition(&curPosition);
@@ -418,7 +418,7 @@
status_t AudioRecord::getPositionUpdatePeriod(uint32_t *updatePeriod)
{
- if (updatePeriod == 0) return BAD_VALUE;
+ if (updatePeriod == NULL) return BAD_VALUE;
*updatePeriod = mUpdatePeriod;
@@ -427,7 +427,7 @@
status_t AudioRecord::getPosition(uint32_t *position)
{
- if (position == 0) return BAD_VALUE;
+ if (position == NULL) return BAD_VALUE;
AutoMutex lock(mLock);
*position = mCblk->user;
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index df5017b..110a294 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -225,7 +225,7 @@
gLock.lock();
outputDesc = AudioSystem::gOutputs.valueFor(output);
- if (outputDesc == 0) {
+ if (outputDesc == NULL) {
ALOGV("getOutputSamplingRate() no output descriptor for output %d in gOutputs", output);
gLock.unlock();
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
@@ -263,7 +263,7 @@
gLock.lock();
outputDesc = AudioSystem::gOutputs.valueFor(output);
- if (outputDesc == 0) {
+ if (outputDesc == NULL) {
gLock.unlock();
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
@@ -294,7 +294,7 @@
gLock.lock();
outputDesc = AudioSystem::gOutputs.valueFor(output);
- if (outputDesc == 0) {
+ if (outputDesc == NULL) {
gLock.unlock();
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
@@ -413,7 +413,7 @@
switch (event) {
case STREAM_CONFIG_CHANGED:
- if (param2 == 0) break;
+ if (param2 == NULL) break;
stream = *(audio_stream_type_t *)param2;
ALOGV("ioConfigChanged() STREAM_CONFIG_CHANGED stream %d, output %d", stream, ioHandle);
if (gStreamOutputMap.indexOfKey(stream) >= 0) {
@@ -425,7 +425,7 @@
ALOGV("ioConfigChanged() opening already existing output! %d", ioHandle);
break;
}
- if (param2 == 0) break;
+ if (param2 == NULL) break;
desc = (OutputDescriptor *)param2;
OutputDescriptor *outputDesc = new OutputDescriptor(*desc);
@@ -454,7 +454,7 @@
ALOGW("ioConfigChanged() modifying unknow output! %d", ioHandle);
break;
}
- if (param2 == 0) break;
+ if (param2 == NULL) break;
desc = (OutputDescriptor *)param2;
ALOGV("ioConfigChanged() new config for output %d samplingRate %d, format %d channels %d frameCount %d latency %d",
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 17e3d4b..8c33f41 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -257,7 +257,7 @@
return status;
}
- if (cbf != 0) {
+ if (cbf != NULL) {
mAudioTrackThread = new AudioTrackThread(*this, threadCanCallJava);
}
@@ -501,7 +501,7 @@
mVolume[LEFT] = left;
mVolume[RIGHT] = right;
- mCblk->volumeLR = (uint32_t(uint16_t(right * 0x1000)) << 16) | uint16_t(left * 0x1000);
+ mCblk->setVolumeLR((uint32_t(uint16_t(right * 0x1000)) << 16) | uint16_t(left * 0x1000));
return NO_ERROR;
}
@@ -604,13 +604,13 @@
status_t AudioTrack::getLoop(uint32_t *loopStart, uint32_t *loopEnd, int *loopCount)
{
AutoMutex lock(mLock);
- if (loopStart != 0) {
+ if (loopStart != NULL) {
*loopStart = mCblk->loopStart;
}
- if (loopEnd != 0) {
+ if (loopEnd != NULL) {
*loopEnd = mCblk->loopEnd;
}
- if (loopCount != 0) {
+ if (loopCount != NULL) {
if (mCblk->loopCount < 0) {
*loopCount = -1;
} else {
@@ -623,7 +623,7 @@
status_t AudioTrack::setMarkerPosition(uint32_t marker)
{
- if (mCbf == 0) return INVALID_OPERATION;
+ if (mCbf == NULL) return INVALID_OPERATION;
mMarkerPosition = marker;
mMarkerReached = false;
@@ -633,7 +633,7 @@
status_t AudioTrack::getMarkerPosition(uint32_t *marker)
{
- if (marker == 0) return BAD_VALUE;
+ if (marker == NULL) return BAD_VALUE;
*marker = mMarkerPosition;
@@ -642,7 +642,7 @@
status_t AudioTrack::setPositionUpdatePeriod(uint32_t updatePeriod)
{
- if (mCbf == 0) return INVALID_OPERATION;
+ if (mCbf == NULL) return INVALID_OPERATION;
uint32_t curPosition;
getPosition(&curPosition);
@@ -654,7 +654,7 @@
status_t AudioTrack::getPositionUpdatePeriod(uint32_t *updatePeriod)
{
- if (updatePeriod == 0) return BAD_VALUE;
+ if (updatePeriod == NULL) return BAD_VALUE;
*updatePeriod = mUpdatePeriod;
@@ -679,7 +679,7 @@
status_t AudioTrack::getPosition(uint32_t *position)
{
- if (position == 0) return BAD_VALUE;
+ if (position == NULL) return BAD_VALUE;
AutoMutex lock(mLock);
*position = mFlushed ? 0 : mCblk->server;
@@ -837,7 +837,7 @@
mCblk->stepUser(mCblk->frameCount);
}
- mCblk->volumeLR = (uint32_t(uint16_t(mVolume[RIGHT] * 0x1000)) << 16) | uint16_t(mVolume[LEFT] * 0x1000);
+ mCblk->setVolumeLR((uint32_t(uint16_t(mVolume[RIGHT] * 0x1000)) << 16) | uint16_t(mVolume[LEFT] * 0x1000));
mCblk->setSendLevel(mSendLevel);
mAudioTrack->attachAuxEffect(mAuxEffectId);
mCblk->bufferTimeoutMs = MAX_STARTUP_TIMEOUT_MS;
@@ -1319,8 +1319,8 @@
audio_track_cblk_t::audio_track_cblk_t()
: lock(Mutex::SHARED), cv(Condition::SHARED), user(0), server(0),
- userBase(0), serverBase(0), buffers(0), frameCount(0),
- loopStart(UINT_MAX), loopEnd(UINT_MAX), loopCount(0), volumeLR(0),
+ userBase(0), serverBase(0), buffers(NULL), frameCount(0),
+ loopStart(UINT_MAX), loopEnd(UINT_MAX), loopCount(0), mVolumeLR(0x10001000),
mSendLevel(0), flags(0)
{
}
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index 0d442ef..fc5520f 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -432,7 +432,7 @@
uint32_t *pSamplingRate,
audio_format_t *pFormat,
uint32_t *pChannels,
- uint32_t acoustics)
+ audio_in_acoustics_t acoustics)
{
Parcel data, reply;
uint32_t devices = pDevices ? *pDevices : 0;
@@ -445,7 +445,7 @@
data.writeInt32(samplingRate);
data.writeInt32(format);
data.writeInt32(channels);
- data.writeInt32(acoustics);
+ data.writeInt32((int32_t) acoustics);
remote()->transact(OPEN_INPUT, data, &reply);
int input = reply.readInt32();
devices = reply.readInt32();
@@ -640,7 +640,7 @@
*id = tmp;
}
tmp = reply.readInt32();
- if (enabled) {
+ if (enabled != NULL) {
*enabled = tmp;
}
effect = interface_cast<IEffect>(reply.readStrongBinder());
@@ -881,13 +881,13 @@
uint32_t samplingRate = data.readInt32();
audio_format_t format = (audio_format_t) data.readInt32();
uint32_t channels = data.readInt32();
- uint32_t acoutics = data.readInt32();
+ audio_in_acoustics_t acoustics = (audio_in_acoustics_t) data.readInt32();
int input = openInput(&devices,
&samplingRate,
&format,
&channels,
- acoutics);
+ acoustics);
reply->writeInt32(input);
reply->writeInt32(devices);
reply->writeInt32(samplingRate);
diff --git a/media/libmedia/IAudioFlingerClient.cpp b/media/libmedia/IAudioFlingerClient.cpp
index 5a3f250..9458bc0 100644
--- a/media/libmedia/IAudioFlingerClient.cpp
+++ b/media/libmedia/IAudioFlingerClient.cpp
@@ -73,7 +73,7 @@
CHECK_INTERFACE(IAudioFlingerClient, data, reply);
int event = data.readInt32();
int ioHandle = data.readInt32();
- void *param2 = 0;
+ void *param2 = NULL;
AudioSystem::OutputDescriptor desc;
uint32_t stream;
if (event == AudioSystem::STREAM_CONFIG_CHANGED) {
diff --git a/media/libmedia/ToneGenerator.cpp b/media/libmedia/ToneGenerator.cpp
index 5ceb912..e6e989d 100644
--- a/media/libmedia/ToneGenerator.cpp
+++ b/media/libmedia/ToneGenerator.cpp
@@ -751,7 +751,7 @@
// Used by ToneGenerator::getToneForRegion() to convert user specified supervisory tone type
// to actual tone for current region.
-const unsigned char ToneGenerator::sToneMappingTable[NUM_REGIONS-1][NUM_SUP_TONES] = {
+const unsigned char /*tone_type*/ ToneGenerator::sToneMappingTable[NUM_REGIONS-1][NUM_SUP_TONES] = {
{ // ANSI
TONE_ANSI_DIAL, // TONE_SUP_DIAL
TONE_ANSI_BUSY, // TONE_SUP_BUSY
@@ -811,9 +811,9 @@
mThreadCanCallJava = threadCanCallJava;
mStreamType = streamType;
mVolume = volume;
- mpAudioTrack = 0;
- mpToneDesc = 0;
- mpNewToneDesc = 0;
+ mpAudioTrack = NULL;
+ mpToneDesc = NULL;
+ mpNewToneDesc = NULL;
// Generate tone by chunks of 20 ms to keep cadencing precision
mProcessSize = (mSamplingRate * 20) / 1000;
@@ -855,7 +855,7 @@
ToneGenerator::~ToneGenerator() {
ALOGV("ToneGenerator destructor\n");
- if (mpAudioTrack) {
+ if (mpAudioTrack != NULL) {
stopTone();
ALOGV("Delete Track: %p\n", mpAudioTrack);
delete mpAudioTrack;
@@ -878,7 +878,7 @@
// none
//
////////////////////////////////////////////////////////////////////////////////
-bool ToneGenerator::startTone(int toneType, int durationMs) {
+bool ToneGenerator::startTone(tone_type toneType, int durationMs) {
bool lResult = false;
status_t lStatus;
@@ -1012,7 +1012,7 @@
if (mpAudioTrack) {
delete mpAudioTrack;
- mpAudioTrack = 0;
+ mpAudioTrack = NULL;
}
// Open audio track in mono, PCM 16bit, default sampling rate, default buffer size
@@ -1048,7 +1048,7 @@
if (mpAudioTrack) {
ALOGV("Delete Track I: %p\n", mpAudioTrack);
delete mpAudioTrack;
- mpAudioTrack = 0;
+ mpAudioTrack = NULL;
}
return false;
@@ -1317,7 +1317,7 @@
bool ToneGenerator::prepareWave() {
unsigned int segmentIdx = 0;
- if (!mpNewToneDesc) {
+ if (mpNewToneDesc == NULL) {
return false;
}
@@ -1434,13 +1434,13 @@
// none
//
////////////////////////////////////////////////////////////////////////////////
-int ToneGenerator::getToneForRegion(int toneType) {
- int regionTone;
+ToneGenerator::tone_type ToneGenerator::getToneForRegion(tone_type toneType) {
+ tone_type regionTone;
if (mRegion == CEPT || toneType < FIRST_SUP_TONE || toneType > LAST_SUP_TONE) {
regionTone = toneType;
} else {
- regionTone = sToneMappingTable[mRegion][toneType - FIRST_SUP_TONE];
+ regionTone = (tone_type) sToneMappingTable[mRegion][toneType - FIRST_SUP_TONE];
}
ALOGV("getToneForRegion, tone %d, region %d, regionTone %d", toneType, mRegion, regionTone);
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 0c44f3f..f71ba0a 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -160,7 +160,10 @@
AudioFlinger::AudioFlinger()
: BnAudioFlinger(),
- mPrimaryHardwareDev(NULL), mMasterVolume(1.0f), mMasterMute(false), mNextUniqueId(1),
+ mPrimaryHardwareDev(NULL),
+ mHardwareStatus(AUDIO_HW_IDLE), // see also onFirstRef()
+ mMasterVolume(1.0f), mMasterMute(false), mNextUniqueId(1),
+ mMode(AUDIO_MODE_INVALID),
mBtNrecIsOff(false)
{
}
@@ -172,7 +175,6 @@
Mutex::Autolock _l(mLock);
/* TODO: move all this work into an Init() function */
- mHardwareStatus = AUDIO_HW_IDLE;
for (size_t i = 0; i < ARRAY_SIZE(audio_interfaces); i++) {
const hw_module_t *mod;
@@ -265,13 +267,10 @@
result.append("Clients:\n");
for (size_t i = 0; i < mClients.size(); ++i) {
- wp<Client> wClient = mClients.valueAt(i);
- if (wClient != 0) {
- sp<Client> client = wClient.promote();
- if (client != 0) {
- snprintf(buffer, SIZE, " pid: %d\n", client->pid());
- result.append(buffer);
- }
+ sp<Client> client = mClients.valueAt(i).promote();
+ if (client != 0) {
+ snprintf(buffer, SIZE, " pid: %d\n", client->pid());
+ result.append(buffer);
}
}
@@ -971,7 +970,8 @@
{
size_t size = mNotificationClients.size();
for (size_t i = 0; i < size; i++) {
- mNotificationClients.valueAt(i)->client()->ioConfigChanged(event, ioHandle, param2);
+ mNotificationClients.valueAt(i)->audioFlingerClient()->ioConfigChanged(event, ioHandle,
+ param2);
}
}
@@ -985,13 +985,19 @@
// ----------------------------------------------------------------------------
-AudioFlinger::ThreadBase::ThreadBase(const sp<AudioFlinger>& audioFlinger, int id, uint32_t device)
+AudioFlinger::ThreadBase::ThreadBase(const sp<AudioFlinger>& audioFlinger, int id, uint32_t device,
+ type_t type)
: Thread(false),
- mAudioFlinger(audioFlinger), mSampleRate(0), mFrameCount(0), mChannelCount(0),
- mFrameSize(1), mFormat(AUDIO_FORMAT_INVALID), mStandby(false), mId(id), mExiting(false),
- mDevice(device)
+ mType(type),
+ mAudioFlinger(audioFlinger), mSampleRate(0), mFrameCount(0),
+ // mChannelMask
+ mChannelCount(0),
+ mFrameSize(1), mFormat(AUDIO_FORMAT_INVALID),
+ mParamStatus(NO_ERROR),
+ mStandby(false), mId(id), mExiting(false),
+ mDevice(device),
+ mDeathRecipient(new PMDeathRecipient(this))
{
- mDeathRecipient = new PMDeathRecipient(this);
}
AudioFlinger::ThreadBase::~ThreadBase()
@@ -1372,20 +1378,24 @@
AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinger,
AudioStreamOut* output,
int id,
- uint32_t device)
- : ThreadBase(audioFlinger, id, device),
- mMixBuffer(NULL), mSuspended(0), mBytesWritten(0), mOutput(output),
+ uint32_t device,
+ type_t type)
+ : ThreadBase(audioFlinger, id, device, type),
+ mMixBuffer(NULL), mSuspended(0), mBytesWritten(0),
+ // Assumes constructor is called by AudioFlinger with it's mLock held,
+ // but it would be safer to explicitly pass initial masterMute as parameter
+ mMasterMute(audioFlinger->masterMute_l()),
+ // mStreamTypes[] initialized in constructor body
+ mOutput(output),
+ // Assumes constructor is called by AudioFlinger with it's mLock held,
+ // but it would be safer to explicitly pass initial masterVolume as parameter
+ mMasterVolume(audioFlinger->masterVolume_l()),
mLastWriteTime(0), mNumWrites(0), mNumDelayedWrites(0), mInWrite(false)
{
snprintf(mName, kNameLength, "AudioOut_%d", id);
readOutputParameters();
- // Assumes constructor is called by AudioFlinger with it's mLock held,
- // but it would be safer to explicitly pass these as parameters
- mMasterVolume = mAudioFlinger->masterVolume_l();
- mMasterMute = mAudioFlinger->masterMute_l();
-
// mStreamTypes[AUDIO_STREAM_CNT] is initialized by stream_type_t default constructor
// There is no AUDIO_STREAM_MIN, and ++ operator does not compile
for (audio_stream_type_t stream = (audio_stream_type_t) 0; stream < AUDIO_STREAM_CNT;
@@ -1431,13 +1441,10 @@
result.append(buffer);
result.append(" Name Clien Typ Fmt Chn mask Session Buf S M F SRate LeftV RighV Serv User Main buf Aux Buf\n");
for (size_t i = 0; i < mActiveTracks.size(); ++i) {
- wp<Track> wTrack = mActiveTracks[i];
- if (wTrack != 0) {
- sp<Track> track = wTrack.promote();
- if (track != 0) {
- track->dump(buffer, SIZE);
- result.append(buffer);
- }
+ sp<Track> track = mActiveTracks[i].promote();
+ if (track != 0) {
+ track->dump(buffer, SIZE);
+ result.append(buffer);
}
}
write(fd, result.string(), result.size());
@@ -1705,7 +1712,7 @@
// audioConfigChanged_l() must be called with AudioFlinger::mLock held
void AudioFlinger::PlaybackThread::audioConfigChanged_l(int event, int param) {
AudioSystem::OutputDescriptor desc;
- void *param2 = 0;
+ void *param2 = NULL;
ALOGV("PlaybackThread::audioConfigChanged_l, thread %p, event %d, param %d", this, event, param);
@@ -1758,7 +1765,7 @@
status_t AudioFlinger::PlaybackThread::getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames)
{
- if (halFrames == 0 || dspFrames == 0) {
+ if (halFrames == NULL || dspFrames == NULL) {
return BAD_VALUE;
}
Mutex::Autolock _l(mLock);
@@ -1845,13 +1852,12 @@
// ----------------------------------------------------------------------------
-AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device)
- : PlaybackThread(audioFlinger, output, id, device),
- mAudioMixer(NULL), mPrevMixerStatus(MIXER_IDLE)
+AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
+ int id, uint32_t device, type_t type)
+ : PlaybackThread(audioFlinger, output, id, device, type),
+ mAudioMixer(new AudioMixer(mFrameCount, mSampleRate)),
+ mPrevMixerStatus(MIXER_IDLE)
{
- mType = ThreadBase::MIXER;
- mAudioMixer = new AudioMixer(mFrameCount, mSampleRate);
-
// FIXME - Current mixer implementation only supports stereo output
if (mChannelCount == 1) {
ALOGE("Invalid audio hardware channel count");
@@ -2193,7 +2199,7 @@
// read original volumes with volume control
float typeVolume = mStreamTypes[track->type()].volume;
float v = masterVolume * typeVolume;
- uint32_t vlr = cblk->volumeLR;
+ uint32_t vlr = cblk->getVolumeLR();
vl = vlr & 0xFFFF;
vr = vlr >> 16;
// track volumes come from shared memory, so can't be trusted and must be clamped
@@ -2515,9 +2521,10 @@
// ----------------------------------------------------------------------------
AudioFlinger::DirectOutputThread::DirectOutputThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device)
- : PlaybackThread(audioFlinger, output, id, device)
+ : PlaybackThread(audioFlinger, output, id, device, DIRECT)
+ // mLeftVolFloat, mRightVolFloat
+ // mLeftVolShort, mRightVolShort
{
- mType = ThreadBase::DIRECT;
}
AudioFlinger::DirectOutputThread::~DirectOutputThread()
@@ -2731,7 +2738,7 @@
} else {
float typeVolume = mStreamTypes[track->type()].volume;
float v = mMasterVolume * typeVolume;
- uint32_t vlr = cblk->volumeLR;
+ uint32_t vlr = cblk->getVolumeLR();
float v_clamped = v * (vlr & 0xFFFF);
if (v_clamped > MAX_GAIN) v_clamped = MAX_GAIN;
left = v_clamped/MAX_GAIN;
@@ -2994,10 +3001,11 @@
// ----------------------------------------------------------------------------
-AudioFlinger::DuplicatingThread::DuplicatingThread(const sp<AudioFlinger>& audioFlinger, AudioFlinger::MixerThread* mainThread, int id)
- : MixerThread(audioFlinger, mainThread->getOutput(), id, mainThread->device()), mWaitTimeMs(UINT_MAX)
+AudioFlinger::DuplicatingThread::DuplicatingThread(const sp<AudioFlinger>& audioFlinger,
+ AudioFlinger::MixerThread* mainThread, int id)
+ : MixerThread(audioFlinger, mainThread->getOutput(), id, mainThread->device(), DUPLICATING),
+ mWaitTimeMs(UINT_MAX)
{
- mType = ThreadBase::DUPLICATING;
addOutputTrack(mainThread);
}
@@ -3246,13 +3254,17 @@
: RefBase(),
mThread(thread),
mClient(client),
- mCblk(0),
+ mCblk(NULL),
+ // mBuffer
+ // mBufferEnd
mFrameCount(0),
mState(IDLE),
mClientTid(-1),
mFormat(format),
mFlags(flags & ~SYSTEM_FLAGS_MASK),
mSessionId(sessionId)
+ // mChannelCount
+ // mChannelMask
{
ALOGV_IF(sharedBuffer != 0, "sharedBuffer: %p, size: %d", sharedBuffer->pointer(), sharedBuffer->size());
@@ -3268,7 +3280,7 @@
mCblkMemory = client->heap()->allocate(size);
if (mCblkMemory != 0) {
mCblk = static_cast<audio_track_cblk_t *>(mCblkMemory->pointer());
- if (mCblk) { // construct the shared structure in-place.
+ if (mCblk != NULL) { // construct the shared structure in-place.
new(mCblk) audio_track_cblk_t();
// clear all buffers
mCblk->frameCount = frameCount;
@@ -3311,7 +3323,7 @@
AudioFlinger::ThreadBase::TrackBase::~TrackBase()
{
- if (mCblk) {
+ if (mCblk != NULL) {
mCblk->~audio_track_cblk_t(); // destroy our shared-structure.
if (mClient == NULL) {
delete mCblk;
@@ -3319,6 +3331,7 @@
}
mCblkMemory.clear(); // and free the shared memory
if (mClient != NULL) {
+ // Client destructor must run with AudioFlinger mutex locked
Mutex::Autolock _l(mClient->audioFlinger()->mLock);
mClient.clear();
}
@@ -3385,7 +3398,7 @@
server %d, serverBase %d, user %d, userBase %d",
bufferStart, bufferEnd, mBuffer, mBufferEnd,
cblk->server, cblk->serverBase, cblk->user, cblk->userBase);
- return 0;
+ return NULL;
}
return bufferStart;
@@ -3470,7 +3483,7 @@
void AudioFlinger::PlaybackThread::Track::dump(char* buffer, size_t size)
{
- uint32_t vlr = mCblk->volumeLR;
+ uint32_t vlr = mCblk->getVolumeLR();
snprintf(buffer, size, " %05d %05d %03u %03u 0x%08x %05u %04u %1d %1d %1d %05u %05u %05u 0x%08x 0x%08x 0x%08x 0x%08x\n",
mName - AudioMixer::TRACK0,
(mClient == NULL) ? getpid() : mClient->pid(),
@@ -3829,7 +3842,6 @@
if (mCblk != NULL) {
mCblk->flags |= CBLK_DIRECTION_OUT;
mCblk->buffers = (char*)mCblk + sizeof(audio_track_cblk_t);
- mCblk->volumeLR = (MAX_GAIN_INT << 16) | MAX_GAIN_INT;
mOutBuffer.frameCount = 0;
playbackThread->mTracks.add(this);
ALOGV("OutputTrack constructor mCblk %p, mBuffer %p, mCblk->buffers %p, " \
@@ -4077,13 +4089,12 @@
AudioFlinger::NotificationClient::NotificationClient(const sp<AudioFlinger>& audioFlinger,
const sp<IAudioFlingerClient>& client,
pid_t pid)
- : mAudioFlinger(audioFlinger), mPid(pid), mClient(client)
+ : mAudioFlinger(audioFlinger), mPid(pid), mAudioFlingerClient(client)
{
}
AudioFlinger::NotificationClient::~NotificationClient()
{
- mClient.clear();
}
void AudioFlinger::NotificationClient::binderDied(const wp<IBinder>& who)
@@ -4268,15 +4279,16 @@
uint32_t channels,
int id,
uint32_t device) :
- ThreadBase(audioFlinger, id, device),
- mInput(input), mTrack(NULL), mResampler(NULL), mRsmpOutBuffer(NULL), mRsmpInBuffer(NULL)
+ ThreadBase(audioFlinger, id, device, RECORD),
+ mInput(input), mTrack(NULL), mResampler(NULL), mRsmpOutBuffer(NULL), mRsmpInBuffer(NULL),
+ // mRsmpInIndex and mInputBytes set by readInputParameters()
+ mReqChannelCount(popcount(channels)),
+ mReqSampleRate(sampleRate)
+ // mBytesRead is only meaningful while active, and so is cleared in start()
+ // (but might be better to also clear here for dump?)
{
- mType = ThreadBase::RECORD;
-
snprintf(mName, kNameLength, "AudioIn_%d", id);
- mReqChannelCount = popcount(channels);
- mReqSampleRate = sampleRate;
readInputParameters();
}
@@ -4807,7 +4819,7 @@
void AudioFlinger::RecordThread::audioConfigChanged_l(int event, int param) {
AudioSystem::OutputDescriptor desc;
- void *param2 = 0;
+ void *param2 = NULL;
switch (event) {
case AudioSystem::INPUT_OPENED:
@@ -4985,10 +4997,10 @@
}
mPlaybackThreads.add(id, thread);
- if (pSamplingRate) *pSamplingRate = samplingRate;
- if (pFormat) *pFormat = format;
- if (pChannels) *pChannels = channels;
- if (pLatencyMs) *pLatencyMs = thread->latency();
+ if (pSamplingRate != NULL) *pSamplingRate = samplingRate;
+ if (pFormat != NULL) *pFormat = format;
+ if (pChannels != NULL) *pChannels = channels;
+ if (pLatencyMs != NULL) *pLatencyMs = thread->latency();
// notify client processes of the new output creation
thread->audioConfigChanged_l(AudioSystem::OUTPUT_OPENED);
@@ -5040,7 +5052,7 @@
}
}
}
- void *param2 = 0;
+ void *param2 = NULL;
audioConfigChanged_l(AudioSystem::OUTPUT_CLOSED, output, param2);
mPlaybackThreads.removeItem(output);
}
@@ -5091,7 +5103,7 @@
uint32_t *pSamplingRate,
audio_format_t *pFormat,
uint32_t *pChannels,
- uint32_t acoustics)
+ audio_in_acoustics_t acoustics)
{
status_t status;
RecordThread *thread = NULL;
@@ -5116,7 +5128,7 @@
status = inHwDev->open_input_stream(inHwDev, *pDevices, &format,
&channels, &samplingRate,
- (audio_in_acoustics_t)acoustics,
+ acoustics,
&inStream);
ALOGV("openInput() openInputStream returned input %p, SamplingRate %d, Format %d, Channels %x, acoustics %x, status %d",
inStream,
@@ -5136,7 +5148,7 @@
ALOGV("openInput() reopening with proposed sampling rate and channels");
status = inHwDev->open_input_stream(inHwDev, *pDevices, &format,
&channels, &samplingRate,
- (audio_in_acoustics_t)acoustics,
+ acoustics,
&inStream);
}
@@ -5156,9 +5168,9 @@
device);
mRecordThreads.add(id, thread);
ALOGV("openInput() created record thread: ID %d thread %p", id, thread);
- if (pSamplingRate) *pSamplingRate = reqSamplingRate;
- if (pFormat) *pFormat = format;
- if (pChannels) *pChannels = reqChannels;
+ if (pSamplingRate != NULL) *pSamplingRate = reqSamplingRate;
+ if (pFormat != NULL) *pFormat = format;
+ if (pChannels != NULL) *pChannels = reqChannels;
input->stream->common.standby(&input->stream->common);
@@ -5183,7 +5195,7 @@
}
ALOGV("closeInput() %d", input);
- void *param2 = 0;
+ void *param2 = NULL;
audioConfigChanged_l(AudioSystem::INPUT_CLOSED, input, param2);
mRecordThreads.removeItem(input);
}
@@ -5245,12 +5257,8 @@
return;
}
}
- AudioSessionRef *ref = new AudioSessionRef();
- ref->sessionid = audioSession;
- ref->pid = caller;
- ref->cnt = 1;
- mAudioSessionRefs.push(ref);
- ALOGV(" added new entry for %d", ref->sessionid);
+ mAudioSessionRefs.push(new AudioSessionRef(audioSession, caller));
+ ALOGV(" added new entry for %d", audioSession);
}
void AudioFlinger::releaseAudioSessionId(int audioSession)
@@ -5794,7 +5802,7 @@
// create effect handle and connect it to effect module
handle = new EffectHandle(effect, client, effectClient, priority);
lStatus = effect->addHandle(handle);
- if (enabled) {
+ if (enabled != NULL) {
*enabled = (int)effect->isEnabled();
}
}
@@ -6228,7 +6236,7 @@
bool enabled = false;
EffectHandle *hdl = handle.unsafe_get();
- if (hdl) {
+ if (hdl != NULL) {
ALOGV("removeHandle() unsafe_get OK");
enabled = hdl->enabled();
}
@@ -6864,7 +6872,7 @@
if (mCblkMemory != 0) {
mCblk = static_cast<effect_param_cblk_t *>(mCblkMemory->pointer());
- if (mCblk) {
+ if (mCblk != NULL) {
new(mCblk) effect_param_cblk_t();
mBuffer = (uint8_t *)mCblk + bufOffset;
}
@@ -6961,7 +6969,7 @@
// release sp on module => module destructor can be called now
mEffect.clear();
if (mClient != 0) {
- if (mCblk) {
+ if (mCblk != NULL) {
mCblk->~effect_param_cblk_t(); // destroy our shared-structure.
}
mCblkMemory.clear(); // and free the shared memory
@@ -7091,7 +7099,7 @@
void AudioFlinger::EffectHandle::dump(char* buffer, size_t size)
{
- bool locked = mCblk ? tryLock(mCblk->lock) : false;
+ bool locked = mCblk != NULL && tryLock(mCblk->lock);
snprintf(buffer, size, "\t\t\t%05d %05d %01u %01u %05u %05u\n",
(mClient == NULL) ? getpid() : mClient->pid(),
@@ -7553,7 +7561,8 @@
ALOGV("setEffectSuspendedAll_l() add entry for 0");
}
if (desc->mRefCount++ == 0) {
- Vector< sp<EffectModule> > effects = getSuspendEligibleEffects();
+ Vector< sp<EffectModule> > effects;
+ getSuspendEligibleEffects(effects);
for (size_t i = 0; i < effects.size(); i++) {
setEffectSuspended_l(&effects[i]->desc().type, true);
}
@@ -7604,16 +7613,14 @@
return true;
}
-Vector< sp<AudioFlinger::EffectModule> > AudioFlinger::EffectChain::getSuspendEligibleEffects()
+void AudioFlinger::EffectChain::getSuspendEligibleEffects(Vector< sp<AudioFlinger::EffectModule> > &effects)
{
- Vector< sp<EffectModule> > effects;
+ effects.clear();
for (size_t i = 0; i < mEffects.size(); i++) {
- if (!isEffectEligibleForSuspend(mEffects[i]->desc())) {
- continue;
+ if (isEffectEligibleForSuspend(mEffects[i]->desc())) {
+ effects.add(mEffects[i]);
}
- effects.add(mEffects[i]);
}
- return effects;
}
sp<AudioFlinger::EffectModule> AudioFlinger::EffectChain::getEffectIfEnabled(
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index ece4ba2..3f3188c 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -131,7 +131,7 @@
uint32_t *pSamplingRate,
audio_format_t *pFormat,
uint32_t *pChannels,
- uint32_t acoustics);
+ audio_in_acoustics_t acoustics);
virtual status_t closeInput(int input);
@@ -233,9 +233,9 @@
private:
Client(const Client&);
Client& operator = (const Client&);
- sp<AudioFlinger> mAudioFlinger;
- sp<MemoryDealer> mMemoryDealer;
- pid_t mPid;
+ const sp<AudioFlinger> mAudioFlinger;
+ const sp<MemoryDealer> mMemoryDealer;
+ const pid_t mPid;
};
// --- Notification Client ---
@@ -246,7 +246,7 @@
pid_t pid);
virtual ~NotificationClient();
- sp<IAudioFlingerClient> client() { return mClient; }
+ sp<IAudioFlingerClient> audioFlingerClient() const { return mAudioFlingerClient; }
// IBinder::DeathRecipient
virtual void binderDied(const wp<IBinder>& who);
@@ -255,9 +255,9 @@
NotificationClient(const NotificationClient&);
NotificationClient& operator = (const NotificationClient&);
- sp<AudioFlinger> mAudioFlinger;
- pid_t mPid;
- sp<IAudioFlingerClient> mClient;
+ const sp<AudioFlinger> mAudioFlinger;
+ const pid_t mPid;
+ const sp<IAudioFlingerClient> mAudioFlingerClient;
};
class TrackHandle;
@@ -277,17 +277,17 @@
class ThreadBase : public Thread {
public:
- ThreadBase (const sp<AudioFlinger>& audioFlinger, int id, uint32_t device);
- virtual ~ThreadBase();
-
- enum type {
+ enum type_t {
MIXER, // Thread class is MixerThread
DIRECT, // Thread class is DirectOutputThread
DUPLICATING, // Thread class is DuplicatingThread
RECORD // Thread class is RecordThread
};
+ ThreadBase (const sp<AudioFlinger>& audioFlinger, int id, uint32_t device, type_t type);
+ virtual ~ThreadBase();
+
status_t dumpBase(int fd, const Vector<String16>& args);
status_t dumpEffectChains(int fd, const Vector<String16>& args);
@@ -367,8 +367,8 @@
bool step();
void reset();
- wp<ThreadBase> mThread;
- sp<Client> mClient;
+ const wp<ThreadBase> mThread;
+ /*const*/ sp<Client> mClient; // see explanation at ~TrackBase() why not const
sp<IMemory> mCblkMemory;
audio_track_cblk_t* mCblk;
void* mBuffer;
@@ -377,9 +377,9 @@
// we don't really need a lock for these
track_state mState;
int mClientTid;
- audio_format_t mFormat;
+ const audio_format_t mFormat;
uint32_t mFlags;
- int mSessionId;
+ const int mSessionId;
uint8_t mChannelCount;
uint32_t mChannelMask;
};
@@ -408,7 +408,7 @@
};
virtual status_t initCheck() const = 0;
- int type() const { return mType; }
+ type_t type() const { return mType; }
uint32_t sampleRate() const;
int channelCount() const;
audio_format_t format() const;
@@ -530,9 +530,9 @@
friend class RecordThread;
friend class RecordTrack;
- int mType;
+ const type_t mType;
Condition mWaitWorkCV;
- sp<AudioFlinger> mAudioFlinger;
+ const sp<AudioFlinger> mAudioFlinger;
uint32_t mSampleRate;
size_t mFrameCount;
uint32_t mChannelMask;
@@ -553,7 +553,7 @@
char mName[kNameLength];
sp<IPowerManager> mPowerManager;
sp<IBinder> mWakeLockToken;
- sp<PMDeathRecipient> mDeathRecipient;
+ const sp<PMDeathRecipient> mDeathRecipient;
// list of suspended effects per session and per type. The first vector is
// keyed by session ID, the second by type UUID timeLow field
KeyedVector< int, KeyedVector< int, sp<SuspendedSessionDesc> > > mSuspendedSessions;
@@ -671,7 +671,7 @@
bool write(int16_t* data, uint32_t frames);
bool bufferQueueEmpty() { return (mBufferQueue.size() == 0) ? true : false; }
bool isActive() { return mActive; }
- wp<ThreadBase>& thread() { return mThread; }
+ const wp<ThreadBase>& thread() { return mThread; }
private:
@@ -688,10 +688,11 @@
Vector < Buffer* > mBufferQueue;
AudioBufferProvider::Buffer mOutBuffer;
bool mActive;
- DuplicatingThread* mSourceThread;
+ DuplicatingThread* const mSourceThread; // for waitTimeMs() in write()
}; // end of OutputTrack
- PlaybackThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device);
+ PlaybackThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id,
+ uint32_t device, type_t type);
virtual ~PlaybackThread();
virtual status_t dump(int fd, const Vector<String16>& args);
@@ -817,7 +818,8 @@
MixerThread (const sp<AudioFlinger>& audioFlinger,
AudioStreamOut* output,
int id,
- uint32_t device);
+ uint32_t device,
+ type_t type = MIXER);
virtual ~MixerThread();
// Thread virtuals
@@ -917,7 +919,7 @@
virtual status_t onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
private:
- sp<PlaybackThread::Track> mTrack;
+ const sp<PlaybackThread::Track> mTrack;
};
friend class Client;
@@ -1021,8 +1023,8 @@
int16_t *mRsmpInBuffer;
size_t mRsmpInIndex;
size_t mInputBytes;
- int mReqChannelCount;
- uint32_t mReqSampleRate;
+ const int mReqChannelCount;
+ const uint32_t mReqSampleRate;
ssize_t mBytesRead;
};
@@ -1036,7 +1038,7 @@
virtual status_t onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
private:
- sp<RecordThread::RecordTrack> mRecordTrack;
+ const sp<RecordThread::RecordTrack> mRecordTrack;
};
//--- Audio Effect Management
@@ -1105,7 +1107,7 @@
int16_t *outBuffer() { return mConfig.outputCfg.buffer.s16; }
void setChain(const wp<EffectChain>& chain) { mChain = chain; }
void setThread(const wp<ThreadBase>& thread) { mThread = thread; }
- wp<ThreadBase>& thread() { return mThread; }
+ const wp<ThreadBase>& thread() { return mThread; }
status_t addHandle(const sp<EffectHandle>& handle);
void disconnect(const wp<EffectHandle>& handle, bool unpiniflast);
@@ -1325,7 +1327,8 @@
// get a list of effect modules to suspend when an effect of the type
// passed is enabled.
- Vector< sp<EffectModule> > getSuspendEligibleEffects();
+ void getSuspendEligibleEffects(Vector< sp<EffectModule> > &effects);
+
// get an effect module if it is currently enable
sp<EffectModule> getEffectIfEnabled(const effect_uuid_t *type);
// true if the effect whose descriptor is passed can be suspended
@@ -1377,8 +1380,11 @@
};
struct AudioSessionRef {
- int sessionid;
- pid_t pid;
+ // FIXME rename parameter names when fields get "m" prefix
+ AudioSessionRef(int sessionid_, pid_t pid_) :
+ sessionid(sessionid_), pid(pid_), cnt(1) {}
+ const int sessionid;
+ const pid_t pid;
int cnt;
};
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index a01c6a8..0b9f8ba 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -48,9 +48,10 @@
mState.enabledTracks= 0;
mState.needsChanged = 0;
mState.frameCount = frameCount;
+ mState.hook = process__nop;
mState.outputTemp = NULL;
mState.resampleTemp = NULL;
- mState.hook = process__nop;
+ // mState.reserved
track_t* t = mState.tracks;
for (unsigned i=0 ; i < MAX_NUM_TRACKS ; i++) {
t->needs = 0;
@@ -70,12 +71,13 @@
t->enabled = 0;
t->format = 16;
t->channelMask = AUDIO_CHANNEL_OUT_STEREO;
- t->buffer.raw = 0;
t->bufferProvider = NULL;
+ t->buffer.raw = NULL;
+ // t->buffer.frameCount
t->hook = NULL;
+ t->in = NULL;
t->resampler = NULL;
t->sampleRate = mSampleRate;
- t->in = NULL;
t->mainBuffer = NULL;
t->auxBuffer = NULL;
t++;
@@ -123,7 +125,7 @@
track.enabled = 0;
invalidateState(1<<name);
}
- if (track.resampler) {
+ if (track.resampler != NULL) {
// delete the resampler
delete track.resampler;
track.resampler = NULL;
@@ -807,7 +809,7 @@
while (outFrames) {
t1.buffer.frameCount = outFrames;
t1.bufferProvider->getNextBuffer(&t1.buffer);
- if (!t1.buffer.raw) break;
+ if (t1.buffer.raw == NULL) break;
outFrames -= t1.buffer.frameCount;
t1.bufferProvider->releaseBuffer(&t1.buffer);
}
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index 7695d2b..1dddbb3 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -144,9 +144,9 @@
}
mInputs.clear();
- if (mpAudioPolicy && mpAudioPolicyDev)
+ if (mpAudioPolicy != NULL && mpAudioPolicyDev != NULL)
mpAudioPolicyDev->destroy_audio_policy(mpAudioPolicyDev, mpAudioPolicy);
- if (mpAudioPolicyDev)
+ if (mpAudioPolicyDev != NULL)
audio_policy_dev_close(mpAudioPolicyDev);
}
@@ -789,7 +789,8 @@
return NO_ERROR;
}
-void AudioPolicyService::AudioCommandThread::startToneCommand(int type, audio_stream_type_t stream)
+void AudioPolicyService::AudioCommandThread::startToneCommand(ToneGenerator::tone_type type,
+ audio_stream_type_t stream)
{
AudioCommand *command = new AudioCommand();
command->mCommand = START_TONE;
@@ -1159,7 +1160,7 @@
if (param == NULL && value == NULL) {
// try to parse simple parameter form {int int}
param = root->first_child;
- if (param) {
+ if (param != NULL) {
// Note: that a pair of random strings is read as 0 0
int *ptr = (int *)fx_param->data;
int *ptr2 = (int *)((char *)param + sizeof(effect_param_t));
@@ -1418,7 +1419,7 @@
uint32_t *pSamplingRate,
audio_format_t *pFormat,
uint32_t *pChannels,
- uint32_t acoustics)
+ audio_in_acoustics_t acoustics)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
if (af == NULL) {
diff --git a/services/audioflinger/AudioPolicyService.h b/services/audioflinger/AudioPolicyService.h
index 3c0f5ed..62219e5 100644
--- a/services/audioflinger/AudioPolicyService.h
+++ b/services/audioflinger/AudioPolicyService.h
@@ -79,7 +79,7 @@
audio_format_t format = AUDIO_FORMAT_DEFAULT,
uint32_t channels = 0,
audio_in_acoustics_t acoustics =
- (audio_in_acoustics_t)0,
+ (audio_in_acoustics_t)0 /*AUDIO_IN_ACOUSTICS_NONE*/,
int audioSession = 0);
virtual status_t startInput(audio_io_handle_t input);
virtual status_t stopInput(audio_io_handle_t input);
@@ -171,7 +171,8 @@
virtual bool threadLoop();
void exit();
- void startToneCommand(int type = 0, audio_stream_type_t stream = AUDIO_STREAM_VOICE_CALL);
+ void startToneCommand(ToneGenerator::tone_type type,
+ audio_stream_type_t stream);
void stopToneCommand();
status_t volumeCommand(audio_stream_type_t stream, float volume, int output, int delayMs = 0);
status_t parametersCommand(int ioHandle, const char *keyValuePairs, int delayMs = 0);
@@ -198,7 +199,7 @@
class ToneData {
public:
- int mType; // tone type (START_TONE only)
+ ToneGenerator::tone_type mType; // tone type (START_TONE only)
audio_stream_type_t mStream; // stream type (START_TONE only)
};