Index: src/AudioIO.cpp
===================================================================
--- src/AudioIO.cpp	(revision 10699)
+++ src/AudioIO.cpp	(working copy)
@@ -3390,6 +3390,10 @@
       // Wrap to start if looping
       if (gAudioIO->mPlayLooped && gAudioIO->mTime >= gAudioIO->mT1)
       {
+         //efm5 start
+         AudacityProject * activeProject = GetActiveProject();
+         if (activeProject->mLoopedFromCursor)
+            gAudioIO->mT0 = activeProject->GetSel0();
          // LL:  This is not exactly right, but I'm at my wits end trying to
          //      figure it out.  Feel free to fix it.  :-)
          gAudioIO->mTime = gAudioIO->mT0 - ((gAudioIO->mTime - gAudioIO->mT1) * factor);
Index: src/Menus.cpp
===================================================================
--- src/Menus.cpp	(revision 10699)
+++ src/Menus.cpp	(working copy)
@@ -594,6 +594,7 @@
 
    c->AddItem(wxT("Play"), _("Play"), FN(OnPlayStop));
    c->AddItem(wxT("PlayLooped"), _("&Loop Play"), FN(OnPlayLooped), wxT("Shift+Space"));
+   c->AddItem(wxT("PlayLoopedFromCursor"), _("Loop Play from cursor"), FN(OnPlayLoopedFromCursor), wxT("Shift+B"));//efm5
    c->AddItem(wxT("Pause"), _("&Pause"), FN(OnPause), wxT("P"),
               AudioIOBusyFlag,
               AudioIOBusyFlag);
@@ -5915,3 +5916,16 @@
       wxTopLevelWindow::ShowFullScreen(true);
 }
 
+//efm5 start
+void AudacityProject::OnPlayLoopedFromCursor()
+{
+   if( !MakeReadyToPlay() )
+      return;
+
+   AudacityProject * activeProject = GetActiveProject();
+   activeProject->SetLoopCursorLocation();
+   // Now play in a loop
+   // Will automatically set mLastPlayMode
+   GetControlToolBar()->PlayCurrentRegion(true, false, true);
+}
+//efm5 end
Index: src/Menus.h
===================================================================
--- src/Menus.h	(revision 10699)
+++ src/Menus.h	(working copy)
@@ -91,6 +91,7 @@
 void OnPlayOneSecond();
 void OnPlayToSelection();
 void OnPlayLooped();
+void OnPlayLoopedFromCursor();//efm5
 void OnPlayCutPreview();
 
         // Wave track control
Index: src/Project.cpp
===================================================================
--- src/Project.cpp	(revision 10699)
+++ src/Project.cpp	(working copy)
@@ -4555,3 +4555,85 @@
    }
 }
 
+bool AudacityProject::ViableStartAtCursor(double * pCurrentCursor, double * pRegionStart, double * pRegionEnd) {
+   AudacityProject * activeProject = GetActiveProject();
+   double currentCursor = activeProject->GetSel0();
+   *pCurrentCursor = currentCursor;
+   if (currentCursor != activeProject->GetSel1()) {
+      wxMessageBox(_("You may not perform this action with audio selected."));
+      return false;
+   }
+   TrackList * trackList = activeProject->GetTracks();
+   TrackListIterator trackListIterator;
+   int numberLabels = 0;
+   int numberLabelTracks = 0;
+   int numberWaveTracks = 0;
+   LabelTrack * labelTrack = NULL;
+   WaveTrack * waveTrack = NULL;
+
+   Track * aTrack;
+   for (aTrack = trackListIterator.First(mTracks); aTrack != NULL; aTrack = trackListIterator.Next()) {
+      switch (aTrack->GetKind()) {
+         // Count WaveTracks, and for linked pairs, count only the second of the pair.
+         case Track::Wave:
+         {
+            waveTrack = (WaveTrack *)aTrack;
+            if (aTrack->GetLinked() == false)
+               numberWaveTracks++;
+            break;
+         }
+         case Track::Label:
+         {
+            // Supports only one LabelTrack.
+            numberLabelTracks++;
+            if (labelTrack == NULL) {
+               labelTrack = (LabelTrack*)aTrack;
+               numberLabels = labelTrack->GetNumLabels();
+            }
+            break;
+         }
+      }
+   }
+   if (numberWaveTracks > 1) {
+      wxMessageBox(_("Loop from Cursor is not be suitable for multiple wave tracks!"));
+      return false;
+   }
+   else if (numberWaveTracks < 1) {
+      //It does not seem possible enter this conditional
+      //the warning "if you think this is a bug..."
+      //pops up and the function is not even called <shrug>
+      wxMessageBox (_("There is no audio to process!"));
+      return false;
+   }
+   if (numberLabels < 1) {
+      wxMessageBox (_("There are no labels to work with."));
+      return false;
+   }
+   if (numberLabelTracks == 1) {
+      const LabelStruct * aLabel = NULL;
+      int labelIndex = 0;
+      while (labelIndex < numberLabels) {
+         aLabel = labelTrack->GetLabel(labelIndex);
+         if (aLabel->t != aLabel->t1) {//region label
+            if (  (aLabel->t == currentCursor) ||
+                  (aLabel->t1 == currentCursor) ||
+                  ( (aLabel->t < currentCursor) && (aLabel->t1 > currentCursor) ) ) {
+                     activeProject->SetSel0(aLabel->t);
+                     *pRegionStart = aLabel->t;
+                     activeProject->SetSel1(aLabel->t1);
+                     *pRegionEnd = aLabel->t1;
+                     return true;
+            }
+         }
+      }
+      wxMessageBox(_("The current cursor location is not within a region label."));
+      return false;
+   }
+   else if (numberLabelTracks > 1) {
+      wxMessageBox (_("There are more than one label tracks. This is not supported."));
+      return false;
+   }
+   else 
+      wxMessageBox (_("There are no label tracks!"));
+   return false;
+}
Index: src/Project.h
===================================================================
--- src/Project.h	(revision 10699)
+++ src/Project.h	(working copy)
@@ -384,7 +384,13 @@
    
    void PushState(wxString desc, wxString shortDesc,
                   bool consolidate = false);
