Class: LAME::Decoding::MPEGAudioFrameFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/lame/decoding/mpeg_audio_frame_finder.rb

Constant Summary collapse

MPEG_HEADER_SIZE =
4

Instance Method Summary collapse

Constructor Details

#initialize(stream) ⇒ MPEGAudioFrameFinder

Returns a new instance of MPEGAudioFrameFinder.



7
8
9
# File 'lib/lame/decoding/mpeg_audio_frame_finder.rb', line 7

def initialize(stream)
  @stream = stream
end

Instance Method Details

#find!Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/lame/decoding/mpeg_audio_frame_finder.rb', line 11

def find!
  begin
    @data = @stream.read(MPEG_HEADER_SIZE)
    if MPEGAudioFrameMatcher.new(@data).match?
      seek_back!
      return
    end
    seek!
  end until end_of_stream?

  raise MPEGAudioFrameNotFoundError
end