Fix indentation to be multiple of 4.
Make it easier to search:
sp< not sp < to
"switch (...)" instead of "switch(...)" (also "if" and "while")
Remove redundant blank line at start or EOF.
Remove whitespace at end of line.
Remove extra blank lines where they don't add value.
Use git diff -b or -w to verify.
Change-Id: I966b7ba852faa5474be6907fb212f5e267c2874e
class IAudioRecord : public IInterface
{
-public:
+public:
DECLARE_META_INTERFACE(AudioRecord);
/* After it's created the track is not active. Call start() to
virtual status_t start(pid_t tid) = 0;
/* Stop a track. If set, the callback will cease being called and
- * obtainBuffer will return an error. Buffers that are already released
+ * obtainBuffer will return an error. Buffers that are already released
* will be processed, unless flush() is called.
*/
virtual void stop() = 0;
/* get this tracks control block */
- virtual sp<IMemory> getCblk() const = 0;
+ virtual sp<IMemory> getCblk() const = 0;
};
// ----------------------------------------------------------------------------
class IAudioTrack : public IInterface
{
-public:
+public:
DECLARE_META_INTERFACE(AudioTrack);
/* Get this track's control block */
virtual status_t start(pid_t tid) = 0;
/* Stop a track. If set, the callback will cease being called and
- * obtainBuffer will return an error. Buffers that are already released
+ * obtainBuffer will return an error. Buffers that are already released
* will continue to be processed, unless/until flush() is called.
*/
virtual void stop() = 0;
* While muted, the callback, if set, is still called.
*/
virtual void mute(bool) = 0;
-
+
/* Pause a track. If set, the callback will cease being called and
- * obtainBuffer will return an error. Buffers that are already released
+ * obtainBuffer will return an error. Buffers that are already released
* will continue to be processed, unless/until flush() is called.
*/
virtual void pause() = 0;
}; // namespace android
#endif // ANDROID_IMEDIAMETADATARETRIEVER_H
-
}; // namespace android
#endif // ANDROID_IMEDIAPLAYERCLIENT_H
-
}; // namespace android
#endif // ANDROID_IMEDIARECORDERCLIENT_H
-
static const int JET_NUMQUEUEDSEGMENT_UPDATE = 3;
static const int JET_PAUSE_UPDATE = 4;
- JetPlayer(jobject javaJetPlayer,
- int maxTracks = 32,
+ JetPlayer(jobject javaJetPlayer,
+ int maxTracks = 32,
int trackBufferSize = 1200);
~JetPlayer();
int init();
int release();
-
+
int loadFromFile(const char* url);
int loadFromFD(const int fd, const long long offset, const long long length);
int closeFile();
int clearQueue();
void setEventCallback(jetevent_callback callback);
-
+
int getMaxTracks() { return mMaxTracks; };
int mMaxTracks; // max number of MIDI tracks, usually 32
EAS_DATA_HANDLE mEasData;
EAS_FILE_LOCATOR mEasJetFileLoc;
- EAS_PCM* mAudioBuffer;// EAS renders the MIDI data into this buffer,
+ EAS_PCM* mAudioBuffer;// EAS renders the MIDI data into this buffer,
AudioTrack* mAudioTrack; // and we play it in this audio track
int mTrackBufferSize;
S_JET_STATUS mJetStatus;
/*
**
-** Copyright (C) 2008 The Android Open Source Project
+** Copyright (C) 2008 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.
}; // namespace android
#endif // ANDROID_MEDIAMETADATARETRIEVERINTERFACE_H
-
}; // namespace android
#endif // ANDROID_MEDIAPROFILES_H
-
-
/*
* Copyright 2011, The Android Open Source Project
*
namespace android {
// A simple buffer to hold binary data
-class MediaAlbumArt
+class MediaAlbumArt
{
public:
MediaAlbumArt(): mSize(0), mData(0) {}
fclose(in);
}
- MediaAlbumArt(const MediaAlbumArt& copy) {
- mSize = copy.mSize;
- mData = NULL; // initialize it first
+ MediaAlbumArt(const MediaAlbumArt& copy) {
+ mSize = copy.mSize;
+ mData = NULL; // initialize it first
if (mSize > 0 && copy.mData != NULL) {
mData = new uint8_t[copy.mSize];
if (mData != NULL) {
{
public:
VideoFrame(): mWidth(0), mHeight(0), mDisplayWidth(0), mDisplayHeight(0), mSize(0), mData(0) {}
-
+
VideoFrame(const VideoFrame& copy) {
mWidth = copy.mWidth;
mHeight = copy.mHeight;
mIEffect->disconnect();
mIEffect->asBinder()->unlinkToDeath(mIEffectClient);
}
- IPCThreadState::self()->flushCommands();
+ IPCThreadState::self()->flushCommands();
}
mIEffect.clear();
mIEffectClient.clear();
}; // namespace android
-
return WOULD_BLOCK;
}
}
- }
+ }
AutoMutex lock(mLock);
// acquire a strong reference on the IAudioRecord and IMemory so that they cannot be destroyed
// while we are accessing the cblk
- sp <IAudioRecord> audioRecord = mAudioRecord;
- sp <IMemory> iMem = mCblkMemory;
+ sp<IAudioRecord> audioRecord = mAudioRecord;
+ sp<IMemory> iMem = mCblkMemory;
audio_track_cblk_t* cblk = mCblk;
if (mActive == 0) {
mActive = 1;
mLock.lock();
// acquire a strong reference on the IAudioRecord and IMemory so that they cannot be destroyed
// while we are accessing the cblk
- sp <IAudioRecord> audioRecord = mAudioRecord;
- sp <IMemory> iMem = mCblkMemory;
+ sp<IAudioRecord> audioRecord = mAudioRecord;
+ sp<IMemory> iMem = mCblkMemory;
mLock.unlock();
do {
mLock.lock();
// acquire a strong reference on the IAudioRecord and IMemory so that they cannot be destroyed
// while we are accessing the cblk
- sp <IAudioRecord> audioRecord = mAudioRecord;
- sp <IMemory> iMem = mCblkMemory;
+ sp<IAudioRecord> audioRecord = mAudioRecord;
+ sp<IMemory> iMem = mCblkMemory;
audio_track_cblk_t* cblk = mCblk;
mLock.unlock();
}
}
ALOGV("restoreRecord_l() status %d mActive %d cblk %p, old cblk %p flags %08x old flags %08x",
- result, mActive, mCblk, cblk, mCblk->flags, cblk->flags);
+ result, mActive, mCblk, cblk, mCblk->flags, cblk->flags);
if (result == NO_ERROR) {
// from now on we switch to the newly created cblk
// -------------------------------------------------------------------------
}; // namespace android
-
break;
ALOGW("AudioFlinger not published, waiting...");
usleep(500000); // 0.5 s
- } while(true);
+ } while (true);
if (gAudioFlingerClient == NULL) {
gAudioFlingerClient = new AudioFlingerClient();
} else {
if (gAudioErrorCallback) {
gAudioErrorCallback(NO_ERROR);
}
- }
+ }
binder->linkToDeath(gAudioFlingerClient);
gAudioFlinger = interface_cast<IAudioFlinger>(binder);
gAudioFlinger->registerClient(gAudioFlingerClient);
}
bool AudioSystem::routedToA2dpOutput(audio_stream_type_t streamType) {
- switch(streamType) {
+ switch (streamType) {
case AUDIO_STREAM_MUSIC:
case AUDIO_STREAM_VOICE_CALL:
case AUDIO_STREAM_BLUETOOTH_SCO:
break;
ALOGW("AudioPolicyService not published, waiting...");
usleep(500000); // 0.5 s
- } while(true);
+ } while (true);
if (gAudioPolicyServiceClient == NULL) {
gAudioPolicyServiceClient = new AudioPolicyServiceClient();
}
}
}; // namespace android
-
if (minBufCount < 2) minBufCount = 2;
*frameCount = (sampleRate == 0) ? afFrameCount * minBufCount :
- afFrameCount * minBufCount * sampleRate / afSampleRate;
+ afFrameCount * minBufCount * sampleRate / afSampleRate;
return NO_ERROR;
}
return;
}
}
- }
+ }
AutoMutex lock(mLock);
// acquire a strong reference on the IMemory and IAudioTrack so that they cannot be destroyed
// while we are accessing the cblk
- sp <IAudioTrack> audioTrack = mAudioTrack;
- sp <IMemory> iMem = mCblkMemory;
+ sp<IAudioTrack> audioTrack = mAudioTrack;
+ sp<IMemory> iMem = mCblkMemory;
audio_track_cblk_t* cblk = mCblk;
if (!mActive) {
status_t status;
const sp<IAudioFlinger>& audioFlinger = AudioSystem::get_audio_flinger();
if (audioFlinger == 0) {
- ALOGE("Could not get audioflinger");
- return NO_INIT;
+ ALOGE("Could not get audioflinger");
+ return NO_INIT;
}
int afSampleRate;
mCblk->buffers = (char*)mCblk + sizeof(audio_track_cblk_t);
} else {
mCblk->buffers = sharedBuffer->pointer();
- // Force buffer full condition as data is already present in shared memory
+ // Force buffer full condition as data is already present in shared memory
mCblk->stepUser(mCblk->frameCount);
}
// acquire a strong reference on the IMemory and IAudioTrack so that they cannot be destroyed
// while we are accessing the cblk
mLock.lock();
- sp <IAudioTrack> audioTrack = mAudioTrack;
- sp <IMemory> iMem = mCblkMemory;
+ sp<IAudioTrack> audioTrack = mAudioTrack;
+ sp<IMemory> iMem = mCblkMemory;
mLock.unlock();
ssize_t written = 0;
mLock.lock();
// acquire a strong reference on the IMemory and IAudioTrack so that they cannot be destroyed
// while we are accessing the cblk
- sp <IAudioTrack> audioTrack = mAudioTrack;
- sp <IMemory> iMem = mCblkMemory;
+ sp<IAudioTrack> audioTrack = mAudioTrack;
+ sp<IMemory> iMem = mCblkMemory;
audio_track_cblk_t* cblk = mCblk;
bool active = mActive;
mLock.unlock();
if (!(android_atomic_or(CBLK_RESTORING_ON, &cblk->flags) & CBLK_RESTORING_MSK)) {
ALOGW("dead IAudioTrack, creating a new one from %s TID %d",
- fromStart ? "start()" : "obtainBuffer()", gettid());
+ fromStart ? "start()" : "obtainBuffer()", gettid());
// signal old cblk condition so that other threads waiting for available buffers stop
// waiting now
}
}
ALOGV("restoreTrack_l() status %d mActive %d cblk %p, old cblk %p flags %08x old flags %08x",
- result, mActive, mCblk, cblk, mCblk->flags, cblk->flags);
+ result, mActive, mCblk, cblk, mCblk->flags, cblk->flags);
if (result == NO_ERROR) {
// from now on we switch to the newly created cblk
sp<IEffect> effect;
if (pDesc == NULL) {
- return effect;
- if (status) {
- *status = BAD_VALUE;
- }
- }
+ return effect;
+ if (status) {
+ *status = BAD_VALUE;
+ }
+ }
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
data.writeInt32(pid);
status_t BnAudioFlinger::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
- switch(code) {
+ switch (code) {
case CREATE_TRACK: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
pid_t pid = data.readInt32();
reply->writeInt32( latency((audio_io_handle_t) data.readInt32()) );
return NO_ERROR;
} break;
- case SET_MASTER_VOLUME: {
+ case SET_MASTER_VOLUME: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
reply->writeInt32( setMasterVolume(data.readFloat()) );
return NO_ERROR;
String8 keyValuePairs(data.readString8());
reply->writeInt32(setParameters(ioHandle, keyValuePairs));
return NO_ERROR;
- } break;
+ } break;
case GET_PARAMETERS: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
String8 keys(data.readString8());
reply->writeString8(getParameters(ioHandle, keys));
return NO_ERROR;
- } break;
+ } break;
case REGISTER_CLIENT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
status_t BnAudioFlingerClient::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
- switch(code) {
+ switch (code) {
case IO_CONFIG_CHANGED: {
CHECK_INTERFACE(IAudioFlingerClient, data, reply);
int event = data.readInt32();
status_t BnAudioPolicyService::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
- switch(code) {
+ switch (code) {
case SET_DEVICE_CONNECTION_STATE: {
CHECK_INTERFACE(IAudioPolicyService, data, reply);
audio_devices_t device =
**
** Copyright 2007, 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
+** 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
+** 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
+** 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.
*/
: BpInterface<IAudioRecord>(impl)
{
}
-
+
virtual status_t start(pid_t tid)
{
Parcel data, reply;
}
return status;
}
-
+
virtual void stop()
{
Parcel data, reply;
data.writeInterfaceToken(IAudioRecord::getInterfaceDescriptor());
remote()->transact(STOP, data, &reply);
}
-
+
virtual sp<IMemory> getCblk() const
{
Parcel data, reply;
cblk = interface_cast<IMemory>(reply.readStrongBinder());
}
return cblk;
- }
+ }
};
IMPLEMENT_META_INTERFACE(AudioRecord, "android.media.IAudioRecord");
status_t BnAudioRecord::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
- switch(code) {
- case GET_CBLK: {
+ switch (code) {
+ case GET_CBLK: {
CHECK_INTERFACE(IAudioRecord, data, reply);
reply->writeStrongBinder(getCblk()->asBinder());
return NO_ERROR;
}
}; // namespace android
-
**
** Copyright 2007, 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
+** 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
+** 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
+** 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.
*/
: BpInterface<IAudioTrack>(impl)
{
}
-
+
virtual sp<IMemory> getCblk() const
{
Parcel data, reply;
}
return status;
}
-
+
virtual void stop()
{
Parcel data, reply;
data.writeInterfaceToken(IAudioTrack::getInterfaceDescriptor());
remote()->transact(STOP, data, &reply);
}
-
+
virtual void flush()
{
Parcel data, reply;
data.writeInt32(e);
remote()->transact(MUTE, data, &reply);
}
-
+
virtual void pause()
{
Parcel data, reply;
data.writeInterfaceToken(IAudioTrack::getInterfaceDescriptor());
remote()->transact(PAUSE, data, &reply);
}
-
+
virtual status_t attachAuxEffect(int effectId)
{
Parcel data, reply;
status_t BnAudioTrack::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
- switch(code) {
- case GET_CBLK: {
+ switch (code) {
+ case GET_CBLK: {
CHECK_INTERFACE(IAudioTrack, data, reply);
reply->writeStrongBinder(getCblk()->asBinder());
return NO_ERROR;
status_t BnEffect::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
- switch(code) {
+ switch (code) {
case ENABLE: {
ALOGV("ENABLE");
CHECK_INTERFACE(IEffect, data, reply);
} break;
case GET_CBLK: {
- CHECK_INTERFACE(IEffect, data, reply);
- reply->writeStrongBinder(getCblk()->asBinder());
- return NO_ERROR;
- } break;
+ CHECK_INTERFACE(IEffect, data, reply);
+ reply->writeStrongBinder(getCblk()->asBinder());
+ return NO_ERROR;
+ } break;
default:
return BBinder::onTransact(code, data, reply, flags);
// ----------------------------------------------------------------------------
}; // namespace android
-
status_t BnEffectClient::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
- switch(code) {
+ switch (code) {
case CONTROL_STATUS_CHANGED: {
ALOGV("CONTROL_STATUS_CHANGED");
CHECK_INTERFACE(IEffectClient, data, reply);
// ----------------------------------------------------------------------------
}; // namespace android
-
binder = sm->getService(String16("media.player"));
if (binder != 0) {
break;
- }
- ALOGW("Media player service not published, waiting...");
- usleep(500000); // 0.5 s
- } while(true);
+ }
+ ALOGW("Media player service not published, waiting...");
+ usleep(500000); // 0.5 s
+ } while (true);
if (sDeathNotifier == NULL) {
sDeathNotifier = new DeathNotifier();
status_t BnMediaPlayer::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
- switch(code) {
+ switch (code) {
case DISCONNECT: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
disconnect();
status_t BnMediaPlayerClient::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
- switch(code) {
+ switch (code) {
case NOTIFY: {
CHECK_INTERFACE(IMediaPlayerClient, data, reply);
int msg = data.readInt32();
status_t BnMediaPlayerService::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
- switch(code) {
+ switch (code) {
case CREATE: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
pid_t pid = data.readInt32();
status_t BnMediaRecorder::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
- switch(code) {
+ switch (code) {
case RELEASE: {
ALOGV("RELEASE");
CHECK_INTERFACE(IMediaRecorder, data, reply);
status_t BnMediaRecorderClient::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
{
- switch(code) {
+ switch (code) {
case NOTIFY: {
CHECK_INTERFACE(IMediaRecorderClient, data, reply);
int msg = data.readInt32();
// init the EAS library
result = EAS_Init(&mEasData);
- if( result != EAS_SUCCESS) {
+ if (result != EAS_SUCCESS) {
ALOGE("JetPlayer::init(): Error initializing Sonivox EAS library, aborting.");
mState = EAS_STATE_ERROR;
return result;
}
// init the JET library with the default app event controller range
result = JET_Init(mEasData, NULL, sizeof(S_JET_CONFIG));
- if( result != EAS_SUCCESS) {
+ if (result != EAS_SUCCESS) {
ALOGE("JetPlayer::init(): Error initializing JET library, aborting.");
mState = EAS_STATE_ERROR;
return result;
mAudioBuffer = NULL;
}
mEasData = NULL;
-
+
return EAS_SUCCESS;
}
ALOGV("JetPlayer::render(): entering");
// allocate render buffer
- mAudioBuffer =
+ mAudioBuffer =
new EAS_PCM[pLibConfig->mixBufferSize * pLibConfig->numChannels * MIX_NUM_BUFFERS];
// signal main thread that we started
mCondition.signal();
}
- while (1) {
-
+ while (1) {
+
mMutex.lock(); // [[[[[[[[ LOCK ---------------------------------------
if (mEasData == NULL) {
ALOGV("JetPlayer::render(): NULL EAS data, exiting render.");
goto threadExit;
}
-
+
// nothing to render, wait for client thread to wake us up
while (!mRender)
{
ALOGV("JetPlayer::render(): signal wait");
- if (audioStarted) {
- mAudioTrack->pause();
+ if (audioStarted) {
+ mAudioTrack->pause();
// we have to restart the playback once we start rendering again
audioStarted = false;
}
mCondition.wait(mMutex);
ALOGV("JetPlayer::render(): signal rx'd");
}
-
+
// render midi data into the input buffer
int num_output = 0;
EAS_PCM* p = mAudioBuffer;
}
p += count * pLibConfig->numChannels;
num_output += count * pLibConfig->numChannels * sizeof(EAS_PCM);
-
- // send events that were generated (if any) to the event callback
+
+ // send events that were generated (if any) to the event callback
fireEventsFromJetQueue();
}
// precondition: mMutex locked
void JetPlayer::fireUpdateOnStatusChange()
{
- if( (mJetStatus.currentUserID != mPreviousJetStatus.currentUserID)
+ if ( (mJetStatus.currentUserID != mPreviousJetStatus.currentUserID)
||(mJetStatus.segmentRepeatCount != mPreviousJetStatus.segmentRepeatCount) ) {
- if(mEventCallback) {
+ if (mEventCallback) {
mEventCallback(
JetPlayer::JET_USERID_UPDATE,
mJetStatus.currentUserID,
mPreviousJetStatus.segmentRepeatCount = mJetStatus.segmentRepeatCount;
}
- if(mJetStatus.numQueuedSegments != mPreviousJetStatus.numQueuedSegments) {
- if(mEventCallback) {
+ if (mJetStatus.numQueuedSegments != mPreviousJetStatus.numQueuedSegments) {
+ if (mEventCallback) {
mEventCallback(
JetPlayer::JET_NUMQUEUEDSEGMENT_UPDATE,
mJetStatus.numQueuedSegments,
mPreviousJetStatus.numQueuedSegments = mJetStatus.numQueuedSegments;
}
- if(mJetStatus.paused != mPreviousJetStatus.paused) {
- if(mEventCallback) {
+ if (mJetStatus.paused != mPreviousJetStatus.paused) {
+ if (mEventCallback) {
mEventCallback(JetPlayer::JET_PAUSE_UPDATE,
mJetStatus.paused,
-1,
// precondition: mMutex locked
void JetPlayer::fireEventsFromJetQueue()
{
- if(!mEventCallback) {
+ if (!mEventCallback) {
// no callback, just empty the event queue
while (JET_GetEvent(mEasData, NULL, NULL)) { }
return;
mEasJetFileLoc->offset = 0;
EAS_RESULT result = JET_OpenFile(mEasData, mEasJetFileLoc);
- if(result != EAS_SUCCESS)
+ if (result != EAS_SUCCESS)
mState = EAS_STATE_ERROR;
else
mState = EAS_STATE_OPEN;
int JetPlayer::loadFromFD(const int fd, const long long offset, const long long length)
{
ALOGV("JetPlayer::loadFromFD(): fd=%d offset=%lld length=%lld", fd, offset, length);
-
+
Mutex::Autolock lock(mMutex);
mEasJetFileLoc = (EAS_FILE_LOCATOR) malloc(sizeof(EAS_FILE));
mEasJetFileLoc->offset = offset;
mEasJetFileLoc->length = length;
mEasJetFileLoc->path = NULL;
-
+
EAS_RESULT result = JET_OpenFile(mEasData, mEasJetFileLoc);
- if(result != EAS_SUCCESS)
+ if (result != EAS_SUCCESS)
mState = EAS_STATE_ERROR;
else
mState = EAS_STATE_OPEN;
JET_Status(mEasData, &mJetStatus);
this->dumpJetStatus(&mJetStatus);
-
+
fireUpdateOnStatusChange();
// wake up render thread
void JetPlayer::dumpJetStatus(S_JET_STATUS* pJetStatus)
{
- if(pJetStatus!=NULL)
+ if (pJetStatus!=NULL)
ALOGV(">> current JET player status: userID=%d segmentRepeatCount=%d numQueuedSegments=%d paused=%d",
pJetStatus->currentUserID, pJetStatus->segmentRepeatCount,
pJetStatus->numQueuedSegments, pJetStatus->paused);
} // end namespace android
-
camcorder_quality quality) const
{
ALOGV("getCamcorderProfileParamByName: %s for camera %d, quality %d",
- name, cameraId, quality);
+ name, cameraId, quality);
int index = getCamcorderProfileIndex(cameraId, quality);
if (index == -1) {
ALOGE("The given camcorder profile camera %d quality %d is not found",
- cameraId, quality);
+ cameraId, quality);
return -1;
}
void MediaScanner::loadSkipList() {
mSkipList = (char *)malloc(PROPERTY_VALUE_MAX * sizeof(char));
if (mSkipList) {
- property_get("testing.mediascanner.skiplist", mSkipList, "");
+ property_get("testing.mediascanner.skiplist", mSkipList, "");
}
if (!mSkipList || (strlen(mSkipList) == 0)) {
free(mSkipList);
struct dirent* entry;
if (shouldSkipDirectory(path)) {
- ALOGD("Skipping: %s", path);
- return MEDIA_SCAN_RESULT_OK;
+ ALOGD("Skipping: %s", path);
+ return MEDIA_SCAN_RESULT_OK;
}
// Treat all files as non-media in directories that contain a ".nomedia" file
}
} // namespace android
-
Metadata::Metadata(Parcel *p)
:mData(p),
- mBegin(p->dataPosition()) { }
+ mBegin(p->dataPosition()) { }
Metadata::~Metadata() { }
repeatCnt: 0,
repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_SP_PRI
{ segments: { { duration: 0, waveFreq: { 0 }, 0, 0} },
- repeatCnt: 0,
- repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_PAT3
+ repeatCnt: 0,
+ repeatSegment: 0 }, // TONE_CDMA_CALL_SIGNAL_ISDN_PAT3
{ segments: { { duration: 32, waveFreq: { 2091, 0 }, 0, 0 },
{ duration: 64, waveFreq: { 2556, 0 }, 4, 0 },
{ duration: 20, waveFreq: { 2091, 0 }, 0, 0 },
mpAudioTrack = NULL;
}
- // Open audio track in mono, PCM 16bit, default sampling rate, default buffer size
+ // Open audio track in mono, PCM 16bit, default sampling rate, default buffer size
mpAudioTrack = new AudioTrack();
ALOGV("Create Track: %p", mpAudioTrack);
ALOGV("Cbk starting track");
lpToneGen->mState = TONE_PLAYING;
lSignal = true;
- break;
+ break;
case TONE_PLAYING:
- break;
+ break;
default:
// Force loop exit
lNumSmp = 0;
}
} // end namespace android
-
}
}
t->mLock.lock();
- }
+ }
status_t status = AudioEffect::setEnabled(enabled);
}
}; // namespace android
-
}
ALOGW("MediaPlayerService not published, waiting...");
usleep(500000); // 0.5 s
- } while(true);
+ } while (true);
if (sDeathNotifier == NULL) {
sDeathNotifier = new DeathNotifier();
}
(mCurrentState != MEDIA_PLAYER_STATE_ERROR) &&
((mCurrentState & MEDIA_PLAYER_IDLE) != MEDIA_PLAYER_IDLE);
if ((mPlayer != NULL) && hasBeenInitialized) {
- ALOGV("invoke %d", request.dataSize());
- return mPlayer->invoke(request, reply);
+ ALOGV("invoke %d", request.dataSize());
+ return mPlayer->invoke(request, reply);
}
ALOGE("invoke failed: wrong state %X", mCurrentState);
return INVALID_OPERATION;
return BAD_VALUE;
}
if (sessionId != mAudioSessionId) {
- AudioSystem::releaseAudioSessionId(mAudioSessionId);
- AudioSystem::acquireAudioSessionId(sessionId);
- mAudioSessionId = sessionId;
+ AudioSystem::releaseAudioSessionId(mAudioSessionId);
+ AudioSystem::acquireAudioSessionId(sessionId);
+ mAudioSessionId = sessionId;
}
return NO_ERROR;
}
ALOGV("MediaPlayer::getParameter(%d)", key);
Mutex::Autolock _l(mLock);
if (mPlayer != NULL) {
- return mPlayer->getParameter(key, reply);
+ return mPlayer->getParameter(key, reply);
}
ALOGV("getParameter: no active player");
return INVALID_OPERATION;
// and seekTo within the same process.
// FIXME: Remember, this is a hack, it's not even a hack that is applied
// consistently for all use-cases, this needs to be revisited.
- if (mLockThreadId != getThreadId()) {
+ if (mLockThreadId != getThreadId()) {
mLock.lock();
locked = true;
}
status_t MediaRecorder::setCamera(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy)
{
ALOGV("setCamera(%p,%p)", camera.get(), proxy.get());
- if(mMediaRecorder == NULL) {
+ if (mMediaRecorder == NULL) {
ALOGE("media recorder is not initialized yet");
return INVALID_OPERATION;
}
status_t MediaRecorder::setPreviewSurface(const sp<Surface>& surface)
{
ALOGV("setPreviewSurface(%p)", surface.get());
- if(mMediaRecorder == NULL) {
+ if (mMediaRecorder == NULL) {
ALOGE("media recorder is not initialized yet");
return INVALID_OPERATION;
}
status_t MediaRecorder::init()
{
ALOGV("init");
- if(mMediaRecorder == NULL) {
+ if (mMediaRecorder == NULL) {
ALOGE("media recorder is not initialized yet");
return INVALID_OPERATION;
}
status_t MediaRecorder::setVideoSource(int vs)
{
ALOGV("setVideoSource(%d)", vs);
- if(mMediaRecorder == NULL) {
+ if (mMediaRecorder == NULL) {
ALOGE("media recorder is not initialized yet");
return INVALID_OPERATION;
}
status_t MediaRecorder::setAudioSource(int as)
{
ALOGV("setAudioSource(%d)", as);
- if(mMediaRecorder == NULL) {
+ if (mMediaRecorder == NULL) {
ALOGE("media recorder is not initialized yet");
return INVALID_OPERATION;
}
status_t MediaRecorder::setOutputFormat(int of)
{
ALOGV("setOutputFormat(%d)", of);
- if(mMediaRecorder == NULL) {
+ if (mMediaRecorder == NULL) {
ALOGE("media recorder is not initialized yet");
return INVALID_OPERATION;
}
status_t MediaRecorder::setVideoEncoder(int ve)
{
ALOGV("setVideoEncoder(%d)", ve);
- if(mMediaRecorder == NULL) {
+ if (mMediaRecorder == NULL) {
ALOGE("media recorder is not initialized yet");
return INVALID_OPERATION;
}
status_t MediaRecorder::setAudioEncoder(int ae)
{
ALOGV("setAudioEncoder(%d)", ae);
- if(mMediaRecorder == NULL) {
+ if (mMediaRecorder == NULL) {
ALOGE("media recorder is not initialized yet");
return INVALID_OPERATION;
}
status_t MediaRecorder::setOutputFile(const char* path)
{
ALOGV("setOutputFile(%s)", path);
- if(mMediaRecorder == NULL) {
+ if (mMediaRecorder == NULL) {
ALOGE("media recorder is not initialized yet");
return INVALID_OPERATION;
}
status_t MediaRecorder::setOutputFile(int fd, int64_t offset, int64_t length)
{
ALOGV("setOutputFile(%d, %lld, %lld)", fd, offset, length);
- if(mMediaRecorder == NULL) {
+ if (mMediaRecorder == NULL) {
ALOGE("media recorder is not initialized yet");
return INVALID_OPERATION;
}
status_t MediaRecorder::setVideoSize(int width, int height)
{
ALOGV("setVideoSize(%d, %d)", width, height);
- if(mMediaRecorder == NULL) {
+ if (mMediaRecorder == NULL) {
ALOGE("media recorder is not initialized yet");
return INVALID_OPERATION;
}
status_t MediaRecorder::setVideoFrameRate(int frames_per_second)
{
ALOGV("setVideoFrameRate(%d)", frames_per_second);
- if(mMediaRecorder == NULL) {
+ if (mMediaRecorder == NULL) {
ALOGE("media recorder is not initialized yet");
return INVALID_OPERATION;
}
status_t MediaRecorder::setParameters(const String8& params) {
ALOGV("setParameters(%s)", params.string());
- if(mMediaRecorder == NULL) {
+ if (mMediaRecorder == NULL) {
ALOGE("media recorder is not initialized yet");
return INVALID_OPERATION;
}
status_t MediaRecorder::prepare()
{
ALOGV("prepare");
- if(mMediaRecorder == NULL) {
+ if (mMediaRecorder == NULL) {
ALOGE("media recorder is not initialized yet");
return INVALID_OPERATION;
}
status_t MediaRecorder::getMaxAmplitude(int* max)
{
ALOGV("getMaxAmplitude");
- if(mMediaRecorder == NULL) {
+ if (mMediaRecorder == NULL) {
ALOGE("media recorder is not initialized yet");
return INVALID_OPERATION;
}
doCleanUp();
status_t ret = UNKNOWN_ERROR;
- switch(mCurrentState) {
+ switch (mCurrentState) {
case MEDIA_RECORDER_IDLE:
ret = OK;
break;
case MEDIA_RECORDER_ERROR: {
ret = doReset();
if (OK != ret) {
- return ret; // No need to continue
+ return ret; // No need to continue
}
} // Intentional fall through
case MEDIA_RECORDER_INITIALIZED:
continue;
ALOGI("Loaded %s audio interface from %s (%s)", audio_interfaces[i],
- mod->name, mod->id);
+ mod->name, mod->id);
mAudioHwDevs.push(dev);
if (mPrimaryHardwareDev == NULL) {
mPrimaryHardwareDev = dev;
ALOGI("Using '%s' (%s.%s) as the primary audio interface",
- mod->name, mod->id, audio_interfaces[i]);
+ mod->name, mod->id, audio_interfaces[i]);
}
}
}
Exit:
- if(status) {
+ if (status != NULL) {
*status = lStatus;
}
return trackHandle;
mMasterVolume = value;
mMasterVolumeSW = swmv;
for (size_t i = 0; i < mPlaybackThreads.size(); i++)
- mPlaybackThreads.valueAt(i)->setMasterVolume(swmv);
+ mPlaybackThreads.valueAt(i)->setMasterVolume(swmv);
return NO_ERROR;
}
Mutex::Autolock _l(mLock);
mMode = mode;
for (size_t i = 0; i < mPlaybackThreads.size(); i++)
- mPlaybackThreads.valueAt(i)->setMode(mode);
+ mPlaybackThreads.valueAt(i)->setMode(mode);
}
return ret;
// This is an optimization, so PlaybackThread doesn't have to look at the one from AudioFlinger
mMasterMute = muted;
for (size_t i = 0; i < mPlaybackThreads.size(); i++)
- mPlaybackThreads.valueAt(i)->setMasterMute(muted);
+ mPlaybackThreads.valueAt(i)->setMasterMute(muted);
return NO_ERROR;
}
if (thread == NULL) {
for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
- mPlaybackThreads.valueAt(i)->setStreamVolume(stream, value);
+ mPlaybackThreads.valueAt(i)->setStreamVolume(stream, value);
}
} else {
thread->setStreamVolume(stream, value);
AutoMutex lock(mLock);
mStreamTypes[stream].mute = muted;
for (uint32_t i = 0; i < mPlaybackThreads.size(); i++)
- mPlaybackThreads.valueAt(i)->setStreamMute(stream, muted);
+ mPlaybackThreads.valueAt(i)->setStreamMute(stream, muted);
return NO_ERROR;
}
void AudioFlinger::ThreadBase::processConfigEvents()
{
mLock.lock();
- while(!mConfigEvents.isEmpty()) {
+ while (!mConfigEvents.isEmpty()) {
ALOGV("processConfigEvents() remaining events %d", mConfigEvents.size());
ConfigEvent configEvent = mConfigEvents[0];
mConfigEvents.removeAt(0);
mSuspendedSessions.editValueAt(index);
for (size_t i = 0; i < sessionEffects.size(); i++) {
- sp <SuspendedSessionDesc> desc = sessionEffects.valueAt(i);
+ sp<SuspendedSessionDesc> desc = sessionEffects.valueAt(i);
for (int j = 0; j < desc->mRefCount; j++) {
if (sessionEffects.keyAt(i) == EffectChain::kKeyForSuspendAll) {
chain->setEffectSuspendedAll_l(true);
} else {
ALOGV("checkSuspendOnAddEffectChain_l() suspending effects %08x",
- desc->mType.timeLow);
+ desc->mType.timeLow);
chain->setEffectSuspended_l(&desc->mType, true);
}
}
}
index = sessionEffects.indexOfKey(key);
- sp <SuspendedSessionDesc> desc;
+ sp<SuspendedSessionDesc> desc;
if (suspend) {
if (index >= 0) {
desc = sessionEffects.valueAt(index);
// createTrack() was called by the client process.
if (!mStreamTypes[streamType].valid) {
ALOGW("createTrack_l() on thread %p: invalidating track on stream %d",
- this, streamType);
+ this, streamType);
android_atomic_or(CBLK_INVALID_ON, &track->mCblk->flags);
}
}
lStatus = NO_ERROR;
Exit:
- if(status) {
+ if (status) {
*status = lStatus;
}
return track;
status = mOutput->stream->common.set_parameters(&mOutput->stream->common,
keyValuePair.string());
if (!mStandby && status == INVALID_OPERATION) {
- mOutput->stream->common.standby(&mOutput->stream->common);
- mStandby = true;
- mBytesWritten = 0;
- status = mOutput->stream->common.set_parameters(&mOutput->stream->common,
+ mOutput->stream->common.standby(&mOutput->stream->common);
+ mStandby = true;
+ mBytesWritten = 0;
+ status = mOutput->stream->common.set_parameters(&mOutput->stream->common,
keyValuePair.string());
}
if (status == NO_ERROR && reconfig) {
size_t count = mFrameCount * mChannelCount;
uint8_t *src = (uint8_t *)mMixBuffer + count-1;
int16_t *dst = mMixBuffer + count-1;
- while(count--) {
+ while (count--) {
*dst-- = (int16_t)(*src--^0x80) << 8;
}
}
size_t count = mFrameCount * mChannelCount;
int16_t *src = mMixBuffer;
uint8_t *dst = (uint8_t *)mMixBuffer;
- while(count--) {
+ while (count--) {
*dst++ = (uint8_t)(((int32_t)*src++ + (1<<7)) >> 8)^0x80;
}
}
status = mOutput->stream->common.set_parameters(&mOutput->stream->common,
keyValuePair.string());
if (!mStandby && status == INVALID_OPERATION) {
- mOutput->stream->common.standby(&mOutput->stream->common);
- mStandby = true;
- mBytesWritten = 0;
- status = mOutput->stream->common.set_parameters(&mOutput->stream->common,
+ mOutput->stream->common.standby(&mOutput->stream->common);
+ mStandby = true;
+ mBytesWritten = 0;
+ status = mOutput->stream->common.set_parameters(&mOutput->stream->common,
keyValuePair.string());
}
if (status == NO_ERROR && reconfig) {
bool AudioFlinger::DuplicatingThread::outputsReady(const SortedVector< sp<OutputTrack> > &outputTracks)
{
for (size_t i = 0; i < outputTracks.size(); i++) {
- sp <ThreadBase> thread = outputTracks[i]->thread().promote();
+ sp<ThreadBase> thread = outputTracks[i]->thread().promote();
if (thread == 0) {
ALOGW("DuplicatingThread::outputsReady() could not promote thread on output track %p", outputTracks[i].get());
return false;
ALOGV_IF(sharedBuffer != 0, "sharedBuffer: %p, size: %d", sharedBuffer->pointer(), sharedBuffer->size());
// ALOGD("Creating track with %d buffers @ %d bytes", bufferCount, bufferSize);
- size_t size = sizeof(audio_track_cblk_t);
- uint8_t channelCount = popcount(channelMask);
- size_t bufferSize = frameCount*channelCount*sizeof(int16_t);
- if (sharedBuffer == 0) {
- size += bufferSize;
- }
-
- if (client != NULL) {
+ size_t size = sizeof(audio_track_cblk_t);
+ uint8_t channelCount = popcount(channelMask);
+ size_t bufferSize = frameCount*channelCount*sizeof(int16_t);
+ if (sharedBuffer == 0) {
+ size += bufferSize;
+ }
+
+ if (client != NULL) {
mCblkMemory = client->heap()->allocate(size);
if (mCblkMemory != 0) {
mCblk = static_cast<audio_track_cblk_t *>(mCblkMemory->pointer());
client->heap()->dump("AudioTrack");
return;
}
- } else {
- mCblk = (audio_track_cblk_t *)(new uint8_t[size]);
- // construct the shared structure in-place.
- new(mCblk) audio_track_cblk_t();
- // clear all buffers
- mCblk->frameCount = frameCount;
- mCblk->sampleRate = sampleRate;
- mChannelCount = channelCount;
- mChannelMask = channelMask;
- mBuffer = (char*)mCblk + sizeof(audio_track_cblk_t);
- memset(mBuffer, 0, frameCount*channelCount*sizeof(int16_t));
- // Force underrun condition to avoid false underrun callback until first data is
- // written to buffer (other flags are cleared)
- mCblk->flags = CBLK_UNDERRUN_ON;
- mBufferEnd = (uint8_t *)mBuffer + bufferSize;
- }
+ } else {
+ mCblk = (audio_track_cblk_t *)(new uint8_t[size]);
+ // construct the shared structure in-place.
+ new(mCblk) audio_track_cblk_t();
+ // clear all buffers
+ mCblk->frameCount = frameCount;
+ mCblk->sampleRate = sampleRate;
+ mChannelCount = channelCount;
+ mChannelMask = channelMask;
+ mBuffer = (char*)mCblk + sizeof(audio_track_cblk_t);
+ memset(mBuffer, 0, frameCount*channelCount*sizeof(int16_t));
+ // Force underrun condition to avoid false underrun callback until first data is
+ // written to buffer (other flags are cleared)
+ mCblk->flags = CBLK_UNDERRUN_ON;
+ mBufferEnd = (uint8_t *)mBuffer + bufferSize;
+ }
}
AudioFlinger::ThreadBase::TrackBase::~TrackBase()
// AudioBufferProvider interface
status_t AudioFlinger::PlaybackThread::Track::getNextBuffer(
- AudioBufferProvider::Buffer* buffer, int64_t pts)
+ AudioBufferProvider::Buffer* buffer, int64_t pts)
{
- audio_track_cblk_t* cblk = this->cblk();
- uint32_t framesReady;
- uint32_t framesReq = buffer->frameCount;
+ audio_track_cblk_t* cblk = this->cblk();
+ uint32_t framesReady;
+ uint32_t framesReq = buffer->frameCount;
- // Check if last stepServer failed, try to step now
- if (mStepServerFailed) {
- if (!step()) goto getNextBuffer_exit;
- ALOGV("stepServer recovered");
- mStepServerFailed = false;
- }
+ // Check if last stepServer failed, try to step now
+ if (mStepServerFailed) {
+ if (!step()) goto getNextBuffer_exit;
+ ALOGV("stepServer recovered");
+ mStepServerFailed = false;
+ }
- framesReady = cblk->framesReady();
+ framesReady = cblk->framesReady();
- if (CC_LIKELY(framesReady)) {
+ if (CC_LIKELY(framesReady)) {
uint32_t s = cblk->server;
uint32_t bufferEnd = cblk->serverBase + cblk->frameCount;
framesReq = bufferEnd - s;
}
- buffer->raw = getBuffer(s, framesReq);
- if (buffer->raw == NULL) goto getNextBuffer_exit;
+ buffer->raw = getBuffer(s, framesReq);
+ if (buffer->raw == NULL) goto getNextBuffer_exit;
- buffer->frameCount = framesReq;
+ buffer->frameCount = framesReq;
return NO_ERROR;
- }
+ }
getNextBuffer_exit:
- buffer->raw = NULL;
- buffer->frameCount = 0;
- ALOGV("getNextBuffer() no more data for track %d on thread %p", mName, mThread.unsafe_get());
- return NOT_ENOUGH_DATA;
+ buffer->raw = NULL;
+ buffer->frameCount = 0;
+ ALOGV("getNextBuffer() no more data for track %d on thread %p", mName, mThread.unsafe_get());
+ return NOT_ENOUGH_DATA;
}
-uint32_t AudioFlinger::PlaybackThread::Track::framesReady() const{
+uint32_t AudioFlinger::PlaybackThread::Track::framesReady() const {
return mCblk->framesReady();
}
status_t status = DEAD_OBJECT;
sp<ThreadBase> thread = mThread.promote();
if (thread != 0) {
- PlaybackThread *playbackThread = (PlaybackThread *)thread.get();
- status = playbackThread->attachAuxEffect(this, EffectId);
+ PlaybackThread *playbackThread = (PlaybackThread *)thread.get();
+ status = playbackThread->attachAuxEffect(this, EffectId);
}
return status;
}
mOverflow(false)
{
if (mCblk != NULL) {
- ALOGV("RecordTrack constructor, size %d", (int)mBufferEnd - (int)mBuffer);
- if (format == AUDIO_FORMAT_PCM_16_BIT) {
- mCblk->frameSize = mChannelCount * sizeof(int16_t);
- } else if (format == AUDIO_FORMAT_PCM_8_BIT) {
- mCblk->frameSize = mChannelCount * sizeof(int8_t);
- } else {
- mCblk->frameSize = sizeof(int8_t);
- }
+ ALOGV("RecordTrack constructor, size %d", (int)mBufferEnd - (int)mBuffer);
+ if (format == AUDIO_FORMAT_PCM_16_BIT) {
+ mCblk->frameSize = mChannelCount * sizeof(int16_t);
+ } else if (format == AUDIO_FORMAT_PCM_8_BIT) {
+ mCblk->frameSize = mChannelCount * sizeof(int8_t);
+ } else {
+ mCblk->frameSize = sizeof(int8_t);
+ }
}
}
uint32_t framesAvail;
uint32_t framesReq = buffer->frameCount;
- // Check if last stepServer failed, try to step now
+ // Check if last stepServer failed, try to step now
if (mStepServerFailed) {
if (!step()) goto getNextBuffer_exit;
ALOGV("stepServer recovered");
status_t AudioFlinger::RecordThread::start(RecordThread::RecordTrack* recordTrack, pid_t tid)
{
ALOGV("RecordThread::start tid=%d", tid);
- sp <ThreadBase> strongMe = this;
+ sp<ThreadBase> strongMe = this;
status_t status = NO_ERROR;
{
AutoMutex lock(mLock);
void AudioFlinger::RecordThread::stop(RecordThread::RecordTrack* recordTrack) {
ALOGV("RecordThread::stop");
- sp <ThreadBase> strongMe = this;
+ sp<ThreadBase> strongMe = this;
{
AutoMutex lock(mLock);
if (mActiveTrack != 0 && recordTrack == mActiveTrack.get()) {
if (status == NO_ERROR) {
status = mInput->stream->common.set_parameters(&mInput->stream->common, keyValuePair.string());
if (status == INVALID_OPERATION) {
- mInput->stream->common.standby(&mInput->stream->common);
- status = mInput->stream->common.set_parameters(&mInput->stream->common, keyValuePair.string());
+ mInput->stream->common.standby(&mInput->stream->common);
+ status = mInput->stream->common.set_parameters(&mInput->stream->common,
+ keyValuePair.string());
}
if (reconfig) {
if (status == BAD_VALUE &&
if (mSampleRate != mReqSampleRate && mChannelCount <= FCC_2 && mReqChannelCount <= FCC_2)
{
int channelCount;
- // optmization: if mono to mono, use the resampler in stereo to stereo mode to avoid
- // stereo to mono post process as the resampler always outputs stereo.
+ // optimization: if mono to mono, use the resampler in stereo to stereo mode to avoid
+ // stereo to mono post process as the resampler always outputs stereo.
if (mChannelCount == 1 && mReqChannelCount == 2) {
channelCount = 1;
} else {
{
// keep strong reference on the playback thread so that
// it is not destroyed while exit() is executed
- sp <PlaybackThread> thread;
+ sp<PlaybackThread> thread;
{
Mutex::Autolock _l(mLock);
thread = checkPlaybackThread_l(output);
{
// keep strong reference on the record thread so that
// it is not destroyed while exit() is executed
- sp <RecordThread> thread;
+ sp<RecordThread> thread;
{
Mutex::Autolock _l(mLock);
thread = checkRecordThread_l(input);
AudioSessionRef *ref = mAudioSessionRefs.itemAt(k);
if (ref->mSessionid == sessionid) {
ALOGV(" session %d still exists for %d with %d refs",
- sessionid, ref->mPid, ref->mCnt);
+ sessionid, ref->mPid, ref->mCnt);
found = true;
break;
}
// because of code checking output when entering the function.
// Note: io is never 0 when creating an effect on an input
if (io == 0) {
- // look for the thread where the specified audio session is present
+ // look for the thread where the specified audio session is present
for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
if (mPlaybackThreads.valueAt(i)->hasAudioSession(sessionId) != 0) {
io = mPlaybackThreads.keyAt(i);
}
}
if (io == 0) {
- for (size_t i = 0; i < mRecordThreads.size(); i++) {
- if (mRecordThreads.valueAt(i)->hasAudioSession(sessionId) != 0) {
- io = mRecordThreads.keyAt(i);
- break;
- }
- }
+ for (size_t i = 0; i < mRecordThreads.size(); i++) {
+ if (mRecordThreads.valueAt(i)->hasAudioSession(sessionId) != 0) {
+ io = mRecordThreads.keyAt(i);
+ break;
+ }
+ }
}
// If no output thread contains the requested session ID, default to
// first output. The effect chain will be moved to the correct output
}
Exit:
- if(status) {
+ if (status != NULL) {
*status = lStatus;
}
return handle;
handle.clear();
}
- if(status) {
+ if (status != NULL) {
*status = lStatus;
}
return handle;
}
void AudioFlinger::ThreadBase::lockEffectChains_l(
- Vector<sp <AudioFlinger::EffectChain> >& effectChains)
+ Vector< sp<AudioFlinger::EffectChain> >& effectChains)
{
effectChains = mEffectChains;
for (size_t i = 0; i < mEffectChains.size(); i++) {
}
void AudioFlinger::ThreadBase::unlockEffectChains(
- const Vector<sp <AudioFlinger::EffectChain> >& effectChains)
+ const Vector< sp<AudioFlinger::EffectChain> >& effectChains)
{
for (size_t i = 0; i < effectChains.size(); i++) {
effectChains[i]->unlock();
void AudioFlinger::PlaybackThread::detachAuxEffect_l(int effectId)
{
- for (size_t i = 0; i < mTracks.size(); ++i) {
+ for (size_t i = 0; i < mTracks.size(); ++i) {
sp<Track> track = mTracks[i];
if (track->auxEffectId() == effectId) {
attachAuxEffect_l(track, 0);
if (mCblk != NULL) {
new(mCblk) effect_param_cblk_t();
mBuffer = (uint8_t *)mCblk + bufOffset;
- }
+ }
} else {
ALOGE("not enough memory for Effect size=%u", EFFECT_PARAM_BUFFER_SIZE + sizeof(effect_param_cblk_t));
return;
}
}
ALOGV("checkSuspendOnEffectEnabled() enable suspending fx %08x",
- effect->desc().type.timeLow);
+ effect->desc().type.timeLow);
sp<SuspendedEffectDesc> desc = mSuspendedEffects.valueAt(index);
// if effect is requested to suspended but was not yet enabled, supend it now.
if (desc->mEffect == 0) {
return;
}
ALOGV("checkSuspendOnEffectEnabled() disable restoring fx %08x",
- effect->desc().type.timeLow);
+ effect->desc().type.timeLow);
sp<SuspendedEffectDesc> desc = mSuspendedEffects.valueAt(index);
desc->mEffect.clear();
effect->setSuspended(false);
// ThreadBase mutex before processing the mixer and effects. This guarantees the
// integrity of the chains during the process.
// Also sets the parameter 'effectChains' to current value of mEffectChains.
- void lockEffectChains_l(Vector<sp <EffectChain> >& effectChains);
+ void lockEffectChains_l(Vector< sp<EffectChain> >& effectChains);
// unlock effect chains after process
- void unlockEffectChains(const Vector<sp<EffectChain> >& effectChains);
+ void unlockEffectChains(const Vector< sp<EffectChain> >& effectChains);
// set audio mode to all effect chains
void setMode(audio_mode_t mode);
// get effect module with corresponding ID on specified audio session
virtual uint32_t activeSleepTimeUs();
private:
- bool outputsReady(const SortedVector<sp<OutputTrack> > &outputTracks);
+ bool outputsReady(const SortedVector< sp<OutputTrack> > &outputTracks);
protected:
// threadLoop snippets
virtual void threadLoop_mix();
uint32_t strategy() const { return mStrategy; }
void setStrategy(uint32_t strategy)
- { mStrategy = strategy; }
+ { mStrategy = strategy; }
// suspend effect of the given type
void setEffectSuspended_l(const effect_uuid_t *type,
wp<ThreadBase> mThread; // parent mixer thread
Mutex mLock; // mutex protecting effect list
- Vector<sp<EffectModule> > mEffects; // list of effect modules
+ Vector< sp<EffectModule> > mEffects; // list of effect modules
int mSessionId; // audio session ID
int16_t *mInBuffer; // chain input buffer
int16_t *mOutBuffer; // chain output buffer
mLock.lock();
while (!exitPending())
{
- while(!mAudioCommands.isEmpty()) {
+ while (!mAudioCommands.isEmpty()) {
nsecs_t curTime = systemTime();
// commands are sorted by increasing time stamp: execute them from index 0 and up
if (mAudioCommands[0]->mTime <= curTime) {
delete data;
}break;
case SET_PARAMETERS: {
- ParametersData *data = (ParametersData *)command->mParam;
- ALOGV("AudioCommandThread() processing set parameters string %s, io %d",
- data->mKeyValuePairs.string(), data->mIO);
- command->mStatus = AudioSystem::setParameters(data->mIO, data->mKeyValuePairs);
- if (command->mWaitStatus) {
- command->mCond.signal();
- mWaitWorkCV.wait(mLock);
- }
- delete data;
- }break;
+ ParametersData *data = (ParametersData *)command->mParam;
+ ALOGV("AudioCommandThread() processing set parameters string %s, io %d",
+ data->mKeyValuePairs.string(), data->mIO);
+ command->mStatus = AudioSystem::setParameters(data->mIO, data->mKeyValuePairs);
+ if (command->mWaitStatus) {
+ command->mCond.signal();
+ mWaitWorkCV.wait(mLock);
+ }
+ delete data;
+ }break;
case SET_VOICE_VOLUME: {
VoiceVolumeData *data = (VoiceVolumeData *)command->mParam;
ALOGV("AudioCommandThread() processing set voice volume volume %f",
AudioParameter param = AudioParameter(data->mKeyValuePairs);
AudioParameter param2 = AudioParameter(data2->mKeyValuePairs);
for (size_t j = 0; j < param.size(); j++) {
- String8 key;
- String8 value;
- param.getAt(j, key, value);
- for (size_t k = 0; k < param2.size(); k++) {
- String8 key2;
- String8 value2;
- param2.getAt(k, key2, value2);
- if (key2 == key) {
- param2.remove(key2);
- ALOGV("Filtering out parameter %s", key2.string());
- break;
- }
- }
+ String8 key;
+ String8 value;
+ param.getAt(j, key, value);
+ for (size_t k = 0; k < param2.size(); k++) {
+ String8 key2;
+ String8 value2;
+ param2.getAt(k, key2, value2);
+ if (key2 == key) {
+ param2.remove(key2);
+ ALOGV("Filtering out parameter %s", key2.string());
+ break;
+ }
+ }
}
// if all keys have been filtered out, remove the command.
// otherwise, update the key value pairs
ALOGE("startTone: illegal tone requested (%d)", tone);
if (stream != AUDIO_STREAM_VOICE_CALL)
ALOGE("startTone: illegal stream (%d) requested for tone %d", stream,
- tone);
+ tone);
mTonePlaybackThread->startToneCommand(ToneGenerator::TONE_SUP_CALL_WAITING,
AUDIO_STREAM_VOICE_CALL);
return 0;
mutable Mutex mLock; // prevents concurrent access to AudioPolicy manager functions changing
// device connection state or routing
- sp <AudioCommandThread> mAudioCommandThread; // audio commands thread
- sp <AudioCommandThread> mTonePlaybackThread; // tone playback thread
+ sp<AudioCommandThread> mAudioCommandThread; // audio commands thread
+ sp<AudioCommandThread> mTonePlaybackThread; // tone playback thread
struct audio_policy_device *mpAudioPolicyDev;
struct audio_policy *mpAudioPolicy;
KeyedVector< audio_source_t, InputSourceDesc* > mInputSources;
mX0L = mBuffer.i16[mBuffer.frameCount*2-2];
mX0R = mBuffer.i16[mBuffer.frameCount*2-1];
provider->releaseBuffer(&mBuffer);
- // mBuffer.frameCount == 0 now so we reload a new buffer
+ // mBuffer.frameCount == 0 now so we reload a new buffer
}
int16_t *in = mBuffer.i16;
// HIGH_QUALITY: fixed multi-tap FIR (e.g. 48KHz->44.1KHz)
// NOTE: high quality SRC will only be supported for
// certain fixed rate conversions. Sample rate cannot be
- // changed dynamically.
+ // changed dynamically.
enum src_quality {
DEFAULT=0,
LOW_QUALITY=1,
p->y1 = p->y2;
p->y2 = p->y3;
p->y3 = in;
- p->a = (3 * (p->y1 - p->y2) - p->y0 + p->y3) >> 1;
+ p->a = (3 * (p->y1 - p->y2) - p->y0 + p->y3) >> 1;
p->b = (p->y2 << 1) + p->y0 - (((5 * p->y1 + p->y3)) >> 1);
p->c = (p->y2 - p->y0) >> 1;
}
} else {
read<CHANNELS>(impulse, phaseFraction, mBuffer.i16, inputIndex);
}
- }
+ }
}
int16_t *in = mBuffer.i16;
const size_t frameCount = mBuffer.frameCount;
if (inputIndex >= frameCount)
break; // need a new buffer
read<CHANNELS>(impulse, phaseFraction, in, inputIndex);
- } else if(phaseIndex == 2) { // maximum value
+ } else if (phaseIndex == 2) { // maximum value
inputIndex++;
if (inputIndex >= frameCount)
break; // 0 frame available, 2 frames needed