Description

The Open method opens a handle to the audio output device to use for playback, and spawns a worker thread to manage playback of the supplied audio data to that device. If an output device is already open for this AudioStream, it is closed before the open attempt is processed. After opening an audio output device, it can be closed again by calling the Close method. If a device is open when the AudioStream object is destroyed, it is closed automatically.

Usage

bool Open(unsigned int achannelCount, unsigned int abitsPerSample, unsigned int asamplesPerSec, unsigned int amaxPendingSamples = 0, unsigned int aminPlayingSamples = 0);

Argument list

achannelCount [unsigned int]
The number of channels in the audio data being sent for playback. Note that this does not need to match the number of channels being used by the actual playback device. This number should be set to the actual number of channels that are present in the audio stream being played.
abitsPerSample [unsigned int]
The number of bits in a single sample entry for a single channel in the audio stream.
asamplesPerSec [unsigned int]
The output sample rate to use on the audio output device. This must be set to a sample rate which is supported by the audio hardware on the computer, such as 44100 or 48000. Note that this is generally going to be different to the sample rate of the actual data being generated by an emulation core. Where the playback sample rate differs from the sample rate of the generated data, the ConvertSampleRate method should be used to resample the audio data prior to sending it for playback. Right now no assistance is provided to determine what sample rates are supported by the local computer. See the AudioStream library overview for more information on this.
amaxPendingSamples [unsigned int]
The maximum number of samples that should be buffered in the Windows audio buffers at any one time. The lower this value, the less latency there is between sending audio data to the AudioStream and the actual playback of that audio data on the hardware, however this also reduces the tolerance of the audio playback to variations in speed at which the audio data is supplied. If the default value of 0 is used, the AudioStream will use a default calculation of samplesPerSec/4.
aminPlayingSamples [unsigned int]
The minimum number of samples that are allowed to be buffered in the Windows audio buffers at any one time, before filler sample buffers are inserted to avoid clicks and pops if the buffer was to underflow. This should be set to a value as low as possible, before clicks or pops begin appearing in the audio playback. If the default value of 0 is used, the AudioStream will use a default calculation of samplesPerSec/20.

Return value

[bool]
True if the audio output stream is created successfully, false otherwise.

See also