xine-lib: xine-lib-1.2.13/src/audio_out/audio_directx2_out.c File Reference

xine-lib 1.2.13-20230125hg15249

Data Structures | Macros | Functions | Variables
audio_directx2_out.c File Reference
`#include <stdarg.h>`
`#include <errno.h>`
`#include <string.h>`
`#include <math.h>`
`#include <windows.h>`
`#include <dsound.h>`
`#include <xine/xine_internal.h>`
`#include <xine/audio_out.h>`

## Data Structures
struct | dx2_class_t
struct | dx2_driver_t

## Macros
#define | LOG_MODULE "audio_directx2_out"
#define | LOG_VERBOSE
#define | AO_OUT_DIRECTX2_IFACE_VERSION 9
#define | GAP_TOLERANCE (AO_MAX_GAP/3)
#define | BUFFER_MS 1000
#define | BUFFER_MIN_MS 200
#define | FACTOR 60.0
#define | STATUS_START 0
#define | STATUS_WAIT 1
#define | STATUS_RUNNING 2
#define | PRIdword "lu"
#define | PRIsizet "u"
#define | IID_IDirectSoundNotify xine_IID_IDirectSoundNotify

## Functions
static void | XINE_FORMAT_PRINTF (1, 2)
static char * | dsound_strerror (HRESULT err)
static LPDIRECTSOUND | dsound_create ()
static void | dsound_destroy (LPDIRECTSOUND ds)
static void | dsound_fill_wfx (WAVEFORMATEX *wfx, uint32_t bits, uint32_t rate, int channels, size_t frame_size)
static void | dsound_fill_desc (DSBUFFERDESC *desc, DWORD flags, DWORD buffer_size, WAVEFORMATEX *wfx)
static void | audio_thread_exit (dx2_driver_t *this)
static void | audio_error (dx2_driver_t *this, HRESULT err, char *msg)
static int | audio_create_buffers (dx2_driver_t *this)
static void | audio_destroy_buffers (dx2_driver_t *this)
static int | audio_play (dx2_driver_t *this)
static int | audio_stop (dx2_driver_t *this)
static int | audio_tell (dx2_driver_t *this, size_t *pos)
static int | audio_seek (dx2_driver_t *this, size_t pos)
static int | audio_flush (dx2_driver_t *this)
static int | audio_set_volume (dx2_driver_t *this, int volume)
static int | audio_fill (dx2_driver_t *this, char *data, size_t size)
static int | mode2channels (uint32_t mode)
static int | test_capability (LPDIRECTSOUNDBUFFER buffer, uint32_t bits, uint32_t rate, int mode)
static int | test_capabilities (dx2_driver_t *this)
static size_t | buffer_free_size (dx2_driver_t *this)
static size_t | buffer_occupied_size (dx2_driver_t *this)
static void * | buffer_service (void *data)
static uint32_t | ao_dx2_get_capabilities (ao_driver_t *this_gen)
static int | ao_dx2_get_property (ao_driver_t *this_gen, int property)
static int | ao_dx2_set_property (ao_driver_t *this_gen, int property, int value)
static int | ao_dx2_open (ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int mode)
static int | ao_dx2_num_channels (ao_driver_t *this_gen)
static int | ao_dx2_bytes_per_frame (ao_driver_t *this_gen)
static int | ao_dx2_delay (ao_driver_t *this_gen)
static int | ao_dx2_write (ao_driver_t *this_gen, int16_t *audio_data, uint32_t num_samples)
static void | ao_dx2_close (ao_driver_t *this_gen)
static void | ao_dx2_exit (ao_driver_t *this_gen)
static int | ao_dx2_get_gap_tolerance (ao_driver_t *this_gen)
static int | ao_dx2_control (ao_driver_t *this_gen, int cmd,...)
static ao_driver_t * | open_plugin (audio_driver_class_t *class_gen, const void *data)
static void * | init_class (xine_t *xine, const void *data)

## Variables
static const GUID | xine_IID_IDirectSoundNotify
static const ao_info_t | ao_info_directx2
const plugin_info_t xine_plugin_info[] | EXPORTED

## Macro Definition Documentation

## ◆ AO_OUT_DIRECTX2_IFACE_VERSION

#define AO_OUT_DIRECTX2_IFACE_VERSION 9

## ◆ BUFFER_MIN_MS

#define BUFFER_MIN_MS 200

Referenced by ao_dx2_write(), and buffer_service().

## ◆ BUFFER_MS

#define BUFFER_MS 1000

Referenced by ao_dx2_write(), and audio_create_buffers().

