Index: apps/playback.c
===================================================================
RCS file: /cvsroot/rockbox/apps/playback.c,v
retrieving revision 1.223
diff -u -b -r1.223 playback.c
--- apps/playback.c	26 Mar 2006 17:07:00 -0000	1.223
+++ apps/playback.c	26 Mar 2006 19:44:21 -0000
@@ -1796,6 +1796,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();
@@ -1819,6 +1822,28 @@
             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:
                 /* Don't start playing immediately if user is skipping tracks
Index: apps/settings.c
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.c,v
retrieving revision 1.370
diff -u -b -r1.370 settings.c
--- apps/settings.c	26 Mar 2006 11:33:41 -0000	1.370
+++ apps/settings.c	26 Mar 2006 19:44:22 -0000
@@ -570,6 +570,10 @@
     {1, S_O(tagcache_ram), 0, "tagcache_ram", off_on },
 #endif
 
+#if CONFIG_CPU == PP5020
+    {1, S_O(pause_phones_unplugged), false, "pause on headphone unplug", off_on},
+#endif
+
     /* If values are just added to the end, no need to bump the version. */
     /* new stuff to be added at the end */
 
Index: apps/settings.h
===================================================================
RCS file: /cvsroot/rockbox/apps/settings.h,v
retrieving revision 1.212
diff -u -b -r1.212 settings.h
--- apps/settings.h	26 Mar 2006 11:33:42 -0000	1.212
+++ apps/settings.h	26 Mar 2006 19:44:22 -0000
@@ -480,6 +480,9 @@
     bool remote_bl_filter_first_keypress; /* filter first remote keypress when remote dark? */
 #endif
 #endif
+#if CONFIG_CPU == PP5020
+    bool pause_phones_unplugged; /* pause ipods on headphone unplug */
+#endif
 };
 
 enum optiontype { INT, BOOL };
Index: apps/settings_menu.c
===================================================================
RCS file: /cvsroot/rockbox/apps/settings_menu.c,v
retrieving revision 1.246
diff -u -b -r1.246 settings_menu.c
--- apps/settings_menu.c	26 Mar 2006 11:33:42 -0000	1.246
+++ apps/settings_menu.c	26 Mar 2006 19:44:26 -0000
@@ -1511,6 +1511,13 @@
 }
 #endif /* HAVE_DIRCACHE */
 
+#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 playback_settings_menu(void)
 {
     int m;
@@ -1540,6 +1547,9 @@
 #endif
         { ID2P(LANG_TAGCACHE_FORCE_UPDATE), tagcache_force_update },
         { 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.233
diff -u -b -r1.233 english.lang
--- apps/lang/english.lang	26 Mar 2006 11:33:42 -0000	1.233
+++ apps/lang/english.lang	26 Mar 2006 19:44:30 -0000
@@ -3880,3 +3880,10 @@
 eng: "Updating in background"
 voice: "Updating in background"
 new:
+
+
+id: LANG_PAUSE_PHONES
+desc: Pause Ipods when headphones are unplugged
+eng: "Pause on headphone unplug"
+voice: "Pause on headphone unplug"
+new:
