Logo Search packages:      
Sourcecode: f-spot version File versions  Download package

static bool TagLib::Mpeg::AudioHeader::Find ( out AudioHeader  header,
TagLib.File  file,
long  position,
int  length 
) [inline, static]

Searches for an audio header in a TagLib.File starting at a specified position and searching through a specified number of bytes.

Parameters:
headerA AudioHeader object in which the found header will be stored.
fileA TagLib.File object to search.
positionA long value specifying the seek position in file at which to start searching.
lengthA int value specifying the maximum number of bytes to search before aborting.
Returns:
A bool value indicating whether or not a header was found.
Exceptions:
ArgumentNullExceptionfile is .

Definition at line 709 of file AudioHeader.cs.

References TagLib::ByteVector::Add(), TagLib::File::BufferSize, TagLib::ByteVector::Count, TagLib::ByteVector::Mid(), and Unknown.

Referenced by TagLib::Mpeg::File::ReadAudioPacket(), and TagLib::Mpeg::AudioFile::ReadStart().

            {
                  if (file == null)
                        throw new ArgumentNullException ("file");
                  
                  long end = position + length;
                  header = AudioHeader.Unknown;
                  
                  file.Seek (position);
                  
                  ByteVector buffer = file.ReadBlock (3);
                  
                  if (buffer.Count < 3)
                        return false;
                  
                  do {
                        file.Seek (position + 3);
                        buffer = buffer.Mid (buffer.Count - 3);
                        buffer.Add (file.ReadBlock (
                              (int) File.BufferSize));
                        
                        for (int i = 0; i < buffer.Count - 3 &&
                              (length < 0 || position + i < end); i++)
                              if (buffer [i] == 0xFF &&
                                    buffer [i + 1] > 0xE0)
                                    try {
                                          header = new AudioHeader (
                                                buffer.Mid (i, 4),
                                                file, position + i);
                                          return true;
                                    } catch (CorruptFileException) {
                                    }
                        
                        position += File.BufferSize;
                  } while (buffer.Count > 3 && (length < 0 || position < end));
                  
                  return false;
            }

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index