IDiscFormat2TrackAtOnce::AddAudioTrack method (imapi2.h)

Writes the data stream to the current media as a new track.


HRESULT AddAudioTrack(
  [in] IStream *data


[in] data

An IStream interface of the audio data to write as the next track on the media.

The data format contains 44.1KHz, 16-bit stereo, raw audio samples. This is the same format used by the audio samples in a Microsoft WAV audio file (without the header).

Return value

S_OK is returned on success, but other success codes may be returned as a result of implementation. The following error codes are commonly returned on operation failure, but do not represent the only possible error values:

Return code Description
Pointer is not valid.

Value: 0x80004003

The requested operation is only valid when media has been "prepared".

Value: 0xC0AA0502

There is currently a write operation in progress.

Value: 0xC0AA0500

CD-R and CD-RW media support a maximum of 99 audio tracks.

Value: 0xC0AA0508

The provided audio stream is not valid.

Value: 0xC0AA050D

There is not enough space left on the media to add the provided audio track.

Value: 0xC0AA0509

Unspecified failure.

Value: 0x80004005

One or more arguments are not valid.

Value: 0x80070057

Failed to allocate the required memory.

Value: 0x8007000E

The device failed to accept the command within the timeout period. This may be caused by the device having entered an inconsistent state, or the timeout value for the command may need to be increased.

Value: 0xC0AA020D

The device reported unexpected or invalid data for a command.

Value: 0xC0AA02FF

The media is inserted upside down.

Value: 0xC0AA0204

The drive reported that it is in the process of becoming ready. Please try the request again later.

Value: 0xC0AA0205

There is no media in the device.

Value: 0xC0AA0202

The media is currently being formatted. Please wait for the format to complete before attempting to use the media.

Value: 0xC0AA0206

The drive reported that it is performing a long-running operation, such as finishing a write. The drive may be unusable for a long period of time.

Value: 0xC0AA0207

The write failed because the drive did not receive data quickly enough to continue writing. Moving the source data to the local computer, reducing the write speed, or enabling a "buffer underrun free" setting may resolve this issue.

Value: 0xC0AA0300

The media is not compatible or of unknown physical format.

Value: 0xC0AA0203

The DVD structure is not present. This may be caused by incompatible drive/medium used.

Value: 0xC0AA020E

The device reported that the requested mode page (and type) is not present.

Value: 0xC0AA0201

The drive reported that the combination of parameters provided in the mode page for a MODE SELECT command were not supported.

Value: 0xC0AA0208

The drive reported that the media is write protected.

Value: 0xC0AA0209

The media's speed is incompatible with the device. This may be caused by using higher or lower speed media than the range of speeds supported by the device.

Value: 0xC0AA020F

The specified handle is invalid.

Value: 6

The specified network resource or device is no longer available.

Value: 55

The device associated with this recorder during the last operation has been exclusively locked, causing this operation to failed.

Value: 0xC0AA0210

The request was canceled.

Value: 0xC0AA0002


Before calling this method, you must call the IDiscFormat2TrackAtOnce::put_Recorder and IDiscFormat2TrackAtOnce::PrepareMedia methods.

You should also consider calling the following methods if their default values are not appropriate for your application:

To determine the progress of the write operation, you must implement the DDiscFormat2TrackAtOnceEvents interface. For examples that show how to implement an event handler in a script, see Monitoring Progress With Events.

The media can accommodate 99 tracks of audio data. Track numbering starts at 1. The last track is 99.

Silence, or data samples containing zeroes, will be added to the track-writing operation in the following ways:

  • The minimum track size is 4 seconds and if needed, the track data will be enlarged to meet this requirement.
  • Due to the nature of track-at-once recording, a two-second gap is added between successive audio tracks. This gap is normally hidden by PC-based players, but may be noticeable on some consumer electronics equipment.


Minimum supported client Windows Vista, Windows XP with SP2 [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header imapi2.h

See also