From 52dfbee90cc3c4426428318e06a92774f5201198 Mon Sep 17 00:00:00 2001 From: Praveen Chavan Date: Wed, 15 Oct 2014 02:24:34 -0700 Subject: Stagefright: MediaCodec: shutdown allocated codec on error If MediaCodec sees a fatal error and transitions to UNINITIALIZED state, The codec may still be alive (with an exception of 'mediaserver-died' error). Handle Shutdown of the codec during release(). Bug: 17784012 Bug: 18033275 Change-Id: I891e036499d9b440a57f77fb735a5ba4da9a6e43 --- include/media/stagefright/MediaCodec.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/media/stagefright/MediaCodec.h b/include/media/stagefright/MediaCodec.h index bca78b9..54a4e8b 100644 --- a/include/media/stagefright/MediaCodec.h +++ b/include/media/stagefright/MediaCodec.h @@ -205,6 +205,7 @@ private: kFlagIsEncoder = 256, kFlagGatherCodecSpecificData = 512, kFlagIsAsync = 1024, + kFlagIsComponentAllocated = 2048, }; struct BufferInfo { -- cgit v1.1 From 30358faf33fb9b638257b017fadb4c5f7352d903 Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Tue, 21 Oct 2014 16:07:52 -0700 Subject: stagefright: try to free codec instance if MediaCodec.release hangs Bug: 18033275 Change-Id: If86cd26566d7b75941976f37829bbec619800778 --- include/media/stagefright/ACodec.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h index d77ddaf..fcccc6d 100644 --- a/include/media/stagefright/ACodec.h +++ b/include/media/stagefright/ACodec.h @@ -120,6 +120,7 @@ private: kWhatSetParameters = 'setP', kWhatSubmitOutputMetaDataBufferIfEOS = 'subm', kWhatOMXDied = 'OMXd', + kWhatReleaseCodecInstance = 'relC', }; enum { -- cgit v1.1 From df2592beab557663a471da2ac33ca463f7eee722 Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Fri, 24 Oct 2014 18:53:44 -0700 Subject: do not hold mNotifyLock when calling MediaPlayer::notify Bug:18120688 Change-Id: Ia66dcfc3fd2d67d1ceba9808d21e0120cc8691d6 --- include/media/MediaPlayerInterface.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h index cf18a45..c412299 100644 --- a/include/media/MediaPlayerInterface.h +++ b/include/media/MediaPlayerInterface.h @@ -208,8 +208,15 @@ public: void sendEvent(int msg, int ext1=0, int ext2=0, const Parcel *obj=NULL) { - Mutex::Autolock autoLock(mNotifyLock); - if (mNotify) mNotify(mCookie, msg, ext1, ext2, obj); + notify_callback_f notifyCB; + void* cookie; + { + Mutex::Autolock autoLock(mNotifyLock); + notifyCB = mNotify; + cookie = mCookie; + } + + if (notifyCB) notifyCB(cookie, msg, ext1, ext2, obj); } virtual status_t dump(int fd, const Vector &args) const { -- cgit v1.1 From 3c1285e8f86bd497e14c14fb6df7b42072ef52bd Mon Sep 17 00:00:00 2001 From: Jeff Tinker Date: Fri, 31 Oct 2014 00:55:16 -0700 Subject: Add missing secure stop methods b/18053197 b/18076411 Change-Id: I923dc893d48c70bf17980007b32f0ac5dfd22896 --- include/media/IDrm.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/media/IDrm.h b/include/media/IDrm.h index 68de87a..affcbd7 100644 --- a/include/media/IDrm.h +++ b/include/media/IDrm.h @@ -73,8 +73,10 @@ struct IDrm : public IInterface { virtual status_t unprovisionDevice() = 0; virtual status_t getSecureStops(List > &secureStops) = 0; + virtual status_t getSecureStop(Vector const &ssid, Vector &secureStop) = 0; virtual status_t releaseSecureStops(Vector const &ssRelease) = 0; + virtual status_t releaseAllSecureStops() = 0; virtual status_t getPropertyString(String8 const &name, String8 &value) const = 0; virtual status_t getPropertyByteArray(String8 const &name, @@ -137,4 +139,3 @@ private: } // namespace android #endif // ANDROID_IDRM_H_ - -- cgit v1.1 From 2514d080c8a54ff603a45d7e336de668fe7329db Mon Sep 17 00:00:00 2001 From: Jeff Tinker Date: Mon, 3 Nov 2014 13:29:35 -0800 Subject: Pass resolution to Crypto plugin on format change Change-Id: I56cd557ce3525fe625db8c312d2557d3c8b51101 related-to-bug: 16034599 --- include/media/ICrypto.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/media/ICrypto.h b/include/media/ICrypto.h index 9dcb8d9..07742ca 100644 --- a/include/media/ICrypto.h +++ b/include/media/ICrypto.h @@ -41,6 +41,8 @@ struct ICrypto : public IInterface { virtual bool requiresSecureDecoderComponent( const char *mime) const = 0; + virtual void notifyResolution(uint32_t width, uint32_t height) = 0; + virtual ssize_t decrypt( bool secure, const uint8_t key[16], @@ -64,4 +66,3 @@ struct BnCrypto : public BnInterface { } // namespace android #endif // ANDROID_ICRYPTO_H_ - -- cgit v1.1 From 04f101c35eaa90b1f95939afac30674ec1611e6f Mon Sep 17 00:00:00 2001 From: Dan Stoza Date: Tue, 4 Nov 2014 11:32:52 -0800 Subject: Add a BufferItem parameter to onFrameAvailable Passes the BufferItem for the queued buffer to the onFrameAvailable callback so the consumer can track the BufferQueue's contents. Bug: 18111837 Change-Id: If9d07229c9b586c668e5f99074e9b63b0468feb0 --- include/camera/ProCamera.h | 2 +- include/media/stagefright/SurfaceMediaSource.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/camera/ProCamera.h b/include/camera/ProCamera.h index 83a3028..e9b687a 100644 --- a/include/camera/ProCamera.h +++ b/include/camera/ProCamera.h @@ -265,7 +265,7 @@ private: } protected: - virtual void onFrameAvailable() { + virtual void onFrameAvailable(const BufferItem& /* item */) { sp c = mCamera.promote(); if (c.get() != NULL) { c->onFrameAvailable(mStreamId); diff --git a/include/media/stagefright/SurfaceMediaSource.h b/include/media/stagefright/SurfaceMediaSource.h index 43b75fd..d15a226 100644 --- a/include/media/stagefright/SurfaceMediaSource.h +++ b/include/media/stagefright/SurfaceMediaSource.h @@ -124,7 +124,7 @@ protected: // Implementation of the BufferQueue::ConsumerListener interface. These // calls are used to notify the Surface of asynchronous events in the // BufferQueue. - virtual void onFrameAvailable(); + virtual void onFrameAvailable(const BufferItem& item); // Used as a hook to BufferQueue::disconnect() // This is called by the client side when it is done -- cgit v1.1 From 74adca9ad30b7f8a70d40c5237bade0d16c4ea58 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Wed, 5 Nov 2014 12:15:36 -0800 Subject: IAudioPolicyService: bound array size in queryDefaultPreProcessing Bug: 18226810. Change-Id: Ib8e2bfe835a8681aac50bf23161db14e50c9a124 --- include/media/AudioEffect.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/media/AudioEffect.h b/include/media/AudioEffect.h index 4932d40..583695d 100644 --- a/include/media/AudioEffect.h +++ b/include/media/AudioEffect.h @@ -133,10 +133,11 @@ public: * * Returned value * *descriptor updated with descriptors of pre processings enabled by default - * *count number of descriptors returned if returned status is N_ERROR. + * *count number of descriptors returned if returned status is NO_ERROR. * total number of pre processing enabled by default if returned status is * NO_MEMORY. This happens if the count passed as input is less than the number - * of descriptors to return + * of descriptors to return. + * *count is limited to kMaxPreProcessing on return. */ static status_t queryDefaultPreProcessing(int audioSession, effect_descriptor_t *descriptors, @@ -391,6 +392,10 @@ public: */ static status_t guidToString(const effect_uuid_t *guid, char *str, size_t maxLen); + // kMaxPreProcessing is a reasonable value for the maximum number of preprocessing effects + // that can be applied simultaneously. + static const uint32_t kMaxPreProcessing = 10; + protected: bool mEnabled; // enable state int32_t mSessionId; // audio session ID -- cgit v1.1 From d2d089fc86c62843992e7d5b371ee9227189a1e6 Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Wed, 5 Nov 2014 11:48:12 -0800 Subject: Improve AudioTrack recovery from mediaserver death 1. Fix race condition in handling of binder death notifications. AudioSystem has a mixture of APIs for both ordinary app clients, and the AudioFlinger and AudioPolicy services within mediaserver. Due to this mix of uses, it is possible for there to be "surprising" sequences of calls on the call stack. Previously, we used a single mutex for all global variables, but this caused a deadlock. To avoid the deadlock, we unlocked the mutex during the critical sequence of calls. But this was a a crucial place where it should have stayed locked; see Change-Id I315c1c5066f62b05e1c13b04fae1272b5fbce977 Now we use separate mutexes for the AudioFlinger, AudioPolicy, and audio port related global variables. This allows us to correctly hold each mutex throughout the atomic region, even when AudioFlinger calls AudioPolicy via AudioSystem, or vice-versa. 2. AudioSystem::clearAudioConfigCache now clears the IAudioFlinger reference. 3. Make AudioSystem::get_audio_policy_service more like get_audio_flinger. Bug: 18242291 Change-Id: I9761443d8337df5bf66d4ca2316a9fd0bd11be94 --- include/media/AudioSystem.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h index f8c0198..341f9ab 100644 --- a/include/media/AudioSystem.h +++ b/include/media/AudioSystem.h @@ -377,7 +377,10 @@ private: friend class AudioFlingerClient; friend class AudioPolicyServiceClient; - static Mutex gLock; + static Mutex gLock; // protects all members except gAudioPolicyService, + // gAudioPolicyServiceClient, and gAudioPortCallback + static Mutex gLockAPS; // protects gAudioPolicyService and gAudioPolicyServiceClient + static Mutex gLockAPC; // protects gAudioPortCallback static sp gAudioFlinger; static audio_error_callback gAudioErrorCallback; -- cgit v1.1 From a36060891425c4ce0621e40344ac473ec14924dd Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Thu, 6 Nov 2014 18:07:23 -0800 Subject: AudioSystem: remove obsolete method. Bug: 18067208. Change-Id: I9bbf9088485f5162c765ca504d9b784b956234c6 --- include/media/AudioSystem.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h index f8c0198..6f46f9e 100644 --- a/include/media/AudioSystem.h +++ b/include/media/AudioSystem.h @@ -116,8 +116,6 @@ public: static status_t getLatency(audio_io_handle_t output, uint32_t* latency); - static bool routedToA2dpOutput(audio_stream_type_t streamType); - // return status NO_ERROR implies *buffSize > 0 static status_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, audio_channel_mask_t channelMask, size_t* buffSize); -- cgit v1.1 From f296e2b262d2a8f7c570eaed454a28cca99eb976 Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Wed, 18 Jun 2014 18:08:52 -0700 Subject: stagefright: add runtime debug support Bug: 18285408 Change-Id: I56346f4652b2c5f7ef5fa3003fd8676051339384 --- include/media/stagefright/foundation/ADebug.h | 30 ++++++++++++++++++ .../media/stagefright/foundation/AStringUtils.h | 36 ++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 include/media/stagefright/foundation/AStringUtils.h (limited to 'include') diff --git a/include/media/stagefright/foundation/ADebug.h b/include/media/stagefright/foundation/ADebug.h index 450dcfe..1d0e2cb 100644 --- a/include/media/stagefright/foundation/ADebug.h +++ b/include/media/stagefright/foundation/ADebug.h @@ -80,6 +80,36 @@ MAKE_COMPARATOR(GT,>) __FILE__ ":" LITERAL_TO_STRING(__LINE__) \ " Should not be here."); +struct ADebug { + enum Level { + kDebugNone, // no debug + kDebugLifeCycle, // lifecycle events: creation/deletion + kDebugState, // commands and events + kDebugConfig, // configuration + kDebugInternalState, // internal state changes + kDebugAll, // all + kDebugMax = kDebugAll, + + }; + + // parse the property or string to get the debug level for a component name + // string format is: + // [:][,[:]...] + // - is 0-5 corresponding to ADebug::Level + // - is used to match component name case insensitively, if omitted, it + // matches all components + // - string is read left-to-right, and the last matching level is returned, or + // the def if no terms matched + static Level GetDebugLevelFromProperty( + const char *name, const char *propertyName, Level def = kDebugNone); + static Level GetDebugLevelFromString( + const char *name, const char *value, Level def = kDebugNone); + + // remove redundant segments of a codec name, and return a newly allocated + // string suitable for debugging + static char *GetDebugName(const char *name); +}; + } // namespace android #endif // A_DEBUG_H_ diff --git a/include/media/stagefright/foundation/AStringUtils.h b/include/media/stagefright/foundation/AStringUtils.h new file mode 100644 index 0000000..76a7791 --- /dev/null +++ b/include/media/stagefright/foundation/AStringUtils.h @@ -0,0 +1,36 @@ +/* + * Copyright 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef A_STRING_UTILS_H_ +#define A_STRING_UTILS_H_ + +#include + +namespace android { + +struct AStringUtils { + // similar to strncmp or strcasecmp, but case sensitivity is parametric + static int Compare(const char *a, const char *b, size_t len, bool ignoreCase); + + // matches a string (str) to a glob pattern that supports: + // * - matches any number of characters + static bool MatchesGlob( + const char *glob, size_t globLen, const char *str, size_t strLen, bool ignoreCase); +}; + +} // namespace android + +#endif // A_STRING_UTILS_H_ -- cgit v1.1 From 1099188151eb63af24ecf542b58d4257bbb8236a Mon Sep 17 00:00:00 2001 From: Praveen Chavan Date: Thu, 16 Oct 2014 11:49:14 -0700 Subject: Stagefright: use MediaCodec in async mode for recording Async mode reduces the number of messages posted between MediaCodec and MediaCodecSource. This reduces thread wakeups and helps reduce CPU utilization. Bug: 18246026 Change-Id: I4b0837f309fdd12e323c1dfa72525f5a31971a03 --- include/media/stagefright/MediaCodecSource.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/media/stagefright/MediaCodecSource.h b/include/media/stagefright/MediaCodecSource.h index 3629c8b..0970b2b 100644 --- a/include/media/stagefright/MediaCodecSource.h +++ b/include/media/stagefright/MediaCodecSource.h @@ -85,8 +85,6 @@ private: status_t initEncoder(); void releaseEncoder(); status_t feedEncoderInputBuffers(); - void scheduleDoMoreWork(); - status_t doMoreWork(int32_t numInput, int32_t numOutput); void suspend(); void resume(int64_t skipFramesBeforeUs = -1ll); void signalEOS(status_t err = ERROR_END_OF_STREAM); @@ -108,8 +106,6 @@ private: bool mDoMoreWorkPending; sp mEncoderActivityNotify; sp mGraphicBufferProducer; - Vector > mEncoderInputBuffers; - Vector > mEncoderOutputBuffers; List mInputBufferQueue; List mAvailEncoderInputIndices; List mDecodingTimeQueue; // decoding time (us) for video -- cgit v1.1 From 0d6db582f2ccc9f8943c5f3965e2994b7d137158 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Wed, 12 Nov 2014 18:39:44 -0800 Subject: remove AudioSystem::getOutputSamplingRateForAttr() It is safer to query the output sampling rate once the output have been acquired by calling getOutputForAttr(). Bug: 16009464. Change-Id: Ib561facd19fba5359a6b837d75f1a1cd2dc51b29 --- include/media/AudioSystem.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h index 6a0f2a6..f3b7fbb 100644 --- a/include/media/AudioSystem.h +++ b/include/media/AudioSystem.h @@ -99,8 +99,6 @@ public: // to be non-zero if status == NO_ERROR static status_t getOutputSamplingRate(uint32_t* samplingRate, audio_stream_type_t stream); - static status_t getOutputSamplingRateForAttr(uint32_t* samplingRate, - const audio_attributes_t *attr); static status_t getOutputFrameCount(size_t* frameCount, audio_stream_type_t stream); static status_t getOutputLatency(uint32_t* latency, -- cgit v1.1 From cb2129b3b568a4e31bcbda3545a468024bc972fe Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Tue, 11 Nov 2014 12:17:22 -0800 Subject: Fix missing loop count for static tracks. StaticAudioTrackServerProxy::framesReady() previously returned only the contiguous frames, update to return the total available frames. This resolves short-count looping in SoundPool for FastTracks. Also (1) Removes the racy condition of reading two variables and (2) Fixes buffer->mNonContig to return the correct value and (3) Restores behavior that loop count of 1 goes back to loopStart once during playback. Bug: 11830751 Bug: 12070295 Bug: 17456842 Change-Id: I64906e6036bb00a1d7375b03efe6deb69d6478ca --- include/private/media/AudioTrackShared.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h index fa1b20a..31dff36 100644 --- a/include/private/media/AudioTrackShared.h +++ b/include/private/media/AudioTrackShared.h @@ -450,7 +450,14 @@ private: ssize_t pollPosition(); // poll for state queue update, and return current position StaticAudioTrackSingleStateQueue::Observer mObserver; size_t mPosition; // server's current play position in frames, relative to 0 - size_t mEnd; // cached value computed from mState, safe for asynchronous read + + size_t mFramesReadySafe; // Assuming size_t read/writes are atomic on 32 / 64 bit + // processors, this is a thread-safe version of + // mFramesReady. + int64_t mFramesReady; // The number of frames ready in the static buffer + // including loops. This is 64 bits since loop mode + // can cause a track to appear to have a large number + // of frames. INT64_MAX means an infinite loop. bool mFramesReadyIsCalledByMultipleThreads; StaticAudioTrackState mState; }; -- cgit v1.1 From f6778fd0c72ab54328f0e9f5ecf0017b73e99dd8 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Tue, 18 Nov 2014 17:26:58 -0800 Subject: AudioSystem: Add mutex for output cache Fix cross deadlock with AudioFlinger by adding a dedicated mutex to protect access to cached output list and parameters. Bug: 18410728. Change-Id: Ia31283b1972d8865a46e84e63695173c187eb781 --- include/media/AudioSystem.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h index f3b7fbb..d54eca7 100644 --- a/include/media/AudioSystem.h +++ b/include/media/AudioSystem.h @@ -373,10 +373,11 @@ private: friend class AudioFlingerClient; friend class AudioPolicyServiceClient; - static Mutex gLock; // protects all members except gAudioPolicyService, - // gAudioPolicyServiceClient, and gAudioPortCallback - static Mutex gLockAPS; // protects gAudioPolicyService and gAudioPolicyServiceClient - static Mutex gLockAPC; // protects gAudioPortCallback + static Mutex gLock; // protects gAudioFlinger and gAudioErrorCallback, + static Mutex gLockCache; // protects gOutputs, gPrevInSamplingRate, gPrevInFormat, + // gPrevInChannelMask and gInBuffSize + static Mutex gLockAPS; // protects gAudioPolicyService and gAudioPolicyServiceClient + static Mutex gLockAPC; // protects gAudioPortCallback static sp gAudioFlinger; static audio_error_callback gAudioErrorCallback; -- cgit v1.1 From 0ebd5f95b68a3a5c9e5509f21938c9e51e74d71b Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Wed, 19 Nov 2014 19:04:52 -0800 Subject: AudioSystem: fix cross deadlock Do not hold gLockAPS when calling AudioPolicyService::registerClient() in get_audio_policy_service(). registerClient() will need to acquire the AudioPolicyService mutex and if at the same time a method called from AudioPolicyService (with mutex held) calls back into AudioSystem and get_audio_policy_service() a cross deadlock occurs. Same preventive fix for get_audio_flinger(). Use a separate mutex for notification client list in AudioPolicyService. This prevents deadlocking if registerClient() is called as a consequence of AudioFlinger calling back into AudioPolicyManager while executing a method with AudioPolicyService locked Bug: 18403952. Bug: 18450065. Change-Id: Ia832e41aede8bc6c843fc615508fbdd74e0863b5 --- include/media/AudioSystem.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h index d54eca7..1614525 100644 --- a/include/media/AudioSystem.h +++ b/include/media/AudioSystem.h @@ -90,7 +90,7 @@ public: static void setErrorCallback(audio_error_callback cb); // helper function to obtain AudioFlinger service handle - static const sp& get_audio_flinger(); + static const sp get_audio_flinger(); static float linearToLog(int volume); static int logToLinear(float volume); @@ -270,7 +270,7 @@ public: // and output configuration cache (gOutputs) static void clearAudioConfigCache(); - static const sp& get_audio_policy_service(); + static const sp get_audio_policy_service(); // helpers for android.media.AudioManager.getProperty(), see description there for meaning static uint32_t getPrimaryOutputSamplingRate(); -- cgit v1.1 From e83b55dc29ca16092ba02f36f55fa6e0e37fd78c Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Fri, 14 Nov 2014 10:06:21 -0800 Subject: 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 --- include/media/AudioPolicyHelper.h | 53 ++++++++++++++++++++++++++++++++++++- include/media/AudioSystem.h | 15 +++++++---- include/media/AudioTrack.h | 11 ++++---- include/media/IAudioPolicyService.h | 25 ++++++++++------- 4 files changed, 83 insertions(+), 21 deletions(-) (limited to 'include') 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 -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 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; -- cgit v1.1 From caf7f48a0ef558689d39aafd187c1571ff4128b4 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Tue, 25 Nov 2014 17:50:47 -0800 Subject: AudioRecord: use audio attributes instead of audio source. Added AudioRecord constructor with audio attributes. Replaced AudioPolicymanager::getInput() by getInputForAttr(). No new functionality for now. Also: - Fixed warnings in AudioPolicyManager - Allocate audio session ID before calling getOutputForAttr() in AudioTrack. Bug: 16006090. Change-Id: I15df21e4411db688e3096dd801cf579d76d81711 --- include/media/AudioRecord.h | 11 +++++++---- include/media/AudioSystem.h | 7 ++++--- include/media/IAudioPolicyService.h | 13 +++++++------ 3 files changed, 18 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h index 4edc1bf..f70d981 100644 --- a/include/media/AudioRecord.h +++ b/include/media/AudioRecord.h @@ -152,6 +152,7 @@ public: * transferType: How data is transferred from AudioRecord. * flags: See comments on audio_input_flags_t in * threadCanCallJava: Not present in parameter list, and so is fixed at false. + * pAttributes: if not NULL, supersedes inputSource for use case selection */ AudioRecord(audio_source_t inputSource, @@ -164,7 +165,8 @@ public: uint32_t notificationFrames = 0, int sessionId = AUDIO_SESSION_ALLOCATE, transfer_type transferType = TRANSFER_DEFAULT, - audio_input_flags_t flags = AUDIO_INPUT_FLAG_NONE); + audio_input_flags_t flags = AUDIO_INPUT_FLAG_NONE, + const audio_attributes_t* pAttributes = NULL); /* Terminates the AudioRecord and unregisters it from AudioFlinger. * Also destroys all resources associated with the AudioRecord. @@ -198,7 +200,8 @@ public: bool threadCanCallJava = false, int sessionId = AUDIO_SESSION_ALLOCATE, transfer_type transferType = TRANSFER_DEFAULT, - audio_input_flags_t flags = AUDIO_INPUT_FLAG_NONE); + audio_input_flags_t flags = AUDIO_INPUT_FLAG_NONE, + const audio_attributes_t* pAttributes = NULL); /* Result of constructing the AudioRecord. This must be checked for successful initialization * before using any AudioRecord API (except for set()), because using @@ -219,7 +222,7 @@ public: uint32_t channelCount() const { return mChannelCount; } size_t frameCount() const { return mFrameCount; } size_t frameSize() const { return mFrameSize; } - audio_source_t inputSource() const { return mInputSource; } + audio_source_t inputSource() const { return mAttributes.source; } /* After it's created the track is not active. Call start() to * make it active. If set, the callback will start being called. @@ -489,7 +492,6 @@ private: audio_format_t mFormat; uint32_t mChannelCount; size_t mFrameSize; // app-level frame size == AudioFlinger frame size - audio_source_t mInputSource; uint32_t mLatency; // in ms audio_channel_mask_t mChannelMask; audio_input_flags_t mFlags; @@ -529,6 +531,7 @@ private: sp mDeathNotifier; uint32_t mSequence; // incremented for each new IAudioRecord attempt + audio_attributes_t mAttributes; }; }; // namespace android diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h index 7f1afb3..bf1fc1c 100644 --- a/include/media/AudioSystem.h +++ b/include/media/AudioSystem.h @@ -236,12 +236,13 @@ public: // Client must successfully hand off the handle reference to AudioFlinger via openRecord(), // or release it with releaseInput(). - static audio_io_handle_t getInput(audio_source_t inputSource, + static status_t getInputForAttr(const audio_attributes_t *attr, + audio_io_handle_t *input, + audio_session_t session, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, - audio_session_t sessionId, - audio_input_flags_t); + audio_input_flags_t flags); static status_t startInput(audio_io_handle_t input, audio_session_t session); diff --git a/include/media/IAudioPolicyService.h b/include/media/IAudioPolicyService.h index 2f30304..3e4b873 100644 --- a/include/media/IAudioPolicyService.h +++ b/include/media/IAudioPolicyService.h @@ -74,12 +74,13 @@ public: 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, - audio_session_t audioSession, - audio_input_flags_t flags) = 0; + virtual status_t getInputForAttr(const audio_attributes_t *attr, + audio_io_handle_t *input, + audio_session_t session, + uint32_t samplingRate, + audio_format_t format, + audio_channel_mask_t channelMask, + audio_input_flags_t flags) = 0; virtual status_t startInput(audio_io_handle_t input, audio_session_t session) = 0; virtual status_t stopInput(audio_io_handle_t input, -- cgit v1.1 From 4e865a3cfe4c955e0890321a6b488cf661808b63 Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Fri, 5 Dec 2014 15:54:51 -0800 Subject: stagefright: preserve output format flags on format change Some flags are only set in configure, and get lost when output format changes. Bug: 17383204 Change-Id: I2011bce70920c4ee46fccc378da3b428f3395c11 --- include/media/stagefright/ACodec.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h index fcccc6d..4d4ce90 100644 --- a/include/media/stagefright/ACodec.h +++ b/include/media/stagefright/ACodec.h @@ -182,6 +182,7 @@ private: sp mNativeWindow; sp mInputFormat; sp mOutputFormat; + sp mBaseOutputFormat; Vector mBuffers[2]; bool mPortEOS[2]; -- cgit v1.1 From 275e8e9de2e11b4b344f5a201f1f0e51fda02d9c Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Sun, 30 Nov 2014 15:14:47 -0800 Subject: audio policy: add support for custom mixes Add support for custom mixes in AudioPolicyManager. Two methods are added to register or unregister a list of custom mixes with their attributes and format. getOutputForAttr() and getInputForAttr() first look for a match in registered mixes before defaulting to normal output/input selection Remote submix device connection disconnection now takes address into account to identify the correspnoding custom mix. Bug: 16009464. Change-Id: I3f1c2a485a0fb71b1f984ed0adc9b68aa971e408 --- include/media/AudioPolicy.h | 82 +++++++++++++++++++++++++++++++++++++++ include/media/AudioPolicyHelper.h | 2 +- 2 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 include/media/AudioPolicy.h (limited to 'include') diff --git a/include/media/AudioPolicy.h b/include/media/AudioPolicy.h new file mode 100644 index 0000000..a755e1e --- /dev/null +++ b/include/media/AudioPolicy.h @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef ANDROID_AUDIO_POLICY_H +#define ANDROID_AUDIO_POLICY_H + +#include +#include +#include +#include +#include + +namespace android { + +// Keep in sync with AudioMix.java, AudioMixingRule.java, AudioPolicyConfig.java +#define RULE_EXCLUSION_MASK 0x8000 +#define RULE_MATCH_ATTRIBUTE_USAGE 0x1 +#define RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET (0x1 << 1) +#define RULE_EXCLUDE_ATTRIBUTE_USAGE (RULE_EXCLUSION_MASK|RULE_MATCH_ATTRIBUTE_USAGE) +#define RULE_EXCLUDE_ATTRIBUTE_CAPTURE_PRESET \ + (RULE_EXCLUSION_MASK|RULE_MATCH_ATTRIBUTE_CAPTURE_PRESET) + +#define MIX_TYPE_INVALID -1 +#define MIX_TYPE_PLAYERS 0 +#define MIX_TYPE_RECORDERS 1 + +#define ROUTE_FLAG_RENDER 0x1 +#define ROUTE_FLAG_LOOP_BACK (0x1 << 1) + +#define MAX_MIXES_PER_POLICY 10 +#define MAX_CRITERIA_PER_MIX 20 + +class AttributeMatchCriterion { +public: + AttributeMatchCriterion() {} + AttributeMatchCriterion(audio_usage_t usage, audio_source_t source, uint32_t rule); + + status_t readFromParcel(Parcel *parcel); + status_t writeToParcel(Parcel *parcel) const; + + union { + audio_usage_t mUsage; + audio_source_t mSource; + } mAttr; + uint32_t mRule; +}; + +class AudioMix { +public: + AudioMix() {} + AudioMix(Vector criteria, uint32_t mixType, audio_config_t format, + uint32_t routeFlags, String8 registrationId) : + mCriteria(criteria), mMixType(mixType), mFormat(format), + mRouteFlags(routeFlags), mRegistrationId(registrationId) {} + + status_t readFromParcel(Parcel *parcel); + status_t writeToParcel(Parcel *parcel) const; + + Vector mCriteria; + uint32_t mMixType; + audio_config_t mFormat; + uint32_t mRouteFlags; + String8 mRegistrationId; +}; + +}; // namespace android + +#endif // ANDROID_AUDIO_POLICY_H diff --git a/include/media/AudioPolicyHelper.h b/include/media/AudioPolicyHelper.h index 3ed0b74..79231be 100644 --- a/include/media/AudioPolicyHelper.h +++ b/include/media/AudioPolicyHelper.h @@ -63,7 +63,7 @@ static audio_stream_type_t audio_attributes_to_stream_type(const audio_attribute static void stream_type_to_audio_attributes(audio_stream_type_t streamType, audio_attributes_t *attr) { - attr->flags = 0x0; + memset(attr, 0, sizeof(audio_attributes_t)); switch (streamType) { case AUDIO_STREAM_DEFAULT: -- cgit v1.1 From baac183f3808d7b68f184647a97bd381620415fe Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Mon, 1 Dec 2014 17:52:59 -0800 Subject: audio policy: binder calls for dynamic audio policy mixes Add binder calls to register and unregister dynamic mixes to AudioPolicyManager. Bug: 16009464. Change-Id: I4ef38166d0cfc88c984970969380d0cd6eb083ac --- include/media/AudioSystem.h | 3 +++ include/media/IAudioPolicyService.h | 3 +++ 2 files changed, 6 insertions(+) (limited to 'include') diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h index bf1fc1c..843a354 100644 --- a/include/media/AudioSystem.h +++ b/include/media/AudioSystem.h @@ -18,6 +18,7 @@ #define ANDROID_AUDIOSYSTEM_H_ #include +#include #include #include #include @@ -324,6 +325,8 @@ public: static audio_mode_t getPhoneState(); + static status_t registerPolicyMixes(Vector mixes, bool registration); + // ---------------------------------------------------------------------------- class AudioPortCallback : public RefBase diff --git a/include/media/IAudioPolicyService.h b/include/media/IAudioPolicyService.h index 3e4b873..c98c475 100644 --- a/include/media/IAudioPolicyService.h +++ b/include/media/IAudioPolicyService.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -150,6 +151,8 @@ public: virtual status_t releaseSoundTriggerSession(audio_session_t session) = 0; virtual audio_mode_t getPhoneState() = 0; + + virtual status_t registerPolicyMixes(Vector mixes, bool registration) = 0; }; -- cgit v1.1 From a0940a569f2bc24b00dc10ce0fa7658b1dc3a3a5 Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Wed, 24 Sep 2014 13:57:35 -0700 Subject: stagefright: misc fixes to software video encoders (and decoders) - move logic to set encoder parameters to common encoder class (similarly to what was done for decoders) - set compressed buffer size based on frame size and compression ratio, and codec-specific minimum size - set raw buffer size based on frame size and metadata mode - do not set stride and slice height on compressed ports - advertise only QCIF support for google H263 encoder - set large-enough input size for video decoders to support adaptive playback - do not change input buffer size on output port reconfiguration, as no input buffer reallocation takes place - do not return empty buffers with EOS after EOS has been signaled Bug: 18513091 Bug: 18639027 Change-Id: Ib13492ef66adf331aa4572c67d2b283ea020cb41 --- include/media/stagefright/foundation/AUtils.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/media/stagefright/foundation/AUtils.h b/include/media/stagefright/foundation/AUtils.h index 3a73a39..d7ecf50 100644 --- a/include/media/stagefright/foundation/AUtils.h +++ b/include/media/stagefright/foundation/AUtils.h @@ -40,6 +40,12 @@ inline static const T divUp(const T &nom, const T &den) { } } +/* == ceil(nom / den) * den. T must be integer type, alignment must be positive power of 2 */ +template +inline static const T align(const T &nom, const U &den) { + return (nom + (T)(den - 1)) & (T)~(den - 1); +} + template inline static T abs(const T &a) { return a < 0 ? -a : a; -- cgit v1.1 From eee82e44548f17253c2e06b25725f91c7b549ec2 Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Fri, 12 Dec 2014 12:27:54 -0800 Subject: MediaCodecList: handle binder death Bug: 18691591 Change-Id: Icc402d6ea9b0de4ac642c3b403fb64e865481b2e --- include/media/stagefright/MediaCodecList.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/media/stagefright/MediaCodecList.h b/include/media/stagefright/MediaCodecList.h index 8605d99..c2bbe4d 100644 --- a/include/media/stagefright/MediaCodecList.h +++ b/include/media/stagefright/MediaCodecList.h @@ -52,6 +52,12 @@ struct MediaCodecList : public BnMediaCodecList { static sp getLocalInstance(); private: + class BinderDeathObserver : public IBinder::DeathRecipient { + void binderDied(const wp &the_late_who __unused); + }; + + static sp sBinderDeathObserver; + enum Section { SECTION_TOPLEVEL, SECTION_DECODERS, -- cgit v1.1 From 8a4728966dc9c78e21c3c93a927707e93c05e5e0 Mon Sep 17 00:00:00 2001 From: Rachad Date: Tue, 23 Dec 2014 16:10:32 -0800 Subject: ACodec: Added support for E-AC3 decoders Bug: 17883772 Change-Id: I05f674c33522eec0e6ceeece88dd800b1857b3ab --- include/media/stagefright/ACodec.h | 2 ++ include/media/stagefright/MediaDefs.h | 1 + 2 files changed, 3 insertions(+) (limited to 'include') diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h index 4d4ce90..f448359 100644 --- a/include/media/stagefright/ACodec.h +++ b/include/media/stagefright/ACodec.h @@ -282,6 +282,8 @@ private: status_t setupAC3Codec(bool encoder, int32_t numChannels, int32_t sampleRate); + status_t setupEAC3Codec(bool encoder, int32_t numChannels, int32_t sampleRate); + status_t selectAudioPortFormat( OMX_U32 portIndex, OMX_AUDIO_CODINGTYPE desiredFormat); diff --git a/include/media/stagefright/MediaDefs.h b/include/media/stagefright/MediaDefs.h index e67d4d5..13695d5 100644 --- a/include/media/stagefright/MediaDefs.h +++ b/include/media/stagefright/MediaDefs.h @@ -47,6 +47,7 @@ extern const char *MEDIA_MIMETYPE_AUDIO_FLAC; extern const char *MEDIA_MIMETYPE_AUDIO_AAC_ADTS; extern const char *MEDIA_MIMETYPE_AUDIO_MSGSM; extern const char *MEDIA_MIMETYPE_AUDIO_AC3; +extern const char *MEDIA_MIMETYPE_AUDIO_EAC3; extern const char *MEDIA_MIMETYPE_CONTAINER_MPEG4; extern const char *MEDIA_MIMETYPE_CONTAINER_WAV; -- cgit v1.1 From 1713460104b86f6be3a5d9993d9ace864d889b2d Mon Sep 17 00:00:00 2001 From: Chong Zhang Date: Wed, 7 Jan 2015 16:14:34 -0800 Subject: mark any copyrighted content as protected to disable capture bug: 18916274 Change-Id: I23f096b51433bf18a10dc5fe6dc6b75c3881c340 --- include/media/stagefright/ACodec.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h index 4d4ce90..faa2caf 100644 --- a/include/media/stagefright/ACodec.h +++ b/include/media/stagefright/ACodec.h @@ -131,6 +131,7 @@ private: enum { kFlagIsSecure = 1, kFlagPushBlankBuffersToNativeWindowOnShutdown = 2, + kFlagIsGrallocUsageProtected = 4, }; struct BufferInfo { -- cgit v1.1 From 78b01639c08fe5e7e9c1be5e9dc5de560f1383f9 Mon Sep 17 00:00:00 2001 From: Rachad Date: Thu, 29 Jan 2015 19:24:08 -0800 Subject: Acodec: Send framerate information to OMX decoder if available Bug: 19110889 Change-Id: Ia8dbe1b77aaac421ec9415884e1248b9b68168dc --- include/media/stagefright/ACodec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h index 371e2c8..8509d55 100644 --- a/include/media/stagefright/ACodec.h +++ b/include/media/stagefright/ACodec.h @@ -264,7 +264,7 @@ private: status_t setVideoFormatOnPort( OMX_U32 portIndex, int32_t width, int32_t height, - OMX_VIDEO_CODINGTYPE compressionFormat); + OMX_VIDEO_CODINGTYPE compressionFormat, float frameRate = -1.0); typedef struct drcParams { int32_t drcCut; -- cgit v1.1 From 0d09182a1dde960f7acda1c28469e5deead1b996 Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Fri, 30 Jan 2015 14:07:25 -0800 Subject: stagefright: add support for native flex-YUV formats Bug: 17906609 Change-Id: I14116796eaa94aa8ae62dcc29f67cb7d2c060d34 --- include/media/stagefright/ACodec.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h index 8509d55..595ace8 100644 --- a/include/media/stagefright/ACodec.h +++ b/include/media/stagefright/ACodec.h @@ -78,7 +78,7 @@ struct ACodec : public AHierarchicalStateMachine, public CodecBase { static bool isFlexibleColorFormat( const sp &omx, IOMX::node_id node, - uint32_t colorFormat, OMX_U32 *flexibleEquivalent); + uint32_t colorFormat, bool usingNativeBuffers, OMX_U32 *flexibleEquivalent); // Returns 0 if configuration is not supported. NOTE: this is treated by // some OMX components as auto level, and by others as invalid level. @@ -251,12 +251,13 @@ private: status_t setVideoPortFormatType( OMX_U32 portIndex, OMX_VIDEO_CODINGTYPE compressionFormat, - OMX_COLOR_FORMATTYPE colorFormat); + OMX_COLOR_FORMATTYPE colorFormat, + bool usingNativeBuffers = false); - status_t setSupportedOutputFormat(); + status_t setSupportedOutputFormat(bool getLegacyFlexibleFormat); status_t setupVideoDecoder( - const char *mime, const sp &msg); + const char *mime, const sp &msg, bool usingNativeBuffers); status_t setupVideoEncoder( const char *mime, const sp &msg); -- cgit v1.1 From 3a01a71dcbb467d06cc5da4a72a82bb588648cfc Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Fri, 30 Jan 2015 19:30:05 -0800 Subject: stagefright: add fallback for native flex-YUV support Use software renderer if codec cannot support flex-YUV on a surface Bug: 17906609 Change-Id: I3d0e3ff5fee7d7b3e2416892968fa18f6139598a --- include/media/stagefright/MediaCodec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/media/stagefright/MediaCodec.h b/include/media/stagefright/MediaCodec.h index 54a4e8b..d448097 100644 --- a/include/media/stagefright/MediaCodec.h +++ b/include/media/stagefright/MediaCodec.h @@ -194,7 +194,7 @@ private: }; enum { - kFlagIsSoftwareCodec = 1, + kFlagUsesSoftwareRenderer = 1, kFlagOutputFormatChanged = 2, kFlagOutputBuffersChanged = 4, kFlagStickyError = 8, -- cgit v1.1 From 35d5af131c9d4962e935082f204ccd6a2130861c Mon Sep 17 00:00:00 2001 From: Weiyin Jiang Date: Wed, 28 Jan 2015 16:14:02 +0800 Subject: nuplayer: acquire wakelock during offload pause timeout Hold a wakelock while paused in audio offload mode, until audio teardown event is received, or pause is canceled. Since ARM cores are sleeping, the delayed AMessage will not be received, and the audio output driver will not be closed. This blocks XO shutdown. Bug: 19297092 Change-Id: I3d11fef633e3f2783f4aa31e71285e2fa09d234c --- include/media/stagefright/foundation/AWakeLock.h | 68 ++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 include/media/stagefright/foundation/AWakeLock.h (limited to 'include') diff --git a/include/media/stagefright/foundation/AWakeLock.h b/include/media/stagefright/foundation/AWakeLock.h new file mode 100644 index 0000000..57716c1 --- /dev/null +++ b/include/media/stagefright/foundation/AWakeLock.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef A_WAKELOCK_H_ +#define A_WAKELOCK_H_ + +#include +#include +#include + +namespace android { + +class AWakeLock : public RefBase { + +public: + AWakeLock(); + + // NOTE: acquire and release are not thread safe + + // returns true if wakelock was acquired + bool acquire(); + void release(bool force = false); + + virtual ~AWakeLock(); + +private: + sp mPowerManager; + sp mWakeLockToken; + uint32_t mWakeLockCount; + + class PMDeathRecipient : public IBinder::DeathRecipient { + public: + PMDeathRecipient(AWakeLock *wakeLock) : mWakeLock(wakeLock) {} + virtual ~PMDeathRecipient() {} + + // IBinder::DeathRecipient + virtual void binderDied(const wp &who); + + private: + PMDeathRecipient(const PMDeathRecipient&); + PMDeathRecipient& operator= (const PMDeathRecipient&); + + AWakeLock *mWakeLock; + }; + + const sp mDeathRecipient; + + void clearPowerManager(); + + DISALLOW_EVIL_CONSTRUCTORS(AWakeLock); +}; + +} // namespace android + +#endif // A_WAKELOCK_H_ -- cgit v1.1