Skip to content
Browse files

Player: handle exceptions when some record corrupted

  + dont kill player, just wait untill it exit
  • Loading branch information...
1 parent c4746ef commit 65ca50cfdfdbcb81da233553823c9715d862bca4 @antono antono committed May 5, 2012
Showing with 8 additions and 4 deletions.
  1. +8 −4 lib/shelr/player.rb
View
12 lib/shelr/player.rb
@@ -29,8 +29,12 @@ def self.play_dump(file)
def self.list
(Dir[File.join(Shelr::DATA_DIR, "**")] - ['.', '..']).sort.each do |dir|
- metadata = JSON.parse(IO.read(File.join(dir, 'meta')))
- puts "#{metadata["recorded_at"]} : #{metadata["title"]}"
+ begin
+ metadata = JSON.parse(IO.read(File.join(dir, 'meta')))
+ puts "#{metadata["recorded_at"]} : #{metadata["title"]}"
+ rescue Errno::ENOENT
+ puts "Corrupted shellcast in #{dir}"
+ end
end
end
@@ -55,7 +59,7 @@ def play(options = {})
def start_sound_player
return unless File.exist?(record_file('sound.ogg'))
- at_exit { system('stty echo') }
+ # at_exit { system('stty echo') }
STDOUT.puts "=> Starting sound player..."
@sox_pid = fork do
`play #{record_file('sound.ogg')} 2>&1`
@@ -65,7 +69,7 @@ def start_sound_player
def stop_sound_player
return unless File.exist?(record_file('sound.ogg'))
STDOUT.puts "=> Stopping sound player..."
- Process.kill("HUP", @sox_pid)
+ Process.waitpid(@sox_pid)
end
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.