summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/AudioPlayer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* warnings be gone.Andreas Huber2014-04-111-1/+1
| | | | | | | | (cherry picked from commit 84333e0475bc911adc16417f4ca327c975cf6c36) Modified by Mark Salyzyn <salyzyn@google.com> to keep merge conflicts or errors downstream to a minimum. Change-Id: Ic3b272f9cbf3155001aabd2f79728f1bc31de613
* update offloaded audio track sampling rateEric Laurent2013-12-171-2/+13
| | | | | | | | AudioPlayer must read the sampling rate from offloaded audio sinks whenever a new time position is computed as the decoder can update the sampling rate on the fly. Change-Id: I997e5248cfd4017aeceb4e11689324ded2a5bc88
* fix playback position after switching to offloadEric Laurent2013-09-271-13/+21
| | | | | | | | | | | | | | | | After switching from offloaded track to PCM track while paused (e.g. when connecting A2DP), playback restarts from the beginning of the song when resuming. Save current position before recreating an AudioPlayer in AwesomePlayer::play_l() and seek to the saved position before starting playback. Also fix a problem where the position is not reported properly by AudioPlayer if a seek is pending and queried just after start and before the first buffer is read from the MediaSource. Bug: 8174034. Change-Id: I254e65418ff903a9bf2e2111b89a00e2e54876c5
* AudioPlayer: timestamp fixes for compress offloadHaynes Mathew George2013-08-291-7/+16
| | | | | | | Use realtime queried from AudioTrack as the only time for compress offload playback. Change-Id: I314447637715c4864690c94173260165369146cb
* stagefright: offload playback supportRichard Fitzgerald2013-07-261-67/+281
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Offloading of compressed audio decoding to audio DSP is implemented for audio only, non streamed content. when the datasource is AudioPlayer: - Create an offloaded sink when playing a compressed source - Send metadata to audio HAL - Return sink start error to AwesomePlayer so that a new player for PCM audio can be created in case of problem. - Forward stream end and tear down callback events to AwesomePlayer - Stop the sink and wait for stream end callback when EOS is reached. - Pause and restart the sink if needed before flushing when seeking (otherwise flush is a no op). - For current media time, directly query the render position from the sink and offset by the start position (seek to time) AwesomePlayer: - When initializing the audio decoder, check with audio policy manager if offloading is supported. If yes, create the software decoder in case a reconfiguration is needed but connect the audio track directly to the AudioPlayer. - In case of error when starting the AudioPlayer, reconnect the software decoder (OMXSource) and recreate a PCM AudioPlayer. - Handle AudioPlayer tear down event by detroying and recreating the AudioPlayer to allow transitions between situations were offloading is supported or not. - Force tear down of offloaded AudioPlayer when paused for a certain time: This will close the sink and allow the DSP to power down. Utils: - Added helper methods: - send meta data to audio ia sink setParameters - query audio policy manager if offloading is supported for a given audio content Change-Id: I115842ce424f947b966d45e253a74d3fd5df9aae Signed-off-by: Eric Laurent <elaurent@google.com>
* Public API changes for audio offload support.Richard Fitzgerald2013-06-271-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NOTE: this does _not_ include all private member variables added to classes as part of offload support. Only public/protected functions and stubs functions/variables needed to make the changes buildable. - isOffloadSupported() added to audio policy service A stub implementation is required to build, this always returns false - setParameters() added to IAudioTrack A stub implementation is required to build, this always returns INVALID_OPERATION - CBlk flag for stream end - Change AudioSystem::getRenderPosition() to take an audio_output_t so caller can specify which output to query - Add AudioSystem::isOffloadSupported() This is fully implemented down to the AudioFlinger function AudioPolicyServer::isOffloadSupported() which is just a stub that always returns false. - Add EVENT_STREAM_END to AudioTrack interface. STREAM_END is used to signal when the hardware has actually finished playing all the data it was sent. - Add event type enumeration to media player interface AudioSink callbacks so that the same callback can be used to handle multiple types of event. For offloaded tracks we also have to handle STREAM_END and TEAR_DOWN events - Pass audio_offload_info_t to various functions used for opening outputs, tracks and audio players. This passes additional information about the compressed stream down to the HAL when using offload. For publicly-available APIs this is an optional parameter (for some of the internal and low-level APIs around the HAL interface it is mandatory) - Add getParameters() and setParameters() API to AudioTrack Currently dummy implementations. - Change AudioPlayer contructor so that it takes a set of bitflags defining what options are required. This replaces the original bool which only specified whether to use deep buffering. - Changes to StageFright class definition related to handling tearing-down of an offloaded track when we need to switch back to software decode - Define new StageFright utility functions used for offloaded tracks Currently dummy implementations. - AudioFlinger changes to use extended audio_config_t. Fills in audio_offload_info_t member if this info is passed in when opening an output. - libvideoeditor changes required to add the new event type parameter to AudioSink callback functions - libmediaplayerservice changes required to add the new event type parameter to AudioSink callback functions Change-Id: I3ab41138aa1083d81fe83b886a9b1021ec7320f1 Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Signed-off-by: Eric Laurent <elaurent@google.com>
* Use sp<AudioTrack> instead of raw AudioTrack *Glenn Kasten2013-06-031-7/+4
| | | | | | | | | | | | | | | | | | | | | This change prepares for the new implementation of AudioTrack client, which will require clients to use only sp<AudioTrack>, not raw AudioTrack *. A raw delete will cause a race condition during AudioTrack destruction. AudioTrack was made a RefBase by commit b68a91a70bc8d0d18e7404e14443d4e4020b3635 on 2011/11/15, when it was needed by OpenSL ES (for the callback protector). At that time, the only other client that was also converted from AudioTrack * to sp<AudioTrack> was android.media.AudioTrack JNI in project frameworks/base (file android_media_AudioTrack.cpp). Details: * Use .clear() instead of delete followed by = NULL. * ALOG %p need .get(). * sp<> don't need to be listed in constructor initializer, if initially 0. * Use == 0 for sp<> vs == NULL for raw pointers. * Use if (sp != 0) instead of if (raw). Change-Id: Ic7cad25795d6e862e112abdc227b6d33afdfce17
* Revert "Stop audio source if AudioPlayer could not be started"Andreas Huber2012-05-221-7/+6
| | | | This reverts commit 022048e95f3f1d65cb776cf21de2001423fcf7d9.
* Stop audio source if AudioPlayer could not be startedJames Dong2012-05-171-6/+7
| | | | | | related-to-bug: 6500580 Change-Id: If47e442db2f1ea400e9b598502bb48513f28cd6d
* Stop extrapolating audio time from the anchor if we're paused or reached eos.Andreas Huber2012-05-151-2/+19
| | | | | Change-Id: I55903ba625d9c075a9a6e7bcd5ff95d450b915b2 related-to-bug: 6479613
* Smoothen audio "real" time by compensating with system_time()Andreas Huber2012-05-141-1/+14
| | | | | | | for the delay since the last buffer submission to the audio sink. Change-Id: Ib1a8672f96ba8bbef07d23372f1076fbb1f0bdcc related-to-bug: 6479613
* Revert "Merge "Improve AudioPlayer position reporting""Eric Laurent2012-05-041-7/+2
| | | | | This reverts commit 887c5d2ac34d81bde66dadbd7b2ff07501744778, reversing changes made to 5aaeb0d64fc98f9b019a4378eb39f0ee49ee6ec4.
* No warning on using channel order in AudioPlayerJean-Michel Trivi2012-05-011-1/+3
| | | | | | | | Don't log a warning when an AudioPlayer derives a channel mask from the channel count, only info-log when channel count is higher than 2. Change-Id: Ia1cbced660903483654eede300ef72f7f17dcf78
* Add support for deep audio buffersEric Laurent2012-04-201-1/+8
| | | | | | | | | | Allow AudioSink to use deep audio buffering when the source is audio only and its duration is more than a certain threshold. This helps improve battery life but implies higher audio latency. Change-Id: Ie79915b61c370292f05aabda9779356570e03cbb
* rename audio policy output flagsEric Laurent2012-04-181-1/+1
| | | | Change-Id: I27c46bd1d1b2b5f96b87af7d05b951fef18a1312
* audio_channel_in/out_mask_from_countGlenn Kasten2012-03-151-1/+1
| | | | | | | and avoid ambiguous term "channels" where it might be confusing as to whether it is a channel mask or channel count Change-Id: I744fa08ccb6001a98c97bd638d2c9d56836c4234
* Merge "Gapless playback, step 1."Marco Nelissen2012-03-131-1/+5
|\
| * Gapless playback, step 1.Marco Nelissen2012-03-131-1/+5
| | | | | | | | | | | | | | Currently able to play Ogg Vorbis, PCM WAV and other lossless files seamlessly by reusing the initial AudioTrack for subsequent players. Change-Id: Ie7cf6b9076bdf4f9211574456d192c02c04fecc7
* | Use audio_policy_output_flags_t consistentlyGlenn Kasten2012-03-091-1/+1
|/ | | | | | | | | | This affects: - IAudioFlinger::openOutput - AudioTrack::AudioTrack - AudioTrack::set - apps that call these Change-Id: I26fb281bac6cb87593d17697bc9cb37a835af205
* Improve AudioPlayer position reportingMarco Nelissen2012-03-091-2/+7
| | | | | | | | | | | | The latency was not taken into account when updating mPositionTimeRealUs inside of the fillBuffer hook, contrary to what the getRealTimeUsLocked() method does. This caused the realTimeOffset calculated in the getMediaTimeUs to always be negative, causing the reported position to always be equal to mPositionTimeMediaUs, which is updated infrequently. With this change, the reported position is updated more frequently, allowing apps to perform smoother UI updates. Change-Id: I61e05c1a8b53d46b9091afb0d18a6289d13a7a5e
* Merge "MediaPlayerService: fix AudioSink latency"Eric Laurent2012-03-061-0/+6
|\
| * MediaPlayerService: fix AudioSink latencyEric Laurent2012-03-051-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | The AudioSink latency is currently cached when the associated AudioTrack is created. However, the AudioTrack latency can change if the AudioTrack is moved from one output stream to another. The AudioPlayer must also periodically update its view of the latency as it is needed to compensate the real audio time used for A/V sync. This fixes an A/V sync problem seen when switching A2DP on and off while playing a video. Change-Id: I28b24049ca114e1af3e24791dcc900f463536ba4
* | Add channel mask in AudioSinkJean-Michel Trivi2012-03-021-6/+15
|/ | | | | | | | | | | | | | | | Add support for specifying a channel mask when opening an AudioSink. This parameter does not replace the channel count parameter in order to not have to duplicate the logic to derive a mask from the channel count everywhere an AudioSink is used without a known mask. A mask of 0 (CHANNEL_MASK_USE_CHANNEL_ORDER) means a mask will be automatically derived from the number of channels. Update existing AudioSink implementations to use the channel mask, and users of AudioSink to specify the mask if available, and CHANNEL_MASK_USE_CHANNEL_ORDER otherwise. Change-Id: Ifa9bd259874816dbc25ead2b03ea52e873cff474
* Playback rate on MediaPlayerJean-Michel Trivi2012-02-131-0/+10
| | | | | | | | | Add support for modifying the playback rate of a MediaPlayer by altering the sample rate of its AudioTrack. The playback rate is expressed in permille, where 1000 is the playback at normal speed. Change-Id: I981d060ab32f7bae7a767e82c60c88ae635dceed
* Rename (IF_)LOGV(_IF) to (IF_)ALOGV(_IF) DO NOT MERGESteve Block2011-10-261-6/+6
| | | | | | | See https://android-git.corp.google.com/g/#/c/143865 Bug: 5449033 Change-Id: I0122812ed6ff6f5b59fe4a43ab8bff0577adde0a
* Flush resets the count of played audio framesJames Dong2011-09-271-0/+3
| | | | | Change-Id: I0cda94646a71757fa113a199d29235e13efd7ac3 related-to-bug: 5331470
* Audio player must not be used as a timesource before it's started.Andreas Huber2011-09-081-2/+4
| | | | | | | | Otherwise it'll trigger a division-by-zero exception since the audio sample rate is as yet unknown. Change-Id: I0793aa7c1c348ffa2611272bb646eff6ecf6ff53 related-to-bug: 5242451
* Properly reset the number of frames we think we've written to the audio sinkAndreas Huber2011-08-261-0/+2
| | | | | | | in order to compute the final delay before posting end-of-stream correctly. Change-Id: I4ff6d7142fdf1ea2d19d12ec78c1e84322d22e5f related-to-bug: 5216930
* Revert "Use AudioTrack::event_type not int in callback"Glenn Kasten2011-06-011-2/+2
| | | This reverts commit 2225e4b7049fa3fb9d39a068b8268b63c952d7c1
* Use AudioTrack::event_type not int in callbackGlenn Kasten2011-06-011-2/+2
| | | | Change-Id: Ifefc708d46874e04fd0d01cb6e2d43b987ee796c
* Properly honour any pending seek request when reading the first buffer afterAndreas Huber2011-05-101-1/+7
| | | | | | starting the audio player. Change-Id: Ibedc1804a8c444e4d0f5be4eb87b22ed5d2c367d
* audio/media: convert to using the audio HAL and new audio defsDima Zavin2011-04-271-4/+4
| | | | | Change-Id: Ibc637918637329e4f2b62f4ac7781102fbc269f5 Signed-off-by: Dima Zavin <dima@android.com>
* Merge "This reverts an earlier change 4aeec2da39fce4de9b07b694d59fd308ffb3d491"Andreas Huber2011-04-041-3/+1
|\
| * This reverts an earlier change 4aeec2da39fce4de9b07b694d59fd308ffb3d491Andreas Huber2011-04-041-3/+1
| | | | | | | | | | | | | | | | | | | | Instead of returning 0-filled buffers after EOS from AudioTrack we do this work in AudioOutput instead. That way the EOS signal (0 frames returned) is preserved in AudioCache which otherwise would lead to a heap size overflow filling everything with zeroes. Change-Id: I7e07429ba887957a4340dd4b21eef4bba76248cd related-to-bug: 3514073
* | Avoid a race condition while signaling audio EOS/seek complete by acquiring ↵Andreas Huber2011-04-041-4/+19
|/ | | | | | | the lock. Change-Id: Idfea452ff661b264e013fe515bcd2a2762bd959c related-to-bug: 4193552
* am a4a81aef: am e7cedad2: am 2edbdcc6: Merge "After a seek there\'s a brief ↵Andreas Huber2011-03-281-0/+5
|\ | | | | | | | | | | | | period where audio time isn\'t reestablished." into honeycomb-mr1 * commit 'a4a81aef39b15649bda146476d98f23ac554887f': After a seek there's a brief period where audio time isn't reestablished.
| * After a seek there's a brief period where audio time isn't reestablished.Andreas Huber2011-03-251-0/+5
| | | | | | | | | | | | | | | | Don't use audio time to trigger a "we're very late, skipping ahead" action until it's reestablished. Change-Id: Ia8534e5bed60203d49a457d14b2e55eb972b5fa1 related-to-bug: 4173683
* | Delay signaling the end of audio playback until all frames have actually played.Andreas Huber2011-03-221-1/+48
|/ | | | | Change-Id: I1fa07358a885a818fd0a5d7da425740f86095e10 related-to-bug: 3404000
* Instead of not feeding the AudioTrack any data after EOS, play silence instead.Andreas Huber2011-01-261-1/+3
| | | | | Change-Id: I9aa797cf5bb58eefed51d732f4e5d09450551158 related-to-bug: 3347428
* Make sure to call AudioTrack::stop() instead of AudioTrack::pause() after ↵Andreas Huber2010-10-051-6/+14
| | | | | | submitting all samples to AudioTrack to make sure those remaining samples are actually played out. Change-Id: Id574a0203efcb5e565f1b0fe77869fc33b9a9d56
* Properly flush the AudioTrack/AudioSink on a seek request and make sure that ↵Andreas Huber2010-09-281-0/+6
| | | | | | | both the mp3 decoder and aac software decoders start fresh after a seek without any dependency on previously decoded content. Change-Id: I4909fdf19518dbabb6c340e2a31b50dfe6c5b067 related-to-bug: 3029947
* Instead of constantly polling the AudioPlayer to see if it reached EOS or ↵Andreas Huber2010-09-281-2/+14
| | | | | | | finished seeking, initiate the notification from the AudioPlayer when the event happens. Change-Id: I43875b6adaf96d4e982ef3dfc3d6c8f7034ac51d related-to-bug: 3036592
* Squashed commit of the following:Andreas Huber2010-07-291-3/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | commit 4abf16bb04dc9695fedf4007a84f903074312ccd Author: Andreas Huber <andih@google.com> Date: Tue Jul 20 09:21:17 2010 -0700 Support a single format change at the beginning of audio playback. This way the AAC+ decoder may change its output format from what is originally encoded in the audio stream and we'll still play it back correctly. Change-Id: Icc790122744745e9a88099788d4818ca1e265a82 related-to-bug: 2826841 commit 09c74da63e6ad5cb5dafb70f62696d75d2978967 Author: James Dong <jdong@google.com> Date: Sun Jul 18 17:57:01 2010 -0700 Fix MPEG4Extractor to extract sampling frequency correctly when SBR is enabled. Change-Id: I883c81dad3ea465e71cb5590e89d763671a90ff8 commit f672bf2a782dc7d5fb6325d611a7fe17045dfe9a Author: James Dong <jdong@google.com> Date: Thu Jul 8 20:56:13 2010 -0700 Enable the support for decoding audio with AAC+ and eAAC+ features bug - 282684 Change-Id: I73c8377af3cc4edd3ee7cea86dc3b1c369fbd78b Change-Id: I012f1179e933b6d1345d2368f357576c722485f7
* Better diagnostics in the stagefright commandline tool, support for playing ↵Andreas Huber2010-04-131-1/+1
| | | | | | | sine-tones using a filename of "sine:[samplingrate]", i.e. sine:44100. Support for playing audio through to the speakers by using "-o" in addition to "-a". related-to-bug: 2553359 Change-Id: Ic49eb89feb62474d9513bc21571e0e8fe3a15e0b
* The audio track was accidentally not participating in the prefetch since it ↵Andreas Huber2010-03-081-4/+7
| | | | | | | wasn't started at the time prepare() was called. Also, properly report the cached duration even near the end when the source has no more data to fetch. Change-Id: I66a92fec24c9bfb25f1c186f1c877127bae2b4f9 related-to-bug: 2444425
* Ensure that the audio codec instance is actually going away before we ↵Andreas Huber2010-03-011-0/+11
| | | | attempt to instantiate another one, otherwise we might end up with the software codec even though the hardware codec would have been available shortly.
* Propagate errors all the way through the MediaSources and send either ↵Andreas Huber2010-02-231-1/+7
| | | | | | MEDIA_PLAYBACK_COMPLETE or MEDIA_ERROR depending on the final reason for running out of buffers to play back. related-to-bug: 2463749
* Store AudioTrack return value for error conditionKenny Root2010-02-181-2/+2
| | | | | | | Store AudioTrack->initCheck()'s return value so we can return it after the AudioTrack is deleted. Change-Id: Ie042a7d6a54d7f9afd8a5767cfd167dbeb2e5c04
* Implementation of stagefright-enabled MediaPlayerService::decode functionalityAndreas Huber2010-02-101-8/+10
| | | | related-to-bug: 2359268
* Fix for 2224736. Sometimes mSeeking is reset without calling setSeekTo first.Gloria Wang2010-02-041-2/+2
|