summaryrefslogtreecommitdiffstats
path: root/libs/audioflinger
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2009-07-28 08:44:33 -0700
committerEric Laurent <elaurent@google.com>2009-08-07 00:27:19 -0700
commite0e9ecc0ce17cce2e681d099426da9d4d3d83377 (patch)
treee4c73b5c2df9f6df3bc16912c1be7d0974e1b9af /libs/audioflinger
parent3b2734f443d2799717e8b2b1847c8e2841764582 (diff)
downloadframeworks_native-e0e9ecc0ce17cce2e681d099426da9d4d3d83377.zip
frameworks_native-e0e9ecc0ce17cce2e681d099426da9d4d3d83377.tar.gz
frameworks_native-e0e9ecc0ce17cce2e681d099426da9d4d3d83377.tar.bz2
Fix issue 2001214: AudioFlinger and AudioPolicyService interfaces should not use pointers as handles to inputs and outputs.
Use integers instead of void* as input/output handles at IAudioFlinger and IAudioPolicyService interfaces. AudioFlinger maintains an always increasing count of opened inputs or outputs as unique ID.
Diffstat (limited to 'libs/audioflinger')
-rw-r--r--libs/audioflinger/AudioFlinger.cpp187
-rw-r--r--libs/audioflinger/AudioFlinger.h52
-rw-r--r--libs/audioflinger/AudioPolicyManagerGeneric.cpp38
-rw-r--r--libs/audioflinger/AudioPolicyService.cpp26
-rw-r--r--libs/audioflinger/AudioPolicyService.h8
5 files changed, 161 insertions, 150 deletions
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp
index 232ffb0..b34f214 100644
--- a/libs/audioflinger/AudioFlinger.cpp
+++ b/libs/audioflinger/AudioFlinger.cpp
@@ -115,7 +115,7 @@ static bool settingsAllowed() {
AudioFlinger::AudioFlinger()
: BnAudioFlinger(),
- mAudioHardware(0), mMasterVolume(1.0f), mMasterMute(false)
+ mAudioHardware(0), mMasterVolume(1.0f), mMasterMute(false), mNextThreadId(0)
{
mHardwareStatus = AUDIO_HW_IDLE;
@@ -231,12 +231,12 @@ status_t AudioFlinger::dump(int fd, const Vector<String16>& args)
// dump playback threads
for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
- mPlaybackThreads[i]->dump(fd, args);
+ mPlaybackThreads.valueAt(i)->dump(fd, args);
}
// dump record threads
for (size_t i = 0; i < mRecordThreads.size(); i++) {
- mRecordThreads[i]->dump(fd, args);
+ mRecordThreads.valueAt(i)->dump(fd, args);
}
if (mAudioHardware) {
@@ -260,7 +260,7 @@ sp<IAudioTrack> AudioFlinger::createTrack(
int frameCount,
uint32_t flags,
const sp<IMemory>& sharedBuffer,
- void *output,
+ int output,
status_t *status)
{
sp<PlaybackThread::Track> track;
@@ -308,56 +308,56 @@ Exit:
return trackHandle;
}
-uint32_t AudioFlinger::sampleRate(void *output) const
+uint32_t AudioFlinger::sampleRate(int output) const
{
Mutex::Autolock _l(mLock);
PlaybackThread *thread = checkPlaybackThread_l(output);
if (thread == NULL) {
- LOGW("sampleRate() unknown thread %p", output);
+ LOGW("sampleRate() unknown thread %d", output);
return 0;
}
return thread->sampleRate();
}
-int AudioFlinger::channelCount(void *output) const
+int AudioFlinger::channelCount(int output) const
{
Mutex::Autolock _l(mLock);
PlaybackThread *thread = checkPlaybackThread_l(output);
if (thread == NULL) {
- LOGW("channelCount() unknown thread %p", output);
+ LOGW("channelCount() unknown thread %d", output);
return 0;
}
return thread->channelCount();
}
-int AudioFlinger::format(void *output) const
+int AudioFlinger::format(int output) const
{
Mutex::Autolock _l(mLock);
PlaybackThread *thread = checkPlaybackThread_l(output);
if (thread == NULL) {
- LOGW("format() unknown thread %p", output);
+ LOGW("format() unknown thread %d", output);
return 0;
}
return thread->format();
}
-size_t AudioFlinger::frameCount(void *output) const
+size_t AudioFlinger::frameCount(int output) const
{
Mutex::Autolock _l(mLock);
PlaybackThread *thread = checkPlaybackThread_l(output);
if (thread == NULL) {
- LOGW("frameCount() unknown thread %p", output);
+ LOGW("frameCount() unknown thread %d", output);
return 0;
}
return thread->frameCount();
}
-uint32_t AudioFlinger::latency(void *output) const
+uint32_t AudioFlinger::latency(int output) const
{
Mutex::Autolock _l(mLock);
PlaybackThread *thread = checkPlaybackThread_l(output);
if (thread == NULL) {
- LOGW("latency() unknown thread %p", output);
+ LOGW("latency() unknown thread %d", output);
return 0;
}
return thread->latency();
@@ -380,7 +380,7 @@ status_t AudioFlinger::setMasterVolume(float value)
mMasterVolume = value;
for (uint32_t i = 0; i < mPlaybackThreads.size(); i++)
- mPlaybackThreads[i]->setMasterVolume(value);
+ mPlaybackThreads.valueAt(i)->setMasterVolume(value);
return NO_ERROR;
}
@@ -435,7 +435,7 @@ status_t AudioFlinger::setMasterMute(bool muted)
mMasterMute = muted;
for (uint32_t i = 0; i < mPlaybackThreads.size(); i++)
- mPlaybackThreads[i]->setMasterMute(muted);
+ mPlaybackThreads.valueAt(i)->setMasterMute(muted);
return NO_ERROR;
}
@@ -450,7 +450,7 @@ bool AudioFlinger::masterMute() const
return mMasterMute;
}
-status_t AudioFlinger::setStreamVolume(int stream, float value, void *output)
+status_t AudioFlinger::setStreamVolume(int stream, float value, int output)
{
// check calling permissions
if (!settingsAllowed()) {
@@ -495,7 +495,7 @@ status_t AudioFlinger::setStreamVolume(int stream, float value, void *output)
if (thread == NULL) {
for (uint32_t i = 0; i < mPlaybackThreads.size(); i++)
- mPlaybackThreads[i]->setStreamVolume(stream, value);
+ mPlaybackThreads.valueAt(i)->setStreamVolume(stream, value);
} else {
thread->setStreamVolume(stream, value);
@@ -518,12 +518,12 @@ status_t AudioFlinger::setStreamMute(int stream, bool muted)
mStreamTypes[stream].mute = muted;
for (uint32_t i = 0; i < mPlaybackThreads.size(); i++)
- mPlaybackThreads[i]->setStreamMute(stream, muted);
+ mPlaybackThreads.valueAt(i)->setStreamMute(stream, muted);
return NO_ERROR;
}
-float AudioFlinger::streamVolume(int stream, void *output) const
+float AudioFlinger::streamVolume(int stream, int output) const
{
if (stream < 0 || uint32_t(stream) >= AudioSystem::NUM_STREAM_TYPES) {
return 0.0f;
@@ -562,18 +562,18 @@ bool AudioFlinger::isMusicActive() const
{
Mutex::Autolock _l(mLock);
for (uint32_t i = 0; i < mPlaybackThreads.size(); i++) {
- if (mPlaybackThreads[i]->isMusicActive()) {
+ if (mPlaybackThreads.valueAt(i)->isMusicActive()) {
return true;
}
}
return false;
}
-status_t AudioFlinger::setParameters(void *ioHandle, const String8& keyValuePairs)
+status_t AudioFlinger::setParameters(int ioHandle, const String8& keyValuePairs)
{
status_t result;
- LOGV("setParameters(): io %p, keyvalue %s, tid %d, calling tid %d",
+ LOGV("setParameters(): io %d, keyvalue %s, tid %d, calling tid %d",
ioHandle, keyValuePairs.string(), gettid(), IPCThreadState::self()->getCallingPid());
// check calling permissions
if (!settingsAllowed()) {
@@ -604,9 +604,9 @@ status_t AudioFlinger::setParameters(void *ioHandle, const String8& keyValuePair
return BAD_VALUE;
}
-String8 AudioFlinger::getParameters(void *ioHandle, const String8& keys)
+String8 AudioFlinger::getParameters(int ioHandle, const String8& keys)
{
-// LOGV("getParameters() io %p, keys %s, tid %d, calling tid %d",
+// LOGV("getParameters() io %d, keys %s, tid %d, calling tid %d",
// ioHandle, keys.string(), gettid(), IPCThreadState::self()->getCallingPid());
if (ioHandle == 0) {
@@ -644,11 +644,11 @@ void AudioFlinger::registerClient(const sp<IAudioFlingerClient>& client)
// the config change is always sent from playback or record threads to avoid deadlock
// with AudioSystem::gLock
for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
- mPlaybackThreads[i]->sendConfigEvent(AudioSystem::OUTPUT_OPENED);
+ mPlaybackThreads.valueAt(i)->sendConfigEvent(AudioSystem::OUTPUT_OPENED);
}
for (size_t i = 0; i < mRecordThreads.size(); i++) {
- mRecordThreads[i]->sendConfigEvent(AudioSystem::INPUT_OPENED);
+ mRecordThreads.valueAt(i)->sendConfigEvent(AudioSystem::INPUT_OPENED);
}
}
@@ -668,14 +668,33 @@ void AudioFlinger::binderDied(const wp<IBinder>& who) {
}
}
-void AudioFlinger::audioConfigChanged(int event, void *param1, void *param2) {
+void AudioFlinger::audioConfigChanged(int event, const sp<ThreadBase>& thread, void *param2) {
Mutex::Autolock _l(mLock);
- size_t size = mNotificationClients.size();
- for (size_t i = 0; i < size; i++) {
- sp<IBinder> binder = mNotificationClients.itemAt(i);
- LOGV("audioConfigChanged() Notifying change to client %p", binder.get());
- sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient> (binder);
- client->ioConfigChanged(event, param1, param2);
+ int ioHandle = 0;
+
+ for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
+ if (mPlaybackThreads.valueAt(i) == thread) {
+ ioHandle = mPlaybackThreads.keyAt(i);
+ break;
+ }
+ }
+ if (ioHandle == 0) {
+ for (size_t i = 0; i < mRecordThreads.size(); i++) {
+ if (mRecordThreads.valueAt(i) == thread) {
+ ioHandle = mRecordThreads.keyAt(i);
+ break;
+ }
+ }
+ }
+
+ if (ioHandle != 0) {
+ size_t size = mNotificationClients.size();
+ for (size_t i = 0; i < size; i++) {
+ sp<IBinder> binder = mNotificationClients.itemAt(i);
+ LOGV("audioConfigChanged() Notifying change to client %p", binder.get());
+ sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient> (binder);
+ client->ioConfigChanged(event, ioHandle, param2);
+ }
}
}
@@ -2711,7 +2730,7 @@ status_t AudioFlinger::TrackHandle::onTransact(
sp<IAudioRecord> AudioFlinger::openRecord(
pid_t pid,
- void *input,
+ int input,
uint32_t sampleRate,
int format,
int channelCount,
@@ -3204,7 +3223,7 @@ void AudioFlinger::RecordThread::readInputParameters()
// ----------------------------------------------------------------------------
-void *AudioFlinger::openOutput(uint32_t *pDevices,
+int AudioFlinger::openOutput(uint32_t *pDevices,
uint32_t *pSamplingRate,
uint32_t *pFormat,
uint32_t *pChannels,
@@ -3227,7 +3246,7 @@ void *AudioFlinger::openOutput(uint32_t *pDevices,
flags);
if (pDevices == NULL || *pDevices == 0) {
- return NULL;
+ return 0;
}
Mutex::Autolock _l(mLock);
@@ -3249,12 +3268,12 @@ void *AudioFlinger::openOutput(uint32_t *pDevices,
(format != AudioSystem::PCM_16_BIT) ||
(channels != AudioSystem::CHANNEL_OUT_STEREO)) {
thread = new DirectOutputThread(this, output);
- LOGV("openOutput() created direct output %p", thread);
+ LOGV("openOutput() created direct output: ID %d thread %p", (mNextThreadId + 1), thread);
} else {
thread = new MixerThread(this, output);
- LOGV("openOutput() created mixer output %p", thread);
+ LOGV("openOutput() created mixer output: ID %d thread %p", (mNextThreadId + 1), thread);
}
- mPlaybackThreads.add(thread);
+ mPlaybackThreads.add(++mNextThreadId, thread);
if (pSamplingRate) *pSamplingRate = samplingRate;
if (pFormat) *pFormat = format;
@@ -3262,26 +3281,28 @@ void *AudioFlinger::openOutput(uint32_t *pDevices,
if (pLatencyMs) *pLatencyMs = thread->latency();
}
- return thread;
+ return mNextThreadId;
}
-void *AudioFlinger::openDuplicateOutput(void *output1, void *output2)
+int AudioFlinger::openDuplicateOutput(int output1, int output2)
{
Mutex::Autolock _l(mLock);
+ MixerThread *thread1 = checkMixerThread_l(output1);
+ MixerThread *thread2 = checkMixerThread_l(output2);
- if (checkMixerThread_l(output1) == NULL ||
- checkMixerThread_l(output2) == NULL) {
- LOGW("openDuplicateOutput() wrong output mixer type %p or %p", output1, output2);
- return NULL;
+ if (thread1 == NULL || thread2 == NULL) {
+ LOGW("openDuplicateOutput() wrong output mixer type for output %d or %d", output1, output2);
+ return 0;
}
- DuplicatingThread *thread = new DuplicatingThread(this, (MixerThread *)output1);
- thread->addOutputTrack( (MixerThread *)output2);
- mPlaybackThreads.add(thread);
- return thread;
+
+ DuplicatingThread *thread = new DuplicatingThread(this, thread1);
+ thread->addOutputTrack(thread2);
+ mPlaybackThreads.add(++mNextThreadId, thread);
+ return mNextThreadId;
}
-status_t AudioFlinger::closeOutput(void *output)
+status_t AudioFlinger::closeOutput(int output)
{
PlaybackThread *thread;
{
@@ -3291,24 +3312,24 @@ status_t AudioFlinger::closeOutput(void *output)
return BAD_VALUE;
}
- LOGV("closeOutput() %p", thread);
+ LOGV("closeOutput() %d", output);
if (thread->type() == PlaybackThread::MIXER) {
for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
- if (mPlaybackThreads[i]->type() == PlaybackThread::DUPLICATING) {
- DuplicatingThread *dupThread = (DuplicatingThread *)mPlaybackThreads[i].get();
+ if (mPlaybackThreads.valueAt(i)->type() == PlaybackThread::DUPLICATING) {
+ DuplicatingThread *dupThread = (DuplicatingThread *)mPlaybackThreads.valueAt(i).get();
dupThread->removeOutputTrack((MixerThread *)thread);
}
}
}
- mPlaybackThreads.remove(thread);
+ mPlaybackThreads.removeItem(output);
}
thread->exit();
return NO_ERROR;
}
-status_t AudioFlinger::suspendOutput(void *output)
+status_t AudioFlinger::suspendOutput(int output)
{
Mutex::Autolock _l(mLock);
PlaybackThread *thread = checkPlaybackThread_l(output);
@@ -3317,13 +3338,13 @@ status_t AudioFlinger::suspendOutput(void *output)
return BAD_VALUE;
}
- LOGV("suspendOutput() %p", output);
+ LOGV("suspendOutput() %d", output);
thread->suspend();
return NO_ERROR;
}
-status_t AudioFlinger::restoreOutput(void *output)
+status_t AudioFlinger::restoreOutput(int output)
{
Mutex::Autolock _l(mLock);
PlaybackThread *thread = checkPlaybackThread_l(output);
@@ -3332,14 +3353,14 @@ status_t AudioFlinger::restoreOutput(void *output)
return BAD_VALUE;
}
- LOGV("restoreOutput() %p", output);
+ LOGV("restoreOutput() %d", output);
thread->restore();
return NO_ERROR;
}
-void *AudioFlinger::openInput(uint32_t *pDevices,
+int AudioFlinger::openInput(uint32_t *pDevices,
uint32_t *pSamplingRate,
uint32_t *pFormat,
uint32_t *pChannels,
@@ -3355,7 +3376,7 @@ void *AudioFlinger::openInput(uint32_t *pDevices,
uint32_t reqChannels = channels;
if (pDevices == NULL || *pDevices == 0) {
- return NULL;
+ return 0;
}
Mutex::Autolock _l(mLock);
@@ -3392,8 +3413,8 @@ void *AudioFlinger::openInput(uint32_t *pDevices,
if (input != 0) {
// Start record thread
thread = new RecordThread(this, input, reqSamplingRate, reqChannels);
- mRecordThreads.add(thread);
-
+ mRecordThreads.add(++mNextThreadId, thread);
+ LOGV("openInput() created record thread: ID %d thread %p", mNextThreadId, thread);
if (pSamplingRate) *pSamplingRate = reqSamplingRate;
if (pFormat) *pFormat = format;
if (pChannels) *pChannels = reqChannels;
@@ -3401,10 +3422,10 @@ void *AudioFlinger::openInput(uint32_t *pDevices,
input->standby();
}
- return thread;
+ return mNextThreadId;
}
-status_t AudioFlinger::closeInput(void *input)
+status_t AudioFlinger::closeInput(int input)
{
RecordThread *thread;
{
@@ -3414,27 +3435,27 @@ status_t AudioFlinger::closeInput(void *input)
return BAD_VALUE;
}
- LOGV("closeInput() %p", thread);
- mRecordThreads.remove(thread);
+ LOGV("closeInput() %d", input);
+ mRecordThreads.removeItem(input);
}
thread->exit();
return NO_ERROR;
}
-status_t AudioFlinger::setStreamOutput(uint32_t stream, void *output)
+status_t AudioFlinger::setStreamOutput(uint32_t stream, int output)
{
Mutex::Autolock _l(mLock);
MixerThread *dstThread = checkMixerThread_l(output);
if (dstThread == NULL) {
- LOGW("setStreamOutput() bad output thread %p", output);
+ LOGW("setStreamOutput() bad output id %d", output);
return BAD_VALUE;
}
- LOGV("setStreamOutput() stream %d to output %p", stream, dstThread);
+ LOGV("setStreamOutput() stream %d to output %d", stream, output);
for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
- PlaybackThread *thread = mPlaybackThreads[i].get();
+ PlaybackThread *thread = mPlaybackThreads.valueAt(i).get();
if (thread != dstThread &&
thread->type() != PlaybackThread::DIRECT) {
MixerThread *srcThread = (MixerThread *)thread;
@@ -3452,22 +3473,17 @@ status_t AudioFlinger::setStreamOutput(uint32_t stream, void *output)
}
// checkPlaybackThread_l() must be called with AudioFlinger::mLock held
-AudioFlinger::PlaybackThread *AudioFlinger::checkPlaybackThread_l(void *output) const
+AudioFlinger::PlaybackThread *AudioFlinger::checkPlaybackThread_l(int output) const
{
PlaybackThread *thread = NULL;
-
- for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
- if (mPlaybackThreads[i] == output) {
- thread = (PlaybackThread *)output;
- break;
- }
+ if (mPlaybackThreads.indexOfKey(output) >= 0) {
+ thread = (PlaybackThread *)mPlaybackThreads.valueFor(output).get();
}
-
return thread;
}
// checkMixerThread_l() must be called with AudioFlinger::mLock held
-AudioFlinger::MixerThread *AudioFlinger::checkMixerThread_l(void *output) const
+AudioFlinger::MixerThread *AudioFlinger::checkMixerThread_l(int output) const
{
PlaybackThread *thread = checkPlaybackThread_l(output);
if (thread != NULL) {
@@ -3479,17 +3495,12 @@ AudioFlinger::MixerThread *AudioFlinger::checkMixerThread_l(void *output) const
}
// checkRecordThread_l() must be called with AudioFlinger::mLock held
-AudioFlinger::RecordThread *AudioFlinger::checkRecordThread_l(void *input) const
+AudioFlinger::RecordThread *AudioFlinger::checkRecordThread_l(int input) const
{
RecordThread *thread = NULL;
-
- for (size_t i = 0; i < mRecordThreads.size(); i++) {
- if (mRecordThreads[i] == input) {
- thread = (RecordThread *)input;
- break;
- }
+ if (mRecordThreads.indexOfKey(input) >= 0) {
+ thread = (RecordThread *)mRecordThreads.valueFor(input).get();
}
-
return thread;
}
diff --git a/libs/audioflinger/AudioFlinger.h b/libs/audioflinger/AudioFlinger.h
index 06c5846..4a4b823 100644
--- a/libs/audioflinger/AudioFlinger.h
+++ b/libs/audioflinger/AudioFlinger.h
@@ -73,14 +73,14 @@ public:
int frameCount,
uint32_t flags,
const sp<IMemory>& sharedBuffer,
- void *output,
+ int output,
status_t *status);
- virtual uint32_t sampleRate(void *output) const;
- virtual int channelCount(void *output) const;
- virtual int format(void *output) const;
- virtual size_t frameCount(void *output) const;
- virtual uint32_t latency(void *output) const;
+ virtual uint32_t sampleRate(int output) const;
+ virtual int channelCount(int output) const;
+ virtual int format(int output) const;
+ virtual size_t frameCount(int output) const;
+ virtual uint32_t latency(int output) const;
virtual status_t setMasterVolume(float value);
virtual status_t setMasterMute(bool muted);
@@ -88,10 +88,10 @@ public:
virtual float masterVolume() const;
virtual bool masterMute() const;
- virtual status_t setStreamVolume(int stream, float value, void *output);
+ virtual status_t setStreamVolume(int stream, float value, int output);
virtual status_t setStreamMute(int stream, bool muted);
- virtual float streamVolume(int stream, void *output) const;
+ virtual float streamVolume(int stream, int output) const;
virtual bool streamMute(int stream) const;
virtual status_t setMode(int mode);
@@ -101,37 +101,37 @@ public:
virtual bool isMusicActive() const;
- virtual status_t setParameters(void *ioHandle, const String8& keyValuePairs);
- virtual String8 getParameters(void *ioHandle, const String8& keys);
+ virtual status_t setParameters(int ioHandle, const String8& keyValuePairs);
+ virtual String8 getParameters(int ioHandle, const String8& keys);
virtual void registerClient(const sp<IAudioFlingerClient>& client);
virtual size_t getInputBufferSize(uint32_t sampleRate, int format, int channelCount);
- virtual void *openOutput(uint32_t *pDevices,
+ virtual int openOutput(uint32_t *pDevices,
uint32_t *pSamplingRate,
uint32_t *pFormat,
uint32_t *pChannels,
uint32_t *pLatencyMs,
uint32_t flags);
- virtual void *openDuplicateOutput(void *output1, void *output2);
+ virtual int openDuplicateOutput(int output1, int output2);
- virtual status_t closeOutput(void *output);
+ virtual status_t closeOutput(int output);
- virtual status_t suspendOutput(void *output);
+ virtual status_t suspendOutput(int output);
- virtual status_t restoreOutput(void *output);
+ virtual status_t restoreOutput(int output);
- virtual void *openInput(uint32_t *pDevices,
+ virtual int openInput(uint32_t *pDevices,
uint32_t *pSamplingRate,
uint32_t *pFormat,
uint32_t *pChannels,
uint32_t acoustics);
- virtual status_t closeInput(void *input);
+ virtual status_t closeInput(int input);
- virtual status_t setStreamOutput(uint32_t stream, void *output);
+ virtual status_t setStreamOutput(uint32_t stream, int output);
// IBinder::DeathRecipient
virtual void binderDied(const wp<IBinder>& who);
@@ -158,7 +158,7 @@ public:
// record interface
virtual sp<IAudioRecord> openRecord(
pid_t pid,
- void *input,
+ int input,
uint32_t sampleRate,
int format,
int channelCount,
@@ -172,8 +172,6 @@ public:
Parcel* reply,
uint32_t flags);
- void audioConfigChanged(int event, void *param1, void *param2);
-
private:
AudioFlinger();
virtual ~AudioFlinger();
@@ -615,10 +613,11 @@ private:
SortedVector < sp<OutputTrack> > mOutputTracks;
};
- PlaybackThread *checkPlaybackThread_l(void *output) const;
- MixerThread *checkMixerThread_l(void *output) const;
- RecordThread *checkRecordThread_l(void *input) const;
+ PlaybackThread *checkPlaybackThread_l(int output) const;
+ MixerThread *checkMixerThread_l(int output) const;
+ RecordThread *checkRecordThread_l(int input) const;
float streamVolumeInternal(int stream) const { return mStreamTypes[stream].volume; }
+ void audioConfigChanged(int event, const sp<ThreadBase>& thread, void *param2);
friend class AudioBuffer;
@@ -744,14 +743,15 @@ private:
mutable int mHardwareStatus;
- SortedVector< sp<PlaybackThread> > mPlaybackThreads;
+ DefaultKeyedVector< int, sp<PlaybackThread> > mPlaybackThreads;
PlaybackThread::stream_type_t mStreamTypes[AudioSystem::NUM_STREAM_TYPES];
float mMasterVolume;
bool mMasterMute;
- SortedVector< sp<RecordThread> > mRecordThreads;
+ DefaultKeyedVector< int, sp<RecordThread> > mRecordThreads;
SortedVector< sp<IBinder> > mNotificationClients;
+ int mNextThreadId;
};
// ----------------------------------------------------------------------------
diff --git a/libs/audioflinger/AudioPolicyManagerGeneric.cpp b/libs/audioflinger/AudioPolicyManagerGeneric.cpp
index 4b31815..6b17b87 100644
--- a/libs/audioflinger/AudioPolicyManagerGeneric.cpp
+++ b/libs/audioflinger/AudioPolicyManagerGeneric.cpp
@@ -224,7 +224,7 @@ audio_io_handle_t AudioPolicyManagerGeneric::getOutput(AudioSystem::stream_type
if ((flags & AudioSystem::OUTPUT_FLAG_DIRECT) ||
(format != 0 && !AudioSystem::isLinearPCM(format)) ||
(channels != 0 && channels != AudioSystem::CHANNEL_OUT_MONO && channels != AudioSystem::CHANNEL_OUT_STEREO)) {
- return NULL;
+ return 0;
}
return mHardwareOutput;
@@ -232,10 +232,10 @@ audio_io_handle_t AudioPolicyManagerGeneric::getOutput(AudioSystem::stream_type
status_t AudioPolicyManagerGeneric::startOutput(audio_io_handle_t output, AudioSystem::stream_type stream)
{
- LOGV("startOutput() output %p, stream %d", output, stream);
+ LOGV("startOutput() output %d, stream %d", output, stream);
ssize_t index = mOutputs.indexOfKey(output);
if (index < 0) {
- LOGW("startOutput() unknow output %p", output);
+ LOGW("startOutput() unknow output %d", output);
return BAD_VALUE;
}
@@ -253,10 +253,10 @@ status_t AudioPolicyManagerGeneric::startOutput(audio_io_handle_t output, AudioS
status_t AudioPolicyManagerGeneric::stopOutput(audio_io_handle_t output, AudioSystem::stream_type stream)
{
- LOGV("stopOutput() output %p, stream %d", output, stream);
+ LOGV("stopOutput() output %d, stream %d", output, stream);
ssize_t index = mOutputs.indexOfKey(output);
if (index < 0) {
- LOGW("stopOutput() unknow output %p", output);
+ LOGW("stopOutput() unknow output %d", output);
return BAD_VALUE;
}
@@ -272,17 +272,17 @@ status_t AudioPolicyManagerGeneric::stopOutput(audio_io_handle_t output, AudioSy
outputDesc->changeRefCount(stream, -1);
return NO_ERROR;
} else {
- LOGW("stopOutput() refcount is already 0 for output %p", output);
+ LOGW("stopOutput() refcount is already 0 for output %d", output);
return INVALID_OPERATION;
}
}
void AudioPolicyManagerGeneric::releaseOutput(audio_io_handle_t output)
{
- LOGV("releaseOutput() %p", output);
+ LOGV("releaseOutput() %d", output);
ssize_t index = mOutputs.indexOfKey(output);
if (index < 0) {
- LOGW("releaseOutput() releasing unknown output %p", output);
+ LOGW("releaseOutput() releasing unknown output %d", output);
return;
}
@@ -332,7 +332,7 @@ audio_io_handle_t AudioPolicyManagerGeneric::getInput(int inputSource,
samplingRate, format, channels);
mpClientInterface->closeInput(input);
delete inputDesc;
- return NULL;
+ return 0;
}
mInputs.add(input, inputDesc);
return input;
@@ -340,10 +340,10 @@ audio_io_handle_t AudioPolicyManagerGeneric::getInput(int inputSource,
status_t AudioPolicyManagerGeneric::startInput(audio_io_handle_t input)
{
- LOGV("startInput() input %p", input);
+ LOGV("startInput() input %d", input);
ssize_t index = mInputs.indexOfKey(input);
if (index < 0) {
- LOGW("startInput() unknow input %p", input);
+ LOGW("startInput() unknow input %d", input);
return BAD_VALUE;
}
AudioInputDescriptor *inputDesc = mInputs.valueAt(index);
@@ -355,7 +355,7 @@ status_t AudioPolicyManagerGeneric::startInput(audio_io_handle_t input)
// refuse 2 active AudioRecord clients at the same time
for (size_t i = 0; i < mInputs.size(); i++) {
if (mInputs.valueAt(i)->mRefCount > 0) {
- LOGW("startInput() input %p, other input %p already started", input, mInputs.keyAt(i));
+ LOGW("startInput() input %d, other input %d already started", input, mInputs.keyAt(i));
return INVALID_OPERATION;
}
}
@@ -367,16 +367,16 @@ status_t AudioPolicyManagerGeneric::startInput(audio_io_handle_t input)
status_t AudioPolicyManagerGeneric::stopInput(audio_io_handle_t input)
{
- LOGV("stopInput() input %p", input);
+ LOGV("stopInput() input %d", input);
ssize_t index = mInputs.indexOfKey(input);
if (index < 0) {
- LOGW("stopInput() unknow input %p", input);
+ LOGW("stopInput() unknow input %d", input);
return BAD_VALUE;
}
AudioInputDescriptor *inputDesc = mInputs.valueAt(index);
if (inputDesc->mRefCount == 0) {
- LOGW("stopInput() input %p already stopped", input);
+ LOGW("stopInput() input %d already stopped", input);
return INVALID_OPERATION;
} else {
inputDesc->mRefCount = 0;
@@ -386,10 +386,10 @@ status_t AudioPolicyManagerGeneric::stopInput(audio_io_handle_t input)
void AudioPolicyManagerGeneric::releaseInput(audio_io_handle_t input)
{
- LOGV("releaseInput() %p", input);
+ LOGV("releaseInput() %d", input);
ssize_t index = mInputs.indexOfKey(input);
if (index < 0) {
- LOGW("releaseInput() releasing unknown input %p", input);
+ LOGW("releaseInput() releasing unknown input %d", input);
return;
}
mpClientInterface->closeInput(input);
@@ -438,7 +438,7 @@ status_t AudioPolicyManagerGeneric::setStreamVolumeIndex(AudioSystem::stream_typ
float volume = computeVolume((int)stream, index, device);
- LOGV("setStreamVolume() for output %p stream %d, volume %f", mOutputs.keyAt(i), stream, volume);
+ LOGV("setStreamVolume() for output %d stream %d, volume %f", mOutputs.keyAt(i), stream, volume);
mpClientInterface->setStreamVolume(stream, volume, mOutputs.keyAt(i));
}
return NO_ERROR;
@@ -657,7 +657,7 @@ float AudioPolicyManagerGeneric::computeVolume(int stream, int index, uint32_t d
void AudioPolicyManagerGeneric::setStreamMute(int stream, bool on, audio_io_handle_t output)
{
- LOGV("setStreamMute() stream %d, mute %d, output %p", stream, on, output);
+ LOGV("setStreamMute() stream %d, mute %d, output %d", stream, on, output);
StreamDescriptor &streamDesc = mStreams[stream];
diff --git a/libs/audioflinger/AudioPolicyService.cpp b/libs/audioflinger/AudioPolicyService.cpp
index 7f6c4ed..ae17d76 100644
--- a/libs/audioflinger/AudioPolicyService.cpp
+++ b/libs/audioflinger/AudioPolicyService.cpp
@@ -201,7 +201,7 @@ audio_io_handle_t AudioPolicyService::getOutput(AudioSystem::stream_type stream,
AudioSystem::output_flags flags)
{
if (mpPolicyManager == NULL) {
- return NULL;
+ return 0;
}
LOGV("getOutput() tid %d", gettid());
Mutex::Autolock _l(mLock);
@@ -245,7 +245,7 @@ audio_io_handle_t AudioPolicyService::getInput(int inputSource,
AudioSystem::audio_in_acoustics acoustics)
{
if (mpPolicyManager == NULL) {
- return NULL;
+ return 0;
}
Mutex::Autolock _l(mLock);
return mpPolicyManager->getInput(inputSource, samplingRate, format, channels, acoustics);
@@ -381,7 +381,7 @@ audio_io_handle_t AudioPolicyService::openOutput(uint32_t *pDevices,
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
if (af == 0) {
LOGW("openOutput() could not get AudioFlinger");
- return NULL;
+ return 0;
}
return af->openOutput(pDevices, pSamplingRate, (uint32_t *)pFormat, pChannels, pLatencyMs, flags);
@@ -392,7 +392,7 @@ audio_io_handle_t AudioPolicyService::openDuplicateOutput(audio_io_handle_t outp
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
if (af == 0) {
LOGW("openDuplicateOutput() could not get AudioFlinger");
- return NULL;
+ return 0;
}
return af->openDuplicateOutput(output1, output2);
}
@@ -437,7 +437,7 @@ audio_io_handle_t AudioPolicyService::openInput(uint32_t *pDevices,
sp<IAudioFlinger> af = AudioSystem::get_audio_flinger();
if (af == 0) {
LOGW("openInput() could not get AudioFlinger");
- return NULL;
+ return 0;
}
return af->openInput(pDevices, pSamplingRate, (uint32_t *)pFormat, pChannels, acoustics);
@@ -453,7 +453,7 @@ status_t AudioPolicyService::closeInput(audio_io_handle_t input)
status_t AudioPolicyService::setStreamVolume(AudioSystem::stream_type stream, float volume, audio_io_handle_t output)
{
- return mAudioCommandThread->volumeCommand((int)stream, volume, (void *)output);
+ return mAudioCommandThread->volumeCommand((int)stream, volume, (int)output);
}
status_t AudioPolicyService::setStreamOutput(AudioSystem::stream_type stream, audio_io_handle_t output)
@@ -467,7 +467,7 @@ status_t AudioPolicyService::setStreamOutput(AudioSystem::stream_type stream, au
void AudioPolicyService::setParameters(audio_io_handle_t ioHandle, const String8& keyValuePairs)
{
- mAudioCommandThread->parametersCommand((void *)ioHandle, keyValuePairs);
+ mAudioCommandThread->parametersCommand((int)ioHandle, keyValuePairs);
}
String8 AudioPolicyService::getParameters(audio_io_handle_t ioHandle, const String8& keys)
@@ -547,7 +547,7 @@ bool AudioPolicyService::AudioCommandThread::threadLoop()
}break;
case SET_VOLUME: {
VolumeData *data = (VolumeData *)command->mParam;
- LOGV("AudioCommandThread() processing set volume stream %d, volume %f, output %p", data->mStream, data->mVolume, data->mIO);
+ LOGV("AudioCommandThread() processing set volume stream %d, volume %f, output %d", data->mStream, data->mVolume, data->mIO);
mCommandStatus = AudioSystem::setStreamVolume(data->mStream, data->mVolume, data->mIO);
mCommandCond.signal();
mWaitWorkCV.wait(mLock);
@@ -555,7 +555,7 @@ bool AudioPolicyService::AudioCommandThread::threadLoop()
}break;
case SET_PARAMETERS: {
ParametersData *data = (ParametersData *)command->mParam;
- LOGV("AudioCommandThread() processing set parameters string %s, io %p", data->mKeyValuePairs.string(), data->mIO);
+ LOGV("AudioCommandThread() processing set parameters string %s, io %d", data->mKeyValuePairs.string(), data->mIO);
mCommandStatus = AudioSystem::setParameters(data->mIO, data->mKeyValuePairs);
mCommandCond.signal();
mWaitWorkCV.wait(mLock);
@@ -599,7 +599,7 @@ void AudioPolicyService::AudioCommandThread::stopToneCommand()
mWaitWorkCV.signal();
}
-status_t AudioPolicyService::AudioCommandThread::volumeCommand(int stream, float volume, void *output)
+status_t AudioPolicyService::AudioCommandThread::volumeCommand(int stream, float volume, int output)
{
Mutex::Autolock _l(mLock);
AudioCommand *command = new AudioCommand();
@@ -610,7 +610,7 @@ status_t AudioPolicyService::AudioCommandThread::volumeCommand(int stream, float
data->mIO = output;
command->mParam = data;
mAudioCommands.add(command);
- LOGV("AudioCommandThread() adding set volume stream %d, volume %f, output %p", stream, volume, output);
+ LOGV("AudioCommandThread() adding set volume stream %d, volume %f, output %d", stream, volume, output);
mWaitWorkCV.signal();
mCommandCond.wait(mLock);
status_t status = mCommandStatus;
@@ -618,7 +618,7 @@ status_t AudioPolicyService::AudioCommandThread::volumeCommand(int stream, float
return status;
}
-status_t AudioPolicyService::AudioCommandThread::parametersCommand(void *ioHandle, const String8& keyValuePairs)
+status_t AudioPolicyService::AudioCommandThread::parametersCommand(int ioHandle, const String8& keyValuePairs)
{
Mutex::Autolock _l(mLock);
AudioCommand *command = new AudioCommand();
@@ -628,7 +628,7 @@ status_t AudioPolicyService::AudioCommandThread::parametersCommand(void *ioHandl
data->mKeyValuePairs = keyValuePairs;
command->mParam = data;
mAudioCommands.add(command);
- LOGV("AudioCommandThread() adding set parameter string %s, io %p", keyValuePairs.string(), ioHandle);
+ LOGV("AudioCommandThread() adding set parameter string %s, io %d", keyValuePairs.string(), ioHandle);
mWaitWorkCV.signal();
mCommandCond.wait(mLock);
status_t status = mCommandStatus;
diff --git a/libs/audioflinger/AudioPolicyService.h b/libs/audioflinger/AudioPolicyService.h
index 1c46975..3909fa4 100644
--- a/libs/audioflinger/AudioPolicyService.h
+++ b/libs/audioflinger/AudioPolicyService.h
@@ -136,8 +136,8 @@ private:
void exit();
void startToneCommand(int type = 0, int stream = 0);
void stopToneCommand();
- status_t volumeCommand(int stream, float volume, void *output);
- status_t parametersCommand(void *ioHandle, const String8& keyValuePairs);
+ status_t volumeCommand(int stream, float volume, int output);
+ status_t parametersCommand(int ioHandle, const String8& keyValuePairs);
private:
// descriptor for requested tone playback event
@@ -157,11 +157,11 @@ private:
public:
int mStream;
float mVolume;
- void *mIO;
+ int mIO;
};
class ParametersData {
public:
- void *mIO;
+ int mIO;
String8 mKeyValuePairs;
};