예제 #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)
             {
                 CDBufferFiller BufferFiller = new CDBufferFiller(Data);
                 return(ReadTrack(track, new CdDataReadEventHandler(BufferFiller.OnCDDataRead), StartSecond, Seconds2Read, ProgressEvent));
             }
             else
             {
                 return(0);
             }
         }
         else
         {
             return(0);
         }
     }
     else
     {
         return(-1);
     }
 }
예제 #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)
					{
						CDBufferFiller BufferFiller = new CDBufferFiller(Data);
						return ReadTrack(track, new CdDataReadEventHandler(BufferFiller.OnCDDataRead), StartSecond, Seconds2Read, ProgressEvent);
					}
					else
					{
						return 0;
					}
				}
				else
				{
					return 0;
				}
			}
			else
			{
				return -1;
			}
		}