Class ExtendedAudioFileServicesReader
- Namespace
- NAudio.MacOS.AudioToolbox
- Assembly
- NAudio.MacOS.dll
Provides the base class for extended audio file services readers.
Not meant to be extended by external code.
Instead, use the dedicated subclasses of this class,
located at the NAudio.Wave namespace.
Extends the WaveStream class and fully supports seeking,
if the source from where the reader is initialized from supports seeking.
public abstract class ExtendedAudioFileServicesReader : WaveStream, IAsyncDisposable, IDisposable, IWaveProvider
- Inheritance
-
ExtendedAudioFileServicesReader
- Implements
- Derived
- Inherited Members
- Extension Methods
Properties
CanRead
We can read from this stream
public override sealed bool CanRead { get; }
Property Value
CanSeek
We can seek within this stream
public override sealed bool CanSeek { get; }
Property Value
CanWrite
We can't write to this stream
public override sealed bool CanWrite { get; }
Property Value
CurrentTime
The current position in the stream in Time format. On set, the resulting byte position is rounded down to a multiple of BlockAlign so the stream stays on a valid block boundary.
public override sealed TimeSpan CurrentTime { get; set; }
Property Value
Exceptions
- ObjectDisposedException
This reader instance has been disposed of.
Length
Gets the length, in bytes, of this extended audio file reader.
public override sealed long Length { get; }
Property Value
Exceptions
- ObjectDisposedException
This reader instance has been disposed of.
Position
Gets the position, in bytes, of this extended audio file reader.
public override sealed long Position { get; set; }
Property Value
Exceptions
- ObjectDisposedException
This reader instance has been disposed of.
Settings
Gets the settings object provided to this instance during construction.
[MaybeNull]
public ExtendedAudioFileReaderSettings Settings { get; }
Property Value
TotalTime
Total length in real-time of the stream (may be an estimate for compressed files)
public override sealed TimeSpan TotalTime { get; }
Property Value
Exceptions
- ObjectDisposedException
This reader instance has been disposed of.
WaveFormat
Retrieves the WaveFormat for this stream
public override sealed WaveFormat WaveFormat { get; }
Property Value
Methods
Dispose(bool)
Releases the unmanaged resources used by the Stream and optionally releases the managed resources.
protected override sealed void Dispose(bool disposing)
Parameters
disposingbooltrue to release both managed and unmanaged resources; false to release only unmanaged resources.
DisposeNativeData()
Disposes of any native data the reader has allocated.
Subclasses that override this should call this implementation
by using the base keyword.
protected virtual void DisposeNativeData()
Init()
Initializes the reader.
This should typically be called inside the constructor.
protected void Init()
InitializeReader()
Implementations of this allow to initialize the Extended Audio File services reader from a source.
protected abstract nint InitializeReader()
Returns
- nint
Handle to an extended audio file.
Read(byte[], int, int)
When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.
public override sealed int Read(byte[] buffer, int offset, int count)
Parameters
bufferbyte[]An array of bytes. When this method returns, the buffer contains the specified byte array with the values between
offsetand (offset+count- 1) replaced by the bytes read from the current source.offsetintThe zero-based byte offset in
bufferat which to begin storing the data read from the current stream.countintThe maximum number of bytes to be read from the current stream.
Returns
- int
The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if
countis 0 or the end of the stream has been reached.
Exceptions
- ArgumentException
The sum of
offsetandcountis larger than the buffer length.- ArgumentNullException
bufferis null.- ArgumentOutOfRangeException
offsetorcountis negative.- IOException
An I/O error occurs.
- NotSupportedException
The stream does not support reading.
- ObjectDisposedException
Methods were called after the stream was closed.
Read(Span<byte>)
Reads audio data and places them to the specified buffer.
public override sealed int Read(Span<byte> buffer)
Parameters
bufferSpan<byte>A region of memory. When this method returns, the contents of this region are replaced by the bytes read from the current reader.
Returns
- int
The total number of bytes read into the buffer. This can be less than the size of the buffer if that many bytes are not currently available, or zero (0) if the buffer's length is zero or the end of the stream has been reached.
Remarks
Note that this method is not thread-safe; You can read from a different thread from where the reader was created from, but you must ensure that this call is only performed by one specific thread.