Index: apps/playback.c
===================================================================
RCS file: /cvsroot/rockbox/apps/playback.c,v
retrieving revision 1.221
diff -u -r1.221 playback.c
--- apps/playback.c	25 Mar 2006 15:58:10 -0000	1.221
+++ apps/playback.c	26 Mar 2006 01:54:59 -0000
@@ -1795,6 +1795,9 @@
     struct event ev;
     int last_tick = 0;
     bool play_pending = false;
+#if CONFIG_CPU == PP5020
+    bool phones_present = false;
+#endif
 
     /* At first initialize audio system in background. */
     playback_init();
@@ -1817,6 +1820,28 @@
             ev.id = Q_AUDIO_PLAY;
             ev.data = (bool *)1;
         }
+
+#if CONFIG_CPU == PP5020		
+        if (global_settings.pause_phones_unplugged)
+        {
+            if ((GPIOA_INPUT_VAL & 0x80) == 0)
+            {
+                if (phones_present)
+                {
+                    ev.id = Q_AUDIO_PAUSE;
+                    ev.data = (bool *)1;
+                    phones_present = false;
+                }
+            } else {
+                if (!phones_present)
+                {
+                    ev.id = Q_AUDIO_RESUME;
+                    ev.data = (bool *)1;
+                    phones_present = true;
+                }
+            }
+        }
+#endif	
         
         switch (ev.id) {
             case Q_AUDIO_PLAY:
Index: apps/settings.c
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.c,v
retrieving revision 1.369
diff -u -r1.369 settings.c
--- apps/settings.c	25 Mar 2006 19:16:44 -0000	1.369
+++ apps/settings.c	26 Mar 2006 01:55:02 -0000
@@ -462,6 +462,10 @@
     {1, S_O(spdif_enable), false, "spdif enable", off_on},
 #endif
 
+#if CONFIG_CPU == PP5020
+    {1, S_O(pause_phones_unplugged), false, "pause on headphone unplug", off_on},
+#endif
+
     {1, S_O(next_folder), false, "folder navigation", off_on },
     {1, S_O(runtimedb), false, "gather runtime data", off_on },
 
Index: apps/settings.h
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.h,v
retrieving revision 1.211
diff -u -r1.211 settings.h
--- apps/settings.h	25 Mar 2006 19:16:44 -0000	1.211
+++ apps/settings.h	26 Mar 2006 01:55:02 -0000
@@ -407,6 +407,10 @@
     bool next_folder; /* move to next folder */
     bool runtimedb;   /* runtime database active? */
 
+#if CONFIG_CPU == PP5020
+    bool pause_phones_unplugged; /* pause ipods on headphone unplug */
+#endif
+
 #if CONFIG_CODEC == SWCODEC
     bool replaygain;        /* enable replaygain */
     bool replaygain_noclip; /* scale to prevent clips */
Index: apps/settings_menu.c
===================================================================
RCS file: /cvsroot/rockbox/apps/settings_menu.c,v
retrieving revision 1.245
diff -u -r1.245 settings_menu.c
--- apps/settings_menu.c	25 Mar 2006 19:16:44 -0000	1.245
+++ apps/settings_menu.c	26 Mar 2006 01:55:02 -0000
@@ -1271,6 +1271,13 @@
     return rc;
 }
 
+#if CONFIG_CPU == PP5020
+static bool pause_phones_unplugged(void)
+{
+    return set_bool( str(LANG_PAUSE_PHONES), &global_settings.pause_phones_unplugged );
+}
+#endif
+
 static bool codepage_setting(void)
 {
     static const struct opt_items names[] = {
@@ -1524,6 +1531,9 @@
         { ID2P(LANG_ID3_ORDER), id3_order },
         { ID2P(LANG_NEXT_FOLDER), next_folder },
         { ID2P(LANG_RUNTIMEDB_ACTIVE), runtimedb },
+#if CONFIG_CPU == PP5020
+        { ID2P(LANG_PAUSE_PHONES), pause_phones_unplugged},
+#endif
     };
 
     bool old_shuffle = global_settings.playlist_shuffle;
Index: apps/lang/english.lang
===================================================================
RCS file: /cvsroot/rockbox/apps/lang/english.lang,v
retrieving revision 1.232
diff -u -r1.232 english.lang
--- apps/lang/english.lang	25 Mar 2006 13:35:30 -0000	1.232
+++ apps/lang/english.lang	26 Mar 2006 01:55:04 -0000
@@ -3838,3 +3838,9 @@
 eng: "First keypress enables backlight only"
 voice: "First keypress enables backlight only"
 new:
+
+id: LANG_PAUSE_PHONES
+desc: Pause Ipods when headphones are unplugged
+eng: "Pause on headphone unplug"
+voice: "Pause on headphone unplug"
+new:
