Exemplo n.º 1
0
        /// <summary>
        /// Checks to see if the track is a data track.
        /// </summary>
        /// <remarks></remarks>
        /// <param name="trackNumber">
        /// Returns true if the track is a data track
        /// </param>
        public bool IsDataTrack(int trackNumber)
        {
            int result = Sdl.CD_INDRIVE((int)this.Status);

            GC.KeepAlive(this);
            if (result == 1)
            {
                Sdl.SDL_CD cd =
                    (Sdl.SDL_CD)Marshal.PtrToStructure(
                        this.Handle, typeof(Sdl.SDL_CD));

                if (cd.track[trackNumber].type == (byte)CDTrackType.Data)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        public void CD_INDRIVE()
        {
            Sdl.SDL_Quit();
            Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING);
            IntPtr cd = Sdl.SDL_CDOpen(0);

            //Console.WriteLine("CD_INDRIVE: " + Sdl.CD_INDRIVE(Sdl.SDL_CDStatus(cd)));
            //Make sure there is a CD in the drive
            Assert.AreEqual(Sdl.CD_INDRIVE(Sdl.SDL_CDStatus(cd)), 1);
            Sdl.SDL_CDClose(cd);
            Sdl.SDL_Quit();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Returns the end time of the track in seconds.
        /// </summary>
        /// <remarks></remarks>
        /// <param name="trackNumber">Track to query</param>
        public int TrackEnd(int trackNumber)
        {
            int result = Sdl.CD_INDRIVE((int)this.Status);

            GC.KeepAlive(this);
            if (result == 1)
            {
                return(this.TrackStart(trackNumber) + this.TrackLength(trackNumber));
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Returns the number of seconds before the audio track starts on the cd.
        /// </summary>
        /// <remarks></remarks>
        /// <param name="trackNumber">Track to query</param>
        public int TrackStart(int trackNumber)
        {
            int result = Sdl.CD_INDRIVE((int)this.Status);

            GC.KeepAlive(this);
            if (result == 1)
            {
                Sdl.SDL_CD cd =
                    (Sdl.SDL_CD)Marshal.PtrToStructure(
                        this.Handle, typeof(Sdl.SDL_CD));
                return((int)Timer.FramesToSeconds(cd.track[trackNumber].offset));
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 5
0
        public void CDPlayTracks()
        {
            Sdl.SDL_Quit();
            Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING);
            IntPtr cd = Sdl.SDL_CDOpen(0);

            Assert.IsFalse(cd == IntPtr.Zero);
            //Console.WriteLine("CDStatus: " + Sdl.SDL_CDStatus(cd));
            if (Sdl.CD_INDRIVE(Sdl.SDL_CDStatus(cd)) == 1)
            {
                int result = Sdl.SDL_CDPlayTracks(cd, 0, 0, 0, Sdl.CD_FPS * 20);
                if (result == -1)
                {
                    Console.WriteLine("Error: " + Sdl.SDL_GetError());
                }
                Assert.AreEqual(0, result);
            }
            Sdl.SDL_CDClose(cd);
            this.Quit();
        }
Exemplo n.º 6
0
        public void TrackAudio()
        {
            Sdl.SDL_Quit();
            Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING);
            IntPtr intPtr = Sdl.SDL_CDOpen(0);

            Console.WriteLine("CD_INDRIVE: " + Sdl.CD_INDRIVE(Sdl.SDL_CDStatus(intPtr)));
            //Make sure there is a CD in the drive
            Assert.AreEqual(Sdl.CD_INDRIVE(Sdl.SDL_CDStatus(intPtr)), 1);

            Sdl.SDL_CD cd =
                (Sdl.SDL_CD)Marshal.PtrToStructure(
                    intPtr, typeof(Sdl.SDL_CD));
            //Sdl.SDL_CDtrack[] cdTrack = new Sdl.SDL_CDtrack[cd.numtracks];
            //IntPtr current;
            Console.WriteLine(cd.numtracks);
            Console.WriteLine(cd.cur_frame);
            Console.WriteLine(cd.cur_track);
            Console.WriteLine(cd.id);
            Console.WriteLine(cd.status);
            int minutes;
            int seconds;
            int frames;

            for (int i = 0; i < cd.numtracks; i++)
            {
                Console.WriteLine("Type: " + cd.track[i].type);
                Sdl.FRAMES_TO_MSF(cd.track[i].length, out minutes, out seconds, out frames);
                Console.WriteLine("Length: " + minutes + ":" + seconds);
                Console.WriteLine("Id: " + cd.track[i].id);
                //Console.WriteLine(cd.track.ToInt32());
                //cdTrack[ i ] = (Sdl.SDL_CDtrack)Marshal.PtrToStructure( cd.track, typeof(Sdl.SDL_CDtrack));

//
//
//				//Marshal.FreeCoTaskMem( (IntPtr)Marshal.ReadInt32( current ));
//				//Marshal.DestroyStructure( current, typeof(Sdl.SDL_CDtrack) );
//				current = (IntPtr)((int)current +
                //Marshal.SizeOf( cdTrack[ i ] ));

                //current = Marshal.ReadIntPtr(intPtr, Marshal.SizeOf(typeof(Sdl.SDL_CDtrack)));
                //current = new IntPtr(intPtr.ToInt32() + i * Marshal.SizeOf(typeof(Sdl.SDL_CDtrack)));
                //Marshal.Copy(current, j, 0, Marshal.SizeOf(typeof(Sdl.SDL_CDtrack)));
                //Marshal.Copy(j, 0, structPtr, Marshal.SizeOf(typeof(Sdl.SDL_CDtrack)));
                //Marshal.WriteIntPtr(intPtr, structPtr[i]);

                //Console.WriteLine("SDL_CDtrack: " + Marshal.SizeOf(typeof(Sdl.SDL_CDtrack)));
                //Assert.IsFalse(intPtr == IntPtr.Zero);
                //Assert.IsFalse(current == IntPtr.Zero);
                //Assert.IsFalse(structPtr[i] == IntPtr.Zero);
                //Console.WriteLine(intPtr.ToString());
                //Console.WriteLine(current.ToString());
                //Console.WriteLine(structPtr[i].ToString());
                //cdTrack[ i ] = (Sdl.SDL_CDtrack)Marshal.PtrToStructure( structPtr[i], typeof(Sdl.SDL_CDtrack));

                //Console.WriteLine( "Track Id: " + cdTrack[ i ].id );
                //Console.WriteLine( "Track Type: " + cdTrack[i].type );

                //Assert.AreEqual(cdTrack[i].type,(byte) Sdl.SDL_AUDIO_TRACK);
            }
            Sdl.SDL_CDClose(intPtr);
            Sdl.SDL_Quit();
        }