The problem comes from the fact that when the duplicated output is closed after BT headset disconnection, the OUTPUT_CLOSED notification is not sent to AudioSystem. Then the mapping between notification stream and duplicated output cached in AudioSystem is not cleared and next time a notification is played, the duplicated output is selected and the createTrack() request is refused by AudioFlinger as the selected output doesn't exist.
The notification is ignored by AudioFlinger because when it is sent by the terminating playback thread, the thread has already been removed from the playback thread list.
The fix consists in sending the notification in closeOutput() and not when exiting the playback thread.
The same fix is applied to record threads.
Merge commit '54c06152e0d9c666aec61ae5d9686d7d3327ea34' into eclair-plus-aosp
* commit '54c06152e0d9c666aec61ae5d9686d7d3327ea34':
Fix issue 2115450: a2dp thread is started, even though we are only connected to headset and not playing music.
Merge commit '678b4c20cb92ac2b86f13e52ea86d70301358680' into eclair-plus-aosp
* commit '678b4c20cb92ac2b86f13e52ea86d70301358680':
Various fixed for back key handling.
Merge commit '151921a62485f2141ad1316076c196ef00e1b421' into eclair-plus-aosp
* commit '151921a62485f2141ad1316076c196ef00e1b421':
add support for RGBX_8888 surfaces in SurfaceFlinger
Merge commit '294cd9856e30daa07efbdd7d925b3fad8cb123de' into eclair-plus-aosp
* commit '294cd9856e30daa07efbdd7d925b3fad8cb123de':
Last big work on #1991910: Make swipes work with capacitive keys
Merge commit '53793416d408366270d21f81734997db348bd918' into eclair-plus-aosp
* commit '53793416d408366270d21f81734997db348bd918':
Fix URI returned by IccProvider.
Merge commit '4503cb75a02f6465bd576366945a1c5f2c8c13f3' into eclair-plus-aosp
* commit '4503cb75a02f6465bd576366945a1c5f2c8c13f3':
Minor perf tweak for fountain.
Merge commit 'c2974809373697147cbe5754835cc871fb93aef1' into eclair-plus-aosp
* commit 'c2974809373697147cbe5754835cc871fb93aef1':
Fix issue #2116977: buttons are huge and bent
Merge commit 'e7f47f50ad0a97e32c87104e56f311db910e98f1' into eclair-plus-aosp
* commit 'e7f47f50ad0a97e32c87104e56f311db910e98f1':
add system properties for experimenting with sync timeouts.
Merge commit '74077c8f2ed67b79be67df853158932fbd774865' into eclair-plus-aosp
* commit '74077c8f2ed67b79be67df853158932fbd774865':
Clear the password field when reloading the current page.
Merge commit 'b06aac86d1be8cd018f2568d64f50d61c421d1f0' into eclair-plus-aosp
* commit 'b06aac86d1be8cd018f2568d64f50d61c421d1f0':
fix [2117464] SF can crash when calling dumpsys
Merge commit 'a1212578bfd11bd391c686c82c18b21b4a3a69b4' into eclair-plus-aosp
* commit 'a1212578bfd11bd391c686c82c18b21b4a3a69b4':
make sure to update the tail pointer when undoing a dequeue
Merge commit '0d5581133285cef4d7582b531e0bf09cee86aa90' into eclair-plus-aosp
* commit '0d5581133285cef4d7582b531e0bf09cee86aa90':
Added a little more logging in OMXCodec.cpp for vendors to be able to reproduce issues...
Merge commit 'd023f9a9a90705410250cd86bc6446c738423a99' into eclair-plus-aosp
* commit 'd023f9a9a90705410250cd86bc6446c738423a99':
Some optizations to wallpaper drawing/scrolling.
Merge commit 'aa931bcb0acb93ce760f4e5d27153fb1c6d33a10' into eclair-plus-aosp
* commit 'aa931bcb0acb93ce760f4e5d27153fb1c6d33a10':
process: Switch to common cutils sched_policy api
Merge commit '55bfddad197f1a82d94152ee82bb110d8a9f32d9' into eclair-plus-aosp
* commit '55bfddad197f1a82d94152ee82bb110d8a9f32d9':
Fix the bogus crashes in layout and reliability tests (the device actually went offline).
Merge commit '944808f392e416858e3265b14b9e0a4410a1dbbf' into eclair-plus-aosp
* commit '944808f392e416858e3265b14b9e0a4410a1dbbf':
Fix a possible NPE in View.
Merge commit '482d54bb0cd9e00fd929185c31fea3ad845d97bc' into eclair-plus-aosp
* commit '482d54bb0cd9e00fd929185c31fea3ad845d97bc':
Add black listing of car kits by name.
Merge commit 'd247aadfc4b8117130908c44a2ed1f6d290a92ef' into eclair-plus-aosp
* commit 'd247aadfc4b8117130908c44a2ed1f6d290a92ef':
Bring up the soft keyboard when touching a focused textfield.
Merge commit 'dd8174928c9c2966b1491acd604612a3b38e600a' into eclair-plus-aosp
* commit 'dd8174928c9c2966b1491acd604612a3b38e600a':
Remove trackball double click. Treat each click as a single click.
Merge commit '298d32e1934cddf6b93e6a4588ab05630cd39ec7' into eclair-plus-aosp
* commit '298d32e1934cddf6b93e6a4588ab05630cd39ec7':
Set the minimum fling to the title height.
Merge commit '13bc4ad18bc401c2a80e7dde8cba18841d709a78' into eclair-plus-aosp
* commit '13bc4ad18bc401c2a80e7dde8cba18841d709a78':
Add "rtsp" to the list of URL schemes that get linkified.