Esempio 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);
            }
        }
Esempio n. 2
0
        public void CDOpen()
        {
            Sdl.SDL_Quit();
            Sdl.SDL_Init(Sdl.SDL_INIT_EVERYTHING);
            IntPtr resultPtr = Sdl.SDL_CDOpen(0);

            Sdl.SDL_CD cd =
                (Sdl.SDL_CD)Marshal.PtrToStructure(resultPtr, typeof(Sdl.SDL_CD));
            //Console.WriteLine("CDName: " + Sdl.SDL_CDName(0));
            Assert.AreEqual(cd.id, 0);
            Sdl.SDL_CDClose(resultPtr);
            this.Quit();
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
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();
        }