Merge "Enable B frame support in MPEG4Writer"
diff --git a/include/media/AudioEffect.h b/include/media/AudioEffect.h
index 7b0b443..02dfc1b 100644
--- a/include/media/AudioEffect.h
+++ b/include/media/AudioEffect.h
@@ -108,7 +108,8 @@
* Returned value
* *descriptor updated with effect descriptor
*/
- static status_t getEffectDescriptor(effect_uuid_t *uuid, effect_descriptor_t *descriptor);
+ static status_t getEffectDescriptor(const effect_uuid_t *uuid,
+ effect_descriptor_t *descriptor) /*const*/;
/*
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index c8c5dba..ca57f9e 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -344,7 +344,6 @@
virtual status_t readyToRun() { return NO_ERROR; }
virtual void onFirstRef() {}
AudioRecord& mReceiver;
- Mutex mLock;
};
bool processAudioBuffer(const sp<ClientRecordThread>& thread);
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index 74a1e62..da99620 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -55,8 +55,10 @@
static status_t getMasterMute(bool* mute);
// set/get stream volume on specified output
- static status_t setStreamVolume(audio_stream_type_t stream, float value, int output);
- static status_t getStreamVolume(audio_stream_type_t stream, float* volume, int output);
+ static status_t setStreamVolume(audio_stream_type_t stream, float value,
+ audio_io_handle_t output);
+ static status_t getStreamVolume(audio_stream_type_t stream, float* volume,
+ audio_io_handle_t output);
// mute/unmute stream
static status_t setStreamMute(audio_stream_type_t stream, bool mute);
@@ -217,7 +219,7 @@
// indicate a change in the configuration of an output or input: keeps the cached
// values for output/input parameters upto date in client process
- virtual void ioConfigChanged(int event, int ioHandle, void *param2);
+ virtual void ioConfigChanged(int event, audio_io_handle_t ioHandle, void *param2);
};
class AudioPolicyServiceClient: public IBinder::DeathRecipient
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index 02c85cd..11db81b 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -273,18 +273,18 @@
* left and right volumes. Levels must be >= 0.0 and <= 1.0.
*/
status_t setVolume(float left, float right);
- void getVolume(float* left, float* right);
+ void getVolume(float* left, float* right) const;
/* Set the send level for this track. An auxiliary effect should be attached
* to the track with attachEffect(). Level must be >= 0.0 and <= 1.0.
*/
status_t setAuxEffectSendLevel(float level);
- void getAuxEffectSendLevel(float* level);
+ void getAuxEffectSendLevel(float* level) const;
/* Set sample rate for this track, mostly used for games' sound effects
*/
status_t setSampleRate(int sampleRate);
- uint32_t getSampleRate();
+ uint32_t getSampleRate() const;
/* Enables looping and sets the start and end points of looping.
*
@@ -299,7 +299,7 @@
* (loopEnd-loopStart) <= framecount()
*/
status_t setLoop(uint32_t loopStart, uint32_t loopEnd, int loopCount);
- status_t getLoop(uint32_t *loopStart, uint32_t *loopEnd, int *loopCount);
+ status_t getLoop(uint32_t *loopStart, uint32_t *loopEnd, int *loopCount) const;
/* Sets marker position. When playback reaches the number of frames specified, a callback with
* event type EVENT_MARKER is called. Calling setMarkerPosition with marker == 0 cancels marker
@@ -315,7 +315,7 @@
* - INVALID_OPERATION: the AudioTrack has no callback installed.
*/
status_t setMarkerPosition(uint32_t marker);
- status_t getMarkerPosition(uint32_t *marker);
+ status_t getMarkerPosition(uint32_t *marker) const;
/* Sets position update period. Every time the number of frames specified has been played,
@@ -333,7 +333,7 @@
* - INVALID_OPERATION: the AudioTrack has no callback installed.
*/
status_t setPositionUpdatePeriod(uint32_t updatePeriod);
- status_t getPositionUpdatePeriod(uint32_t *updatePeriod);
+ status_t getPositionUpdatePeriod(uint32_t *updatePeriod) const;
/* Sets playback head position within AudioTrack buffer. The new position is specified
* in number of frames.
@@ -384,7 +384,7 @@
* Returned value:
* AudioTrack session ID.
*/
- int getSessionId();
+ int getSessionId() const;
/* Attach track auxiliary output to specified effect. Use effectId = 0
* to detach track from effect.
@@ -446,7 +446,6 @@
virtual status_t readyToRun();
virtual void onFirstRef();
AudioTrack& mReceiver;
- Mutex mLock;
};
bool processAudioBuffer(const sp<AudioTrackThread>& thread);
diff --git a/include/media/EffectsFactoryApi.h b/include/media/EffectsFactoryApi.h
index 8ae13cc..df83995 100644
--- a/include/media/EffectsFactoryApi.h
+++ b/include/media/EffectsFactoryApi.h
@@ -109,7 +109,7 @@
// *pHandle: updated with the effect handle.
//
////////////////////////////////////////////////////////////////////////////////
-int EffectCreate(effect_uuid_t *pEffectUuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle);
+int EffectCreate(const effect_uuid_t *pEffectUuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle);
////////////////////////////////////////////////////////////////////////////////
//
@@ -151,7 +151,7 @@
// *pDescriptor: updated with the effect descriptor.
//
////////////////////////////////////////////////////////////////////////////////
-int EffectGetDescriptor(effect_uuid_t *pEffectUuid, effect_descriptor_t *pDescriptor);
+int EffectGetDescriptor(const effect_uuid_t *pEffectUuid, effect_descriptor_t *pDescriptor);
////////////////////////////////////////////////////////////////////////////////
//
@@ -167,7 +167,7 @@
// 1 if uuid is equal to EFFECT_UUID_NULL.
//
////////////////////////////////////////////////////////////////////////////////
-int EffectIsNullUuid(effect_uuid_t *pEffectUuid);
+int EffectIsNullUuid(const effect_uuid_t *pEffectUuid);
#if __cplusplus
} // extern "C"
diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h
index 760595c..433ce7c 100644
--- a/include/media/IAudioFlinger.h
+++ b/include/media/IAudioFlinger.h
@@ -27,6 +27,7 @@
#include <media/IAudioTrack.h>
#include <media/IAudioRecord.h>
#include <media/IAudioFlingerClient.h>
+#include <system/audio.h>
#include <hardware/audio_effect.h>
#include <media/IEffect.h>
#include <media/IEffectClient.h>
@@ -53,13 +54,13 @@
int frameCount,
uint32_t flags,
const sp<IMemory>& sharedBuffer,
- int output,
+ audio_io_handle_t output,
int *sessionId,
status_t *status) = 0;
virtual sp<IAudioRecord> openRecord(
pid_t pid,
- int input,
+ audio_io_handle_t input,
uint32_t sampleRate,
audio_format_t format,
uint32_t channelMask,
@@ -71,11 +72,11 @@
/* query the audio hardware state. This state never changes,
* and therefore can be cached.
*/
- virtual uint32_t sampleRate(int output) const = 0;
- virtual int channelCount(int output) const = 0;
- virtual audio_format_t format(int output) const = 0;
- virtual size_t frameCount(int output) const = 0;
- virtual uint32_t latency(int output) const = 0;
+ virtual uint32_t sampleRate(audio_io_handle_t output) const = 0;
+ virtual int channelCount(audio_io_handle_t output) const = 0;
+ virtual audio_format_t format(audio_io_handle_t output) const = 0;
+ virtual size_t frameCount(audio_io_handle_t output) const = 0;
+ virtual uint32_t latency(audio_io_handle_t output) const = 0;
/* set/get the audio hardware state. This will probably be used by
* the preference panel, mostly.
@@ -89,10 +90,12 @@
/* set/get stream type state. This will probably be used by
* the preference panel, mostly.
*/
- virtual status_t setStreamVolume(audio_stream_type_t stream, float value, int output) = 0;
+ virtual status_t setStreamVolume(audio_stream_type_t stream, float value,
+ audio_io_handle_t output) = 0;
virtual status_t setStreamMute(audio_stream_type_t stream, bool muted) = 0;
- virtual float streamVolume(audio_stream_type_t stream, int output) const = 0;
+ virtual float streamVolume(audio_stream_type_t stream,
+ audio_io_handle_t output) const = 0;
virtual bool streamMute(audio_stream_type_t stream) const = 0;
// set audio mode
@@ -102,63 +105,68 @@
virtual status_t setMicMute(bool state) = 0;
virtual bool getMicMute() const = 0;
- virtual status_t setParameters(int ioHandle, const String8& keyValuePairs) = 0;
- virtual String8 getParameters(int ioHandle, const String8& keys) = 0;
+ virtual status_t setParameters(audio_io_handle_t ioHandle,
+ const String8& keyValuePairs) = 0;
+ virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const = 0;
// register a current process for audio output change notifications
virtual void registerClient(const sp<IAudioFlingerClient>& client) = 0;
// retrieve the audio recording buffer size
- virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount) = 0;
+ virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount) const = 0;
- virtual int openOutput(uint32_t *pDevices,
+ virtual audio_io_handle_t openOutput(uint32_t *pDevices,
uint32_t *pSamplingRate,
audio_format_t *pFormat,
uint32_t *pChannels,
uint32_t *pLatencyMs,
uint32_t flags) = 0;
- virtual int openDuplicateOutput(int output1, int output2) = 0;
- virtual status_t closeOutput(int output) = 0;
- virtual status_t suspendOutput(int output) = 0;
- virtual status_t restoreOutput(int output) = 0;
+ virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1,
+ audio_io_handle_t output2) = 0;
+ virtual status_t closeOutput(audio_io_handle_t output) = 0;
+ virtual status_t suspendOutput(audio_io_handle_t output) = 0;
+ virtual status_t restoreOutput(audio_io_handle_t output) = 0;
- virtual int openInput(uint32_t *pDevices,
+ virtual audio_io_handle_t openInput(uint32_t *pDevices,
uint32_t *pSamplingRate,
audio_format_t *pFormat,
uint32_t *pChannels,
audio_in_acoustics_t acoustics) = 0;
- virtual status_t closeInput(int input) = 0;
+ virtual status_t closeInput(audio_io_handle_t input) = 0;
- virtual status_t setStreamOutput(audio_stream_type_t stream, int output) = 0;
+ virtual status_t setStreamOutput(audio_stream_type_t stream, audio_io_handle_t output) = 0;
virtual status_t setVoiceVolume(float volume) = 0;
- virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output) = 0;
+ virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames,
+ audio_io_handle_t output) const = 0;
- virtual unsigned int getInputFramesLost(int ioHandle) = 0;
+ virtual unsigned int getInputFramesLost(audio_io_handle_t ioHandle) const = 0;
virtual int newAudioSessionId() = 0;
virtual void acquireAudioSessionId(int audioSession) = 0;
virtual void releaseAudioSessionId(int audioSession) = 0;
- virtual status_t queryNumberEffects(uint32_t *numEffects) = 0;
+ virtual status_t queryNumberEffects(uint32_t *numEffects) const = 0;
- virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) = 0;
+ virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) const = 0;
- virtual status_t getEffectDescriptor(effect_uuid_t *pEffectUUID, effect_descriptor_t *pDescriptor) = 0;
+ virtual status_t getEffectDescriptor(const effect_uuid_t *pEffectUUID,
+ effect_descriptor_t *pDescriptor) const = 0;
virtual sp<IEffect> createEffect(pid_t pid,
effect_descriptor_t *pDesc,
const sp<IEffectClient>& client,
int32_t priority,
- int output,
+ audio_io_handle_t output,
int sessionId,
status_t *status,
int *id,
int *enabled) = 0;
- virtual status_t moveEffects(int session, int srcOutput, int dstOutput) = 0;
+ virtual status_t moveEffects(int session, audio_io_handle_t srcOutput,
+ audio_io_handle_t dstOutput) = 0;
};
diff --git a/include/media/IAudioFlingerClient.h b/include/media/IAudioFlingerClient.h
index aa0cdcf..f3b4df1 100644
--- a/include/media/IAudioFlingerClient.h
+++ b/include/media/IAudioFlingerClient.h
@@ -21,6 +21,7 @@
#include <utils/RefBase.h>
#include <binder/IInterface.h>
#include <utils/KeyedVector.h>
+#include <system/audio.h>
namespace android {
@@ -32,7 +33,7 @@
DECLARE_META_INTERFACE(AudioFlingerClient);
// Notifies a change of audio input/output configuration.
- virtual void ioConfigChanged(int event, int ioHandle, void *param2) = 0;
+ virtual void ioConfigChanged(int event, audio_io_handle_t ioHandle, void *param2) = 0;
};
diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h
index dd97ce4..23226c0 100644
--- a/include/private/media/AudioTrackShared.h
+++ b/include/private/media/AudioTrackShared.h
@@ -54,6 +54,7 @@
#define CBLK_RESTORED_ON 0x0040 // track has been restored after invalidation
#define CBLK_RESTORED_OFF 0x0040 // by AudioFlinger
+// Important: do not add any virtual methods, including ~
struct audio_track_cblk_t
{
diff --git a/media/libeffects/factory/EffectsFactory.c b/media/libeffects/factory/EffectsFactory.c
index 9f6599f..59cd9e3 100644
--- a/media/libeffects/factory/EffectsFactory.c
+++ b/media/libeffects/factory/EffectsFactory.c
@@ -53,8 +53,8 @@
static lib_entry_t *getLibrary(const char *path);
static void resetEffectEnumeration();
static uint32_t updateNumEffects();
-static int findEffect(effect_uuid_t *type,
- effect_uuid_t *uuid,
+static int findEffect(const effect_uuid_t *type,
+ const effect_uuid_t *uuid,
lib_entry_t **lib,
effect_descriptor_t **desc);
static void dumpEffectDescriptor(effect_descriptor_t *desc, char *str, size_t len);
@@ -236,7 +236,7 @@
return ret;
}
-int EffectGetDescriptor(effect_uuid_t *uuid, effect_descriptor_t *pDescriptor)
+int EffectGetDescriptor(const effect_uuid_t *uuid, effect_descriptor_t *pDescriptor)
{
lib_entry_t *l = NULL;
effect_descriptor_t *d = NULL;
@@ -257,7 +257,7 @@
return ret;
}
-int EffectCreate(effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle)
+int EffectCreate(const effect_uuid_t *uuid, int32_t sessionId, int32_t ioId, effect_handle_t *pHandle)
{
list_elem_t *e = gLibraryList;
lib_entry_t *l = NULL;
@@ -372,7 +372,7 @@
return ret;
}
-int EffectIsNullUuid(effect_uuid_t *uuid)
+int EffectIsNullUuid(const effect_uuid_t *uuid)
{
if (memcmp(uuid, EFFECT_UUID_NULL, sizeof(effect_uuid_t))) {
return 0;
@@ -628,8 +628,8 @@
return cnt;
}
-int findEffect(effect_uuid_t *type,
- effect_uuid_t *uuid,
+int findEffect(const effect_uuid_t *type,
+ const effect_uuid_t *uuid,
lib_entry_t **lib,
effect_descriptor_t **desc)
{
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index 108d36a..3714283 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -195,7 +195,7 @@
return 0;
} /* end EffectQueryEffect */
-extern "C" int EffectCreate(effect_uuid_t *uuid,
+extern "C" int EffectCreate(const effect_uuid_t *uuid,
int32_t sessionId,
int32_t ioId,
effect_handle_t *pHandle){
@@ -471,7 +471,7 @@
} /* end EffectRelease */
-extern "C" int EffectGetDescriptor(effect_uuid_t *uuid,
+extern "C" int EffectGetDescriptor(const effect_uuid_t *uuid,
effect_descriptor_t *pDescriptor) {
const effect_descriptor_t *desc = NULL;
diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
index 09cd5cc..358357e 100755
--- a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
+++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
@@ -210,7 +210,7 @@
return 0;
} /* end EffectQueryEffect */
-extern "C" int EffectCreate(effect_uuid_t *uuid,
+extern "C" int EffectCreate(const effect_uuid_t *uuid,
int32_t sessionId,
int32_t ioId,
effect_handle_t *pHandle){
@@ -317,7 +317,7 @@
return 0;
} /* end EffectRelease */
-extern "C" int EffectGetDescriptor(effect_uuid_t *uuid,
+extern "C" int EffectGetDescriptor(const effect_uuid_t *uuid,
effect_descriptor_t *pDescriptor) {
int i;
int length = sizeof(gDescriptors) / sizeof(const effect_descriptor_t *);
diff --git a/media/libeffects/preprocessing/PreProcessing.cpp b/media/libeffects/preprocessing/PreProcessing.cpp
index 9fd6764..4d94a75 100755
--- a/media/libeffects/preprocessing/PreProcessing.cpp
+++ b/media/libeffects/preprocessing/PreProcessing.cpp
@@ -1072,7 +1072,7 @@
return sInitStatus;
}
-const effect_descriptor_t *PreProc_GetDescriptor(effect_uuid_t *uuid)
+const effect_descriptor_t *PreProc_GetDescriptor(const effect_uuid_t *uuid)
{
size_t i;
for (i = 0; i < PREPROC_NUM_EFFECTS; i++) {
@@ -1568,7 +1568,7 @@
return 0;
}
-int PreProcessingLib_Create(effect_uuid_t *uuid,
+int PreProcessingLib_Create(const effect_uuid_t *uuid,
int32_t sessionId,
int32_t ioId,
effect_handle_t *pInterface)
@@ -1620,7 +1620,7 @@
return Session_ReleaseEffect(fx->session, fx);
}
-int PreProcessingLib_GetDescriptor(effect_uuid_t *uuid,
+int PreProcessingLib_GetDescriptor(const effect_uuid_t *uuid,
effect_descriptor_t *pDescriptor) {
if (pDescriptor == NULL || uuid == NULL){
diff --git a/media/libeffects/testlibs/EffectEqualizer.cpp b/media/libeffects/testlibs/EffectEqualizer.cpp
index 5241660..35a4a61 100644
--- a/media/libeffects/testlibs/EffectEqualizer.cpp
+++ b/media/libeffects/testlibs/EffectEqualizer.cpp
@@ -140,7 +140,7 @@
return 0;
} /* end EffectQueryNext */
-extern "C" int EffectCreate(effect_uuid_t *uuid,
+extern "C" int EffectCreate(const effect_uuid_t *uuid,
int32_t sessionId,
int32_t ioId,
effect_handle_t *pHandle) {
@@ -195,7 +195,7 @@
return 0;
} /* end EffectRelease */
-extern "C" int EffectGetDescriptor(effect_uuid_t *uuid,
+extern "C" int EffectGetDescriptor(const effect_uuid_t *uuid,
effect_descriptor_t *pDescriptor) {
if (pDescriptor == NULL || uuid == NULL){
diff --git a/media/libeffects/testlibs/EffectReverb.c b/media/libeffects/testlibs/EffectReverb.c
index ebb72c1..8351712 100644
--- a/media/libeffects/testlibs/EffectReverb.c
+++ b/media/libeffects/testlibs/EffectReverb.c
@@ -111,7 +111,7 @@
return 0;
}
-int EffectCreate(effect_uuid_t *uuid,
+int EffectCreate(const effect_uuid_t *uuid,
int32_t sessionId,
int32_t ioId,
effect_handle_t *pHandle) {
@@ -182,7 +182,7 @@
return 0;
}
-int EffectGetDescriptor(effect_uuid_t *uuid,
+int EffectGetDescriptor(const effect_uuid_t *uuid,
effect_descriptor_t *pDescriptor) {
int i;
int length = sizeof(gDescriptors) / sizeof(const effect_descriptor_t *);
diff --git a/media/libeffects/testlibs/EffectReverb.h b/media/libeffects/testlibs/EffectReverb.h
index 5137074..1fb14a7 100644
--- a/media/libeffects/testlibs/EffectReverb.h
+++ b/media/libeffects/testlibs/EffectReverb.h
@@ -303,12 +303,12 @@
int EffectQueryNumberEffects(uint32_t *pNumEffects);
int EffectQueryEffect(uint32_t index,
effect_descriptor_t *pDescriptor);
-int EffectCreate(effect_uuid_t *effectUID,
+int EffectCreate(const effect_uuid_t *effectUID,
int32_t sessionId,
int32_t ioId,
effect_handle_t *pHandle);
int EffectRelease(effect_handle_t handle);
-int EffectGetDescriptor(effect_uuid_t *uuid,
+int EffectGetDescriptor(const effect_uuid_t *uuid,
effect_descriptor_t *pDescriptor);
static int Reverb_Process(effect_handle_t self,
diff --git a/media/libeffects/visualizer/EffectVisualizer.cpp b/media/libeffects/visualizer/EffectVisualizer.cpp
index 5d70a9b..51c8b68 100644
--- a/media/libeffects/visualizer/EffectVisualizer.cpp
+++ b/media/libeffects/visualizer/EffectVisualizer.cpp
@@ -190,7 +190,7 @@
return 0;
}
-int VisualizerLib_Create(effect_uuid_t *uuid,
+int VisualizerLib_Create(const effect_uuid_t *uuid,
int32_t sessionId,
int32_t ioId,
effect_handle_t *pHandle) {
@@ -240,7 +240,7 @@
return 0;
}
-int VisualizerLib_GetDescriptor(effect_uuid_t *uuid,
+int VisualizerLib_GetDescriptor(const effect_uuid_t *uuid,
effect_descriptor_t *pDescriptor) {
if (pDescriptor == NULL || uuid == NULL){
diff --git a/media/libmedia/AudioEffect.cpp b/media/libmedia/AudioEffect.cpp
index a242846..6549ce6 100644
--- a/media/libmedia/AudioEffect.cpp
+++ b/media/libmedia/AudioEffect.cpp
@@ -412,7 +412,8 @@
return af->queryEffect(index, descriptor);
}
-status_t AudioEffect::getEffectDescriptor(effect_uuid_t *uuid, effect_descriptor_t *descriptor)
+status_t AudioEffect::getEffectDescriptor(const effect_uuid_t *uuid,
+ effect_descriptor_t *descriptor) /*const*/
{
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index c96bc76..b74b3e3 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -293,7 +293,6 @@
return WOULD_BLOCK;
}
}
- t->mLock.lock();
}
AutoMutex lock(mLock);
@@ -334,10 +333,6 @@
}
}
- if (t != 0) {
- t->mLock.unlock();
- }
-
return ret;
}
@@ -347,10 +342,6 @@
ALOGV("stop");
- if (t != 0) {
- t->mLock.lock();
- }
-
AutoMutex lock(mLock);
if (mActive == 1) {
mActive = 0;
@@ -367,10 +358,6 @@
}
}
- if (t != 0) {
- t->mLock.unlock();
- }
-
return NO_ERROR;
}
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index 110a294..ec4c044 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -121,7 +121,8 @@
return NO_ERROR;
}
-status_t AudioSystem::setStreamVolume(audio_stream_type_t stream, float value, int output)
+status_t AudioSystem::setStreamVolume(audio_stream_type_t stream, float value,
+ audio_io_handle_t output)
{
if (uint32_t(stream) >= AUDIO_STREAM_CNT) return BAD_VALUE;
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
@@ -139,7 +140,8 @@
return NO_ERROR;
}
-status_t AudioSystem::getStreamVolume(audio_stream_type_t stream, float* volume, int output)
+status_t AudioSystem::getStreamVolume(audio_stream_type_t stream, float* volume,
+ audio_io_handle_t output)
{
if (uint32_t(stream) >= AUDIO_STREAM_CNT) return BAD_VALUE;
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
@@ -402,7 +404,8 @@
ALOGW("AudioFlinger server died!");
}
-void AudioSystem::AudioFlingerClient::ioConfigChanged(int event, int ioHandle, void *param2) {
+void AudioSystem::AudioFlingerClient::ioConfigChanged(int event, audio_io_handle_t ioHandle,
+ void *param2) {
ALOGV("ioConfigChanged() event %d", event);
OutputDescriptor *desc;
audio_stream_type_t stream;
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 8c33f41..087d7b2 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -345,7 +345,6 @@
return;
}
}
- t->mLock.lock();
}
AutoMutex lock(mLock);
@@ -396,9 +395,6 @@
}
}
- if (t != 0) {
- t->mLock.unlock();
- }
}
void AudioTrack::stop()
@@ -406,9 +402,6 @@
sp<AudioTrackThread> t = mAudioTrackThread;
ALOGV("stop %p", this);
- if (t != 0) {
- t->mLock.lock();
- }
AutoMutex lock(mLock);
if (mActive) {
@@ -434,9 +427,6 @@
}
}
- if (t != 0) {
- t->mLock.unlock();
- }
}
bool AudioTrack::stopped() const
@@ -506,7 +496,7 @@
return NO_ERROR;
}
-void AudioTrack::getVolume(float* left, float* right)
+void AudioTrack::getVolume(float* left, float* right) const
{
if (left != NULL) {
*left = mVolume[LEFT];
@@ -531,7 +521,7 @@
return NO_ERROR;
}
-void AudioTrack::getAuxEffectSendLevel(float* level)
+void AudioTrack::getAuxEffectSendLevel(float* level) const
{
if (level != NULL) {
*level = mSendLevel;
@@ -553,7 +543,7 @@
return NO_ERROR;
}
-uint32_t AudioTrack::getSampleRate()
+uint32_t AudioTrack::getSampleRate() const
{
AutoMutex lock(mLock);
return mCblk->sampleRate;
@@ -601,7 +591,7 @@
return NO_ERROR;
}
-status_t AudioTrack::getLoop(uint32_t *loopStart, uint32_t *loopEnd, int *loopCount)
+status_t AudioTrack::getLoop(uint32_t *loopStart, uint32_t *loopEnd, int *loopCount) const
{
AutoMutex lock(mLock);
if (loopStart != NULL) {
@@ -631,7 +621,7 @@
return NO_ERROR;
}
-status_t AudioTrack::getMarkerPosition(uint32_t *marker)
+status_t AudioTrack::getMarkerPosition(uint32_t *marker) const
{
if (marker == NULL) return BAD_VALUE;
@@ -652,7 +642,7 @@
return NO_ERROR;
}
-status_t AudioTrack::getPositionUpdatePeriod(uint32_t *updatePeriod)
+status_t AudioTrack::getPositionUpdatePeriod(uint32_t *updatePeriod) const
{
if (updatePeriod == NULL) return BAD_VALUE;
@@ -712,7 +702,7 @@
mCblk->sampleRate, mFormat, mChannelMask, (audio_policy_output_flags_t)mFlags);
}
-int AudioTrack::getSessionId()
+int AudioTrack::getSessionId() const
{
return mSessionId;
}
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index fc5520f..c3252e7 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -89,7 +89,7 @@
int frameCount,
uint32_t flags,
const sp<IMemory>& sharedBuffer,
- int output,
+ audio_io_handle_t output,
int *sessionId,
status_t *status)
{
@@ -104,7 +104,7 @@
data.writeInt32(frameCount);
data.writeInt32(flags);
data.writeStrongBinder(sharedBuffer->asBinder());
- data.writeInt32(output);
+ data.writeInt32((int32_t) output);
int lSessionId = 0;
if (sessionId != NULL) {
lSessionId = *sessionId;
@@ -129,7 +129,7 @@
virtual sp<IAudioRecord> openRecord(
pid_t pid,
- int input,
+ audio_io_handle_t input,
uint32_t sampleRate,
audio_format_t format,
uint32_t channelMask,
@@ -142,7 +142,7 @@
sp<IAudioRecord> record;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
data.writeInt32(pid);
- data.writeInt32(input);
+ data.writeInt32((int32_t) input);
data.writeInt32(sampleRate);
data.writeInt32(format);
data.writeInt32(channelMask);
@@ -170,47 +170,47 @@
return record;
}
- virtual uint32_t sampleRate(int output) const
+ virtual uint32_t sampleRate(audio_io_handle_t output) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(output);
+ data.writeInt32((int32_t) output);
remote()->transact(SAMPLE_RATE, data, &reply);
return reply.readInt32();
}
- virtual int channelCount(int output) const
+ virtual int channelCount(audio_io_handle_t output) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(output);
+ data.writeInt32((int32_t) output);
remote()->transact(CHANNEL_COUNT, data, &reply);
return reply.readInt32();
}
- virtual audio_format_t format(int output) const
+ virtual audio_format_t format(audio_io_handle_t output) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(output);
+ data.writeInt32((int32_t) output);
remote()->transact(FORMAT, data, &reply);
return (audio_format_t) reply.readInt32();
}
- virtual size_t frameCount(int output) const
+ virtual size_t frameCount(audio_io_handle_t output) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(output);
+ data.writeInt32((int32_t) output);
remote()->transact(FRAME_COUNT, data, &reply);
return reply.readInt32();
}
- virtual uint32_t latency(int output) const
+ virtual uint32_t latency(audio_io_handle_t output) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(output);
+ data.writeInt32((int32_t) output);
remote()->transact(LATENCY, data, &reply);
return reply.readInt32();
}
@@ -249,13 +249,14 @@
return reply.readInt32();
}
- virtual status_t setStreamVolume(audio_stream_type_t stream, float value, int output)
+ virtual status_t setStreamVolume(audio_stream_type_t stream, float value,
+ audio_io_handle_t output)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
data.writeInt32((int32_t) stream);
data.writeFloat(value);
- data.writeInt32(output);
+ data.writeInt32((int32_t) output);
remote()->transact(SET_STREAM_VOLUME, data, &reply);
return reply.readInt32();
}
@@ -270,12 +271,12 @@
return reply.readInt32();
}
- virtual float streamVolume(audio_stream_type_t stream, int output) const
+ virtual float streamVolume(audio_stream_type_t stream, audio_io_handle_t output) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
data.writeInt32((int32_t) stream);
- data.writeInt32(output);
+ data.writeInt32((int32_t) output);
remote()->transact(STREAM_VOLUME, data, &reply);
return reply.readFloat();
}
@@ -315,21 +316,21 @@
return reply.readInt32();
}
- virtual status_t setParameters(int ioHandle, const String8& keyValuePairs)
+ virtual status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(ioHandle);
+ data.writeInt32((int32_t) ioHandle);
data.writeString8(keyValuePairs);
remote()->transact(SET_PARAMETERS, data, &reply);
return reply.readInt32();
}
- virtual String8 getParameters(int ioHandle, const String8& keys)
+ virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(ioHandle);
+ data.writeInt32((int32_t) ioHandle);
data.writeString8(keys);
remote()->transact(GET_PARAMETERS, data, &reply);
return reply.readString8();
@@ -343,7 +344,7 @@
remote()->transact(REGISTER_CLIENT, data, &reply);
}
- virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount)
+ virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
@@ -354,7 +355,7 @@
return reply.readInt32();
}
- virtual int openOutput(uint32_t *pDevices,
+ virtual audio_io_handle_t openOutput(uint32_t *pDevices,
uint32_t *pSamplingRate,
audio_format_t *pFormat,
uint32_t *pChannels,
@@ -376,8 +377,8 @@
data.writeInt32(latency);
data.writeInt32(flags);
remote()->transact(OPEN_OUTPUT, data, &reply);
- int output = reply.readInt32();
- ALOGV("openOutput() returned output, %p", output);
+ audio_io_handle_t output = (audio_io_handle_t) reply.readInt32();
+ ALOGV("openOutput() returned output, %d", output);
devices = reply.readInt32();
if (pDevices) *pDevices = devices;
samplingRate = reply.readInt32();
@@ -391,44 +392,45 @@
return output;
}
- virtual int openDuplicateOutput(int output1, int output2)
+ virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1,
+ audio_io_handle_t output2)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(output1);
- data.writeInt32(output2);
+ data.writeInt32((int32_t) output1);
+ data.writeInt32((int32_t) output2);
remote()->transact(OPEN_DUPLICATE_OUTPUT, data, &reply);
- return reply.readInt32();
+ return (audio_io_handle_t) reply.readInt32();
}
- virtual status_t closeOutput(int output)
+ virtual status_t closeOutput(audio_io_handle_t output)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(output);
+ data.writeInt32((int32_t) output);
remote()->transact(CLOSE_OUTPUT, data, &reply);
return reply.readInt32();
}
- virtual status_t suspendOutput(int output)
+ virtual status_t suspendOutput(audio_io_handle_t output)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(output);
+ data.writeInt32((int32_t) output);
remote()->transact(SUSPEND_OUTPUT, data, &reply);
return reply.readInt32();
}
- virtual status_t restoreOutput(int output)
+ virtual status_t restoreOutput(audio_io_handle_t output)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(output);
+ data.writeInt32((int32_t) output);
remote()->transact(RESTORE_OUTPUT, data, &reply);
return reply.readInt32();
}
- virtual int openInput(uint32_t *pDevices,
+ virtual audio_io_handle_t openInput(uint32_t *pDevices,
uint32_t *pSamplingRate,
audio_format_t *pFormat,
uint32_t *pChannels,
@@ -447,7 +449,7 @@
data.writeInt32(channels);
data.writeInt32((int32_t) acoustics);
remote()->transact(OPEN_INPUT, data, &reply);
- int input = reply.readInt32();
+ audio_io_handle_t input = (audio_io_handle_t) reply.readInt32();
devices = reply.readInt32();
if (pDevices) *pDevices = devices;
samplingRate = reply.readInt32();
@@ -468,12 +470,12 @@
return reply.readInt32();
}
- virtual status_t setStreamOutput(audio_stream_type_t stream, int output)
+ virtual status_t setStreamOutput(audio_stream_type_t stream, audio_io_handle_t output)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
data.writeInt32((int32_t) stream);
- data.writeInt32(output);
+ data.writeInt32((int32_t) output);
remote()->transact(SET_STREAM_OUTPUT, data, &reply);
return reply.readInt32();
}
@@ -487,11 +489,12 @@
return reply.readInt32();
}
- virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output)
+ virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames,
+ audio_io_handle_t output) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(output);
+ data.writeInt32((int32_t) output);
remote()->transact(GET_RENDER_POSITION, data, &reply);
status_t status = reply.readInt32();
if (status == NO_ERROR) {
@@ -507,11 +510,11 @@
return status;
}
- virtual unsigned int getInputFramesLost(int ioHandle)
+ virtual unsigned int getInputFramesLost(audio_io_handle_t ioHandle) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
- data.writeInt32(ioHandle);
+ data.writeInt32((int32_t) ioHandle);
remote()->transact(GET_INPUT_FRAMES_LOST, data, &reply);
return reply.readInt32();
}
@@ -544,7 +547,7 @@
remote()->transact(RELEASE_AUDIO_SESSION_ID, data, &reply);
}
- virtual status_t queryNumberEffects(uint32_t *numEffects)
+ virtual status_t queryNumberEffects(uint32_t *numEffects) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
@@ -562,7 +565,7 @@
return NO_ERROR;
}
- virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor)
+ virtual status_t queryEffect(uint32_t index, effect_descriptor_t *pDescriptor) const
{
if (pDescriptor == NULL) {
return BAD_VALUE;
@@ -582,7 +585,8 @@
return NO_ERROR;
}
- virtual status_t getEffectDescriptor(effect_uuid_t *pUuid, effect_descriptor_t *pDescriptor)
+ virtual status_t getEffectDescriptor(const effect_uuid_t *pUuid,
+ effect_descriptor_t *pDescriptor) const
{
if (pUuid == NULL || pDescriptor == NULL) {
return BAD_VALUE;
@@ -606,7 +610,7 @@
effect_descriptor_t *pDesc,
const sp<IEffectClient>& client,
int32_t priority,
- int output,
+ audio_io_handle_t output,
int sessionId,
status_t *status,
int *id,
@@ -627,7 +631,7 @@
data.write(pDesc, sizeof(effect_descriptor_t));
data.writeStrongBinder(client->asBinder());
data.writeInt32(priority);
- data.writeInt32(output);
+ data.writeInt32((int32_t) output);
data.writeInt32(sessionId);
status_t lStatus = remote()->transact(CREATE_EFFECT, data, &reply);
@@ -653,13 +657,14 @@
return effect;
}
- virtual status_t moveEffects(int session, int srcOutput, int dstOutput)
+ virtual status_t moveEffects(int session, audio_io_handle_t srcOutput,
+ audio_io_handle_t dstOutput)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
data.writeInt32(session);
- data.writeInt32(srcOutput);
- data.writeInt32(dstOutput);
+ data.writeInt32((int32_t) srcOutput);
+ data.writeInt32((int32_t) dstOutput);
remote()->transact(MOVE_EFFECTS, data, &reply);
return reply.readInt32();
}
@@ -683,7 +688,7 @@
size_t bufferCount = data.readInt32();
uint32_t flags = data.readInt32();
sp<IMemory> buffer = interface_cast<IMemory>(data.readStrongBinder());
- int output = data.readInt32();
+ audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
int sessionId = data.readInt32();
status_t status;
sp<IAudioTrack> track = createTrack(pid,
@@ -697,7 +702,7 @@
case OPEN_RECORD: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
pid_t pid = data.readInt32();
- int input = data.readInt32();
+ audio_io_handle_t input = (audio_io_handle_t) data.readInt32();
uint32_t sampleRate = data.readInt32();
audio_format_t format = (audio_format_t) data.readInt32();
int channelCount = data.readInt32();
@@ -714,27 +719,27 @@
} break;
case SAMPLE_RATE: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- reply->writeInt32( sampleRate(data.readInt32()) );
+ reply->writeInt32( sampleRate((audio_io_handle_t) data.readInt32()) );
return NO_ERROR;
} break;
case CHANNEL_COUNT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- reply->writeInt32( channelCount(data.readInt32()) );
+ reply->writeInt32( channelCount((audio_io_handle_t) data.readInt32()) );
return NO_ERROR;
} break;
case FORMAT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- reply->writeInt32( format(data.readInt32()) );
+ reply->writeInt32( format((audio_io_handle_t) data.readInt32()) );
return NO_ERROR;
} break;
case FRAME_COUNT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- reply->writeInt32( frameCount(data.readInt32()) );
+ reply->writeInt32( frameCount((audio_io_handle_t) data.readInt32()) );
return NO_ERROR;
} break;
case LATENCY: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- reply->writeInt32( latency(data.readInt32()) );
+ reply->writeInt32( latency((audio_io_handle_t) data.readInt32()) );
return NO_ERROR;
} break;
case SET_MASTER_VOLUME: {
@@ -761,7 +766,7 @@
CHECK_INTERFACE(IAudioFlinger, data, reply);
int stream = data.readInt32();
float volume = data.readFloat();
- int output = data.readInt32();
+ audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
reply->writeInt32( setStreamVolume((audio_stream_type_t) stream, volume, output) );
return NO_ERROR;
} break;
@@ -803,14 +808,14 @@
} break;
case SET_PARAMETERS: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- int ioHandle = data.readInt32();
+ audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
String8 keyValuePairs(data.readString8());
reply->writeInt32(setParameters(ioHandle, keyValuePairs));
return NO_ERROR;
} break;
case GET_PARAMETERS: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- int ioHandle = data.readInt32();
+ audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
String8 keys(data.readString8());
reply->writeString8(getParameters(ioHandle, keys));
return NO_ERROR;
@@ -838,14 +843,14 @@
uint32_t channels = data.readInt32();
uint32_t latency = data.readInt32();
uint32_t flags = data.readInt32();
- int output = openOutput(&devices,
+ audio_io_handle_t output = openOutput(&devices,
&samplingRate,
&format,
&channels,
&latency,
flags);
ALOGV("OPEN_OUTPUT output, %p", output);
- reply->writeInt32(output);
+ reply->writeInt32((int32_t) output);
reply->writeInt32(devices);
reply->writeInt32(samplingRate);
reply->writeInt32(format);
@@ -855,24 +860,24 @@
} break;
case OPEN_DUPLICATE_OUTPUT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- int output1 = data.readInt32();
- int output2 = data.readInt32();
- reply->writeInt32(openDuplicateOutput(output1, output2));
+ audio_io_handle_t output1 = (audio_io_handle_t) data.readInt32();
+ audio_io_handle_t output2 = (audio_io_handle_t) data.readInt32();
+ reply->writeInt32((int32_t) openDuplicateOutput(output1, output2));
return NO_ERROR;
} break;
case CLOSE_OUTPUT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- reply->writeInt32(closeOutput(data.readInt32()));
+ reply->writeInt32(closeOutput((audio_io_handle_t) data.readInt32()));
return NO_ERROR;
} break;
case SUSPEND_OUTPUT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- reply->writeInt32(suspendOutput(data.readInt32()));
+ reply->writeInt32(suspendOutput((audio_io_handle_t) data.readInt32()));
return NO_ERROR;
} break;
case RESTORE_OUTPUT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- reply->writeInt32(restoreOutput(data.readInt32()));
+ reply->writeInt32(restoreOutput((audio_io_handle_t) data.readInt32()));
return NO_ERROR;
} break;
case OPEN_INPUT: {
@@ -883,12 +888,12 @@
uint32_t channels = data.readInt32();
audio_in_acoustics_t acoustics = (audio_in_acoustics_t) data.readInt32();
- int input = openInput(&devices,
+ audio_io_handle_t input = openInput(&devices,
&samplingRate,
&format,
&channels,
acoustics);
- reply->writeInt32(input);
+ reply->writeInt32((int32_t) input);
reply->writeInt32(devices);
reply->writeInt32(samplingRate);
reply->writeInt32(format);
@@ -897,13 +902,13 @@
} break;
case CLOSE_INPUT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- reply->writeInt32(closeInput(data.readInt32()));
+ reply->writeInt32(closeInput((audio_io_handle_t) data.readInt32()));
return NO_ERROR;
} break;
case SET_STREAM_OUTPUT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
uint32_t stream = data.readInt32();
- int output = data.readInt32();
+ audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
reply->writeInt32(setStreamOutput((audio_stream_type_t) stream, output));
return NO_ERROR;
} break;
@@ -915,7 +920,7 @@
} break;
case GET_RENDER_POSITION: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- int output = data.readInt32();
+ audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
uint32_t halFrames;
uint32_t dspFrames;
status_t status = getRenderPosition(&halFrames, &dspFrames, output);
@@ -928,7 +933,7 @@
}
case GET_INPUT_FRAMES_LOST: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
- int ioHandle = data.readInt32();
+ audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
reply->writeInt32(getInputFramesLost(ioHandle));
return NO_ERROR;
} break;
@@ -988,7 +993,7 @@
data.read(&desc, sizeof(effect_descriptor_t));
sp<IEffectClient> client = interface_cast<IEffectClient>(data.readStrongBinder());
int32_t priority = data.readInt32();
- int output = data.readInt32();
+ audio_io_handle_t output = (audio_io_handle_t) data.readInt32();
int sessionId = data.readInt32();
status_t status;
int id;
@@ -1005,8 +1010,8 @@
case MOVE_EFFECTS: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
int session = data.readInt32();
- int srcOutput = data.readInt32();
- int dstOutput = data.readInt32();
+ audio_io_handle_t srcOutput = (audio_io_handle_t) data.readInt32();
+ audio_io_handle_t dstOutput = (audio_io_handle_t) data.readInt32();
reply->writeInt32(moveEffects(session, srcOutput, dstOutput));
return NO_ERROR;
} break;
diff --git a/media/libmedia/IAudioFlingerClient.cpp b/media/libmedia/IAudioFlingerClient.cpp
index 9458bc0..ce28b33 100644
--- a/media/libmedia/IAudioFlingerClient.cpp
+++ b/media/libmedia/IAudioFlingerClient.cpp
@@ -39,12 +39,12 @@
{
}
- void ioConfigChanged(int event, int ioHandle, void *param2)
+ void ioConfigChanged(int event, audio_io_handle_t ioHandle, void *param2)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlingerClient::getInterfaceDescriptor());
data.writeInt32(event);
- data.writeInt32(ioHandle);
+ data.writeInt32((int32_t) ioHandle);
if (event == AudioSystem::STREAM_CONFIG_CHANGED) {
uint32_t stream = *(uint32_t *)param2;
ALOGV("ioConfigChanged stream %d", stream);
@@ -72,7 +72,7 @@
case IO_CONFIG_CHANGED: {
CHECK_INTERFACE(IAudioFlingerClient, data, reply);
int event = data.readInt32();
- int ioHandle = data.readInt32();
+ audio_io_handle_t ioHandle = (audio_io_handle_t) data.readInt32();
void *param2 = NULL;
AudioSystem::OutputDescriptor desc;
uint32_t stream;
diff --git a/media/libstagefright/matroska/MatroskaExtractor.cpp b/media/libstagefright/matroska/MatroskaExtractor.cpp
index 4fbf47e..a1644d2 100644
--- a/media/libstagefright/matroska/MatroskaExtractor.cpp
+++ b/media/libstagefright/matroska/MatroskaExtractor.cpp
@@ -610,36 +610,41 @@
return mIsLiveStreaming;
}
-static void addESDSFromAudioSpecificInfo(
- const sp<MetaData> &meta, const void *asi, size_t asiSize) {
+static void addESDSFromCodecPrivate(
+ const sp<MetaData> &meta,
+ bool isAudio, const void *priv, size_t privSize) {
static const uint8_t kStaticESDS[] = {
0x03, 22,
0x00, 0x00, // ES_ID
0x00, // streamDependenceFlag, URL_Flag, OCRstreamFlag
0x04, 17,
- 0x40, // Audio ISO/IEC 14496-3
+ 0x40, // ObjectTypeIndication
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x05,
- // AudioSpecificInfo (with size prefix) follows
+ // CodecSpecificInfo (with size prefix) follows
};
// Make sure all sizes can be coded in a single byte.
- CHECK(asiSize + 22 - 2 < 128);
- size_t esdsSize = sizeof(kStaticESDS) + asiSize + 1;
+ CHECK(privSize + 22 - 2 < 128);
+ size_t esdsSize = sizeof(kStaticESDS) + privSize + 1;
uint8_t *esds = new uint8_t[esdsSize];
memcpy(esds, kStaticESDS, sizeof(kStaticESDS));
uint8_t *ptr = esds + sizeof(kStaticESDS);
- *ptr++ = asiSize;
- memcpy(ptr, asi, asiSize);
+ *ptr++ = privSize;
+ memcpy(ptr, priv, privSize);
// Increment by codecPrivateSize less 2 bytes that are accounted for
// already in lengths of 22/17
- esds[1] += asiSize - 2;
- esds[6] += asiSize - 2;
+ esds[1] += privSize - 2;
+ esds[6] += privSize - 2;
+
+ // Set ObjectTypeIndication.
+ esds[7] = isAudio ? 0x40 // Audio ISO/IEC 14496-3
+ : 0x20; // Visual ISO/IEC 14496-2
meta->setData(kKeyESDS, 0, esds, esdsSize);
@@ -707,9 +712,21 @@
if (!strcmp("V_MPEG4/ISO/AVC", codecID)) {
meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_AVC);
meta->setData(kKeyAVCC, 0, codecPrivate, codecPrivateSize);
+ } else if (!strcmp("V_MPEG4/ISO/ASP", codecID)) {
+ if (codecPrivateSize > 0) {
+ meta->setCString(
+ kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_MPEG4);
+ addESDSFromCodecPrivate(
+ meta, false, codecPrivate, codecPrivateSize);
+ } else {
+ ALOGW("%s is detected, but does not have configuration.",
+ codecID);
+ continue;
+ }
} else if (!strcmp("V_VP8", codecID)) {
meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_VIDEO_VPX);
} else {
+ ALOGW("%s is not supported.", codecID);
continue;
}
@@ -727,13 +744,16 @@
meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_AAC);
CHECK(codecPrivateSize >= 2);
- addESDSFromAudioSpecificInfo(
- meta, codecPrivate, codecPrivateSize);
+ addESDSFromCodecPrivate(
+ meta, true, codecPrivate, codecPrivateSize);
} else if (!strcmp("A_VORBIS", codecID)) {
meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_VORBIS);
addVorbisCodecInfo(meta, codecPrivate, codecPrivateSize);
+ } else if (!strcmp("A_MPEG/L3", codecID)) {
+ meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_MPEG);
} else {
+ ALOGW("%s is not supported.", codecID);
continue;
}
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index f71ba0a..93c91fb 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -245,7 +245,6 @@
audio_hw_device_t *dev = mAudioHwDevs[i];
audio_hw_device_close(dev);
}
- mAudioHwDevs.clear();
}
audio_hw_device_t* AudioFlinger::findSuitableHwDev_l(uint32_t devices)
@@ -371,6 +370,18 @@
return NO_ERROR;
}
+sp<AudioFlinger::Client> AudioFlinger::registerPid_l(pid_t pid)
+{
+ // If pid is already in the mClients wp<> map, then use that entry
+ // (for which promote() is always != 0), otherwise create a new entry and Client.
+ sp<Client> client = mClients.valueFor(pid).promote();
+ if (client == 0) {
+ client = new Client(this, pid);
+ mClients.add(pid, client);
+ }
+
+ return client;
+}
// IAudioFlinger interface
@@ -384,14 +395,13 @@
int frameCount,
uint32_t flags,
const sp<IMemory>& sharedBuffer,
- int output,
+ audio_io_handle_t output,
int *sessionId,
status_t *status)
{
sp<PlaybackThread::Track> track;
sp<TrackHandle> trackHandle;
sp<Client> client;
- wp<Client> wclient;
status_t lStatus;
int lSessionId;
@@ -413,14 +423,7 @@
goto Exit;
}
- wclient = mClients.valueFor(pid);
-
- if (wclient != NULL) {
- client = wclient.promote();
- } else {
- client = new Client(this, pid);
- mClients.add(pid, client);
- }
+ client = registerPid_l(pid);
ALOGV("createTrack() sessionId: %d", (sessionId == NULL) ? -2 : *sessionId);
if (sessionId != NULL && *sessionId != AUDIO_SESSION_OUTPUT_MIX) {
@@ -477,7 +480,7 @@
return trackHandle;
}
-uint32_t AudioFlinger::sampleRate(int output) const
+uint32_t AudioFlinger::sampleRate(audio_io_handle_t output) const
{
Mutex::Autolock _l(mLock);
PlaybackThread *thread = checkPlaybackThread_l(output);
@@ -488,7 +491,7 @@
return thread->sampleRate();
}
-int AudioFlinger::channelCount(int output) const
+int AudioFlinger::channelCount(audio_io_handle_t output) const
{
Mutex::Autolock _l(mLock);
PlaybackThread *thread = checkPlaybackThread_l(output);
@@ -499,7 +502,7 @@
return thread->channelCount();
}
-audio_format_t AudioFlinger::format(int output) const
+audio_format_t AudioFlinger::format(audio_io_handle_t output) const
{
Mutex::Autolock _l(mLock);
PlaybackThread *thread = checkPlaybackThread_l(output);
@@ -510,7 +513,7 @@
return thread->format();
}
-size_t AudioFlinger::frameCount(int output) const
+size_t AudioFlinger::frameCount(audio_io_handle_t output) const
{
Mutex::Autolock _l(mLock);
PlaybackThread *thread = checkPlaybackThread_l(output);
@@ -521,7 +524,7 @@
return thread->frameCount();
}
-uint32_t AudioFlinger::latency(int output) const
+uint32_t AudioFlinger::latency(audio_io_handle_t output) const
{
Mutex::Autolock _l(mLock);
PlaybackThread *thread = checkPlaybackThread_l(output);
@@ -655,7 +658,8 @@
return masterMute_l();
}
-status_t AudioFlinger::setStreamVolume(audio_stream_type_t stream, float value, int output)
+status_t AudioFlinger::setStreamVolume(audio_stream_type_t stream, float value,
+ audio_io_handle_t output)
{
// check calling permissions
if (!settingsAllowed()) {
@@ -710,7 +714,7 @@
return NO_ERROR;
}
-float AudioFlinger::streamVolume(audio_stream_type_t stream, int output) const
+float AudioFlinger::streamVolume(audio_stream_type_t stream, audio_io_handle_t output) const
{
if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return 0.0f;
@@ -740,7 +744,7 @@
return mStreamTypes[stream].mute;
}
-status_t AudioFlinger::setParameters(int ioHandle, const String8& keyValuePairs)
+status_t AudioFlinger::setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs)
{
status_t result;
@@ -809,14 +813,13 @@
}
}
}
- if (thread != NULL) {
- result = thread->setParameters(keyValuePairs);
- return result;
+ if (thread != 0) {
+ return thread->setParameters(keyValuePairs);
}
return BAD_VALUE;
}
-String8 AudioFlinger::getParameters(int ioHandle, const String8& keys)
+String8 AudioFlinger::getParameters(audio_io_handle_t ioHandle, const String8& keys) const
{
// ALOGV("getParameters() io %d, keys %s, tid %d, calling tid %d",
// ioHandle, keys.string(), gettid(), IPCThreadState::self()->getCallingPid());
@@ -846,7 +849,7 @@
return String8("");
}
-size_t AudioFlinger::getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount)
+size_t AudioFlinger::getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount) const
{
status_t ret = initCheck();
if (ret != NO_ERROR) {
@@ -856,7 +859,7 @@
return mPrimaryHardwareDev->get_input_buffer_size(mPrimaryHardwareDev, sampleRate, format, channelCount);
}
-unsigned int AudioFlinger::getInputFramesLost(int ioHandle)
+unsigned int AudioFlinger::getInputFramesLost(audio_io_handle_t ioHandle) const
{
if (ioHandle == 0) {
return 0;
@@ -891,7 +894,8 @@
return ret;
}
-status_t AudioFlinger::getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output)
+status_t AudioFlinger::getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames,
+ audio_io_handle_t output) const
{
status_t status;
@@ -910,7 +914,7 @@
Mutex::Autolock _l(mLock);
- int pid = IPCThreadState::self()->getCallingPid();
+ pid_t pid = IPCThreadState::self()->getCallingPid();
if (mNotificationClients.indexOfKey(pid) < 0) {
sp<NotificationClient> notificationClient = new NotificationClient(this,
client,
@@ -966,7 +970,7 @@
}
// audioConfigChanged_l() must be called with AudioFlinger::mLock held
-void AudioFlinger::audioConfigChanged_l(int event, int ioHandle, void *param2)
+void AudioFlinger::audioConfigChanged_l(int event, audio_io_handle_t ioHandle, void *param2)
{
size_t size = mNotificationClients.size();
for (size_t i = 0; i < size; i++) {
@@ -985,8 +989,8 @@
// ----------------------------------------------------------------------------
-AudioFlinger::ThreadBase::ThreadBase(const sp<AudioFlinger>& audioFlinger, int id, uint32_t device,
- type_t type)
+AudioFlinger::ThreadBase::ThreadBase(const sp<AudioFlinger>& audioFlinger, audio_io_handle_t id,
+ uint32_t device, type_t type)
: Thread(false),
mType(type),
mAudioFlinger(audioFlinger), mSampleRate(0), mFrameCount(0),
@@ -1027,26 +1031,6 @@
requestExitAndWait();
}
-uint32_t AudioFlinger::ThreadBase::sampleRate() const
-{
- return mSampleRate;
-}
-
-int AudioFlinger::ThreadBase::channelCount() const
-{
- return (int)mChannelCount;
-}
-
-audio_format_t AudioFlinger::ThreadBase::format() const
-{
- return mFormat;
-}
-
-size_t AudioFlinger::ThreadBase::frameCount() const
-{
- return mFrameCount;
-}
-
status_t AudioFlinger::ThreadBase::setParameters(const String8& keyValuePairs)
{
status_t status;
@@ -1248,8 +1232,7 @@
void AudioFlinger::ThreadBase::setEffectSuspended_l(
const effect_uuid_t *type, bool suspend, int sessionId)
{
- sp<EffectChain> chain;
- chain = getEffectChain_l(sessionId);
+ sp<EffectChain> chain = getEffectChain_l(sessionId);
if (chain != 0) {
if (type != NULL) {
chain->setEffectSuspended_l(type, suspend);
@@ -1377,7 +1360,7 @@
AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinger,
AudioStreamOut* output,
- int id,
+ audio_io_handle_t id,
uint32_t device,
type_t type)
: ThreadBase(audioFlinger, id, device, type),
@@ -1611,16 +1594,6 @@
return NO_ERROR;
}
-float AudioFlinger::PlaybackThread::masterVolume() const
-{
- return mMasterVolume;
-}
-
-bool AudioFlinger::PlaybackThread::masterMute() const
-{
- return mMasterMute;
-}
-
status_t AudioFlinger::PlaybackThread::setStreamVolume(audio_stream_type_t stream, float value)
{
mStreamTypes[stream].volume = value;
@@ -1853,7 +1826,7 @@
// ----------------------------------------------------------------------------
AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
- int id, uint32_t device, type_t type)
+ audio_io_handle_t id, uint32_t device, type_t type)
: PlaybackThread(audioFlinger, output, id, device, type),
mAudioMixer(new AudioMixer(mFrameCount, mSampleRate)),
mPrevMixerStatus(MIXER_IDLE)
@@ -2520,7 +2493,8 @@
}
// ----------------------------------------------------------------------------
-AudioFlinger::DirectOutputThread::DirectOutputThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device)
+AudioFlinger::DirectOutputThread::DirectOutputThread(const sp<AudioFlinger>& audioFlinger,
+ AudioStreamOut* output, audio_io_handle_t id, uint32_t device)
: PlaybackThread(audioFlinger, output, id, device, DIRECT)
// mLeftVolFloat, mRightVolFloat
// mLeftVolShort, mRightVolShort
@@ -3002,7 +2976,7 @@
// ----------------------------------------------------------------------------
AudioFlinger::DuplicatingThread::DuplicatingThread(const sp<AudioFlinger>& audioFlinger,
- AudioFlinger::MixerThread* mainThread, int id)
+ AudioFlinger::MixerThread* mainThread, audio_io_handle_t id)
: MixerThread(audioFlinger, mainThread->getOutput(), id, mainThread->device(), DUPLICATING),
mWaitTimeMs(UINT_MAX)
{
@@ -3014,7 +2988,6 @@
for (size_t i = 0; i < mOutputTracks.size(); i++) {
mOutputTracks[i]->destroy();
}
- mOutputTracks.clear();
}
bool AudioFlinger::DuplicatingThread::threadLoop()
@@ -3206,7 +3179,7 @@
mWaitTimeMs = UINT_MAX;
for (size_t i = 0; i < mOutputTracks.size(); i++) {
sp<ThreadBase> strong = mOutputTracks[i]->thread().promote();
- if (strong != NULL) {
+ if (strong != 0) {
uint32_t waitTimeMs = (strong->frameCount() * 2 * 1000) / strong->sampleRate();
if (waitTimeMs < mWaitTimeMs) {
mWaitTimeMs = waitTimeMs;
@@ -3259,7 +3232,6 @@
// mBufferEnd
mFrameCount(0),
mState(IDLE),
- mClientTid(-1),
mFormat(format),
mFlags(flags & ~SYSTEM_FLAGS_MASK),
mSessionId(sessionId)
@@ -3324,15 +3296,19 @@
AudioFlinger::ThreadBase::TrackBase::~TrackBase()
{
if (mCblk != NULL) {
- mCblk->~audio_track_cblk_t(); // destroy our shared-structure.
- if (mClient == NULL) {
+ if (mClient == 0) {
delete mCblk;
+ } else {
+ mCblk->~audio_track_cblk_t(); // destroy our shared-structure.
}
}
- mCblkMemory.clear(); // and free the shared memory
- if (mClient != NULL) {
+ mCblkMemory.clear(); // free the shared memory before releasing the heap it belongs to
+ if (mClient != 0) {
// Client destructor must run with AudioFlinger mutex locked
Mutex::Autolock _l(mClient->audioFlinger()->mLock);
+ // If the client's reference count drops to zero, the associated destructor
+ // must run with AudioFlinger lock held. Thus the explicit clear() rather than
+ // relying on the automatic clear() at end of scope.
mClient.clear();
}
}
@@ -3368,23 +3344,10 @@
ALOGV("TrackBase::reset");
}
-sp<IMemory> AudioFlinger::ThreadBase::TrackBase::getCblk() const
-{
- return mCblkMemory;
-}
-
int AudioFlinger::ThreadBase::TrackBase::sampleRate() const {
return (int)mCblk->sampleRate;
}
-int AudioFlinger::ThreadBase::TrackBase::channelCount() const {
- return (const int)mChannelCount;
-}
-
-uint32_t AudioFlinger::ThreadBase::TrackBase::channelMask() const {
- return mChannelMask;
-}
-
void* AudioFlinger::ThreadBase::TrackBase::getBuffer(uint32_t offset, uint32_t frames) const {
audio_track_cblk_t* cblk = this->cblk();
size_t frameSize = cblk->frameSize;
@@ -3486,7 +3449,7 @@
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(),
+ (mClient == 0) ? getpid() : mClient->pid(),
mStreamType,
mFormat,
mChannelMask,
@@ -3813,7 +3776,7 @@
void AudioFlinger::RecordThread::RecordTrack::dump(char* buffer, size_t size)
{
snprintf(buffer, size, " %05d %03u 0x%08x %05d %04u %01d %05u %08x %08x\n",
- (mClient == NULL) ? getpid() : mClient->pid(),
+ (mClient == 0) ? getpid() : mClient->pid(),
mFormat,
mChannelMask,
mSessionId,
@@ -4160,7 +4123,7 @@
sp<IAudioRecord> AudioFlinger::openRecord(
pid_t pid,
- int input,
+ audio_io_handle_t input,
uint32_t sampleRate,
audio_format_t format,
uint32_t channelMask,
@@ -4172,7 +4135,6 @@
sp<RecordThread::RecordTrack> recordTrack;
sp<RecordHandle> recordHandle;
sp<Client> client;
- wp<Client> wclient;
status_t lStatus;
RecordThread *thread;
size_t inFrameCount;
@@ -4193,13 +4155,7 @@
goto Exit;
}
- wclient = mClients.valueFor(pid);
- if (wclient != NULL) {
- client = wclient.promote();
- } else {
- client = new Client(this, pid);
- mClients.add(pid, client);
- }
+ client = registerPid_l(pid);
// If no audio session id is provided, create one here
if (sessionId != NULL && *sessionId != AUDIO_SESSION_OUTPUT_MIX) {
@@ -4277,7 +4233,7 @@
AudioStreamIn *input,
uint32_t sampleRate,
uint32_t channels,
- int id,
+ audio_io_handle_t id,
uint32_t device) :
ThreadBase(audioFlinger, id, device, RECORD),
mInput(input), mTrack(NULL), mResampler(NULL), mRsmpOutBuffer(NULL), mRsmpInBuffer(NULL),
@@ -4528,7 +4484,7 @@
track = new RecordTrack(this, client, sampleRate,
format, channelMask, frameCount, flags, sessionId);
- if (track->getCblk() == NULL) {
+ if (track->getCblk() == 0) {
lStatus = NO_MEMORY;
goto Exit;
}
@@ -4631,7 +4587,6 @@
const size_t SIZE = 256;
char buffer[SIZE];
String8 result;
- pid_t pid = 0;
snprintf(buffer, SIZE, "\nInput thread %p internals\n", this);
result.append(buffer);
@@ -4938,7 +4893,7 @@
// ----------------------------------------------------------------------------
-int AudioFlinger::openOutput(uint32_t *pDevices,
+audio_io_handle_t AudioFlinger::openOutput(uint32_t *pDevices,
uint32_t *pSamplingRate,
audio_format_t *pFormat,
uint32_t *pChannels,
@@ -4984,7 +4939,7 @@
mHardwareStatus = AUDIO_HW_IDLE;
if (outStream != NULL) {
AudioStreamOut *output = new AudioStreamOut(outHwDev, outStream);
- int id = nextUniqueId();
+ audio_io_handle_t id = nextUniqueId();
if ((flags & AUDIO_POLICY_OUTPUT_FLAG_DIRECT) ||
(format != AUDIO_FORMAT_PCM_16_BIT) ||
@@ -5010,7 +4965,8 @@
return 0;
}
-int AudioFlinger::openDuplicateOutput(int output1, int output2)
+audio_io_handle_t AudioFlinger::openDuplicateOutput(audio_io_handle_t output1,
+ audio_io_handle_t output2)
{
Mutex::Autolock _l(mLock);
MixerThread *thread1 = checkMixerThread_l(output1);
@@ -5021,7 +4977,7 @@
return 0;
}
- int id = nextUniqueId();
+ audio_io_handle_t id = nextUniqueId();
DuplicatingThread *thread = new DuplicatingThread(this, thread1, id);
thread->addOutputTrack(thread2);
mPlaybackThreads.add(id, thread);
@@ -5030,7 +4986,7 @@
return id;
}
-status_t AudioFlinger::closeOutput(int output)
+status_t AudioFlinger::closeOutput(audio_io_handle_t output)
{
// keep strong reference on the playback thread so that
// it is not destroyed while exit() is executed
@@ -5068,7 +5024,7 @@
return NO_ERROR;
}
-status_t AudioFlinger::suspendOutput(int output)
+status_t AudioFlinger::suspendOutput(audio_io_handle_t output)
{
Mutex::Autolock _l(mLock);
PlaybackThread *thread = checkPlaybackThread_l(output);
@@ -5083,7 +5039,7 @@
return NO_ERROR;
}
-status_t AudioFlinger::restoreOutput(int output)
+status_t AudioFlinger::restoreOutput(audio_io_handle_t output)
{
Mutex::Autolock _l(mLock);
PlaybackThread *thread = checkPlaybackThread_l(output);
@@ -5099,7 +5055,7 @@
return NO_ERROR;
}
-int AudioFlinger::openInput(uint32_t *pDevices,
+audio_io_handle_t AudioFlinger::openInput(uint32_t *pDevices,
uint32_t *pSamplingRate,
audio_format_t *pFormat,
uint32_t *pChannels,
@@ -5155,7 +5111,7 @@
if (inStream != NULL) {
AudioStreamIn *input = new AudioStreamIn(inHwDev, inStream);
- int id = nextUniqueId();
+ audio_io_handle_t id = nextUniqueId();
// Start record thread
// RecorThread require both input and output device indication to forward to audio
// pre processing modules
@@ -5182,7 +5138,7 @@
return 0;
}
-status_t AudioFlinger::closeInput(int input)
+status_t AudioFlinger::closeInput(audio_io_handle_t input)
{
// keep strong reference on the record thread so that
// it is not destroyed while exit() is executed
@@ -5210,7 +5166,7 @@
return NO_ERROR;
}
-status_t AudioFlinger::setStreamOutput(audio_stream_type_t stream, int output)
+status_t AudioFlinger::setStreamOutput(audio_stream_type_t stream, audio_io_handle_t output)
{
Mutex::Autolock _l(mLock);
MixerThread *dstThread = checkMixerThread_l(output);
@@ -5246,7 +5202,7 @@
void AudioFlinger::acquireAudioSessionId(int audioSession)
{
Mutex::Autolock _l(mLock);
- int caller = IPCThreadState::self()->getCallingPid();
+ pid_t caller = IPCThreadState::self()->getCallingPid();
ALOGV("acquiring %d from %d", audioSession, caller);
int num = mAudioSessionRefs.size();
for (int i = 0; i< num; i++) {
@@ -5264,7 +5220,7 @@
void AudioFlinger::releaseAudioSessionId(int audioSession)
{
Mutex::Autolock _l(mLock);
- int caller = IPCThreadState::self()->getCallingPid();
+ pid_t caller = IPCThreadState::self()->getCallingPid();
ALOGV("releasing %d from %d", audioSession, caller);
int num = mAudioSessionRefs.size();
for (int i = 0; i< num; i++) {
@@ -5348,7 +5304,7 @@
}
// checkPlaybackThread_l() must be called with AudioFlinger::mLock held
-AudioFlinger::PlaybackThread *AudioFlinger::checkPlaybackThread_l(int output) const
+AudioFlinger::PlaybackThread *AudioFlinger::checkPlaybackThread_l(audio_io_handle_t output) const
{
PlaybackThread *thread = NULL;
if (mPlaybackThreads.indexOfKey(output) >= 0) {
@@ -5358,7 +5314,7 @@
}
// checkMixerThread_l() must be called with AudioFlinger::mLock held
-AudioFlinger::MixerThread *AudioFlinger::checkMixerThread_l(int output) const
+AudioFlinger::MixerThread *AudioFlinger::checkMixerThread_l(audio_io_handle_t output) const
{
PlaybackThread *thread = checkPlaybackThread_l(output);
if (thread != NULL) {
@@ -5370,7 +5326,7 @@
}
// checkRecordThread_l() must be called with AudioFlinger::mLock held
-AudioFlinger::RecordThread *AudioFlinger::checkRecordThread_l(int input) const
+AudioFlinger::RecordThread *AudioFlinger::checkRecordThread_l(audio_io_handle_t input) const
{
RecordThread *thread = NULL;
if (mRecordThreads.indexOfKey(input) >= 0) {
@@ -5413,19 +5369,20 @@
// ----------------------------------------------------------------------------
-status_t AudioFlinger::queryNumberEffects(uint32_t *numEffects)
+status_t AudioFlinger::queryNumberEffects(uint32_t *numEffects) const
{
Mutex::Autolock _l(mLock);
return EffectQueryNumberEffects(numEffects);
}
-status_t AudioFlinger::queryEffect(uint32_t index, effect_descriptor_t *descriptor)
+status_t AudioFlinger::queryEffect(uint32_t index, effect_descriptor_t *descriptor) const
{
Mutex::Autolock _l(mLock);
return EffectQueryEffect(index, descriptor);
}
-status_t AudioFlinger::getEffectDescriptor(effect_uuid_t *pUuid, effect_descriptor_t *descriptor)
+status_t AudioFlinger::getEffectDescriptor(const effect_uuid_t *pUuid,
+ effect_descriptor_t *descriptor) const
{
Mutex::Autolock _l(mLock);
return EffectGetDescriptor(pUuid, descriptor);
@@ -5436,7 +5393,7 @@
effect_descriptor_t *pDesc,
const sp<IEffectClient>& effectClient,
int32_t priority,
- int io,
+ audio_io_handle_t io,
int sessionId,
status_t *status,
int *id,
@@ -5445,10 +5402,8 @@
status_t lStatus = NO_ERROR;
sp<EffectHandle> handle;
effect_descriptor_t desc;
- sp<Client> client;
- wp<Client> wclient;
- ALOGV("createEffect pid %d, client %p, priority %d, sessionId %d, io %d",
+ ALOGV("createEffect pid %d, effectClient %p, priority %d, sessionId %d, io %d",
pid, effectClient.get(), priority, sessionId, io);
if (pDesc == NULL) {
@@ -5599,14 +5554,7 @@
}
}
- wclient = mClients.valueFor(pid);
-
- if (wclient != NULL) {
- client = wclient.promote();
- } else {
- client = new Client(this, pid);
- mClients.add(pid, client);
- }
+ sp<Client> client = registerPid_l(pid);
// create effect on selected output thread
handle = thread->createEffect_l(client, effectClient, priority, sessionId,
@@ -5623,7 +5571,8 @@
return handle;
}
-status_t AudioFlinger::moveEffects(int sessionId, int srcOutput, int dstOutput)
+status_t AudioFlinger::moveEffects(int sessionId, audio_io_handle_t srcOutput,
+ audio_io_handle_t dstOutput)
{
ALOGV("moveEffects() session %d, srcOutput %d, dstOutput %d",
sessionId, srcOutput, dstOutput);
@@ -5674,7 +5623,7 @@
// transfer all effects one by one so that new effect chain is created on new thread with
// correct buffer sizes and audio parameters and effect engines reconfigured accordingly
- int dstOutput = dstThread->id();
+ audio_io_handle_t dstOutput = dstThread->id();
sp<EffectChain> dstChain;
uint32_t strategy = 0; // prevent compiler warning
sp<EffectModule> effect = chain->getEffectFromId_l(0);
@@ -5830,13 +5779,8 @@
sp<AudioFlinger::EffectModule> AudioFlinger::ThreadBase::getEffect_l(int sessionId, int effectId)
{
- sp<EffectModule> effect;
-
sp<EffectChain> chain = getEffectChain_l(sessionId);
- if (chain != 0) {
- effect = chain->getEffectFromId_l(effectId);
- }
- return effect;
+ return chain != 0 ? chain->getEffectFromId_l(effectId) : 0;
}
// PlaybackThread::addEffect_l() must be called with AudioFlinger::mLock and
@@ -5921,16 +5865,13 @@
sp<AudioFlinger::EffectChain> AudioFlinger::ThreadBase::getEffectChain_l(int sessionId)
{
- sp<EffectChain> chain;
-
size_t size = mEffectChains.size();
for (size_t i = 0; i < size; i++) {
if (mEffectChains[i]->sessionId() == sessionId) {
- chain = mEffectChains[i];
- break;
+ return mEffectChains[i];
}
}
- return chain;
+ return 0;
}
void AudioFlinger::ThreadBase::setMode(audio_mode_t mode)
@@ -6263,11 +6204,7 @@
sp<AudioFlinger::EffectHandle> AudioFlinger::EffectModule::controlHandle()
{
Mutex::Autolock _l(mLock);
- sp<EffectHandle> handle;
- if (mHandles.size() != 0) {
- handle = mHandles[0].promote();
- }
- return handle;
+ return mHandles.size() != 0 ? mHandles[0].promote() : 0;
}
void AudioFlinger::EffectModule::disconnect(const wp<EffectHandle>& handle, bool unpiniflast)
@@ -6622,7 +6559,7 @@
return NO_ERROR;
}
-bool AudioFlinger::EffectModule::isEnabled()
+bool AudioFlinger::EffectModule::isEnabled() const
{
switch (mState) {
case RESTART:
@@ -6638,7 +6575,7 @@
}
}
-bool AudioFlinger::EffectModule::isProcessEnabled()
+bool AudioFlinger::EffectModule::isProcessEnabled() const
{
switch (mState) {
case RESTART:
@@ -6970,9 +6907,11 @@
mEffect.clear();
if (mClient != 0) {
if (mCblk != NULL) {
+ // unlike ~TrackBase(), mCblk is never a local new, so don't delete
mCblk->~effect_param_cblk_t(); // destroy our shared-structure.
}
- mCblkMemory.clear(); // and free the shared memory
+ mCblkMemory.clear(); // free the shared memory before releasing the heap it belongs to
+ // Client destructor must run with AudioFlinger mutex locked
Mutex::Autolock _l(mClient->audioFlinger()->mLock);
mClient.clear();
}
@@ -7054,10 +6993,6 @@
return mEffect->command(cmdCode, cmdSize, pCmdData, replySize, pReplyData);
}
-sp<IMemory> AudioFlinger::EffectHandle::getCblk() const {
- return mCblkMemory;
-}
-
void AudioFlinger::EffectHandle::setControl(bool hasControl, bool signal, bool enabled)
{
ALOGV("setControl %p control %d", this, hasControl);
@@ -7102,7 +7037,7 @@
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(),
+ (mClient == 0) ? getpid() : mClient->pid(),
mPriority,
mHasControl,
!locked,
@@ -7144,48 +7079,42 @@
// getEffectFromDesc_l() must be called with ThreadBase::mLock held
sp<AudioFlinger::EffectModule> AudioFlinger::EffectChain::getEffectFromDesc_l(effect_descriptor_t *descriptor)
{
- sp<EffectModule> effect;
size_t size = mEffects.size();
for (size_t i = 0; i < size; i++) {
if (memcmp(&mEffects[i]->desc().uuid, &descriptor->uuid, sizeof(effect_uuid_t)) == 0) {
- effect = mEffects[i];
- break;
+ return mEffects[i];
}
}
- return effect;
+ return 0;
}
// getEffectFromId_l() must be called with ThreadBase::mLock held
sp<AudioFlinger::EffectModule> AudioFlinger::EffectChain::getEffectFromId_l(int id)
{
- sp<EffectModule> effect;
size_t size = mEffects.size();
for (size_t i = 0; i < size; i++) {
// by convention, return first effect if id provided is 0 (0 is never a valid id)
if (id == 0 || mEffects[i]->id() == id) {
- effect = mEffects[i];
- break;
+ return mEffects[i];
}
}
- return effect;
+ return 0;
}
// getEffectFromType_l() must be called with ThreadBase::mLock held
sp<AudioFlinger::EffectModule> AudioFlinger::EffectChain::getEffectFromType_l(
const effect_uuid_t *type)
{
- sp<EffectModule> effect;
size_t size = mEffects.size();
for (size_t i = 0; i < size; i++) {
if (memcmp(&mEffects[i]->desc().type, type, sizeof(effect_uuid_t)) == 0) {
- effect = mEffects[i];
- break;
+ return mEffects[i];
}
}
- return effect;
+ return 0;
}
// Must be called with EffectChain::mLock locked
@@ -7626,12 +7555,8 @@
sp<AudioFlinger::EffectModule> AudioFlinger::EffectChain::getEffectIfEnabled(
const effect_uuid_t *type)
{
- sp<EffectModule> effect;
- effect = getEffectFromType_l(type);
- if (effect != 0 && !effect->isEnabled()) {
- effect.clear();
- }
- return effect;
+ sp<EffectModule> effect = getEffectFromType_l(type);
+ return effect != 0 && effect->isEnabled() ? effect : 0;
}
void AudioFlinger::EffectChain::checkSuspendOnEffectEnabled(const sp<EffectModule>& effect,
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 3f3188c..97103c4 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -77,15 +77,15 @@
int frameCount,
uint32_t flags,
const sp<IMemory>& sharedBuffer,
- int output,
+ audio_io_handle_t output,
int *sessionId,
status_t *status);
- virtual uint32_t sampleRate(int output) const;
- virtual int channelCount(int output) const;
- virtual audio_format_t format(int output) const;
- virtual size_t frameCount(int output) const;
- virtual uint32_t latency(int output) const;
+ virtual uint32_t sampleRate(audio_io_handle_t output) const;
+ virtual int channelCount(audio_io_handle_t output) const;
+ virtual audio_format_t format(audio_io_handle_t output) const;
+ virtual size_t frameCount(audio_io_handle_t output) const;
+ virtual uint32_t latency(audio_io_handle_t output) const;
virtual status_t setMasterVolume(float value);
virtual status_t setMasterMute(bool muted);
@@ -93,10 +93,12 @@
virtual float masterVolume() const;
virtual bool masterMute() const;
- virtual status_t setStreamVolume(audio_stream_type_t stream, float value, int output);
+ virtual status_t setStreamVolume(audio_stream_type_t stream, float value,
+ audio_io_handle_t output);
virtual status_t setStreamMute(audio_stream_type_t stream, bool muted);
- virtual float streamVolume(audio_stream_type_t stream, int output) const;
+ virtual float streamVolume(audio_stream_type_t stream,
+ audio_io_handle_t output) const;
virtual bool streamMute(audio_stream_type_t stream) const;
virtual status_t setMode(audio_mode_t mode);
@@ -104,42 +106,44 @@
virtual status_t setMicMute(bool state);
virtual bool getMicMute() const;
- virtual status_t setParameters(int ioHandle, const String8& keyValuePairs);
- virtual String8 getParameters(int ioHandle, const String8& keys);
+ virtual status_t setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs);
+ virtual String8 getParameters(audio_io_handle_t ioHandle, const String8& keys) const;
virtual void registerClient(const sp<IAudioFlingerClient>& client);
- virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount);
- virtual unsigned int getInputFramesLost(int ioHandle);
+ virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount) const;
+ virtual unsigned int getInputFramesLost(audio_io_handle_t ioHandle) const;
- virtual int openOutput(uint32_t *pDevices,
+ virtual audio_io_handle_t openOutput(uint32_t *pDevices,
uint32_t *pSamplingRate,
audio_format_t *pFormat,
uint32_t *pChannels,
uint32_t *pLatencyMs,
uint32_t flags);
- virtual int openDuplicateOutput(int output1, int output2);
+ virtual audio_io_handle_t openDuplicateOutput(audio_io_handle_t output1,
+ audio_io_handle_t output2);
- virtual status_t closeOutput(int output);
+ virtual status_t closeOutput(audio_io_handle_t output);
- virtual status_t suspendOutput(int output);
+ virtual status_t suspendOutput(audio_io_handle_t output);
- virtual status_t restoreOutput(int output);
+ virtual status_t restoreOutput(audio_io_handle_t output);
- virtual int openInput(uint32_t *pDevices,
+ virtual audio_io_handle_t openInput(uint32_t *pDevices,
uint32_t *pSamplingRate,
audio_format_t *pFormat,
uint32_t *pChannels,
audio_in_acoustics_t acoustics);
- virtual status_t closeInput(int input);
+ virtual status_t closeInput(audio_io_handle_t input);
- virtual status_t setStreamOutput(audio_stream_type_t stream, int output);
+ virtual status_t setStreamOutput(audio_stream_type_t stream, audio_io_handle_t output);
virtual status_t setVoiceVolume(float volume);
- virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output);
+ virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames,
+ audio_io_handle_t output) const;
virtual int newAudioSessionId();
@@ -147,23 +151,25 @@
virtual void releaseAudioSessionId(int audioSession);
- virtual status_t queryNumberEffects(uint32_t *numEffects);
+ virtual status_t queryNumberEffects(uint32_t *numEffects) const;
- virtual status_t queryEffect(uint32_t index, effect_descriptor_t *descriptor);
+ virtual status_t queryEffect(uint32_t index, effect_descriptor_t *descriptor) const;
- virtual status_t getEffectDescriptor(effect_uuid_t *pUuid, effect_descriptor_t *descriptor);
+ virtual status_t getEffectDescriptor(const effect_uuid_t *pUuid,
+ effect_descriptor_t *descriptor) const;
virtual sp<IEffect> createEffect(pid_t pid,
effect_descriptor_t *pDesc,
const sp<IEffectClient>& effectClient,
int32_t priority,
- int io,
+ audio_io_handle_t io,
int sessionId,
status_t *status,
int *id,
int *enabled);
- virtual status_t moveEffects(int sessionId, int srcOutput, int dstOutput);
+ virtual status_t moveEffects(int sessionId, audio_io_handle_t srcOutput,
+ audio_io_handle_t dstOutput);
enum hardware_call_state {
AUDIO_HW_IDLE = 0,
@@ -187,7 +193,7 @@
// record interface
virtual sp<IAudioRecord> openRecord(
pid_t pid,
- int input,
+ audio_io_handle_t input,
uint32_t sampleRate,
audio_format_t format,
uint32_t channelMask,
@@ -204,7 +210,7 @@
audio_mode_t getMode() const { return mMode; }
- bool btNrecIsOff() { return mBtNrecIsOff; }
+ bool btNrecIsOff() const { return mBtNrecIsOff; }
private:
@@ -228,7 +234,7 @@
virtual ~Client();
sp<MemoryDealer> heap() const;
pid_t pid() const { return mPid; }
- sp<AudioFlinger> audioFlinger() { return mAudioFlinger; }
+ sp<AudioFlinger> audioFlinger() const { return mAudioFlinger; }
private:
Client(const Client&);
@@ -285,7 +291,7 @@
RECORD // Thread class is RecordThread
};
- ThreadBase (const sp<AudioFlinger>& audioFlinger, int id, uint32_t device, type_t type);
+ ThreadBase (const sp<AudioFlinger>& audioFlinger, audio_io_handle_t id, uint32_t device, type_t type);
virtual ~ThreadBase();
status_t dumpBase(int fd, const Vector<String16>& args);
@@ -322,13 +328,13 @@
uint32_t flags,
const sp<IMemory>& sharedBuffer,
int sessionId);
- ~TrackBase();
+ virtual ~TrackBase();
virtual status_t start() = 0;
virtual void stop() = 0;
- sp<IMemory> getCblk() const;
+ sp<IMemory> getCblk() const { return mCblkMemory; }
audio_track_cblk_t* cblk() const { return mCblk; }
- int sessionId() { return mSessionId; }
+ int sessionId() const { return mSessionId; }
protected:
friend class ThreadBase;
@@ -348,11 +354,11 @@
return mFormat;
}
- int channelCount() const ;
+ int channelCount() const { return mChannelCount; }
- uint32_t channelMask() const;
+ uint32_t channelMask() const { return mChannelMask; }
- int sampleRate() const;
+ int sampleRate() const; // FIXME inline after cblk sr moved
void* getBuffer(uint32_t offset, uint32_t frames) const;
@@ -376,7 +382,6 @@
uint32_t mFrameCount;
// we don't really need a lock for these
track_state mState;
- int mClientTid;
const audio_format_t mFormat;
uint32_t mFlags;
const int mSessionId;
@@ -409,10 +414,10 @@
virtual status_t initCheck() const = 0;
type_t type() const { return mType; }
- uint32_t sampleRate() const;
- int channelCount() const;
- audio_format_t format() const;
- size_t frameCount() const;
+ uint32_t sampleRate() const { return mSampleRate; }
+ int channelCount() const { return mChannelCount; }
+ audio_format_t format() const { return mFormat; }
+ size_t frameCount() const { return mFrameCount; }
void wakeUp() { mWaitWorkCV.broadcast(); }
void exit();
virtual bool checkForNewParameters_l() = 0;
@@ -422,7 +427,7 @@
void sendConfigEvent(int event, int param = 0);
void sendConfigEvent_l(int event, int param = 0);
void processConfigEvents();
- int id() const { return mId;}
+ audio_io_handle_t id() const { return mId;}
bool standby() { return mStandby; }
uint32_t device() { return mDevice; }
virtual audio_stream_t* stream() = 0;
@@ -544,7 +549,7 @@
status_t mParamStatus;
Vector<ConfigEvent> mConfigEvents;
bool mStandby;
- int mId;
+ const audio_io_handle_t mId;
bool mExiting;
Vector< sp<EffectChain> > mEffectChains;
uint32_t mDevice; // output device for PlaybackThread
@@ -581,7 +586,7 @@
int frameCount,
const sp<IMemory>& sharedBuffer,
int sessionId);
- ~Track();
+ virtual ~Track();
void dump(char* buffer, size_t size);
virtual status_t start();
@@ -600,10 +605,10 @@
}
status_t attachAuxEffect(int EffectId);
void setAuxBuffer(int EffectId, int32_t *buffer);
- int32_t *auxBuffer() { return mAuxBuffer; }
+ int32_t *auxBuffer() const { return mAuxBuffer; }
void setMainBuffer(int16_t *buffer) { mMainBuffer = buffer; }
- int16_t *mainBuffer() { return mMainBuffer; }
- int auxEffectId() { return mAuxEffectId; }
+ int16_t *mainBuffer() const { return mMainBuffer; }
+ int auxEffectId() const { return mAuxEffectId; }
protected:
@@ -617,7 +622,7 @@
Track& operator = (const Track&);
virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer);
- bool isMuted() { return mMute; }
+ bool isMuted() const { return mMute; }
bool isPausing() const {
return mState == PAUSING;
}
@@ -664,14 +669,14 @@
audio_format_t format,
uint32_t channelMask,
int frameCount);
- ~OutputTrack();
+ virtual ~OutputTrack();
virtual status_t start();
virtual void stop();
bool write(int16_t* data, uint32_t frames);
- bool bufferQueueEmpty() { return (mBufferQueue.size() == 0) ? true : false; }
- bool isActive() { return mActive; }
- const wp<ThreadBase>& thread() { return mThread; }
+ bool bufferQueueEmpty() const { return (mBufferQueue.size() == 0) ? true : false; }
+ bool isActive() const { return mActive; }
+ const wp<ThreadBase>& thread() const { return mThread; }
private:
@@ -691,8 +696,8 @@
DuplicatingThread* const mSourceThread; // for waitTimeMs() in write()
}; // end of OutputTrack
- PlaybackThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id,
- uint32_t device, type_t type);
+ PlaybackThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
+ audio_io_handle_t id, uint32_t device, type_t type);
virtual ~PlaybackThread();
virtual status_t dump(int fd, const Vector<String16>& args);
@@ -708,8 +713,8 @@
virtual status_t setMasterVolume(float value);
virtual status_t setMasterMute(bool muted);
- virtual float masterVolume() const;
- virtual bool masterMute() const;
+ virtual float masterVolume() const { return mMasterVolume; }
+ virtual bool masterMute() const { return mMasterMute; }
virtual status_t setStreamVolume(audio_stream_type_t stream, float value);
virtual status_t setStreamMute(audio_stream_type_t stream, bool muted);
@@ -738,7 +743,7 @@
virtual String8 getParameters(const String8& keys);
virtual void audioConfigChanged_l(int event, int param = 0);
virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames);
- int16_t *mixBuffer() { return mMixBuffer; };
+ int16_t *mixBuffer() const { return mMixBuffer; };
virtual void detachAuxEffect_l(int effectId);
status_t attachAuxEffect(const sp<AudioFlinger::PlaybackThread::Track> track,
@@ -817,7 +822,7 @@
public:
MixerThread (const sp<AudioFlinger>& audioFlinger,
AudioStreamOut* output,
- int id,
+ audio_io_handle_t id,
uint32_t device,
type_t type = MIXER);
virtual ~MixerThread();
@@ -844,8 +849,9 @@
class DirectOutputThread : public PlaybackThread {
public:
- DirectOutputThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device);
- ~DirectOutputThread();
+ DirectOutputThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
+ audio_io_handle_t id, uint32_t device);
+ virtual ~DirectOutputThread();
// Thread virtuals
virtual bool threadLoop();
@@ -870,8 +876,9 @@
class DuplicatingThread : public MixerThread {
public:
- DuplicatingThread (const sp<AudioFlinger>& audioFlinger, MixerThread* mainThread, int id);
- ~DuplicatingThread();
+ DuplicatingThread (const sp<AudioFlinger>& audioFlinger, MixerThread* mainThread,
+ audio_io_handle_t id);
+ virtual ~DuplicatingThread();
// Thread virtuals
virtual bool threadLoop();
@@ -889,13 +896,16 @@
uint32_t mWaitTimeMs;
};
- PlaybackThread *checkPlaybackThread_l(int output) const;
- MixerThread *checkMixerThread_l(int output) const;
- RecordThread *checkRecordThread_l(int input) const;
- float streamVolumeInternal(audio_stream_type_t stream) const { return mStreamTypes[stream].volume; }
- void audioConfigChanged_l(int event, int ioHandle, void *param2);
+ PlaybackThread *checkPlaybackThread_l(audio_io_handle_t output) const;
+ MixerThread *checkMixerThread_l(audio_io_handle_t output) const;
+ RecordThread *checkRecordThread_l(audio_io_handle_t input) const;
+ float streamVolumeInternal(audio_stream_type_t stream) const
+ { return mStreamTypes[stream].volume; }
+ void audioConfigChanged_l(int event, audio_io_handle_t ioHandle, void *param2);
+ // allocate an audio_io_handle_t, session ID, or effect ID
uint32_t nextUniqueId();
+
status_t moveEffectChain_l(int sessionId,
AudioFlinger::PlaybackThread *srcThread,
AudioFlinger::PlaybackThread *dstThread,
@@ -946,7 +956,7 @@
int frameCount,
uint32_t flags,
int sessionId);
- ~RecordTrack();
+ virtual ~RecordTrack();
virtual status_t start();
virtual void stop();
@@ -973,9 +983,9 @@
AudioStreamIn *input,
uint32_t sampleRate,
uint32_t channels,
- int id,
+ audio_io_handle_t id,
uint32_t device);
- ~RecordThread();
+ virtual ~RecordThread();
virtual bool threadLoop();
virtual status_t readyToRun();
@@ -1064,7 +1074,7 @@
effect_descriptor_t *desc,
int id,
int sessionId);
- ~EffectModule();
+ virtual ~EffectModule();
enum effect_state {
IDLE,
@@ -1076,7 +1086,7 @@
DESTROYED
};
- int id() { return mId; }
+ int id() const { return mId; }
void process();
void updateState();
status_t command(uint32_t cmdCode,
@@ -1094,12 +1104,12 @@
uint32_t status() {
return mStatus;
}
- int sessionId() {
+ int sessionId() const {
return mSessionId;
}
status_t setEnabled(bool enabled);
- bool isEnabled();
- bool isProcessEnabled();
+ bool isEnabled() const;
+ bool isProcessEnabled() const;
void setInBuffer(int16_t *buffer) { mConfig.inputCfg.buffer.s16 = buffer; }
int16_t *inBuffer() { return mConfig.inputCfg.buffer.s16; }
@@ -1126,7 +1136,7 @@
sp<EffectHandle> controlHandle();
- bool isPinned() { return mPinned; }
+ bool isPinned() const { return mPinned; }
void unPin() { mPinned = false; }
status_t dump(int fd, const Vector<String16>& args);
@@ -1187,7 +1197,7 @@
void *pReplyData);
virtual void disconnect();
virtual void disconnect(bool unpiniflast);
- virtual sp<IMemory> getCblk() const;
+ virtual sp<IMemory> getCblk() const { return mCblkMemory; }
virtual status_t onTransact(uint32_t code, const Parcel& data,
Parcel* reply, uint32_t flags);
@@ -1203,13 +1213,13 @@
uint32_t replySize,
void *pReplyData);
void setEnabled(bool enabled);
- bool enabled() { return mEnabled; }
+ bool enabled() const { return mEnabled; }
// Getters
- int id() { return mEffect->id(); }
- int priority() { return mPriority; }
- bool hasControl() { return mHasControl; }
- sp<EffectModule> effect() { return mEffect; }
+ int id() const { return mEffect->id(); }
+ int priority() const { return mPriority; }
+ bool hasControl() const { return mHasControl; }
+ sp<EffectModule> effect() const { return mEffect; }
void dump(char* buffer, size_t size);
@@ -1221,7 +1231,7 @@
sp<EffectModule> mEffect; // pointer to controlled EffectModule
sp<IEffectClient> mEffectClient; // callback interface for client notifications
- sp<Client> mClient; // client for shared memory allocation
+ /*const*/ sp<Client> mClient; // client for shared memory allocation, see disconnect()
sp<IMemory> mCblkMemory; // shared memory for control block
effect_param_cblk_t* mCblk; // control block for deferred parameter setting via shared memory
uint8_t* mBuffer; // pointer to parameter area in shared memory
@@ -1241,7 +1251,7 @@
class EffectChain: public RefBase {
public:
EffectChain(const wp<ThreadBase>& wThread, int sessionId);
- ~EffectChain();
+ virtual ~EffectChain();
// special key used for an entry in mSuspendedEffects keyed vector
// corresponding to a suspend all request.
@@ -1263,7 +1273,7 @@
status_t addEffect_l(const sp<EffectModule>& handle);
size_t removeEffect_l(const sp<EffectModule>& handle);
- int sessionId() { return mSessionId; }
+ int sessionId() const { return mSessionId; }
void setSessionId(int sessionId) { mSessionId = sessionId; }
sp<EffectModule> getEffectFromDesc_l(effect_descriptor_t *descriptor);
@@ -1277,26 +1287,26 @@
mInBuffer = buffer;
mOwnInBuffer = ownsBuffer;
}
- int16_t *inBuffer() {
+ int16_t *inBuffer() const {
return mInBuffer;
}
void setOutBuffer(int16_t *buffer) {
mOutBuffer = buffer;
}
- int16_t *outBuffer() {
+ int16_t *outBuffer() const {
return mOutBuffer;
}
void incTrackCnt() { android_atomic_inc(&mTrackCnt); }
void decTrackCnt() { android_atomic_dec(&mTrackCnt); }
- int32_t trackCnt() { return mTrackCnt;}
+ int32_t trackCnt() const { return mTrackCnt;}
void incActiveTrackCnt() { android_atomic_inc(&mActiveTrackCnt);
mTailBufferCount = mMaxTailBuffers; }
void decActiveTrackCnt() { android_atomic_dec(&mActiveTrackCnt); }
- int32_t activeTrackCnt() { return mActiveTrackCnt;}
+ int32_t activeTrackCnt() const { return mActiveTrackCnt;}
- uint32_t strategy() { return mStrategy; }
+ uint32_t strategy() const { return mStrategy; }
void setStrategy(uint32_t strategy)
{ mStrategy = strategy; }
@@ -1393,7 +1403,7 @@
mutable Mutex mLock;
- DefaultKeyedVector< pid_t, wp<Client> > mClients;
+ DefaultKeyedVector< pid_t, wp<Client> > mClients; // see ~Client()
mutable Mutex mHardwareLock;
audio_hw_device_t* mPrimaryHardwareDev;
@@ -1401,14 +1411,14 @@
mutable hardware_call_state mHardwareStatus; // for dump only
- DefaultKeyedVector< int, sp<PlaybackThread> > mPlaybackThreads;
+ DefaultKeyedVector< audio_io_handle_t, sp<PlaybackThread> > mPlaybackThreads;
PlaybackThread::stream_type_t mStreamTypes[AUDIO_STREAM_CNT];
// both are protected by mLock
float mMasterVolume;
bool mMasterMute;
- DefaultKeyedVector< int, sp<RecordThread> > mRecordThreads;
+ DefaultKeyedVector< audio_io_handle_t, sp<RecordThread> > mRecordThreads;
DefaultKeyedVector< pid_t, sp<NotificationClient> > mNotificationClients;
volatile int32_t mNextUniqueId;
@@ -1419,6 +1429,10 @@
float masterVolume_l() const { return mMasterVolume; }
bool masterMute_l() const { return mMasterMute; }
+
+private:
+ sp<Client> registerPid_l(pid_t pid); // always returns non-0
+
};
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index 0b9f8ba..191520a 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -68,7 +68,7 @@
// t->prevAuxLevel
// t->frameCount
t->channelCount = 2;
- t->enabled = 0;
+ t->enabled = false;
t->format = 16;
t->channelMask = AUDIO_CHANNEL_OUT_STEREO;
t->bufferProvider = NULL;
@@ -121,8 +121,8 @@
assert(uint32_t(name) < MAX_NUM_TRACKS);
ALOGV("deleteTrackName(%d)", name);
track_t& track(mState.tracks[ name ]);
- if (track.enabled != 0) {
- track.enabled = 0;
+ if (track.enabled) {
+ track.enabled = false;
invalidateState(1<<name);
}
if (track.resampler != NULL) {
@@ -143,8 +143,8 @@
assert(uint32_t(name) < MAX_NUM_TRACKS);
track_t& track = mState.tracks[name];
- if (track.enabled != 1) {
- track.enabled = 1;
+ if (!track.enabled) {
+ track.enabled = true;
ALOGV("enable(%d)", name);
invalidateState(1 << name);
}
@@ -156,8 +156,8 @@
assert(uint32_t(name) < MAX_NUM_TRACKS);
track_t& track = mState.tracks[name];
- if (track.enabled != 0) {
- track.enabled = 0;
+ if (track.enabled) {
+ track.enabled = false;
ALOGV("disable(%d)", name);
invalidateState(1 << name);
}
@@ -296,18 +296,6 @@
return false;
}
-bool AudioMixer::track_t::doesResample() const
-{
- return resampler != NULL;
-}
-
-void AudioMixer::track_t::resetResampler()
-{
- if (resampler != NULL) {
- resampler->reset();
- }
-}
-
inline
void AudioMixer::track_t::adjustVolumeRamp(bool aux)
{
@@ -327,20 +315,11 @@
}
}
-size_t AudioMixer::track_t::getUnreleasedFrames()
-{
- if (resampler != NULL) {
- return resampler->getUnreleasedFrames();
- }
- return 0;
-}
-
-size_t AudioMixer::getUnreleasedFrames(int name)
+size_t AudioMixer::getUnreleasedFrames(int name) const
{
name -= TRACK0;
if (uint32_t(name) < MAX_NUM_TRACKS) {
- track_t& track(mState.tracks[name]);
- return track.getUnreleasedFrames();
+ return mState.tracks[name].getUnreleasedFrames();
}
return 0;
}
@@ -383,9 +362,9 @@
// compute everything we need...
int countActiveTracks = 0;
- int all16BitsStereoNoResample = 1;
- int resampling = 0;
- int volumeRamp = 0;
+ bool all16BitsStereoNoResample = true;
+ bool resampling = false;
+ bool volumeRamp = false;
uint32_t en = state->enabledTracks;
while (en) {
const int i = 31 - __builtin_clz(en);
@@ -402,7 +381,7 @@
}
if (t.volumeInc[0]|t.volumeInc[1]) {
- volumeRamp = 1;
+ volumeRamp = true;
} else if (!t.doesResample() && t.volumeRL == 0) {
n |= NEEDS_MUTE_ENABLED;
}
@@ -412,16 +391,16 @@
t.hook = track__nop;
} else {
if ((n & NEEDS_AUX__MASK) == NEEDS_AUX_ENABLED) {
- all16BitsStereoNoResample = 0;
+ all16BitsStereoNoResample = false;
}
if ((n & NEEDS_RESAMPLE__MASK) == NEEDS_RESAMPLE_ENABLED) {
- all16BitsStereoNoResample = 0;
- resampling = 1;
+ all16BitsStereoNoResample = false;
+ resampling = true;
t.hook = track__genericResample;
} else {
if ((n & NEEDS_CHANNEL_COUNT__MASK) == NEEDS_CHANNEL_1){
t.hook = track__16BitsMono;
- all16BitsStereoNoResample = 0;
+ all16BitsStereoNoResample = false;
}
if ((n & NEEDS_CHANNEL_COUNT__MASK) == NEEDS_CHANNEL_2){
t.hook = track__16BitsStereo;
@@ -469,7 +448,7 @@
// Now that the volume ramp has been done, set optimal state and
// track hooks for subsequent mixer process
if (countActiveTracks) {
- int allMuted = 1;
+ bool allMuted = true;
uint32_t en = state->enabledTracks;
while (en) {
const int i = 31 - __builtin_clz(en);
@@ -480,7 +459,7 @@
t.needs |= NEEDS_MUTE_ENABLED;
t.hook = track__nop;
} else {
- allMuted = 0;
+ allMuted = false;
}
}
if (allMuted) {
diff --git a/services/audioflinger/AudioMixer.h b/services/audioflinger/AudioMixer.h
index 84f6330..c709686 100644
--- a/services/audioflinger/AudioMixer.h
+++ b/services/audioflinger/AudioMixer.h
@@ -33,7 +33,7 @@
public:
AudioMixer(size_t frameCount, uint32_t sampleRate);
- ~AudioMixer();
+ /*virtual*/ ~AudioMixer(); // non-virtual saves a v-table, restore if sub-classed
static const uint32_t MAX_NUM_TRACKS = 32;
static const uint32_t MAX_NUM_CHANNELS = 2;
@@ -83,7 +83,7 @@
uint32_t trackNames() const { return mTrackNames; }
- size_t getUnreleasedFrames(int name);
+ size_t getUnreleasedFrames(int name) const;
private:
@@ -153,10 +153,11 @@
int32_t* auxBuffer;
bool setResampler(uint32_t sampleRate, uint32_t devSampleRate);
- bool doesResample() const;
- void resetResampler();
+ bool doesResample() const { return resampler != NULL; }
+ void resetResampler() { if (resampler != NULL) resampler->reset(); }
void adjustVolumeRamp(bool aux);
- size_t getUnreleasedFrames();
+ size_t getUnreleasedFrames() const { return resampler != NULL ?
+ resampler->getUnreleasedFrames() : 0; };
};
// pad to 32-bytes to fill cache line
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index 1dddbb3..10efd85 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -819,7 +819,7 @@
status_t AudioPolicyService::AudioCommandThread::volumeCommand(audio_stream_type_t stream,
float volume,
- int output,
+ audio_io_handle_t output,
int delayMs)
{
status_t status = NO_ERROR;
@@ -849,7 +849,7 @@
return status;
}
-status_t AudioPolicyService::AudioCommandThread::parametersCommand(int ioHandle,
+status_t AudioPolicyService::AudioCommandThread::parametersCommand(audio_io_handle_t ioHandle,
const char *keyValuePairs,
int delayMs)
{
@@ -1019,7 +1019,7 @@
const char *keyValuePairs,
int delayMs)
{
- mAudioCommandThread->parametersCommand((int)ioHandle, keyValuePairs,
+ mAudioCommandThread->parametersCommand(ioHandle, keyValuePairs,
delayMs);
}
@@ -1029,7 +1029,7 @@
int delayMs)
{
return (int)mAudioCommandThread->volumeCommand(stream, volume,
- (int)output, delayMs);
+ output, delayMs);
}
int AudioPolicyService::startTone(audio_policy_tone_t tone,
@@ -1362,7 +1362,7 @@
audio_policy_output_flags_t flags)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL) {
+ if (af == 0) {
ALOGW("%s: could not get AudioFlinger", __func__);
return 0;
}
@@ -1376,7 +1376,7 @@
audio_io_handle_t output2)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL) {
+ if (af == 0) {
ALOGW("%s: could not get AudioFlinger", __func__);
return 0;
}
@@ -1386,7 +1386,7 @@
static int aps_close_output(void *service, audio_io_handle_t output)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL)
+ if (af == 0)
return PERMISSION_DENIED;
return af->closeOutput(output);
@@ -1395,7 +1395,7 @@
static int aps_suspend_output(void *service, audio_io_handle_t output)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL) {
+ if (af == 0) {
ALOGW("%s: could not get AudioFlinger", __func__);
return PERMISSION_DENIED;
}
@@ -1406,7 +1406,7 @@
static int aps_restore_output(void *service, audio_io_handle_t output)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL) {
+ if (af == 0) {
ALOGW("%s: could not get AudioFlinger", __func__);
return PERMISSION_DENIED;
}
@@ -1422,7 +1422,7 @@
audio_in_acoustics_t acoustics)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL) {
+ if (af == 0) {
ALOGW("%s: could not get AudioFlinger", __func__);
return 0;
}
@@ -1434,7 +1434,7 @@
static int aps_close_input(void *service, audio_io_handle_t input)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL)
+ if (af == 0)
return PERMISSION_DENIED;
return af->closeInput(input);
@@ -1444,7 +1444,7 @@
audio_io_handle_t output)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL)
+ if (af == 0)
return PERMISSION_DENIED;
return af->setStreamOutput(stream, output);
@@ -1455,10 +1455,10 @@
audio_io_handle_t dst_output)
{
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
- if (af == NULL)
+ if (af == 0)
return PERMISSION_DENIED;
- return af->moveEffects(session, (int)src_output, (int)dst_output);
+ return af->moveEffects(session, src_output, dst_output);
}
static char * aps_get_parameters(void *service, audio_io_handle_t io_handle,
diff --git a/services/audioflinger/AudioPolicyService.h b/services/audioflinger/AudioPolicyService.h
index 62219e5..fdaf576 100644
--- a/services/audioflinger/AudioPolicyService.h
+++ b/services/audioflinger/AudioPolicyService.h
@@ -174,8 +174,10 @@
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);
+ status_t volumeCommand(audio_stream_type_t stream, float volume,
+ audio_io_handle_t output, int delayMs = 0);
+ status_t parametersCommand(audio_io_handle_t ioHandle,
+ const char *keyValuePairs, int delayMs = 0);
status_t voiceVolumeCommand(float volume, int delayMs = 0);
void insertCommand_l(AudioCommand *command, int delayMs = 0);
@@ -207,12 +209,12 @@
public:
audio_stream_type_t mStream;
float mVolume;
- int mIO;
+ audio_io_handle_t mIO;
};
class ParametersData {
public:
- int mIO;
+ audio_io_handle_t mIO;
String8 mKeyValuePairs;
};
diff --git a/services/audioflinger/AudioResampler.cpp b/services/audioflinger/AudioResampler.cpp
index feacd96..6e17a4a 100644
--- a/services/audioflinger/AudioResampler.cpp
+++ b/services/audioflinger/AudioResampler.cpp
@@ -130,12 +130,6 @@
mVolume[0] = mVolume[1] = 0;
mBuffer.frameCount = 0;
- // save format for quick lookup
- if (inChannelCount == 1) {
- mFormat = MONO_16_BIT;
- } else {
- mFormat = STEREO_16_BIT;
- }
}
AudioResampler::~AudioResampler() {
diff --git a/services/audioflinger/AudioResampler.h b/services/audioflinger/AudioResampler.h
index ffa690a..ee171ff 100644
--- a/services/audioflinger/AudioResampler.h
+++ b/services/audioflinger/AudioResampler.h
@@ -54,7 +54,7 @@
AudioBufferProvider* provider) = 0;
virtual void reset();
- virtual size_t getUnreleasedFrames() { return mInputIndex; }
+ virtual size_t getUnreleasedFrames() const { return mInputIndex; }
protected:
// number of bits for phase fraction - 30 bits allows nearly 2x downsampling
@@ -66,7 +66,6 @@
// multiplier to calculate fixed point phase increment
static const double kPhaseMultiplier = 1L << kNumPhaseBits;
- enum format {MONO_16_BIT, STEREO_16_BIT};
AudioResampler(int bitDepth, int inChannelCount, int32_t sampleRate);
// prevent copying
@@ -83,7 +82,6 @@
uint32_t mVolumeRL;
};
int16_t mTargetVolume[2];
- format mFormat;
size_t mInputIndex;
int32_t mPhaseIncrement;
uint32_t mPhaseFraction;
diff --git a/services/audioflinger/AudioResamplerSinc.h b/services/audioflinger/AudioResamplerSinc.h
index 0e1bc44..f0a07b8 100644
--- a/services/audioflinger/AudioResamplerSinc.h
+++ b/services/audioflinger/AudioResamplerSinc.h
@@ -31,7 +31,7 @@
public:
AudioResamplerSinc(int bitDepth, int inChannelCount, int32_t sampleRate);
- ~AudioResamplerSinc();
+ virtual ~AudioResamplerSinc();
virtual void resample(int32_t* out, size_t outFrameCount,
AudioBufferProvider* provider);