summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRicardo Cerqueira <cyanogenmod@cerqueira.org>2013-11-01 16:05:30 +0000
committerRicardo Cerqueira <cyanogenmod@cerqueira.org>2013-11-01 16:05:30 +0000
commit1ed613c615bc0b74c1c5953056b21f02ee464eee (patch)
tree01fff43e1c87da5cad9a5d5665e5915b79de6a59
parent073b5888c2af197c129b1b8d2a4deeaf9870e2ed (diff)
parentf0c3b4edf597c40aae4ea311575f39c8bcf203df (diff)
downloadandroid_frameworks_wilhelm-stable/cm-11.0-XNG3C.tar.gz
android_frameworks_wilhelm-stable/cm-11.0-XNG3C.tar.bz2
android_frameworks_wilhelm-stable/cm-11.0-XNG3C.zip
Android 4.4 Release 1.0
-rw-r--r--src/android/AudioPlayer_to_android.cpp6
-rw-r--r--src/android/AudioRecorder_to_android.cpp25
-rw-r--r--src/android/CallbackProtector.cpp6
-rw-r--r--src/android/VideoCodec_to_android.cpp3
-rw-r--r--src/classes.h5
-rw-r--r--src/devices.c4
-rw-r--r--src/itf/IEngine.c5
-rw-r--r--tests/sandbox/Android.mk39
-rw-r--r--tests/sandbox/playbq.c2
9 files changed, 60 insertions, 35 deletions
diff --git a/src/android/AudioPlayer_to_android.cpp b/src/android/AudioPlayer_to_android.cpp
index 43a9353..d72cf4b 100644
--- a/src/android/AudioPlayer_to_android.cpp
+++ b/src/android/AudioPlayer_to_android.cpp
@@ -1332,9 +1332,9 @@ SLresult android_audioPlayer_getConfig(CAudioPlayer* ap, const SLchar *configKey
static bool canUseFastTrack(CAudioPlayer *pAudioPlayer)
{
assert(pAudioPlayer->mAndroidObjType == AUDIOPLAYER_FROM_PCM_BUFFERQUEUE);
- if (pAudioPlayer->mBufferQueue.mNumBuffers < 2) {
- return false;
- }
+
+ // no need to check the buffer queue size, application side
+ // double-buffering (and more) is not a requirement for using fast tracks
// Check a blacklist of interfaces that are incompatible with fast tracks.
// The alternative, to check a whitelist of compatible interfaces, is
diff --git a/src/android/AudioRecorder_to_android.cpp b/src/android/AudioRecorder_to_android.cpp
index 6a22d6f..ebb9592 100644
--- a/src/android/AudioRecorder_to_android.cpp
+++ b/src/android/AudioRecorder_to_android.cpp
@@ -61,7 +61,7 @@ SLresult audioRecorder_setPreset(CAudioRecorder* ar, SLuint32 recordPreset) {
}
// recording preset needs to be set before the object is realized
- // (ap->mAudioRecord is supposed to be NULL until then)
+ // (ap->mAudioRecord is supposed to be 0 until then)
if (SL_OBJECT_STATE_UNREALIZED != ar->mObject.mState) {
SL_LOGE(ERROR_RECORDERPRESET_REALIZED);
result = SL_RESULT_PRECONDITIONS_VIOLATED;
@@ -311,7 +311,7 @@ SLresult android_audioRecorder_create(CAudioRecorder* ar) {
(SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE == sinkLocatorType)) {
// microphone to simple buffer queue
ar->mAndroidObjType = AUDIORECORDER_FROM_MIC_TO_PCM_BUFFERQUEUE;
- ar->mAudioRecord = NULL;
+ ar->mAudioRecord.clear();
ar->mRecordSource = AUDIO_SOURCE_DEFAULT;
} else {
result = SL_RESULT_CONTENT_UNSUPPORTED;
@@ -393,6 +393,9 @@ SLresult android_audioRecorder_realize(CAudioRecorder* ar, SLboolean async) {
SL_LOGV("new AudioRecord %u channels, %u mHz", ar->mNumChannels, ar->mSampleRateMilliHz);
+ // currently nothing analogous to canUseFastTrack() for recording
+ audio_input_flags_t policy = AUDIO_INPUT_FLAG_FAST;
+
// initialize platform-specific CAudioRecorder fields
ar->mAudioRecord = new android::AudioRecord();
ar->mAudioRecord->set(ar->mRecordSource, // source
@@ -404,8 +407,12 @@ SLresult android_audioRecorder_realize(CAudioRecorder* ar, SLboolean async) {
audioRecorder_callback,// callback_t
(void*)ar, // user, callback data, here the AudioRecorder
0, // notificationFrames
- false); // threadCanCallJava, note: this will prevent direct Java
+ false, // threadCanCallJava, note: this will prevent direct Java
// callbacks, but we don't want them in the recording loop
+ 0, // session ID
+ android::AudioRecord::TRANSFER_CALLBACK,
+ // transfer type
+ policy); // audio_input_flags_t
if (android::NO_ERROR != ar->mAudioRecord->initCheck()) {
SL_LOGE("android_audioRecorder_realize(%p) error creating AudioRecord object", ar);
@@ -426,11 +433,11 @@ SLresult android_audioRecorder_realize(CAudioRecorder* ar, SLboolean async) {
void android_audioRecorder_destroy(CAudioRecorder* ar) {
SL_LOGV("android_audioRecorder_destroy(%p) entering", ar);
- if (NULL != ar->mAudioRecord) {
+ if (ar->mAudioRecord != 0) {
ar->mAudioRecord->stop();
- delete ar->mAudioRecord;
- ar->mAudioRecord = NULL;
}
+ // explicit destructor
+ ar->mAudioRecord.~sp();
#ifdef MONITOR_RECORDING
if (NULL != gMonitorFp) {
@@ -445,7 +452,7 @@ void android_audioRecorder_destroy(CAudioRecorder* ar) {
void android_audioRecorder_setRecordState(CAudioRecorder* ar, SLuint32 state) {
SL_LOGV("android_audioRecorder_setRecordState(%p, %u) entering", ar, state);
- if (NULL == ar->mAudioRecord) {
+ if (ar->mAudioRecord == 0) {
return;
}
@@ -474,7 +481,7 @@ void android_audioRecorder_useRecordEventMask(CAudioRecorder *ar) {
IRecord *pRecordItf = &ar->mRecord;
SLuint32 eventFlags = pRecordItf->mCallbackEventsMask;
- if (NULL == ar->mAudioRecord) {
+ if (ar->mAudioRecord == 0) {
return;
}
@@ -524,7 +531,7 @@ void android_audioRecorder_useRecordEventMask(CAudioRecorder *ar) {
//-----------------------------------------------------------------------------
void android_audioRecorder_getPosition(CAudioRecorder *ar, SLmillisecond *pPosMsec) {
- if ((NULL == ar) || (NULL == ar->mAudioRecord)) {
+ if ((NULL == ar) || (ar->mAudioRecord == 0)) {
*pPosMsec = 0;
} else {
uint32_t positionInFrames;
diff --git a/src/android/CallbackProtector.cpp b/src/android/CallbackProtector.cpp
index 85eceac..7b9f107 100644
--- a/src/android/CallbackProtector.cpp
+++ b/src/android/CallbackProtector.cpp
@@ -27,9 +27,9 @@ CallbackProtector::CallbackProtector() : RefBase(),
mSafeToEnterCb(true),
mCbCount(0)
#ifdef USE_DEBUG
- , mCallbackThread(NULL),
+ , mCallbackThread((pthread_t) NULL),
mCallbackTid(0),
- mRequesterThread(NULL),
+ mRequesterThread((pthread_t) NULL),
mRequesterTid(0)
#endif
{
@@ -101,7 +101,7 @@ void CallbackProtector::exitCb() {
mCbExitedCondition.broadcast();
}
#ifdef USE_DEBUG
- mCallbackThread = NULL;
+ mCallbackThread = (pthread_t) NULL;
mCallbackTid = 0;
#endif
}
diff --git a/src/android/VideoCodec_to_android.cpp b/src/android/VideoCodec_to_android.cpp
index 113bd8c..0d5dd22 100644
--- a/src/android/VideoCodec_to_android.cpp
+++ b/src/android/VideoCodec_to_android.cpp
@@ -31,7 +31,8 @@ static const char *kVideoMimeTypes[] = {
MEDIA_MIMETYPE_VIDEO_H263,
MEDIA_MIMETYPE_VIDEO_MPEG4,
MEDIA_MIMETYPE_VIDEO_AVC,
- MEDIA_MIMETYPE_VIDEO_VPX
+ MEDIA_MIMETYPE_VIDEO_VP8,
+ MEDIA_MIMETYPE_VIDEO_VP9
};
// must == kMaxVideoDecoders
static const size_t kNbVideoMimeTypes = sizeof(kVideoMimeTypes) / sizeof(kVideoMimeTypes[0]);
diff --git a/src/classes.h b/src/classes.h
index 5ccbbae..977772d 100644
--- a/src/classes.h
+++ b/src/classes.h
@@ -147,9 +147,10 @@
SLuint32 mSampleRateMilliHz;// initially UNKNOWN_SAMPLERATE, then const once it is known
// implementation-specific data for this instance
#ifdef ANDROID
+ // FIXME consolidate the next several variables into ARecorder class to avoid placement new
enum AndroidObjectType mAndroidObjType;
- android::AudioRecord *mAudioRecord; //FIXME candidate to be encapsulated in a ARecorder subclass
- audio_source_t mRecordSource; //FIXME candidate to be encapsulated in a ARecorder subclass
+ android::sp<android::AudioRecord> mAudioRecord;
+ audio_source_t mRecordSource;
#endif
} /*CAudioRecorder*/;
diff --git a/src/devices.c b/src/devices.c
index 920dd5e..9959360 100644
--- a/src/devices.c
+++ b/src/devices.c
@@ -89,7 +89,7 @@ const struct AudioOutput_id_descriptor AudioOutput_id_descriptors[] = {
static const SLLEDDescriptor SLLEDDescriptor_default = {
32, // ledCount
0, // primaryLED
- ~0 // colorMask
+ (SLuint32) ~0 // colorMask
};
const struct LED_id_descriptor LED_id_descriptors[] = {
@@ -169,7 +169,7 @@ static const SLAudioCodecDescriptor CodecDescriptor_A = {
sizeof(SamplingRates_A) / sizeof(SamplingRates_A[0]),
// numSampleRatesSupported
1, // minBitRate
- ~0, // maxBitRate
+ (SLuint32) ~0, // maxBitRate
SL_BOOLEAN_TRUE, // isBitrateRangeContinuous
NULL, // pBitratesSupported
0, // numBitratesSupported
diff --git a/src/itf/IEngine.c b/src/itf/IEngine.c
index 4b6d2b6..6950baf 100644
--- a/src/itf/IEngine.c
+++ b/src/itf/IEngine.c
@@ -449,7 +449,10 @@ static SLresult IEngine_CreateAudioRecorder(SLEngineItf self, SLObjectItf *pReco
thiz->mNumChannels = UNKNOWN_NUMCHANNELS;
thiz->mSampleRateMilliHz = UNKNOWN_SAMPLERATE;
#ifdef ANDROID
- thiz->mAudioRecord = NULL;
+ // placement new (explicit constructor)
+ // FIXME unnecessary once those fields are encapsulated in one class, rather
+ // than a structure
+ (void) new (&thiz->mAudioRecord) android::sp<android::AudioRecord>();
thiz->mRecordSource = AUDIO_SOURCE_DEFAULT;
#endif
diff --git a/tests/sandbox/Android.mk b/tests/sandbox/Android.mk
index dab840d..af4d750 100644
--- a/tests/sandbox/Android.mk
+++ b/tests/sandbox/Android.mk
@@ -75,7 +75,8 @@ LOCAL_SHARED_LIBRARIES := \
libOpenSLES
LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
+ libOpenSLESUT \
+ liblog
ifeq ($(TARGET_OS),linux)
LOCAL_CFLAGS += -DXP_UNIX
@@ -106,7 +107,8 @@ LOCAL_SHARED_LIBRARIES := \
libOpenSLES
LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
+ libOpenSLESUT \
+ liblog
ifeq ($(TARGET_OS),linux)
LOCAL_CFLAGS += -DXP_UNIX
@@ -163,7 +165,8 @@ LOCAL_SHARED_LIBRARIES := \
libOpenSLES
LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
+ libOpenSLESUT \
+ liblog
ifeq ($(TARGET_OS),linux)
LOCAL_CFLAGS += -DXP_UNIX
@@ -193,7 +196,8 @@ LOCAL_SHARED_LIBRARIES := \
libOpenSLES
LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
+ libOpenSLESUT \
+ liblog
ifeq ($(TARGET_OS),linux)
LOCAL_CFLAGS += -DXP_UNIX
@@ -224,7 +228,8 @@ LOCAL_SHARED_LIBRARIES := \
libOpenSLES
LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
+ libOpenSLESUT \
+ liblog
ifeq ($(TARGET_OS),linux)
LOCAL_CFLAGS += -DXP_UNIX
@@ -254,7 +259,8 @@ LOCAL_SHARED_LIBRARIES := \
libOpenSLES
LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
+ libOpenSLESUT \
+ liblog
ifeq ($(TARGET_OS),linux)
LOCAL_CFLAGS += -DXP_UNIX
@@ -284,7 +290,8 @@ LOCAL_SHARED_LIBRARIES := \
libOpenSLES
LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
+ libOpenSLESUT \
+ liblog
ifeq ($(TARGET_OS),linux)
LOCAL_CFLAGS += -DXP_UNIX
@@ -314,7 +321,8 @@ LOCAL_SHARED_LIBRARIES := \
libOpenSLES
LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
+ libOpenSLESUT \
+ liblog
ifeq ($(TARGET_OS),linux)
LOCAL_CFLAGS += -DXP_UNIX
@@ -348,7 +356,8 @@ LOCAL_SHARED_LIBRARIES := \
LOCAL_STATIC_LIBRARIES := \
libOpenSLESUT \
- libsndfile
+ libsndfile \
+ liblog
ifeq ($(TARGET_OS),linux)
LOCAL_CFLAGS += -DXP_UNIX
@@ -378,7 +387,8 @@ LOCAL_SHARED_LIBRARIES := \
libOpenSLES
LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
+ libOpenSLESUT \
+ liblog
ifeq ($(TARGET_OS),linux)
LOCAL_CFLAGS += -DXP_UNIX
@@ -408,7 +418,8 @@ LOCAL_SHARED_LIBRARIES := \
libOpenMAXAL
LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
+ libOpenSLESUT \
+ liblog
ifeq ($(TARGET_OS),linux)
LOCAL_CFLAGS += -DXP_UNIX
@@ -439,7 +450,8 @@ LOCAL_SHARED_LIBRARIES := \
libOpenMAXAL
LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
+ libOpenSLESUT \
+ liblog
ifeq ($(TARGET_OS),linux)
LOCAL_CFLAGS += -DXP_UNIX
@@ -472,7 +484,8 @@ LOCAL_SHARED_LIBRARIES := \
libandroid
LOCAL_STATIC_LIBRARIES := \
- libOpenSLESUT
+ libOpenSLESUT \
+ liblog
ifeq ($(TARGET_OS),linux)
LOCAL_CFLAGS += -DXP_UNIX
diff --git a/tests/sandbox/playbq.c b/tests/sandbox/playbq.c
index 9a33f4d..a6e7b46 100644
--- a/tests/sandbox/playbq.c
+++ b/tests/sandbox/playbq.c
@@ -373,7 +373,7 @@ int main(int argc, char **argv)
// get the playback rate interface and configure the rate
SLPlaybackRateItf playerPlaybackRate;
- SLpermille currentRate;
+ SLpermille currentRate = 0;
if (enablePlaybackRate) {
result = (*playerObject)->GetInterface(playerObject, SL_IID_PLAYBACKRATE,
&playerPlaybackRate);