summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioTrack.cpp
Commit message (Collapse)AuthorAgeFilesLines
* audioflinger: send priority request from a threadEric Laurent2012-09-131-2/+1
| | | | | | | | | | | | | | | | | | | When creating a fast AudioTrack, a request is sent to SchedulingPolicyService to elevate the requesting thread priority. This generates a binder call into system_server process and to a JAVA service via JNI. If the thread from which the track was created is in the system_server process and does not have the "can call java" attribute, a crash occurs because the binder optimization reuses the same thread to process the returning binder call and no JNI env is present. The fix consists in sending the priority change request from the AudioFlinger mixer thread, not from the binder thread. This also reverts the workaround in commit 73431968 Bug 7126707. Change-Id: I3347adf71ffbb56ed8436506d4357eab693078a3
* Workaround for track recreation bugJean-Michel Trivi2012-09-121-1/+2
| | | | | | | | Ignore thread can call Java parameter to work around bug where AudioTrack instance gets recreated when key clicks are enabled and WFD gets turned on, with the wrong parameters. Change-Id: Ia42c8704b46fe3ffea560b05b60939fa2e4b29e1
* Update audio commentsGlenn Kasten2012-08-301-1/+1
| | | | Change-Id: Ie7504d0ddb252f7e4d4f99ed0b44cfc7b1049816
* Revert "Swap the order of creating IAudioTrack and thread"Glenn Kasten2012-08-071-5/+10
| | | | | | | This reverts commit 5d464eb0b8cffb994a754ff108795e858a882414. It caused the wrong thread ID -1 to be passed to IAudioFlinger::createTrack(). Change-Id: Ic221d2bb4af572d3d2d752af19238c52f6728e3a
* Swap the order of creating IAudioTrack and threadGlenn Kasten2012-07-271-10/+5
| | | | | | Simplifies the error recovery in case IAudioTrack fails. Change-Id: I6aee41a2ac747a5689fb4836b04174e6107bf32f
* Use audio_channel_mask_t for channel maskGlenn Kasten2012-07-171-8/+9
| | | | Change-Id: I1c1896da48983aa9f1462a4b471f910498816f60
* getMinFrameCount error handlingGlenn Kasten2012-07-131-0/+5
| | | | | | | | Convention is for "get" APIs that directly return status_t and indirectly return a value via a pointer, to return BAD_VALUE if the pointer is NULL. Also indirectly return 0 for other errors. Change-Id: I1599f20ecb26e9723f9fb384ffbf911ff3a2ce1c
* Remove dead code in libmediaGlenn Kasten2012-07-121-9/+0
| | | | Change-Id: I7d8201590cda29c9fa99662a4fdba222091febfe
* Move declarations of local variables to first useGlenn Kasten2012-06-211-1/+1
| | | | Change-Id: I48b193a742b32b6746aa938b84dc405124a6a5c3
* Fix audio track pause.Eric Laurent2012-06-141-0/+1
| | | | | | | | | | | | AudioTrack::pause() should signal the control block condition to release threads waiting for available buffers in obtainBuffer(). Otherwise the behavior relies on the timout on the condition or the fact that audioflinger will mix a new audio buffer while executing the pause. Bug 6653769. Change-Id: I5f8f73c471fe306070f30b814f32fd4b4dc1d575
* Log track name on obtain/releaseBuffer warningsGlenn Kasten2012-06-131-3/+3
| | | | | | | This should help diagnose problems by allowing us to correlate the logs with the dumpsys media.audio_flinger output. Change-Id: I8c7c592b4f87d13b0f29c66ce7a2f301a0f063c9
* Do not keep audio wake lock when apps underrun.Eric Laurent2012-05-311-14/+24
| | | | | | | | | Do not automatically restart an AudioTrack after an underrun if the callback is executed but no data is written by the app. Bug 6541286. Change-Id: I11e7ab8dc968d7ff087058fec68f44490d3a7731
* Fix issues with synchronous record start.Eric Laurent2012-05-141-0/+3
| | | | | | | | | | | | | | | | - Added a timeout in case the trigger event is never fired. - Extend AudioRecord obtainBuffer() timeout in case of synchronous start to avoid spurious warning. - Make sure that the event is triggered if the track is destroyed. - Reject event if the triggering track is in an incompatible state. Also fix a problem when restoring a static AudioTrack after a mediaserver crash. Bug 6449468. Change-Id: Ib36e11111fb88f73caa31dcb0622792737d57a4b
* Don't allow AudioTrack frameCount to decreaseGlenn Kasten2012-05-031-1/+11
| | | | | | | | | | | | | | | This is a workaround for bug that client can cache return value of frameCount(), and is not notified when this value changes due to automatic re-recreation of the underlying IAudioTrack. A better long-term fix would be to notify clients when these kinds of parameters change, and to fix assumptions in client code that they are constant (e.g. in SoundPool and maybe obtainBuffer). Also, once a fast track request is denied, don't request it again. Bug: 6431187 Change-Id: I55b4ff30bbd9ed3a402e39452a38de52cdea53a9
* Fix race in AudioTrack destructionGlenn Kasten2012-05-021-1/+1
| | | | | Bug: 6427369 Change-Id: Id3b4487406235b881f6f0b4b95c5a02a9b797e75
* Disable fast track log spamGlenn Kasten2012-05-011-2/+2
| | | | | | except for "denied by client" and "denied by server" Change-Id: I133ab747933729cc1f386813ee06ece055bdb294
* Move frame count calculations for fast tracksGlenn Kasten2012-04-251-44/+84
| | | | | | | | | | | | | | | | | | | | | For fast tracks: move the default and minimum frame count calculations from client to server. If accepted, the default and minimum frame count is the fast mixer (HAL) frame count. If denied, the default and minimum frame count is the same as it currently is for normal tracks. For normal tracks: there is no change yet, preserve legacy behavior for now but add a FIXME to change this later. Bug fix: the test for buffer alignment matches channelCount was wrong. Bug fix: check for 8-bit data in shared memory, which isn't supported. Optimizations: - in set(), only call AudioSystem::getOutputSamplingRate() when needed - in createTrack_l(), only call AudioSystem::getSamplingRate() and AudioSystem::getFrameCount() when needed Change-Id: I79d2fe507db1a8f7bb094c71da8a129951dbb82f
* Use C APIs instead of C++ APIs for policyGlenn Kasten2012-04-231-7/+7
| | | | | | | | | The C++ APIs are going away. Note: we use tid == 0 which is not supported yet by the C APIs, do not submit this until that is added. Change-Id: I0e90789e6c81c69f2544e899c52421ea5d1342be
* Fix regression in AudioTrack::pause()Glenn Kasten2012-04-231-1/+4
| | | | | Bug: 6379646 Change-Id: I12b53bc4118499ddc73a53a981f3f56328140868
* Configure policy of mediaserver threadsGlenn Kasten2012-04-221-32/+81
| | | | Change-Id: Ifd825590ba36996064a458f64453a94b84722cb0
* Add support for deep audio buffersEric Laurent2012-04-201-0/+4
| | | | | | | | | | 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-15/+15
| | | | Change-Id: I27c46bd1d1b2b5f96b87af7d05b951fef18a1312
* audio policy: add configuration fileEric Laurent2012-04-031-13/+10
| | | | | | | | | | | removed outputs to stream mapping cache in audio system: the output for a given stream type must always be queried from audio policy manager as the cache is not always updated fast enough by audioflinger callback. removed AudioFlinger::PlaybackThread::setStreamValid() not used anymore if stream to output mapping is not cached. Change-Id: Ieca720c0b292181f81247259c8a44359bc74c66b
* AudioTrack client fast policyGlenn Kasten2012-04-021-3/+20
| | | | Change-Id: I42ce691df3f586ac061b62237f35a263a0116f1f
* Make AudioTrack/AudioRecord handle more than 2^32 framesMarco Nelissen2012-03-301-8/+27
| | | | | b/6160363 Change-Id: I471815012c6a113ec2c4dd7676e8fa288a70bc76
* Merge "IAudioFlinger::createTrack and openRecord flags"Glenn Kasten2012-03-261-2/+5
|\
| * IAudioFlinger::createTrack and openRecord flagsGlenn Kasten2012-03-191-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | createTrack and openRecord don't need the "old" flags parameter, which was either audio_policy_output_t or audio_in_acoustics_t shifted left by 16 bits. But they do need "new" flags, which are defined by the application use case. Initially, the only application use case flag is timed output, but others are planned. For output, the audio_policy_output_t flags are passed to AudioSystem::getOutput, which returns an audio_io_handle_t, and that handle is then passed to createTrack. So createTrack doesn't need the old flags parameter. For input, the audio_in_acoustics_t flags are passed to AudioSystem::getInput, which returns an audio_io_handle_t, and that handle is then passed to openRecord. So openRecord doesn't need the old flags parameter. Change-Id: I18a9870911846cca69d420c19fe6a9face2fe8c4
* | Remove enforceFrameCountGlenn Kasten2012-03-211-7/+5
| | | | | | | | | | | | | | | | | | It was only used to decide whether to issue a warning. The warning was issued the first time track was created but not at re-creation. Now it is a verbose message every time, not a warning since it happens all the time with key clicks on A2DP. Change-Id: I9d39f53c0a7eb84b666e55b1b76ff830cf8f37ba
* | Merge "Update comments"Glenn Kasten2012-03-211-4/+5
|\ \
| * | Update commentsGlenn Kasten2012-03-191-4/+5
| |/ | | | | | | Change-Id: I327663a020670d0a72ff57bd0b682e2ce0528650
* | WhitespaceGlenn Kasten2012-03-191-0/+3
|/ | | | | | Fix indentation, and add blank lines in key places for clarity Change-Id: I57a0a8142394f83203161aa9b8aa9276abf3ed7c
* Whitespace and indentationGlenn Kasten2012-03-131-13/+13
| | | | | | | | | | | | | | Fix indentation to be multiple of 4. Make it easier to search: sp< not sp < to "switch (...)" instead of "switch(...)" (also "if" and "while") Remove redundant blank line at start or EOF. Remove whitespace at end of line. Remove extra blank lines where they don't add value. Use git diff -b or -w to verify. Change-Id: I966b7ba852faa5474be6907fb212f5e267c2874e
* Use audio_policy_output_flags_t consistentlyGlenn Kasten2012-03-091-8/+9
| | | | | | | | | | This affects: - IAudioFlinger::openOutput - AudioTrack::AudioTrack - AudioTrack::set - apps that call these Change-Id: I26fb281bac6cb87593d17697bc9cb37a835af205
* AudioTrack: relax check on minimum buffer sizeEric Laurent2012-03-051-6/+3
| | | | | | | | | | | | | Current AudioTrack implementation enforces that the requested audio buffer size is at least corresponding the audio latency. This requirement is too strong and leads to problems with current stagefright and AudioSink implementations when playing over output streams with long latency. Ultimately, the AudioSink design should be changed to specify a minimum buffer size in time or frames units but not in buffer count units. Change-Id: I8ba603956f92ac49143a8249572665aa548f2f0f
* Shorten thread namesGlenn Kasten2012-02-281-1/+1
| | | | | | | | prctl(PR_SET_NAME) limits to 15 characters. Before we had names like "Binder Thread #" and the counter was cut off :-( Also remove redundant "thread" at end of name; it's always a thread. Change-Id: I1f99c2730ba0787ed9b59c15914356cddf698e2f
* Upintegrate Audio Flinger changes from ICS_AAHJohn Grossman2012-02-161-3/+78
| | | | | | | | Bring in changes to audio flinger made to support timed audio tracks and HW master volume control. Change-Id: Ide52d48809bdbed13acf35fd59b24637e35064ae Signed-off-by: John Grossman <johngro@google.com>
* Merge "Update comments"Glenn Kasten2012-02-141-8/+7
|\
| * Update commentsGlenn Kasten2012-02-141-8/+7
| | | | | | | | | | | | We no longer put the filename at start of file. Change-Id: Ic435b159a23105681e3d4a6cb1ac097bc853302e
* | Merge "Remove dead code AudioTrack::getLoop"Glenn Kasten2012-02-141-20/+0
|\ \ | |/ |/|
| * Remove dead code AudioTrack::getLoopGlenn Kasten2012-02-081-20/+0
| | | | | | | | Change-Id: I868329c52f31bc20125f068500d8f892b4ec9796
* | AudioRecord and AudioTrack client tidGlenn Kasten2012-02-141-4/+12
|/ | | | | | Inform AudioFlinger of the tid of the callback thread. Change-Id: I670df92dd06749b057238b48ed1094b13aab720b
* Merge "Remove dead mutex in AudioTrack/AudioRecord thread"Glenn Kasten2012-02-081-10/+0
|\
| * Remove dead mutex in AudioTrack/AudioRecord threadGlenn Kasten2012-02-021-10/+0
| | | | | | | | | | | | | | | | | | | | The client callback threads had mutexes called AudioTrackThread::mLock and ClientRecordThread::mLock. These mutexes were only used by start() and stop(), and were unused by the thread itself. But start() and stop() already have their own protection provided by AudioTrack::mLock and AudioRecord::mLock. So the thread mutexes can be removed. Change-Id: I098406d381645d77fba06a15511e179a327848ef
* | AudioTrack declare more methods constGlenn Kasten2012-02-031-7/+7
| | | | | | | | Change-Id: I4999e984460893961d0d8092cff17f3cf07d7214
* | Use NULL not 0 for raw pointersGlenn Kasten2012-02-031-10/+10
| | | | | | | | | | | | Use if (p != NULL) instead of if (ptr) Change-Id: Iaec3413a59ccbf233c98fcd918cc7d70ac5da9fa
* | Make AudioTrack control block volume field privateGlenn Kasten2012-01-201-3/+3
|/ | | | | | | This is part of the process of abstracting the control block to make it easier to maintain. Change-Id: Idb8f461e68dab3bcf268159cc0781651c6fb7094
* Merge "Move memcpy_to_i16_from_u8 to audio_utils"Glenn Kasten2012-01-201-13/+5
|\
| * Move memcpy_to_i16_from_u8 to audio_utilsGlenn Kasten2012-01-171-13/+5
| | | | | | | | | | | | | | This will make it easier for this kind of code to be optimized for each target architecture. Change-Id: I9efd27d6c0175b00b9a784353244805cec63c0b8
* | Temporarily restore AudioSystem/AudioTrack APIs with their former signaturesAndreas Huber2012-01-181-0/+19
| | | | | | | | | | | | until we get updated prebuilts from vendor. Change-Id: I8aae81d2513edca0ab268053a11c8c4206879e61
* | Track volume cleanupGlenn Kasten2012-01-171-1/+0
|/ | | | | | | | | | | | | | | | | | | | Always read and write track volumes atomically. In most places this was already being done, but there were a couple places where the left and right channels were read independently. Changed constant MAX_GAIN_INT to be a uint32_t instead of a float. It is always used as a uint32_t in comparisons and assignments. Use MAX_GAIN_INT in more places. Now that volume is always accessed atomically, removed the union and alias for uint16_t volume[2], and kept only volumeLR. Removed volatile as it's meaningless. In AudioFlinger, clamp the track volumes read from shared memory before applying master and stream volume. Change-Id: If65e2b27e5bc3db5bf75540479843041b58433f0