Skip to content

Commit

Permalink
make buffer local
Browse files Browse the repository at this point in the history
  • Loading branch information
ricksterhd123 committed Dec 11, 2023
1 parent a3f72b3 commit 01bb756
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/shout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ def play(file_path) # rubocop:disable Metrics/MethodLength
# stream file to icecast2
until file.eof?
file_data = file.read(MAX_BUFFER_SIZE)
@buffer = FFI::MemoryPointer.from_string(file_data)
buffer = FFI::MemoryPointer.from_string(file_data)
Shout.shout_sync(@t_shout)
send_result = Shout.shout_send(@t_shout, @buffer, MAX_BUFFER_SIZE)
send_result = Shout.shout_send(@t_shout, buffer, MAX_BUFFER_SIZE)
raise StandardError, "Failed to play file #{file_path}, code: #{send_result}" if send_result != SHOUTERR_SUCCESS

Shout.shout_delay(@t_shout)
Expand All @@ -124,7 +124,6 @@ def begin(&block)
instance_eval(&block)
ensure
puts "shutting down..."
@buffer.free
Shout.shout_free(@t_shout)
Shout.shout_close(@t_shout)
Shout.shout_shutdown
Expand Down

0 comments on commit 01bb756

Please sign in to comment.