Merge "Fix race in AudioSystem::getInputBufferSize"
diff --git a/include/media/IAudioTrack.h b/include/media/IAudioTrack.h
index 3fa2bf8..b83e552 100644
--- a/include/media/IAudioTrack.h
+++ b/include/media/IAudioTrack.h
@@ -35,6 +35,9 @@
public:
DECLARE_META_INTERFACE(AudioTrack);
+ /* Get this track's control block */
+ virtual sp<IMemory> getCblk() const = 0;
+
/* After it's created the track is not active. Call start() to
* make it active. If set, the callback will start being called.
*/
@@ -67,8 +70,6 @@
*/
virtual status_t attachAuxEffect(int effectId) = 0;
- /* get this track's control block */
- virtual sp<IMemory> getCblk() const = 0;
};
// ----------------------------------------------------------------------------
diff --git a/include/media/JetPlayer.h b/include/media/JetPlayer.h
index 6d53989..491a950 100644
--- a/include/media/JetPlayer.h
+++ b/include/media/JetPlayer.h
@@ -94,7 +94,7 @@
S_JET_STATUS mJetStatus;
S_JET_STATUS mPreviousJetStatus;
- char mJetFilePath[256];
+ char mJetFilePath[PATH_MAX];
class JetPlayerThread : public Thread {
public:
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index caa3d30..9d4137e 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -158,7 +158,7 @@
status_t AudioSystem::setMode(int mode)
{
- if (mode >= AUDIO_MODE_CNT) return BAD_VALUE;
+ if (uint32_t(mode) >= AUDIO_MODE_CNT) return BAD_VALUE;
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
return af->setMode(mode);
diff --git a/media/libmedia/IAudioTrack.cpp b/media/libmedia/IAudioTrack.cpp
index 0b372f3..e618619 100644
--- a/media/libmedia/IAudioTrack.cpp
+++ b/media/libmedia/IAudioTrack.cpp
@@ -46,6 +46,18 @@
{
}
+ virtual sp<IMemory> getCblk() const
+ {
+ Parcel data, reply;
+ sp<IMemory> cblk;
+ data.writeInterfaceToken(IAudioTrack::getInterfaceDescriptor());
+ status_t status = remote()->transact(GET_CBLK, data, &reply);
+ if (status == NO_ERROR) {
+ cblk = interface_cast<IMemory>(reply.readStrongBinder());
+ }
+ return cblk;
+ }
+
virtual status_t start()
{
Parcel data, reply;
@@ -88,18 +100,6 @@
remote()->transact(PAUSE, data, &reply);
}
- virtual sp<IMemory> getCblk() const
- {
- Parcel data, reply;
- sp<IMemory> cblk;
- data.writeInterfaceToken(IAudioTrack::getInterfaceDescriptor());
- status_t status = remote()->transact(GET_CBLK, data, &reply);
- if (status == NO_ERROR) {
- cblk = interface_cast<IMemory>(reply.readStrongBinder());
- }
- return cblk;
- }
-
virtual status_t attachAuxEffect(int effectId)
{
Parcel data, reply;
diff --git a/media/libmedia/JetPlayer.cpp b/media/libmedia/JetPlayer.cpp
index 188e582..38f05f2 100644
--- a/media/libmedia/JetPlayer.cpp
+++ b/media/libmedia/JetPlayer.cpp
@@ -338,8 +338,8 @@
Mutex::Autolock lock(mMutex);
mEasJetFileLoc = (EAS_FILE_LOCATOR) malloc(sizeof(EAS_FILE));
- memset(mJetFilePath, 0, 256);
- strncpy(mJetFilePath, path, strlen(path));
+ strncpy(mJetFilePath, path, sizeof(mJetFilePath));
+ mJetFilePath[sizeof(mJetFilePath) - 1] = '\0';
mEasJetFileLoc->path = mJetFilePath;
mEasJetFileLoc->fd = 0;
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 7a2d7b3..d0cb7ff 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -1841,6 +1841,10 @@
return;
}
mAudioStatusEventPending = true;
+ // Do not honor delay when looping in order to limit audio gap
+ if (mFlags & (LOOPING | AUTO_LOOPING)) {
+ delayUs = 0;
+ }
mQueue.postEventWithDelay(mCheckAudioStatusEvent, delayUs);
}
diff --git a/media/mediaserver/main_mediaserver.cpp b/media/mediaserver/main_mediaserver.cpp
index 21496a9..1520c01 100644
--- a/media/mediaserver/main_mediaserver.cpp
+++ b/media/mediaserver/main_mediaserver.cpp
@@ -15,6 +15,8 @@
** limitations under the License.
*/
+#define LOG_TAG "mediaserver"
+
#include <binder/IPCThreadState.h>
#include <binder/ProcessState.h>
#include <binder/IServiceManager.h>
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index 4ddefdb..9fb666e 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -294,7 +294,7 @@
const size_t SIZE = 256;
char buffer[SIZE];
String8 result;
- int hardwareStatus = mHardwareStatus;
+ hardware_call_state hardwareStatus = mHardwareStatus;
snprintf(buffer, SIZE, "Hardware status: %d\n", hardwareStatus);
result.append(buffer);
@@ -574,7 +574,7 @@
if (!settingsAllowed()) {
return PERMISSION_DENIED;
}
- if ((mode < 0) || (mode >= AUDIO_MODE_CNT)) {
+ if (uint32_t(mode) >= AUDIO_MODE_CNT) {
ALOGW("Illegal value: setMode(%d)", mode);
return BAD_VALUE;
}
@@ -1011,7 +1011,7 @@
ALOGV("ThreadBase::exit");
{
- AutoMutex lock(&mLock);
+ AutoMutex lock(mLock);
mExiting = true;
requestExit();
mWaitWorkCV.signal();
@@ -3243,7 +3243,7 @@
}
} else {
mCblk = (audio_track_cblk_t *)(new uint8_t[size]);
- if (mCblk) { // construct the shared structure in-place.
+ // construct the shared structure in-place.
new(mCblk) audio_track_cblk_t();
// clear all buffers
mCblk->frameCount = frameCount;
@@ -3256,7 +3256,6 @@
// written to buffer (other flags are cleared)
mCblk->flags = CBLK_UNDERRUN_ON;
mBufferEnd = (uint8_t *)mBuffer + bufferSize;
- }
}
}
@@ -4506,7 +4505,7 @@
sp <ThreadBase> strongMe = this;
status_t status = NO_ERROR;
{
- AutoMutex lock(&mLock);
+ AutoMutex lock(mLock);
if (mActiveTrack != 0) {
if (recordTrack != mActiveTrack.get()) {
status = -EBUSY;
@@ -4558,7 +4557,7 @@
ALOGV("RecordThread::stop");
sp <ThreadBase> strongMe = this;
{
- AutoMutex lock(&mLock);
+ AutoMutex lock(mLock);
if (mActiveTrack != 0 && recordTrack == mActiveTrack.get()) {
mActiveTrack->mState = TrackBase::PAUSING;
// do not wait for mStartStopCond if exiting
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index ff8dedb..f99e764 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -1383,7 +1383,7 @@
mutable Mutex mHardwareLock;
audio_hw_device_t* mPrimaryHardwareDev;
Vector<audio_hw_device_t*> mAudioHwDevs;
- mutable int mHardwareStatus;
+ mutable hardware_call_state mHardwareStatus; // for dump only
DefaultKeyedVector< int, sp<PlaybackThread> > mPlaybackThreads;
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index 8df4605..a8102e5 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -309,7 +309,7 @@
inline
void AudioMixer::track_t::adjustVolumeRamp(bool aux)
{
- for (int i=0 ; i<MAX_NUM_CHANNELS ; i++) {
+ for (uint32_t i=0 ; i<MAX_NUM_CHANNELS ; i++) {
if (((volumeInc[i]>0) && (((prevVolume[i]+volumeInc[i])>>16) >= volume[i])) ||
((volumeInc[i]<0) && (((prevVolume[i]+volumeInc[i])>>16) <= volume[i]))) {
volumeInc[i] = 0;
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index f572fce..3f86d58 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -193,7 +193,7 @@
if (!checkPermission()) {
return PERMISSION_DENIED;
}
- if (state < 0 || state >= AUDIO_MODE_CNT) {
+ if (uint32_t(state) >= AUDIO_MODE_CNT) {
return BAD_VALUE;
}