lib/hallon/observable/session.rb in hallon-0.12.0 vs lib/hallon/observable/session.rb in hallon-0.13.0
- old
+ new
@@ -105,10 +105,14 @@
format[:rate] = struct[:sample_rate]
format[:channels] = struct[:channels]
format[:type] = struct[:sample_type]
# read the frames of the given type
- frames = frames.public_send("read_array_of_#{format[:type]}", num_frames * format[:channels])
+ frames = unless num_frames.zero?
+ frames.public_send("read_array_of_#{format[:type]}", num_frames * format[:channels])
+ else
+ [] # when seeking, for example, num_frames will be zero and frames will be nil
+ end
# pass the frames to the callback, allowing it to do whatever
consumed_frames = trigger(pointer, :music_delivery, format, frames.each_slice(format[:channels]))
# finally return how many frames the callback reportedly consumed