Skip to content
This repository
Browse code

Player: handle exceptions when some record corrupted

  + dont kill player, just wait untill it exit
  • Loading branch information...
commit 65ca50cfdfdbcb81da233553823c9715d862bca4 1 parent c4746ef
Antono Vasiljev antono authored

Showing 1 changed file with 8 additions and 4 deletions. Show diff stats Hide diff stats

  1. +8 4 lib/shelr/player.rb
12 lib/shelr/player.rb
@@ -29,8 +29,12 @@ def self.play_dump(file)
29 29
30 30 def self.list
31 31 (Dir[File.join(Shelr::DATA_DIR, "**")] - ['.', '..']).sort.each do |dir|
32   - metadata = JSON.parse(IO.read(File.join(dir, 'meta')))
33   - puts "#{metadata["recorded_at"]} : #{metadata["title"]}"
  32 + begin
  33 + metadata = JSON.parse(IO.read(File.join(dir, 'meta')))
  34 + puts "#{metadata["recorded_at"]} : #{metadata["title"]}"
  35 + rescue Errno::ENOENT
  36 + puts "Corrupted shellcast in #{dir}"
  37 + end
34 38 end
35 39 end
36 40
@@ -55,7 +59,7 @@ def play(options = {})
55 59
56 60 def start_sound_player
57 61 return unless File.exist?(record_file('sound.ogg'))
58   - at_exit { system('stty echo') }
  62 + # at_exit { system('stty echo') }
59 63 STDOUT.puts "=> Starting sound player..."
60 64 @sox_pid = fork do
61 65 `play #{record_file('sound.ogg')} 2>&1`
@@ -65,7 +69,7 @@ def start_sound_player
65 69 def stop_sound_player
66 70 return unless File.exist?(record_file('sound.ogg'))
67 71 STDOUT.puts "=> Stopping sound player..."
68   - Process.kill("HUP", @sox_pid)
  72 + Process.waitpid(@sox_pid)
69 73 end
70 74
71 75 def self.scriptreplay(typescript_file, timing_file)

0 comments on commit 65ca50c

Please sign in to comment.
Something went wrong with that request. Please try again.