get rid of the stream parsing that occurs in the Layer III decoder. BitStream.readFra...
[IRC.git] / Robust / src / Tests / ssJava / mp3decoder / Player.java
index 406876e29d014782df961ed279abef4304855e25..75d5863b5e07491e711e22bbcef88f301a7777d1 100644 (file)
@@ -19,7 +19,7 @@
  */\r
 \r
 \r
-import java.io.InputStream;\r
+//import java.io.InputStream;\r
 \r
        \r
 /**\r
@@ -32,23 +32,24 @@ import java.io.InputStream;
 \r
 // REVIEW: the audio device should not be opened until the\r
 // first MPEG audio frame has been decoded. \r
+@LATTICE("B<DE,DE<ST,DE<HE,HE<ST,ST<FR")\r
 public class Player\r
 {              \r
        /**\r
         * The current frame number. \r
         */\r
-       private int frame = 0;\r
+       @LOC("FR") private int frame = 0;\r
        \r
        /**\r
         * The MPEG audio bitstream. \r
         */\r
        // javac blank final bug. \r
-       /*final*/ private Bitstream             bitstream;\r
+       /*final*/ @LOC("ST") private Bitstream          bitstream;\r
        \r
        /**\r
         * The MPEG audio decoder. \r
         */\r
-       /*final*/ private Decoder               decoder; \r
+       /*final*/ @LOC("DE") private Decoder            decoder; \r
        \r
        /**\r
         * The AudioDevice the audio samples are written to. \r
@@ -58,41 +59,42 @@ public class Player
        /**\r
         * Has the player been closed?\r
         */\r
-       private boolean         closed = false;\r
+       @LOC("B") private boolean               closed = false;\r
        \r
        /**\r
         * Has the player played back all frames from the stream?\r
         */\r
-       private boolean         complete = false;\r
+       @LOC("B") private boolean               complete = false;\r
 \r
-       private int                     lastPosition = 0;\r
+       @LOC("B") private int                   lastPosition = 0;\r
        \r
        /**\r
         * Creates a new <code>Player</code> instance. \r
         */\r
        public Player(InputStream stream) throws JavaLayerException\r
        {\r
-               //this(stream, null);   \r
+               this(stream, null);     \r
        }\r
 \r
-       /* temporarily disabled by eom\r
+\r
        public Player(InputStream stream, AudioDevice device) throws JavaLayerException\r
        {\r
                bitstream = new Bitstream(stream);              \r
                decoder = new Decoder();\r
-                               \r
-               if (device!=null)\r
-               {               \r
-                       audio = device;\r
-               }\r
-               else\r
-               {                       \r
-                       FactoryRegistry r = FactoryRegistry.systemRegistry();\r
-                       audio = r.createAudioDevice();\r
-               }\r
-               audio.open(decoder);\r
+               \r
+//             if (device!=null)\r
+//             {               \r
+//                     audio = device;\r
+//             }\r
+//             else\r
+//             {                       \r
+//                     FactoryRegistry r = FactoryRegistry.systemRegistry();\r
+//                     audio = r.createAudioDevice();\r
+//             }\r
+               \r
+               device.open(decoder);\r
        }\r
-       */\r
+       \r
        \r
        public void play() throws JavaLayerException\r
        {\r
@@ -106,14 +108,16 @@ public class Player
         * @return      true if the last frame was played, or false if there are\r
         *                      more frames. \r
         */\r
-       public boolean play(int frames) throws JavaLayerException\r
+       @LATTICE("IN<T,IN*,THISLOC=T")\r
+       @RETURNLOC("IN")\r
+       public boolean play(@LOC("IN") int frames) throws JavaLayerException\r
        {\r
-               boolean ret = true;\r
-               \r
-               \r
+           @LOC("IN") boolean ret = true;\r
+           \r
+            SSJAVA:\r
                while (frames-- > 0 && ret)\r
                {\r
-                       ret = decodeFrame();                    \r
+                        ret = decodeFrame();\r
                }\r
                /*\r
                if (!ret)\r
@@ -198,6 +202,8 @@ public class Player
         * \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
        {               \r
                try\r
@@ -212,7 +218,7 @@ public class Player
                                return false;\r
                                \r
                        // sample buffer set when decoder constructed\r
-                       SampleBuffer output = (SampleBuffer)decoder.decodeFrame(h, bitstream);\r
+                       @LOC("O") SampleBuffer output = (SampleBuffer)decoder.decodeFrame(h, bitstream);\r
                                                                                                                                                                                                                                                                                                        \r
                        //synchronized (this)\r
                        //{\r
@@ -248,6 +254,5 @@ public class Player
 */             \r
                return true;\r
        }\r
-\r
        \r
 }\r