Example #1
0
 /// <summary>
 /// Read the digital data of the track
 /// </summary>
 /// <param name="track">Track to read</param>
 /// <param name="Data">Buffer that will receive the data</param>
 /// <param name="DataSize">On return the size needed to read the track</param>
 /// <param name="StartSecond">First second of the track to read, 0 means to start at beginning of the track</param>
 /// <param name="Seconds2Read">Number of seconds to read, 0 means to read until the end of the track</param>
 /// <param name="OnProgress">Delegate to indicate the reading progress</param>
 /// <returns>Negative value means an error. On success returns the number of bytes read</returns>
 public int ReadTrack(int track, byte[] Data, ref uint DataSize, uint StartSecond, uint Seconds2Read,
                      CdReadProgressEventHandler ProgressEvent)
 {
     if (TocValid && (track >= Toc.FirstTrack) && (track <= Toc.LastTrack))
     {
         int StartSect = GetStartSector(track);
         int EndSect   = GetEndSector(track);
         if ((StartSect += (int)StartSecond * 75) >= EndSect)
         {
             StartSect -= (int)StartSecond * 75;
         }
         if ((Seconds2Read > 0) && ((int)(StartSect + Seconds2Read * 75) < EndSect))
         {
             EndSect = StartSect + (int)Seconds2Read * 75;
         }
         DataSize = (uint)(EndSect - StartSect) * CB_AUDIO;
         if (Data != null)
         {
             if (Data.Length >= DataSize)
             {
                 var BufferFiller = new CDBufferFiller(Data);
                 return(ReadTrack(track, BufferFiller.OnCdDataRead, StartSecond, Seconds2Read, ProgressEvent));
             }
             else
             {
                 return(0);
             }
         }
         else
         {
             return(0);
         }
     }
     else
     {
         return(-1);
     }
 }
Example #2
0
 /// <summary>
 /// Read the digital data of the track
 /// </summary>
 /// <param name="track">Track to read</param>
 /// <param name="Data">Buffer that will receive the data</param>
 /// <param name="DataSize">On return the size needed to read the track</param>
 /// <param name="StartSecond">First second of the track to read, 0 means to start at beginning of the track</param>
 /// <param name="Seconds2Read">Number of seconds to read, 0 means to read until the end of the track</param>
 /// <param name="OnProgress">Delegate to indicate the reading progress</param>
 /// <returns>Negative value means an error. On success returns the number of bytes read</returns>
 public int ReadTrack(int track, byte[] Data, ref uint DataSize, uint StartSecond, uint Seconds2Read,
                      CdReadProgressEventHandler ProgressEvent)
 {
     if (TocValid && (track >= Toc.FirstTrack) && (track <= Toc.LastTrack))
     {
         int StartSect = GetStartSector(track);
         int EndSect = GetEndSector(track);
         if ((StartSect += (int) StartSecond*75) >= EndSect)
         {
             StartSect -= (int) StartSecond*75;
         }
         if ((Seconds2Read > 0) && ((int) (StartSect + Seconds2Read*75) < EndSect))
         {
             EndSect = StartSect + (int) Seconds2Read*75;
         }
         DataSize = (uint) (EndSect - StartSect)*CB_AUDIO;
         if (Data != null)
         {
             if (Data.Length >= DataSize)
             {
                 var BufferFiller = new CDBufferFiller(Data);
                 return ReadTrack(track, BufferFiller.OnCdDataRead, StartSecond, Seconds2Read, ProgressEvent);
             }
             else
             {
                 return 0;
             }
         }
         else
         {
             return 0;
         }
     }
     else
     {
         return -1;
     }
 }