diff options
author | Eric Laurent <elaurent@google.com> | 2014-11-14 10:06:21 -0800 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2014-11-25 12:48:19 -0800 |
commit | e83b55dc29ca16092ba02f36f55fa6e0e37fd78c (patch) | |
tree | f8232611b6372b74579e3ed03dfbeb167011d257 /include | |
parent | 0f78eabb733e1413d7febd00c0bad0f0add02314 (diff) | |
download | frameworks_av-e83b55dc29ca16092ba02f36f55fa6e0e37fd78c.zip frameworks_av-e83b55dc29ca16092ba02f36f55fa6e0e37fd78c.tar.gz frameworks_av-e83b55dc29ca16092ba02f36f55fa6e0e37fd78c.tar.bz2 |
audio policy: new getOutputForAttr() prototype.
Update getOutputForAttr() prototype and group all logic
dealing with audio attributes to stream type conversion in
audio policy manager.
getOutputForAttr():
- specifies the audio session (for future use)
- returns a status code
- receives either stream type (for legacy) or audio attributes
- returns an updated streamtype
Remove logic dealing with legacy stream types to attributes conversion
from AudioTrack.
Use correct type for audio sessions in other APIs (startOutput() ...).
releaseOutput() specifies the audio session (for future use).
Bug: 18067208.
Change-Id: I1bfbe9626c04c7955d77f8a70aecfad2cb204817
Diffstat (limited to 'include')
-rw-r--r-- | include/media/AudioPolicyHelper.h | 53 | ||||
-rw-r--r-- | include/media/AudioSystem.h | 15 | ||||
-rw-r--r-- | include/media/AudioTrack.h | 11 | ||||
-rw-r--r-- | include/media/IAudioPolicyService.h | 25 |
4 files changed, 83 insertions, 21 deletions
diff --git a/include/media/AudioPolicyHelper.h b/include/media/AudioPolicyHelper.h index f4afd45..3ed0b74 100644 --- a/include/media/AudioPolicyHelper.h +++ b/include/media/AudioPolicyHelper.h @@ -18,7 +18,7 @@ #include <system/audio.h> -audio_stream_type_t audio_attributes_to_stream_type(const audio_attributes_t *attr) +static audio_stream_type_t audio_attributes_to_stream_type(const audio_attributes_t *attr) { // flags to stream type mapping if ((attr->flags & AUDIO_FLAG_AUDIBILITY_ENFORCED) == AUDIO_FLAG_AUDIBILITY_ENFORCED) { @@ -61,4 +61,55 @@ audio_stream_type_t audio_attributes_to_stream_type(const audio_attributes_t *at } } +static void stream_type_to_audio_attributes(audio_stream_type_t streamType, + audio_attributes_t *attr) { + attr->flags = 0x0; + + switch (streamType) { + case AUDIO_STREAM_DEFAULT: + case AUDIO_STREAM_MUSIC: + attr->content_type = AUDIO_CONTENT_TYPE_MUSIC; + attr->usage = AUDIO_USAGE_MEDIA; + break; + case AUDIO_STREAM_VOICE_CALL: + attr->content_type = AUDIO_CONTENT_TYPE_SPEECH; + attr->usage = AUDIO_USAGE_VOICE_COMMUNICATION; + break; + case AUDIO_STREAM_ENFORCED_AUDIBLE: + attr->flags |= AUDIO_FLAG_AUDIBILITY_ENFORCED; + // intended fall through, attributes in common with STREAM_SYSTEM + case AUDIO_STREAM_SYSTEM: + attr->content_type = AUDIO_CONTENT_TYPE_SONIFICATION; + attr->usage = AUDIO_USAGE_ASSISTANCE_SONIFICATION; + break; + case AUDIO_STREAM_RING: + attr->content_type = AUDIO_CONTENT_TYPE_SONIFICATION; + attr->usage = AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE; + break; + case AUDIO_STREAM_ALARM: + attr->content_type = AUDIO_CONTENT_TYPE_SONIFICATION; + attr->usage = AUDIO_USAGE_ALARM; + break; + case AUDIO_STREAM_NOTIFICATION: + attr->content_type = AUDIO_CONTENT_TYPE_SONIFICATION; + attr->usage = AUDIO_USAGE_NOTIFICATION; + break; + case AUDIO_STREAM_BLUETOOTH_SCO: + attr->content_type = AUDIO_CONTENT_TYPE_SPEECH; + attr->usage = AUDIO_USAGE_VOICE_COMMUNICATION; + attr->flags |= AUDIO_FLAG_SCO; + break; + case AUDIO_STREAM_DTMF: + attr->content_type = AUDIO_CONTENT_TYPE_SONIFICATION; + attr->usage = AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING; + break; + case AUDIO_STREAM_TTS: + attr->content_type = AUDIO_CONTENT_TYPE_SPEECH; + attr->usage = AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY; + break; + default: + ALOGE("invalid stream type %d when converting to attributes", streamType); + } +} + #endif //AUDIO_POLICY_HELPER_H_ diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h index 1614525..7f1afb3 100644 --- a/include/media/AudioSystem.h +++ b/include/media/AudioSystem.h @@ -215,7 +215,10 @@ public: audio_channel_mask_t channelMask = AUDIO_CHANNEL_OUT_STEREO, audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE, const audio_offload_info_t *offloadInfo = NULL); - static audio_io_handle_t getOutputForAttr(const audio_attributes_t *attr, + static status_t getOutputForAttr(const audio_attributes_t *attr, + audio_io_handle_t *output, + audio_session_t session, + audio_stream_type_t *stream, uint32_t samplingRate = 0, audio_format_t format = AUDIO_FORMAT_DEFAULT, audio_channel_mask_t channelMask = AUDIO_CHANNEL_OUT_STEREO, @@ -223,11 +226,13 @@ public: const audio_offload_info_t *offloadInfo = NULL); static status_t startOutput(audio_io_handle_t output, audio_stream_type_t stream, - int session); + audio_session_t session); static status_t stopOutput(audio_io_handle_t output, audio_stream_type_t stream, - int session); - static void releaseOutput(audio_io_handle_t output); + audio_session_t session); + static void releaseOutput(audio_io_handle_t output, + audio_stream_type_t stream, + audio_session_t session); // Client must successfully hand off the handle reference to AudioFlinger via openRecord(), // or release it with releaseInput(). @@ -235,7 +240,7 @@ public: uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, - int sessionId, + audio_session_t sessionId, audio_input_flags_t); static status_t startInput(audio_io_handle_t input, diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h index b5256f0..fd51b8f 100644 --- a/include/media/AudioTrack.h +++ b/include/media/AudioTrack.h @@ -239,6 +239,9 @@ public: * Parameters not listed in the AudioTrack constructors above: * * threadCanCallJava: Whether callbacks are made from an attached thread and thus can call JNI. + * + * Internal state post condition: + * (mStreamType == AUDIO_STREAM_DEFAULT) implies this AudioTrack has valid attributes */ status_t set(audio_stream_type_t streamType, uint32_t sampleRate, @@ -273,7 +276,7 @@ public: /* getters, see constructors and set() */ - audio_stream_type_t streamType() const { return mStreamType; } + audio_stream_type_t streamType() const; audio_format_t format() const { return mFormat; } /* Return frame size in bytes, which for linear PCM is @@ -598,9 +601,6 @@ protected: AudioTrack& operator = (const AudioTrack& other); void setAttributesFromStreamType(audio_stream_type_t streamType); - void setStreamTypeFromAttributes(audio_attributes_t& aa); - /* paa is guaranteed non-NULL */ - bool isValidAttributes(const audio_attributes_t *paa); /* a small internal class to handle the callback */ class AudioTrackThread : public Thread @@ -688,7 +688,8 @@ protected: // constant after constructor or set() audio_format_t mFormat; // as requested by client, not forced to 16-bit - audio_stream_type_t mStreamType; + audio_stream_type_t mStreamType; // mStreamType == AUDIO_STREAM_DEFAULT implies + // this AudioTrack has valid attributes uint32_t mChannelCount; audio_channel_mask_t mChannelMask; sp<IMemory> mSharedBuffer; diff --git a/include/media/IAudioPolicyService.h b/include/media/IAudioPolicyService.h index 16fe9cf..2f30304 100644 --- a/include/media/IAudioPolicyService.h +++ b/include/media/IAudioPolicyService.h @@ -56,24 +56,29 @@ public: audio_channel_mask_t channelMask = 0, audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE, const audio_offload_info_t *offloadInfo = NULL) = 0; - virtual audio_io_handle_t getOutputForAttr(const audio_attributes_t *attr, - uint32_t samplingRate = 0, - audio_format_t format = AUDIO_FORMAT_DEFAULT, - audio_channel_mask_t channelMask = 0, - audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE, - const audio_offload_info_t *offloadInfo = NULL) = 0; + virtual status_t getOutputForAttr(const audio_attributes_t *attr, + audio_io_handle_t *output, + audio_session_t session, + audio_stream_type_t *stream, + uint32_t samplingRate = 0, + audio_format_t format = AUDIO_FORMAT_DEFAULT, + audio_channel_mask_t channelMask = 0, + audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE, + const audio_offload_info_t *offloadInfo = NULL) = 0; virtual status_t startOutput(audio_io_handle_t output, audio_stream_type_t stream, - int session = 0) = 0; + audio_session_t session) = 0; virtual status_t stopOutput(audio_io_handle_t output, audio_stream_type_t stream, - int session = 0) = 0; - virtual void releaseOutput(audio_io_handle_t output) = 0; + audio_session_t session) = 0; + virtual void releaseOutput(audio_io_handle_t output, + audio_stream_type_t stream, + audio_session_t session) = 0; virtual audio_io_handle_t getInput(audio_source_t inputSource, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, - int audioSession, + audio_session_t audioSession, audio_input_flags_t flags) = 0; virtual status_t startInput(audio_io_handle_t input, audio_session_t session) = 0; |