abort flushes block queue
authorJim Morris <morris@wolfman.com>
Mon, 3 Nov 2014 08:19:19 +0000 (00:19 -0800)
committerJim Morris <morris@wolfman.com>
Mon, 3 Nov 2014 08:19:19 +0000 (00:19 -0800)
src/modules/utils/player/Player.cpp
src/modules/utils/player/Player.h

index 441fc73..a86b9db 100644 (file)
@@ -48,11 +48,12 @@ void Player::on_module_loaded()
     this->on_boot_gcode_enable = THEKERNEL->config->value(on_boot_gcode_enable_checksum)->by_default(true)->as_bool();
     this->elapsed_secs = 0;
     this->reply_stream = NULL;
+    this->halted= false;
 }
 
 void Player::on_halt(void *)
 {
-    abort_command("", &(StreamOutput::NullStream));
+    halted= true;
 }
 
 void Player::on_second_tick(void *)
@@ -311,6 +312,8 @@ void Player::abort_command( string parameters, StreamOutput *stream )
     this->current_stream = NULL;
     fclose(current_file_handler);
     current_file_handler = NULL;
+    // clear out the block queue
+    THEKERNEL->conveyor->flush_queue();
     stream->printf("Aborted playing or paused file\r\n");
 }
 
@@ -326,6 +329,12 @@ void Player::on_main_loop(void *argument)
     }
 
     if( this->playing_file ) {
+        if(halted) {
+            halted= false;
+            abort_command("", &(StreamOutput::NullStream));
+            return;
+        }
+
         char buf[130]; // lines upto 128 characters are allowed, anything longer is discarded
         bool discard = false;
 
index 40af04d..b46c881 100644 (file)
@@ -38,15 +38,18 @@ class Player : public Module {
 
         string filename;
 
-        bool on_boot_gcode_enable;
-        bool booted;
         string on_boot_gcode;
-        bool playing_file;
         StreamOutput* current_stream;
         StreamOutput* reply_stream;
         FILE* current_file_handler;
         unsigned long file_size, played_cnt;
         unsigned long elapsed_secs;
+        struct {
+            bool on_boot_gcode_enable:1;
+            bool booted:1;
+            bool playing_file:1;
+            bool halted:1;
+        };
 };
 
 #endif // PLAYER_H