## ◆ FACTOR

#define FACTOR 60.0

Referenced by audio_set_volume().

## ◆ GAP_TOLERANCE

#define GAP_TOLERANCE (AO_MAX_GAP/3)

Referenced by ao_dx2_get_gap_tolerance().

## ◆ IID_IDirectSoundNotify

#define IID_IDirectSoundNotify xine_IID_IDirectSoundNotify

## ◆ LOG_MODULE

#define LOG_MODULE "audio_directx2_out"

Referenced by ao_dx2_close(), ao_dx2_control(), ao_dx2_exit(), ao_dx2_open(), audio_error(), audio_fill(), buffer_service(), and open_plugin().

## ◆ LOG_VERBOSE

#define LOG_VERBOSE

## ◆ PRIdword

#define PRIdword "lu"

Referenced by ao_dx2_delay().

## ◆ PRIsizet

#define PRIsizet "u"

## ◆ STATUS_RUNNING

#define STATUS_RUNNING 2

Referenced by ao_dx2_delay(), and buffer_service().

## ◆ STATUS_START

#define STATUS_START 0

Referenced by ao_dx2_open(), and audio_error().

## ◆ STATUS_WAIT

#define STATUS_WAIT 1

Referenced by ao_dx2_control(), ao_dx2_write(), audio_flush(), and buffer_service().

## Function Documentation

## ◆ ao_dx2_bytes_per_frame()

static int ao_dx2_bytes_per_frame | ( | ao_driver_t * | this_gen | ) |
| static

References lprintf.

Referenced by open_plugin().

## ◆ ao_dx2_close()

static void ao_dx2_close | ( | ao_driver_t * | this_gen | ) |
| static

References _, audio_destroy_buffers(), audio_thread_exit(), buffer_service(), LOG_MODULE, lprintf, NULL, xine_log(), and XINE_LOG_MSG.

Referenced by open_plugin().

## ◆ ao_dx2_control()

static int ao_dx2_control | ( | ao_driver_t * | this_gen,
|  | int | cmd,
|  |  | ... )
| static

References _, AO_CTRL_FLUSH_BUFFERS, AO_CTRL_PLAY_PAUSE, AO_CTRL_PLAY_RESUME, audio_flush(), audio_play(), audio_stop(), LOG_MODULE, lprintf, STATUS_WAIT, xine_log(), and XINE_LOG_MSG.

Referenced by open_plugin().

## ◆ ao_dx2_delay()

static int ao_dx2_delay | ( | ao_driver_t * | this_gen | ) |
| static

References audio_tell(), buffer_occupied_size(), lprintf, PRIdword, and STATUS_RUNNING.

Referenced by open_plugin().

## ◆ ao_dx2_exit()

static void ao_dx2_exit | ( | ao_driver_t * | this_gen | ) |
| static

References _, dsound_destroy(), LOG_MODULE, lprintf, xine_log(), and XINE_LOG_MSG.

Referenced by open_plugin().

## ◆ ao_dx2_get_capabilities()

static uint32_t ao_dx2_get_capabilities | ( | ao_driver_t * | this_gen | ) |
| static

Referenced by open_plugin().

## ◆ ao_dx2_get_gap_tolerance()

static int ao_dx2_get_gap_tolerance | ( | ao_driver_t * | this_gen | ) |
| static

References GAP_TOLERANCE.

Referenced by open_plugin().

## ◆ ao_dx2_get_property()

static int ao_dx2_get_property | ( | ao_driver_t * | this_gen,
|  | int | property )
| static

References AO_PROP_MIXER_VOL, AO_PROP_MUTE_VOL, and AO_PROP_PCM_VOL.

Referenced by open_plugin().

## ◆ ao_dx2_num_channels()

static int ao_dx2_num_channels | ( | ao_driver_t * | this_gen | ) |
| static

References lprintf.

Referenced by open_plugin().

## ◆ ao_dx2_open()

static int ao_dx2_open | ( | ao_driver_t * | this_gen,
|  | uint32_t | bits,
|  | uint32_t | rate,
|  | int | mode )
| static

References _, audio_create_buffers(), audio_destroy_buffers(), audio_set_volume(), bits, buffer_service(), LOG_MODULE, lprintf, mode(), mode2channels(), NULL, STATUS_START, xine_log(), and XINE_LOG_MSG.

Referenced by open_plugin().

## ◆ ao_dx2_set_property()

static int ao_dx2_set_property | ( | ao_driver_t * | this_gen,
|  | int | property,
|  | int | value )
| static

