/* * myLib - https://github.com/taktod/myLib * Copyright (c) 2014 ttProject. All rights reserved. * * Licensed under The MIT license. */ package com.ttProject.frame.vorbis.type; import java.nio.ByteBuffer; import com.ttProject.frame.vorbis.VorbisFrame; import com.ttProject.nio.channels.IReadChannel; import com.ttProject.util.BufferUtil; /** * frame for vorbis * @author taktod */ public class Frame extends VorbisFrame { private ByteBuffer buffer = null; /** * {@inheritDoc} */ @Override public void minimumLoad(IReadChannel channel) throws Exception { super.setSize(channel.size()); super.update(); } /** * {@inheritDoc} */ @Override public void load(IReadChannel channel) throws Exception { buffer = BufferUtil.safeRead(channel, channel.size()); super.update(); } /** * {@inheritDoc} */ @Override protected void requestUpdate() throws Exception { if(buffer == null) { throw new Exception("buffer is undefined."); } setData(buffer); } /** * {@inheritDoc} */ @Override public ByteBuffer getPackBuffer() throws Exception { return getData(); } }