Permalink
Browse files

only rewinding output files that can be rewound

  • Loading branch information...
tenderlove committed May 11, 2008
1 parent 423240a commit 5d25cea1f3419912e66b3eea69dd3cb30e4c92aa
Showing with 22 additions and 8 deletions.
  1. +5 −0 .gitignore
  2. +5 −0 History.txt
  3. +1 −1 examples/kexp.rb
  4. +1 −7 ext/decoder.c
  5. +10 −0 lib/icanhasaudio/mpeg.rb
View
@@ -0,0 +1,5 @@
+.*.swp
+*.o
+Makefile
+*.bundle
+mkmf.log
View
@@ -1,3 +1,8 @@
+=== 0.1.1
+
+* 1 Bugfix
+ * Only rewinding output files if its possible.
+
=== 0.1.0
* 1 major enhancement
View
@@ -17,7 +17,7 @@
sleep 2
-raop = Net::RAOP::Client.new('192.168.1.173')
+raop = Net::RAOP::Client.new('10.0.1.1')
raop.connect
raop.play rd
raop.disconnect
View
@@ -86,13 +86,7 @@ lame_decoder(VALUE self, VALUE infile, VALUE outf, mp3data_struct * mp3data)
wavsize *= i;
}
- if(!raw && rb_respond_to(outf, rb_intern("seek")) == Qtrue) {
- rb_funcall( outf,
- rb_intern("seek"),
- 2,
- INT2NUM(0),
- rb_const_get(rb_cIO, rb_intern("SEEK_SET")) );
-
+ if(!raw && rb_funcall(self, rb_intern("attempt_rewind"), 1, outf)) {
rewrite_header(headbuf, (int)wavsize);
rb_funcall(outf, rb_intern("write"), 1, rb_str_new(headbuf, 44));
}
View
@@ -10,5 +10,15 @@ def initialize
@bits = 16
yield self if block_given?
end
+
+ private
+ def attempt_rewind(outf)
+ begin
+ outf.seek(0, IO::SEEK_SET)
+ true
+ rescue
+ false
+ end
+ end
end

0 comments on commit 5d25cea

Please sign in to comment.