NVDA Helper
In-process and lite high-speed utilities for NVDA
WasapiPlayer Class Reference

Play a stream of audio using WASAPI. More...

Public Types

using ChunkCompletedCallback
 

Public Member Functions

 WasapiPlayer (wchar_t *deviceName, WAVEFORMATEX format, ChunkCompletedCallback callback)
 Constructor.
 
HRESULT open (bool force=false)
 Open the audio device.
 
HRESULT feed (unsigned char *data, unsigned int size, unsigned int *id)
 Feed a chunk of audio.
 
HRESULT stop ()
 
HRESULT sync ()
 
HRESULT idle ()
 
HRESULT pause ()
 
HRESULT resume ()
 
HRESULT setChannelVolume (unsigned int channel, float level)
 

Detailed Description

Play a stream of audio using WASAPI.

Member Typedef Documentation

◆ ChunkCompletedCallback

Initial value:
void(*)(WasapiPlayer* player,
unsigned int id)
Play a stream of audio using WASAPI.
Definition wasapi.cpp:161
void(__stdcall *_notifySendMessageCancelled)()

Constructor & Destructor Documentation

◆ WasapiPlayer()

WasapiPlayer::WasapiPlayer ( wchar_t * deviceName,
WAVEFORMATEX format,
ChunkCompletedCallback callback )

Constructor.

Specify an empty (not null) deviceName to use the default device.

Member Function Documentation

◆ open()

HRESULT WasapiPlayer::open ( bool force = false)

Open the audio device.

If force is true, the device will be reopened even if it is already open.

References BUFFER_SIZE, CLSID_MMDeviceEnumerator, HRESULT(), IID_IAudioClient, IID_IAudioClock, IID_IAudioRenderClient, and notificationClient.

Referenced by feed(), SilencePlayer::init(), setChannelVolume(), and wasPlay_open().

◆ feed()

HRESULT WasapiPlayer::feed ( unsigned char * data,
unsigned int size,
unsigned int * id )

Feed a chunk of audio.

If not null, id will be set to a number used to identify the audio associated with this call. The callback will be called with this number when this audio finishes playing.

References HRESULT(), notificationClient, and open().

Referenced by wasPlay_feed().

◆ stop()

HRESULT WasapiPlayer::stop ( )

References HRESULT().

Referenced by idle(), SilencePlayer::terminate(), and wasPlay_stop().

◆ sync()

HRESULT WasapiPlayer::sync ( )

Referenced by idle(), and wasPlay_sync().

◆ idle()

HRESULT WasapiPlayer::idle ( )

References HRESULT(), stop(), and sync().

Referenced by wasPlay_idle().

◆ pause()

HRESULT WasapiPlayer::pause ( )

References HRESULT().

Referenced by wasPlay_pause().

◆ resume()

HRESULT WasapiPlayer::resume ( )

References HRESULT().

Referenced by wasPlay_resume().

◆ setChannelVolume()

HRESULT WasapiPlayer::setChannelVolume ( unsigned int channel,
float level )

The documentation for this class was generated from the following file: