Skip to content

Loading…

Added filter for `sox` dependencies and updated README for installation of sox #14

Merged
merged 2 commits into from

2 participants

@baldrailers

No description provided.

@baldrailers

This will ensure that sox dependency was installed and displays a pretty warning message that will tell the users that sox is not installed and will not record audio.

@antono
Shelr.tv member

Thanks!

@antono antono merged commit fe5550c into shelr:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 20 additions and 8 deletions.
  1. +6 −0 README.md
  2. +14 −8 lib/shelr/recorder.rb
View
6 README.md
@@ -76,6 +76,12 @@ and setup it as recording backend.
sudo port install ttyrec # BSD / OSX
shelr backend ttyrec # BSD / OSX
+To enable sound recordings, you need to install `sox`.
+
+ brew install sox # OSX
+ sudo port install sox # BSD / OSX
+ sudo apt-get install sox # Ubuntu / Debian
+
## Copyright
(Э) 2010, 2011, 2012 Antono Vasiljev and
View
22 lib/shelr/recorder.rb
@@ -110,18 +110,24 @@ def record_file(name)
end
def start_sound_recording
- STDOUT.puts "Sound file stored in #{record_file('sound.ogg')}"
- @sox_pid = fork do
- Signal.trap("INT") { puts "=> Sound recording finished!"; exit }
- `rec -C 1 --channels 1 --rate 16k --comment 'Recorded for http://shelr.tv/' #{record_file('sound.ogg')} 2>&1`
+ if system('which rec')
+ STDOUT.puts "Sound file stored in #{record_file('sound.ogg')}"
+ @sox_pid = fork do
+ Signal.trap("INT") { puts "=> Sound recording finished!"; exit }
+ `rec -C 1 --channels 1 --rate 16k --comment 'Recorded for http://shelr.tv/' #{record_file('sound.ogg')} 2>&1`
+ end
+ else
+ STDOUT.puts "Sound recording is not available. You need to install `sox` to enable sound recordings."
end
end
def stop_sound_recording
- STDOUT.puts "=> Stopping sound recorder"
- sleep 2 # otherwise record will be cropped for some reason
- Process.kill("INT", @sox_pid)
- Process.waitpid(@sox_pid)
+ unless system('which rec')
+ STDOUT.puts "=> Stopping sound recorder"
+ sleep 2 # otherwise record will be cropped for some reason
+ Process.kill("INT", @sox_pid)
+ Process.waitpid(@sox_pid)
+ end
end
def recorder_cmd
Something went wrong with that request. Please try again.