diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2011-06-04 19:17:51 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2011-06-04 19:17:51 +0000 |
commit | d25a61f01c21978d0c9e229fd72852e99da1414a (patch) | |
tree | a3334620eae5b1818d0afea69e686ddc0a610905 | |
parent | 6c22be4a3db4ad72acf67f99059872e92d1931b4 (diff) | |
download | rockbox-d25a61f01c21978d0c9e229fd72852e99da1414a.tar.gz rockbox-d25a61f01c21978d0c9e229fd72852e99da1414a.zip |
Android: listen to ACTION_AUDIO_BECOMING_NOISY for headphone (FS#12097).
This event is sent before the audio is routed back to the speaker so we
get the information about the unplugged headphone notably earlier.
Decrease the debouncing of the headphone status from 1s to 0.5s to work
around audio still getting played back via the speaker due to the pause
delay by debouncing. On Android we shouldn't need the debouncing at all.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29957 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | android/src/org/rockbox/RockboxService.java | 16 | ||||
-rw-r--r-- | firmware/drivers/button.c | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/android/src/org/rockbox/RockboxService.java b/android/src/org/rockbox/RockboxService.java index 71b133edc8..3182b73b1c 100644 --- a/android/src/org/rockbox/RockboxService.java +++ b/android/src/org/rockbox/RockboxService.java | |||
@@ -67,11 +67,13 @@ public class RockboxService extends Service | |||
67 | private IntentFilter ifh; | 67 | private IntentFilter ifh; |
68 | private BroadcastReceiver batt_monitor; | 68 | private BroadcastReceiver batt_monitor; |
69 | private BroadcastReceiver headphone_monitor; | 69 | private BroadcastReceiver headphone_monitor; |
70 | private BroadcastReceiver noisy_monitor; | ||
70 | private RunForegroundManager fg_runner; | 71 | private RunForegroundManager fg_runner; |
71 | private MediaButtonReceiver mMediaButtonReceiver; | 72 | private MediaButtonReceiver mMediaButtonReceiver; |
72 | private int battery_level; | 73 | private int battery_level; |
73 | private int headphone_state; | 74 | private int headphone_state; |
74 | private ResultReceiver resultReceiver; | 75 | private ResultReceiver resultReceiver; |
76 | private RockboxService rbservice; | ||
75 | 77 | ||
76 | public static final int RESULT_INVOKING_MAIN = 0; | 78 | public static final int RESULT_INVOKING_MAIN = 0; |
77 | public static final int RESULT_LIB_LOAD_PROGRESS = 1; | 79 | public static final int RESULT_LIB_LOAD_PROGRESS = 1; |
@@ -357,6 +359,20 @@ public class RockboxService extends Service | |||
357 | } | 359 | } |
358 | }; | 360 | }; |
359 | registerReceiver(headphone_monitor, ifh); | 361 | registerReceiver(headphone_monitor, ifh); |
362 | noisy_monitor = new BroadcastReceiver() | ||
363 | { | ||
364 | @Override | ||
365 | public void onReceive(Context context, Intent intent) | ||
366 | { | ||
367 | LOG("audio becoming noisy"); | ||
368 | headphone_state = 0; | ||
369 | } | ||
370 | }; | ||
371 | rbservice = RockboxService.get_instance(); | ||
372 | /* We're relying on internal API's here, | ||
373 | this can break in the future! */ | ||
374 | rbservice.registerReceiver(noisy_monitor, | ||
375 | new IntentFilter("android.media.AUDIO_BECOMING_NOISY")); | ||
360 | } | 376 | } |
361 | 377 | ||
362 | 378 | ||
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c index f8e4a35b47..3ee5e7c2f4 100644 --- a/firmware/drivers/button.c +++ b/firmware/drivers/button.c | |||
@@ -177,7 +177,7 @@ static void button_tick(void) | |||
177 | /* Use the autoresetting oneshot to debounce the detection signal */ | 177 | /* Use the autoresetting oneshot to debounce the detection signal */ |
178 | phones_present = !phones_present; | 178 | phones_present = !phones_present; |
179 | timeout_register(&hp_detect_timeout, btn_detect_callback, | 179 | timeout_register(&hp_detect_timeout, btn_detect_callback, |
180 | HZ, phones_present); | 180 | HZ/2, phones_present); |
181 | } | 181 | } |
182 | #endif | 182 | #endif |
183 | 183 | ||