+import java.awt.image.SampleModel;\r
+\r
import FileOutputStream;\r
\r
/*\r
/**\r
* The MPEG audio bitstream.\r
*/\r
- // javac blank final bug.\r
- /* final */@LOC("ST")\r
- private Bitstream bitstream;\r
+ // private Bitstream bitstream;\r
\r
/**\r
* The MPEG audio decoder.\r
/**\r
* Creates a new <code>Player</code> instance.\r
*/\r
- public Player(InputStream stream) throws JavaLayerException {\r
- this(stream, null);\r
+ public Player() throws JavaLayerException {\r
+ this(null);\r
}\r
\r
- public Player(InputStream stream, AudioDevice device) throws JavaLayerException {\r
- bitstream = new Bitstream(stream);\r
+ public Player(AudioDevice device) throws JavaLayerException {\r
+ // bitstream = new Bitstream(stream);\r
decoder = new Decoder();\r
\r
// if (device!=null)\r
* @return true if the last frame was played, or false if there are more\r
* frames.\r
*/\r
- @LATTICE("IN<T,IN*,THISLOC=T")\r
- @RETURNLOC("IN")\r
+ @LATTICE("OUT<THIS,THIS<IN,IN*,THISLOC=THIS")\r
+ @RETURNLOC("OUT")\r
public boolean play(@LOC("IN") int frames) throws JavaLayerException {\r
- @LOC("IN") boolean ret = true;\r
+ @LOC("OUT") boolean ret = true;\r
\r
- // FileOutputStream fos = new FileOutputStream("output.txt");\r
+ // initialization before ssjava loop\r
+ @LOC("THIS,Player.FR") boolean init = true;\r
+ @LOC("THIS,Player.ST") Header h = BitstreamWrapper.readFrame();\r
+ decoder.init(h);\r
\r
- int count = 0;\r
- SSJAVA: while (frames-- > 0 && ret) {\r
- ret = decodeFrame();\r
+ @LOC("IN") int count = 0;\r
+ SSJAVA: while (count++ < 2147483646) {\r
+ if (h == null) {\r
+ break;\r
+ }\r
+ ret = decodeFrame(init, h);\r
+ if (!ret) {\r
+ break;\r
+ }\r
+ h = BitstreamWrapper.readFrame();\r
}\r
\r
- // fos.flush();\r
- // fos.close();\r
/*\r
* if (!ret) { // last frame, ensure all data flushed to the audio device.\r
* AudioDevice out = audio; if (out!=null) { out.flush(); synchronized\r
* \r
* @return true if there are no more frames to decode, false otherwise.\r
*/\r
- @LATTICE("O<TH,THISLOC=TH")\r
- @RETURNLOC("O")\r
- protected boolean decodeFrame() throws JavaLayerException {\r
+ @LATTICE("C<THIS,O<THIS,THIS<IN,C*,THISLOC=THIS,RETURNLOC=O,GLOBALLOC=THIS")\r
+ protected boolean decodeFrame(@LOC("THIS,Player.FR") boolean init, @LOC("THIS,Player.ST") Header h)\r
+ throws JavaLayerException {\r
try {\r
// AudioDevice out = audio;\r
// if (out==null)\r
// return false;\r
\r
- Header h = bitstream.readFrame();\r
-\r
- if (h == null)\r
- return false;\r
+ // Header h = bitstream.readFrame();\r
\r
- // eom debug\r
- // System.out.println("header framesize=" + h.framesize);\r
- // System.out.println("br total="+h.getBitReserve().hsstell());\r
- //\r
+ // if (h == null){\r
+ // return false;\r
+ // }\r
\r
- // sample buffer set when decoder constructed\r
- @LOC("O") SampleBuffer output = (SampleBuffer) decoder.decodeFrame(h, bitstream);\r
+ // @LOC("O") SampleBuffer output = (SampleBuffer) decoder.decodeFrame(h);\r
+ decoder.decodeFrame(h);\r
\r
// eom debug\r
- int sum=0;\r
- short[] outbuf = output.getBuffer();\r
- for (int i = 0; i < output.getBufferLength(); i++) {\r
-// System.out.println(outbuf[i]);\r
- sum+=outbuf[i];\r
+ @LOC("C") int sum = 0;\r
+ @LOC("C") short[] outbuf = SampleBufferWrapper.getBuffer();\r
+ // short[] outbuf = output.getBuffer();\r
+ TERMINATE: for (@LOC("C") int i = 0; i < SampleBufferWrapper.getBufferLength(); i++) {\r
+ // System.out.println(outbuf[i]);\r
+ sum += outbuf[i];\r
}\r
System.out.println(sum);\r
//\r