-
+   //efm5 start
+   double mLoopCursorLocation;
+   bool mLoopedFromCursor;
+   void SetLoopCursorLocation() {mLoopCursorLocation = GetSel0();};
+   double GetLoopCursorLocation () {return mLoopCursorLocation;};
+   bool ViableStartAtCursor(double * pCurrentCursor, double * pRegionStart, double * pRegionEnd);
+   //efm5 end
  private:
 
    void ClearClipboard();
Index: src/toolbars/ControlToolBar.cpp
===================================================================
--- src/toolbars/ControlToolBar.cpp	(revision 10699)
+++ src/toolbars/ControlToolBar.cpp	(working copy)
@@ -421,7 +421,8 @@
 void ControlToolBar::PlayPlayRegion(double t0, double t1,
                                     bool looped /* = false */,
                                     bool cutpreview /* = false */,
-                                    TimeTrack *timetrack /* = NULL */)
+                                    TimeTrack *timetrack /* = NULL */,
+                                    bool startAtCursor /* = false*/)
 {
    SetPlay(true);
 
@@ -560,13 +561,38 @@
          if (!timetrack) {
             timetrack = t->GetTimeTrack();
          }
-         token = gAudioIO->StartStream(t->GetWaveTrackArray(false),
-                                       WaveTrackArray(),
+         //efm5 start
+         if (startAtCursor) {
+            p->mLoopedFromCursor = true;
+            double currentCursor, regionStart, regionEnd;
+            bool viable = p->ViableStartAtCursor(&currentCursor, &regionStart, &regionEnd);
+            if (viable) {
+               token = gAudioIO->StartStream(t->GetWaveTrackArray(false),
+                                             WaveTrackArray(),
 #ifdef EXPERIMENTAL_MIDI_OUT
-                                       t->GetNoteTrackArray(false),
+                                             t->GetNoteTrackArray(false),
 #endif
-                                       timetrack,
-                                       p->GetRate(), t0, t1, p, looped);
+                                             timetrack,
+                                             p->GetRate(), currentCursor, regionEnd, p, looped);
+            }
+            else {
+               SetPlay(false);
+               SetStop(false);
+               SetRecord(false);
+               return;
+            }
+         }
+         else {
+            p->mLoopedFromCursor = false;
+            token = gAudioIO->StartStream(t->GetWaveTrackArray(false),
+                                          WaveTrackArray(),
+#ifdef EXPERIMENTAL_MIDI_OUT
+                                          t->GetNoteTrackArray(false),
+#endif
+                                          timetrack,
+                                          p->GetRate(), t0, t1, p, looped);
+         }
+         //efm5 end
       }
       if (token != 0) {
          success = true;
@@ -606,7 +632,8 @@
 }
 
 void ControlToolBar::PlayCurrentRegion(bool looped /* = false */,
-                                       bool cutpreview /* = false */)
+                                       bool cutpreview /* = false */,
+                                       bool loopFromCursor /* = false*/)
 {
    mPlay->SetAlternate(looped);
 
@@ -624,7 +651,8 @@
 
       PlayPlayRegion(playRegionStart,
                      playRegionEnd,
-                     looped, cutpreview);
+                     looped, cutpreview,
+                     NULL, loopFromCursor);//efm5
    }
 }
 
Index: src/toolbars/ControlToolBar.h
===================================================================
--- src/toolbars/ControlToolBar.h	(revision 10699)
+++ src/toolbars/ControlToolBar.h	(working copy)
@@ -60,12 +60,14 @@
 
    // Play currently selected region, or if nothing selected,
    // play from current cursor.
-   void PlayCurrentRegion(bool looped = false, bool cutpreview = false);
+   void PlayCurrentRegion(bool looped = false, bool cutpreview = false,
+      bool loopFromCursor = false);//efm5
    // Play the region [t0,t1]
    void PlayPlayRegion(double t0, double t1,
                        bool looped = false,
                        bool cutpreview = false,
-                       TimeTrack *timetrack = NULL);
+                       TimeTrack *timetrack = NULL,
+                       bool startAtCursor = false);
    void PlayDefault();
    
    // Stop playing
