diff options
author | Glenn Kasten <gkasten@google.com> | 2012-01-17 11:09:42 -0800 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2012-02-08 10:06:32 -0800 |
commit | 39d00cb442985723295540468610b5c612d251c9 (patch) | |
tree | 65c1f26c9a8a770f27891d153ef433a9068a7a1b | |
parent | f31d05007c9cc5db90e0641e4f8621f5463dcb4e (diff) | |
download | frameworks_base-39d00cb442985723295540468610b5c612d251c9.zip frameworks_base-39d00cb442985723295540468610b5c612d251c9.tar.gz frameworks_base-39d00cb442985723295540468610b5c612d251c9.tar.bz2 |
Use audio_io_handle_t consistently instead of int
Other:
- add a comment to nextUniqueId
- made ThreadBase::mId const, since it is only assigned in constructor.
Change-Id: I4e8b7bec4e45badcde6274d574b8a9aabd046837
-rw-r--r-- | include/media/AudioSystem.h | 8 | ||||
-rw-r--r-- | include/media/IAudioFlinger.h | 53 | ||||
-rw-r--r-- | include/media/IAudioFlingerClient.h | 3 | ||||
-rw-r--r-- | media/libmedia/AudioSystem.cpp | 9 | ||||
-rw-r--r-- | media/libmedia/IAudioFlinger.cpp | 154 | ||||
-rw-r--r-- | media/libmedia/IAudioFlingerClient.cpp | 6 | ||||
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 81 | ||||
-rw-r--r-- | services/audioflinger/AudioFlinger.h | 88 | ||||
-rw-r--r-- | services/audioflinger/AudioPolicyService.cpp | 10 | ||||
-rw-r--r-- | services/audioflinger/AudioPolicyService.h | 10 |
10 files changed, 228 insertions, 194 deletions
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 @@ public: 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 @@ private: // 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/IAudioFlinger.h b/include/media/IAudioFlinger.h index 361cee6..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 @@ public: 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 @@ public: /* 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 @@ public: /* 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,8 +105,9 @@ public: 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) const = 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; @@ -111,31 +115,33 @@ public: // retrieve the audio recording buffer size 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) const = 0; + virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, + audio_io_handle_t output) const = 0; - virtual unsigned int getInputFramesLost(int ioHandle) const = 0; + virtual unsigned int getInputFramesLost(audio_io_handle_t ioHandle) const = 0; virtual int newAudioSessionId() = 0; @@ -153,13 +159,14 @@ public: 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 @@ public: 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/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 @@ status_t AudioSystem::getMasterMute(bool* mute) 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 @@ status_t AudioSystem::setStreamMute(audio_stream_type_t stream, bool mute) 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 @@ void AudioSystem::AudioFlingerClient::binderDied(const wp<IBinder>& who) { 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/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp index f6cf5ae..c3252e7 100644 --- a/media/libmedia/IAudioFlinger.cpp +++ b/media/libmedia/IAudioFlinger.cpp @@ -89,7 +89,7 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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) const + 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(); @@ -354,7 +355,7 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: return reply.readInt32(); } - virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output) const + 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 @@ public: return status; } - virtual unsigned int getInputFramesLost(int ioHandle) const + 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(); } @@ -607,7 +610,7 @@ public: 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, @@ -628,7 +631,7 @@ public: 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); @@ -654,13 +657,14 @@ public: 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(); } @@ -684,7 +688,7 @@ status_t BnAudioFlinger::onTransact( 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, @@ -698,7 +702,7 @@ status_t BnAudioFlinger::onTransact( 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(); @@ -715,27 +719,27 @@ status_t BnAudioFlinger::onTransact( } 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: { @@ -762,7 +766,7 @@ status_t BnAudioFlinger::onTransact( 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; @@ -804,14 +808,14 @@ status_t BnAudioFlinger::onTransact( } 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; @@ -839,14 +843,14 @@ status_t BnAudioFlinger::onTransact( 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); @@ -856,24 +860,24 @@ status_t BnAudioFlinger::onTransact( } 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: { @@ -884,12 +888,12 @@ status_t BnAudioFlinger::onTransact( 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); @@ -898,13 +902,13 @@ status_t BnAudioFlinger::onTransact( } 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; @@ -916,7 +920,7 @@ status_t BnAudioFlinger::onTransact( } 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); @@ -929,7 +933,7 @@ status_t BnAudioFlinger::onTransact( } 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; @@ -989,7 +993,7 @@ status_t BnAudioFlinger::onTransact( 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; @@ -1006,8 +1010,8 @@ status_t BnAudioFlinger::onTransact( 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 @@ public: { } - 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 @@ status_t BnAudioFlingerClient::onTransact( 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/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 70fb808..d05e9d9 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -383,7 +383,7 @@ sp<IAudioTrack> AudioFlinger::createTrack( int frameCount, uint32_t flags, const sp<IMemory>& sharedBuffer, - int output, + audio_io_handle_t output, int *sessionId, status_t *status) { @@ -476,7 +476,7 @@ Exit: 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); @@ -487,7 +487,7 @@ uint32_t AudioFlinger::sampleRate(int output) const 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); @@ -498,7 +498,7 @@ int AudioFlinger::channelCount(int output) const 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); @@ -509,7 +509,7 @@ audio_format_t AudioFlinger::format(int output) const 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); @@ -520,7 +520,7 @@ size_t AudioFlinger::frameCount(int output) const 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); @@ -654,7 +654,8 @@ bool AudioFlinger::masterMute() const 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()) { @@ -709,7 +710,7 @@ status_t AudioFlinger::setStreamMute(audio_stream_type_t stream, bool muted) 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; @@ -739,7 +740,7 @@ bool AudioFlinger::streamMute(audio_stream_type_t stream) const 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; @@ -814,7 +815,7 @@ status_t AudioFlinger::setParameters(int ioHandle, const String8& keyValuePairs) return BAD_VALUE; } -String8 AudioFlinger::getParameters(int ioHandle, const String8& keys) const +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()); @@ -854,7 +855,7 @@ size_t AudioFlinger::getInputBufferSize(uint32_t sampleRate, audio_format_t form return mPrimaryHardwareDev->get_input_buffer_size(mPrimaryHardwareDev, sampleRate, format, channelCount); } -unsigned int AudioFlinger::getInputFramesLost(int ioHandle) const +unsigned int AudioFlinger::getInputFramesLost(audio_io_handle_t ioHandle) const { if (ioHandle == 0) { return 0; @@ -889,7 +890,8 @@ status_t AudioFlinger::setVoiceVolume(float value) return ret; } -status_t AudioFlinger::getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output) const +status_t AudioFlinger::getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, + audio_io_handle_t output) const { status_t status; @@ -964,7 +966,7 @@ void AudioFlinger::removeNotificationClient(pid_t pid) } // 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++) { @@ -983,8 +985,8 @@ void AudioFlinger::removeClient_l(pid_t pid) // ---------------------------------------------------------------------------- -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), @@ -1354,7 +1356,7 @@ void AudioFlinger::ThreadBase::checkSuspendOnEffectEnabled_l(const sp<EffectModu 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), @@ -1820,7 +1822,7 @@ uint32_t AudioFlinger::PlaybackThread::activeSleepTimeUs() // ---------------------------------------------------------------------------- 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) @@ -2487,7 +2489,8 @@ uint32_t AudioFlinger::MixerThread::suspendSleepTimeUs() } // ---------------------------------------------------------------------------- -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 @@ -2969,7 +2972,7 @@ uint32_t AudioFlinger::DirectOutputThread::suspendSleepTimeUs() // ---------------------------------------------------------------------------- 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) { @@ -4116,7 +4119,7 @@ status_t AudioFlinger::TrackHandle::onTransact( sp<IAudioRecord> AudioFlinger::openRecord( pid_t pid, - int input, + audio_io_handle_t input, uint32_t sampleRate, audio_format_t format, uint32_t channelMask, @@ -4233,7 +4236,7 @@ AudioFlinger::RecordThread::RecordThread(const sp<AudioFlinger>& audioFlinger, 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), @@ -4893,7 +4896,7 @@ audio_stream_t* AudioFlinger::RecordThread::stream() // ---------------------------------------------------------------------------- -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, @@ -4939,7 +4942,7 @@ int AudioFlinger::openOutput(uint32_t *pDevices, 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) || @@ -4965,7 +4968,8 @@ int AudioFlinger::openOutput(uint32_t *pDevices, 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); @@ -4976,7 +4980,7 @@ int AudioFlinger::openDuplicateOutput(int output1, int output2) 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); @@ -4985,7 +4989,7 @@ int AudioFlinger::openDuplicateOutput(int output1, int output2) 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 @@ -5023,7 +5027,7 @@ status_t AudioFlinger::closeOutput(int output) 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); @@ -5038,7 +5042,7 @@ status_t AudioFlinger::suspendOutput(int output) 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); @@ -5054,7 +5058,7 @@ status_t AudioFlinger::restoreOutput(int output) 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, @@ -5110,7 +5114,7 @@ int AudioFlinger::openInput(uint32_t *pDevices, 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 @@ -5137,7 +5141,7 @@ int AudioFlinger::openInput(uint32_t *pDevices, 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 @@ -5165,7 +5169,7 @@ status_t AudioFlinger::closeInput(int input) 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); @@ -5303,7 +5307,7 @@ void AudioFlinger::purgeStaleEffects_l() { } // 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) { @@ -5313,7 +5317,7 @@ AudioFlinger::PlaybackThread *AudioFlinger::checkPlaybackThread_l(int output) co } // 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) { @@ -5325,7 +5329,7 @@ AudioFlinger::MixerThread *AudioFlinger::checkMixerThread_l(int output) const } // 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) { @@ -5392,7 +5396,7 @@ sp<IEffect> AudioFlinger::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, @@ -5579,7 +5583,8 @@ Exit: 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); @@ -5630,7 +5635,7 @@ status_t AudioFlinger::moveEffectChain_l(int sessionId, // 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); diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h index eca7eb8..dac9986 100644 --- a/services/audioflinger/AudioFlinger.h +++ b/services/audioflinger/AudioFlinger.h @@ -77,15 +77,15 @@ public: 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 @@ public: 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 @@ public: 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) const; + 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) const; - virtual unsigned int getInputFramesLost(int ioHandle) 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) const; + virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, + audio_io_handle_t output) const; virtual int newAudioSessionId(); @@ -158,13 +162,14 @@ public: 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, @@ -188,7 +193,7 @@ public: // 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, @@ -286,7 +291,7 @@ private: 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); @@ -422,7 +427,7 @@ private: 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 @@ private: 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 @@ -691,8 +696,8 @@ private: 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); @@ -817,7 +822,7 @@ private: 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,7 +849,8 @@ private: class DirectOutputThread : public PlaybackThread { public: - DirectOutputThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, int id, uint32_t device); + DirectOutputThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, + audio_io_handle_t id, uint32_t device); virtual ~DirectOutputThread(); // Thread virtuals @@ -870,7 +876,8 @@ private: class DuplicatingThread : public MixerThread { public: - DuplicatingThread (const sp<AudioFlinger>& audioFlinger, MixerThread* mainThread, int id); + DuplicatingThread (const sp<AudioFlinger>& audioFlinger, MixerThread* mainThread, + audio_io_handle_t id); virtual ~DuplicatingThread(); // Thread virtuals @@ -889,13 +896,16 @@ private: 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, @@ -973,7 +983,7 @@ private: AudioStreamIn *input, uint32_t sampleRate, uint32_t channels, - int id, + audio_io_handle_t id, uint32_t device); virtual ~RecordThread(); @@ -1401,14 +1411,14 @@ mutable Mutex mLock; // mutex for process, commands and handl 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; diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp index 755f51f..10efd85 100644 --- a/services/audioflinger/AudioPolicyService.cpp +++ b/services/audioflinger/AudioPolicyService.cpp @@ -819,7 +819,7 @@ void AudioPolicyService::AudioCommandThread::stopToneCommand() 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 @@ status_t AudioPolicyService::AudioCommandThread::volumeCommand(audio_stream_type 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 @@ void AudioPolicyService::setParameters(audio_io_handle_t ioHandle, const char *keyValuePairs, int delayMs) { - mAudioCommandThread->parametersCommand((int)ioHandle, keyValuePairs, + mAudioCommandThread->parametersCommand(ioHandle, keyValuePairs, delayMs); } @@ -1029,7 +1029,7 @@ int AudioPolicyService::setStreamVolume(audio_stream_type_t stream, int delayMs) { return (int)mAudioCommandThread->volumeCommand(stream, volume, - (int)output, delayMs); + output, delayMs); } int AudioPolicyService::startTone(audio_policy_tone_t tone, @@ -1458,7 +1458,7 @@ static int aps_move_effects(void *service, int session, 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 @@ private: 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 @@ private: 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; }; |