Cleanup
This commit is contained in:
parent
f9d6c66f7e
commit
510420d42d
|
@ -50,8 +50,7 @@ defmodule MPEGAudioFrameParser.Impl do
|
||||||
|
|
||||||
# Not synced, found a sync word. Create a new frame struct:
|
# Not synced, found a sync word. Create a new frame struct:
|
||||||
defp process_bytes(%{current_frame: nil} = state, <<@sync_word::size(11), header::size(21), rest::bits>>) do
|
defp process_bytes(%{current_frame: nil} = state, <<@sync_word::size(11), header::size(21), rest::bits>>) do
|
||||||
header = <<@sync_word::size(11), header::size(21)>>
|
frame = <<@sync_word::size(11), header::size(21)>> |> Frame.from_header
|
||||||
frame = Frame.from_header(header)
|
|
||||||
process_bytes(%{state | current_frame: frame}, rest)
|
process_bytes(%{state | current_frame: frame}, rest)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,8 +62,7 @@ defmodule MPEGAudioFrameParser.Impl do
|
||||||
|
|
||||||
# Synced, but with an invalid header. Discard a byte:
|
# Synced, but with an invalid header. Discard a byte:
|
||||||
defp process_bytes(%{current_frame: %Frame{valid: false}} = state, packet) do
|
defp process_bytes(%{current_frame: %Frame{valid: false}} = state, packet) do
|
||||||
data = <<state.current_frame.data, packet::bits>>
|
<<_byte, rest::bits>> = <<state.current_frame.data, packet::bits>>
|
||||||
<<_byte, rest::bits>> = data
|
|
||||||
process_bytes(%{state | current_frame: nil}, rest)
|
process_bytes(%{state | current_frame: nil}, rest)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue