summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/AudioPlayer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Fix for getPosition after seekWang Liyong2015-11-301-1/+17
| | | | | | | | | | | When starting playback with a seek pending (calling seek before start) there is a brief period when the audioplayer returns an incorrect position (zero) This is caused by that mSeeking is set to false before the position in the audioplayer actually is updated. Change-Id: Iaec355c8fdfe589d9b826d20c2531034f2b4e6fb
* Correct the time returned by AudioPlayer::getMediaTimeBertil Akesson2015-11-301-2/+2
| | | | | | | | | | | | | | The change 80a68deec52c9a1b47215ed68526206ec88197f8 was added to eliminate returning negative media positions. In the change all negative values of realTimeOffset were discarded. The value realTimeOffset accounts for the latency and the number of samples played since last feeding the AudioTrack and is generally negative. By discarding this value for negative values the time returned does not account for latency or the number of samples played. Change-Id: I470450934228732e34539c227365a225be74ccc8
* stagefright: Squashed commit of pause/resume featuresSteve Kondik2015-11-071-4/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add 2 APIs (suspend/resume) in MediaPlayer - API:suspend() will just pause the player and release all the decoders to replace release() which will release the whole player - API:resume() will just init the decoders again, then start() will be called to restart streaming playback - Add a check in AwesomePlayer::onVideoEvent() to make sure the first seek operation will always seek to the next i-frame Change-Id: Ie4c82906a2a056378119921a656128ebdc1007c4 audio: Add pause support for hardware omx component - ADSP doesn't enter sleep state after wma playback is paused and power suspended. - No support for NT session pause in case of hardware component. NT session need to be paused to put ADSP into power collapse. - Add support of pause in stagefright to ensure device enters suspend mode. Also add intermediate states to avoid concurrency issues between read and pause. Change-Id: I41b946b8c8805e6ee303646b63513b5b16514ef6 libstagefright: Drain input buffer on resume - Buffers returned from codec in paused state are not drained. When codec is resumed these buffers are not drained until the next flush, and may cause timed out issue. - Added change to drain input buffers for sw decoders when resuming. Change-Id: Ida2ab1d5dc3a1910accdd6fb89548262a912d8e7 CRs-Fixed: 569585, 574967 libstagefright: camcorder pause-resume implementation - Add pause resume feature in camcorder app. So that user can pause recording and resume later which results in a single recorded clip. Change-Id: Id19c45ae5bb85265aa4d5304b160ebf119d9575a libstagefright: support pause/resume for timelapse recording Modify the timestamp calculation mechanism in CameraSourceTimeLapse in order to support pause/resume. Change-Id: Icb02ea798b0b807ffb7ada2d1ef5b2414b74edfb
* stagefright: support setting/getting playback/sync config in MediaSyncLajos Molnar2015-04-301-3/+14
| | | | | | | Bug: 18249558 Bug: 19666434 Bug: 20057497 Change-Id: I5868b17423d7c20cfaf4a399f3eb67bfba440605
* stagefright: Return correct play position after EOSaarti jadhav-gaikwad2014-07-111-0/+5
| | | | | | | | | In case of offload getOutputPlayPositionUs_l returns zero on reaching EOS. Return duration as position. Bug: 15770459 Change-Id: I7aeafdc315a86ccd197d555d604e1069eead3153
* stagefright: Pass audio aac sub formats in offloadinfoaarti jadhav-gaikwad2014-07-111-0/+7
| | | | | | | | Pass audio aac sub formats in offloadinfo according to aac profile. Audio HAL can take decision about offload using DSP capabilities Change-Id: If269a3654b5d2b09c183212b0646ef03e06f2d8f
* libstagefright: 64-bit compile warningsMark Salyzyn2014-06-261-6/+8
| | | | Change-Id: I3d1146714fa23be3d4e696599b6f70cac1f9d28b
* Update commentsGlenn Kasten2014-03-261-1/+2
| | | | Change-Id: I5776313b9b49072cd666d28880f0d07cc73f827b
* warnings be gone.Andreas Huber2014-02-111-1/+1
| | | | Change-Id: Ie3bae3f037730e316d7fca12e7a3527973f752ef
* update offloaded audio track sampling rateEric Laurent2013-11-221-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