References AO_PROP_MIXER_VOL, AO_PROP_MUTE_VOL, AO_PROP_PCM_VOL, audio_set_volume(), and lprintf.

Referenced by open_plugin().

## ◆ ao_dx2_write()

static int ao_dx2_write | ( | ao_driver_t * | this_gen,
|  | int16_t * | audio_data,
|  | uint32_t | num_samples )
| static

References audio_fill(), audio_thread_exit(), buffer_free_size(), BUFFER_MIN_MS, BUFFER_MS, buffer_occupied_size(), lprintf, STATUS_WAIT, and xine_usec_sleep().

Referenced by open_plugin().

## ◆ audio_create_buffers()

static int audio_create_buffers | ( | dx2_driver_t * | this | ) |
| static

References _, audio_error(), bits, BUFFER_MS, dsound_fill_desc(), dsound_fill_wfx(), lprintf, and NULL.

Referenced by ao_dx2_open().

## ◆ audio_destroy_buffers()

static void audio_destroy_buffers | ( | dx2_driver_t * | this | ) |
| static

Referenced by ao_dx2_close(), and ao_dx2_open().

## ◆ audio_error()

static void audio_error | ( | dx2_driver_t * | this,
|  | HRESULT | err,
|  | char * | msg )
| static

References audio_thread_exit(), dsound_strerror(), LOG_MODULE, STATUS_START, xine_log(), and XINE_LOG_MSG.

Referenced by audio_create_buffers(), audio_fill(), audio_play(), audio_seek(), audio_set_volume(), audio_stop(), and audio_tell().

## ◆ audio_fill()

static int audio_fill | ( | dx2_driver_t * | this,
|  | char * | data,
|  | size_t | size )
| static

References _, _x_assert, audio_error(), LOG_MODULE, lprintf, NULL, xine_fast_memcpy, xine_log(), and XINE_LOG_MSG.

Referenced by ao_dx2_write().

## ◆ audio_flush()

static int audio_flush | ( | dx2_driver_t * | this | ) |
| static

References audio_seek(), and STATUS_WAIT.

Referenced by ao_dx2_control(), and buffer_service().

## ◆ audio_play()

static int audio_play | ( | dx2_driver_t * | this | ) |
| static

References _, and audio_error().

Referenced by ao_dx2_control(), and buffer_service().

## ◆ audio_seek()

static int audio_seek | ( | dx2_driver_t * | this,
|  | size_t | pos )
| static

References _, and audio_error().

Referenced by audio_flush(), and buffer_service().

## ◆ audio_set_volume()

static int audio_set_volume | ( | dx2_driver_t * | this,
|  | int | volume )
| static

References _, audio_error(), FACTOR, and lprintf.

Referenced by ao_dx2_open(), and ao_dx2_set_property().

## ◆ audio_stop()

static int audio_stop | ( | dx2_driver_t * | this | ) |
| static

References _, and audio_error().

Referenced by ao_dx2_control(), and buffer_service().

## ◆ audio_tell()

static int audio_tell | ( | dx2_driver_t * | this,
|  | size_t * | pos )
| static

References _, audio_error(), and NULL.

Referenced by ao_dx2_delay(), buffer_free_size(), and buffer_occupied_size().

## ◆ audio_thread_exit()

static void audio_thread_exit | ( | dx2_driver_t * | this | ) |
| static

Referenced by ao_dx2_close(), ao_dx2_write(), and audio_error().

## ◆ buffer_free_size()

static size_t buffer_free_size | ( | dx2_driver_t * | this | ) |
| static

References audio_tell().

Referenced by ao_dx2_write(), and buffer_service().

## ◆ buffer_occupied_size()

static size_t buffer_occupied_size | ( | dx2_driver_t * | this | ) |
| static

References audio_tell().

Referenced by ao_dx2_delay(), ao_dx2_write(), and buffer_service().

## ◆ buffer_service()

static void * buffer_service | ( | void * | data | ) |
| static

References _, audio_flush(), audio_play(), audio_seek(), audio_stop(), buffer_free_size(), BUFFER_MIN_MS, buffer_occupied_size(), LOG_MODULE, lprintf, NULL, STATUS_RUNNING, STATUS_WAIT, xine_log(), XINE_LOG_MSG, and xine_usec_sleep().

Referenced by ao_dx2_close(), and ao_dx2_open().

## ◆ dsound_create()

static LPDIRECTSOUND dsound_create | ( |  | ) |
| static

References _, and NULL.

Referenced by open_plugin().

## ◆ dsound_destroy()

static void dsound_destroy | ( | LPDIRECTSOUND | ds | ) |
| static

