Skip to content

Latest commit

 

History

History
302 lines (244 loc) · 9.96 KB

nf-mmeapi-waveoutopen.md

File metadata and controls

302 lines (244 loc) · 9.96 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:mmeapi.waveOutOpen
waveOutOpen function (mmeapi.h)
The waveOutOpen function opens the given waveform-audio output device for playback.
_win32_waveOutOpen
mmeapi/waveOutOpen
multimedia.waveoutopen
waveOutOpen
waveOutOpen function [Windows Multimedia]
multimedia\waveoutopen.htm
Multimedia
ef02221b-df45-4fc3-8d9d-f119fa802d34
12/05/2018
_win32_waveOutOpen, mmeapi/waveOutOpen, multimedia.waveoutopen, waveOutOpen, waveOutOpen function [Windows Multimedia]
mmeapi.h
Windows.h
Windows
Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
Winmm.lib
Winmm.dll
Windows
19H1
waveOutOpen
mmeapi/waveOutOpen
c++
APIRef
kbSyntax
DllExport
Winmm.dll
API-MS-Win-mm-mme-l1-1-0.dll
winmmbase.dll
waveOutOpen

waveOutOpen function

-description

The waveOutOpen function opens the given waveform-audio output device for playback.

-parameters

-param phwo

Pointer to a buffer that receives a handle identifying the open waveform-audio output device. Use the handle to identify the device when calling other waveform-audio output functions. This parameter might be NULL if the WAVE_FORMAT_QUERY flag is specified for fdwOpen.

-param uDeviceID

Identifier of the waveform-audio output device to open. It can be either a device identifier or a handle of an open waveform-audio input device. You can also use the following flag instead of a device identifier:

Value Meaning
WAVE_MAPPER The function selects a waveform-audio output device capable of playing the given format.

-param pwfx

Pointer to a WAVEFORMATEX structure that identifies the format of the waveform-audio data to be sent to the device. You can free this structure immediately after passing it to waveOutOpen.

-param dwCallback

Specifies the callback mechanism. The value must be one of the following:

  • A pointer to a callback function. For the function signature, see waveOutProc.
  • A handle to a window.
  • A thread identifier.
  • A handle to an event.
  • The value NULL.
The fdwOpen parameter specifies how the dwCallback parameter is interpreted. For more information, see Remarks.

-param dwInstance

User-instance data passed to the callback mechanism. This parameter is not used with the window callback mechanism.

-param fdwOpen

Flags for opening the device. The following values are defined.

Value Meaning
CALLBACK_EVENT The dwCallback parameter is an event handle.
CALLBACK_FUNCTION The dwCallback parameter is a callback procedure address.
CALLBACK_NULL No callback mechanism. This is the default setting.
CALLBACK_THREAD The dwCallback parameter is a thread identifier.
CALLBACK_WINDOW The dwCallback parameter is a window handle.
WAVE_ALLOWSYNC If this flag is specified, a synchronous waveform-audio device can be opened. If this flag is not specified while opening a synchronous driver, the device will fail to open.
WAVE_MAPPED_DEFAULT_COMMUNICATION_DEVICE If this flag is specified and the uDeviceID parameter is WAVE_MAPPER, the function opens the default communication device.

This flag applies only when uDeviceID equals WAVE_MAPPER.

Note  Requires Windows 7
 
WAVE_FORMAT_DIRECT If this flag is specified, the ACM driver does not perform conversions on the audio data.
WAVE_FORMAT_QUERY If this flag is specified, waveOutOpen queries the device to determine if it supports the given format, but the device is not actually opened.
WAVE_MAPPED If this flag is specified, the uDeviceID parameter specifies a waveform-audio device to be mapped to by the wave mapper.

-returns

Returns MMSYSERR_NOERROR if successful or an error otherwise. Possible error values include the following.

Return code Description
MMSYSERR_ALLOCATED
Specified resource is already allocated.
MMSYSERR_BADDEVICEID
Specified device identifier is out of range.
MMSYSERR_NODRIVER
No device driver is present.
MMSYSERR_NOMEM
Unable to allocate or lock memory.
WAVERR_BADFORMAT
Attempted to open with an unsupported waveform-audio format.
WAVERR_SYNC
The device is synchronous but waveOutOpen was called without using the WAVE_ALLOWSYNC flag.

-remarks

Use the waveOutGetNumDevs function to determine the number of waveform-audio output devices present in the system. If the value specified by the uDeviceID parameter is a device identifier, it can vary from zero to one less than the number of devices present. The WAVE_MAPPER constant can also be used as a device identifier.

The structure pointed to by pwfx can be extended to include type-specific information for certain data formats. For example, for PCM data, an extra UINT is added to specify the number of bits per sample. Use the PCMWAVEFORMAT structure in this case. For all other waveform-audio formats, use the WAVEFORMATEX structure to specify the length of the additional data.

If you choose to have a window or thread receive callback information, the following messages are sent to the window procedure function to indicate the progress of waveform-audio output: MM_WOM_OPEN, MM_WOM_CLOSE, and MM_WOM_DONE.

Callback Mechanism

The dwCallback and fdwOpen parameters specify how the application is notified about the progress of waveform-audio output.

If fdwOpen contains the CALLBACK_FUNCTION flag, dwCallback is a pointer to a callback function. For the function signature, see waveOutProc. The uMsg parameter of the callback indicates the progress of the audio output:

If fdwOpen contains the CALLBACK_WINDOW flag, dwCallback is a handle to a window.The window receives the following messages, indicating the progress: If fdwOpen contains the CALLBACK_THREAD flag, dwCallback is a thread identifier. The thread receives the messages listed previously for CALLBACK_WINDOW.

If fdwOpen contains the CALLBACK_EVENT flag, dwCallback is a handle to an event. The event is signaled whenever the state of the waveform buffer changes. The application can use WaitForSingleObject or WaitForMultipleObjects to wait for the event. When the event is signaled, you can get the current state of the waveform buffer by checking the dwFlags member of the WAVEHDR structure. (See waveOutPrepareHeader.)

If fdwOpen contains the CALLBACK_NULL flag, dwCallback must be NULL. In that case, no callback mechanism is used.

-see-also

Using a Callback Function to Process Driver Messages

Using a Window or Thread to Process Driver Messages

Using an Event Callback to Process Driver Messages

Waveform Audio

Waveform Functions