Referenced by ao_dx2_exit().

## ◆ dsound_fill_desc()

static void dsound_fill_desc | ( | DSBUFFERDESC * | desc,
|  | DWORD | flags,
|  | DWORD | buffer_size,
|  | WAVEFORMATEX * | wfx )
| static

Referenced by audio_create_buffers(), and test_capabilities().

## ◆ dsound_fill_wfx()

static void dsound_fill_wfx | ( | WAVEFORMATEX * | wfx,
|  | uint32_t | bits,
|  | uint32_t | rate,
|  | int | channels,
|  | size_t | frame_size )
| static

References bits.

Referenced by audio_create_buffers(), and test_capability().

## ◆ dsound_strerror()

static char * dsound_strerror | ( | HRESULT | err | ) |
| static

References _.

Referenced by audio_error().

## ◆ init_class()

static void * init_class | ( | xine_t * | xine,
|  | const void * | data )
| static

References default_audio_driver_class_dispose, lprintf, N_, NULL, and open_plugin().

## ◆ mode2channels()

static int mode2channels | ( | uint32_t | mode | ) |
| static

References AO_CAP_MODE_4CHANNEL, AO_CAP_MODE_5_1CHANNEL, AO_CAP_MODE_5CHANNEL, AO_CAP_MODE_MONO, AO_CAP_MODE_STEREO, and mode().

Referenced by ao_dx2_open(), and test_capability().

## ◆ open_plugin()

static ao_driver_t * open_plugin | ( | audio_driver_class_t * | class_gen,
|  | const void * | data )
| static

References _, ao_dx2_bytes_per_frame(), ao_dx2_close(), ao_dx2_control(), ao_dx2_delay(), ao_dx2_exit(), ao_dx2_get_capabilities(), ao_dx2_get_gap_tolerance(), ao_dx2_get_property(), ao_dx2_num_channels(), ao_dx2_open(), ao_dx2_set_property(), ao_dx2_write(), dsound_create(), LOG_MODULE, lprintf, NULL, test_capabilities(), xine_log(), and XINE_LOG_MSG.

Referenced by init_class().

## ◆ test_capabilities()

static int test_capabilities | ( | dx2_driver_t * | this | ) |
| static

References _, AO_CAP_16BITS, AO_CAP_24BITS, AO_CAP_8BITS, AO_CAP_FLOAT32, AO_CAP_MODE_4CHANNEL, AO_CAP_MODE_5_1CHANNEL, AO_CAP_MODE_5CHANNEL, AO_CAP_MODE_MONO, AO_CAP_MODE_STEREO, bits, dsound_fill_desc(), lprintf, mode(), NULL, and test_capability().

Referenced by open_plugin().

## ◆ test_capability()

static int test_capability | ( | LPDIRECTSOUNDBUFFER | buffer,
|  | uint32_t | bits,
|  | uint32_t | rate,
|  | int | mode )
| static

References bits, dsound_fill_wfx(), lprintf, mode(), and mode2channels().

Referenced by test_capabilities().

## ◆ XINE_FORMAT_PRINTF()

static void XINE_FORMAT_PRINTF | ( | 1 | ,
|  | 2 | )
| static

References _.

## Variable Documentation

## ◆ ao_info_directx2

const ao_info_t ao_info_directx2
| static

Initial value:
= {
.priority = 10,
}

## ◆ EXPORTED

const plugin_info_t xine_plugin_info [] EXPORTED

Initial value:
= {
{ PLUGIN_AUDIO_OUT, 9 , "directx2", XINE_VERSION_CODE, &ao_info_directx2, init_class },
{ PLUGIN_NONE, 0, NULL, 0, NULL, NULL }
}
init_class
static void * init_class(xine_t *xine, const void *data)
Definition audio_directx2_out.c:945
ao_info_directx2
static const ao_info_t ao_info_directx2
Definition audio_directx2_out.c:965
XINE_VERSION_CODE
#define XINE_VERSION_CODE
Definition xine_internal.h:57
NULL
NULL
Definition xine_plugin.c:78
PLUGIN_NONE
#define PLUGIN_NONE
Definition xine_plugin.h:29
PLUGIN_AUDIO_OUT
#define PLUGIN_AUDIO_OUT
Definition xine_plugin.h:35

## ◆ xine_IID_IDirectSoundNotify

const GUID xine_IID_IDirectSoundNotify
| static

Initial value:
= {
0xB0210783, 0x89CD, 0x11D0, {0xAF, 0x08, 0x00, 0xA0, 0xC9, 0x25, 0xCD, 0x16}
}