xine-lib: xine-lib-1.2.12/src/audio_out/audio_alsa_out.c File Reference

xine-lib 1.2.12

Data Structures | Macros | Typedefs | Functions | Variables
audio_alsa_out.c File Reference
`#include <stdio.h>`
`#include <stdarg.h>`
`#include <errno.h>`
`#include <string.h>`
`#include <unistd.h>`
`#include <stdlib.h>`
`#include <fcntl.h>`
`#include <math.h>`
`#include <alsa/asoundlib.h>`
`#include <sys/ioctl.h>`
`#include <inttypes.h>`
`#include <pthread.h>`
`#include <xine/xine_internal.h>`
`#include <xine/xineutils.h>`
`#include <xine/compat.h>`
`#include <xine/audio_out.h>`
`#include "speakers.h"`

## Data Structures
struct | alsa_class_t
struct | alsa_driver_s
struct | alsa_driver_s::_alsa_dev_info_s

## Macros
#define | ALSA_PCM_NEW_HW_PARAMS_API
#define | ALSA_PCM_NEW_SW_PARAMS_API
#define | AO_OUT_ALSA_IFACE_VERSION 9
#define | BUFFER_TIME 1000*1000
#define | GAP_TOLERANCE 5000
#define | MIXER_MASK_LEFT 0x0001
#define | MIXER_MASK_RIGHT 0x0002
#define | MIXER_MASK_MUTE 0x0004
#define | MIXER_MASK_STEREO 0x0008
#define | MIXER_HAS_MUTE_SWITCH 0x0010

## Typedefs
typedef struct alsa_driver_s | alsa_driver_t

## Functions
static int | ao_alsa_get_percent_from_volume (long val, long min, long max)
static int | my_snd_mixer_wait (snd_mixer_t *mixer, int timeout)
static void * | ao_alsa_handle_event_thread (void *data)
static long | ao_alsa_get_volume_from_percent (int val, long min, long max)
static void | error_callback (const char *file, int line, const char *function, int err, const char *fmt,...)
static int | ao_alsa_open (ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int mode)
static int | ao_alsa_num_channels (ao_driver_t *this_gen)
static int | ao_alsa_bytes_per_frame (ao_driver_t *this_gen)
static int | ao_alsa_get_gap_tolerance (ao_driver_t *this_gen)
static int | ao_alsa_delay (ao_driver_t *this_gen)
static int | resume (snd_pcm_t *pcm)
static int | ao_alsa_write (ao_driver_t *this_gen, int16_t *data, uint32_t count)
static void | ao_alsa_close (ao_driver_t *this_gen)
static uint32_t | ao_alsa_get_capabilities (ao_driver_t *this_gen)
static void | ao_alsa_exit (ao_driver_t *this_gen)
static int | ao_alsa_get_property (ao_driver_t *this_gen, int property)
static int | ao_alsa_set_property (ao_driver_t *this_gen, int property, int value)
static int | ao_alsa_ctrl (ao_driver_t *this_gen, int cmd,...)
static void | ao_alsa_mixer_init (ao_driver_t *this_gen)
static void | alsa_apply_speaker_arrangement (alsa_driver_t *this, int speakers)
static void | _alsa_mmap_cb (void *user_data, xine_cfg_entry_t *entry)
static void | _alsa_speaker_arrangement_cb (void *user_data, xine_cfg_entry_t *entry)
static char * | _alsa_safe_strdup (const char *s)
static void | _alsa_dev_name_cb (void *user_data, xine_cfg_entry_t *entry)
static int | _alsa_query_dev (alsa_driver_t *this, uint32_t index)
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 snd_output_t * | jcd_out
static ao_info_t | ao_info_alsa
const plugin_info_t xine_plugin_info[] | EXPORTED

## Macro Definition Documentation

## ◆ ALSA_PCM_NEW_HW_PARAMS_API

#define ALSA_PCM_NEW_HW_PARAMS_API

## ◆ ALSA_PCM_NEW_SW_PARAMS_API

#define ALSA_PCM_NEW_SW_PARAMS_API

## ◆ AO_OUT_ALSA_IFACE_VERSION

#define AO_OUT_ALSA_IFACE_VERSION 9

## ◆ BUFFER_TIME

#define BUFFER_TIME 1000*1000

## ◆ GAP_TOLERANCE

#define GAP_TOLERANCE 5000

## ◆ MIXER_HAS_MUTE_SWITCH

#define MIXER_HAS_MUTE_SWITCH 0x0010

## ◆ MIXER_MASK_LEFT

#define MIXER_MASK_LEFT 0x0001

## ◆ MIXER_MASK_MUTE

#define MIXER_MASK_MUTE 0x0004

## ◆ MIXER_MASK_RIGHT

#define MIXER_MASK_RIGHT 0x0002

## ◆ MIXER_MASK_STEREO

#define MIXER_MASK_STEREO 0x0008

## Typedef Documentation

## ◆ alsa_driver_t

typedef struct alsa_driver_s alsa_driver_t

## Function Documentation

## ◆ _alsa_dev_name_cb()

static void _alsa_dev_name_cb | ( | void * | user_data,
|  | xine_cfg_entry_t * | entry
| ) |  |
| static

References _alsa_safe_strdup(), xine_cfg_entry_s::str_value, and user_data().

Referenced by open_plugin().

## ◆ _alsa_mmap_cb()

static void _alsa_mmap_cb | ( | void * | user_data,
|  | xine_cfg_entry_t * | entry
| ) |  |
| static

References xine_cfg_entry_s::num_value, and user_data().

Referenced by open_plugin().

## ◆ _alsa_query_dev()

static int _alsa_query_dev | ( | alsa_driver_t * | this,
|  | uint32_t | index
| ) |  |
| static

References _, AO_CAP_16BITS, AO_CAP_24BITS, AO_CAP_8BITS, AO_CAP_FLOAT32, AO_CAP_MODE_A52, AO_CAP_MODE_AC5, name, NULL, type, xine_log(), XINE_LOG_MSG, XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by open_plugin().

## ◆ _alsa_safe_strdup()

static char * _alsa_safe_strdup | ( | const char * | s | ) |
| static

References NULL.

Referenced by _alsa_dev_name_cb(), and open_plugin().

## ◆ _alsa_speaker_arrangement_cb()

static void _alsa_speaker_arrangement_cb | ( | void * | user_data,
|  | xine_cfg_entry_t * | entry
| ) |  |
| static

References alsa_apply_speaker_arrangement(), xine_cfg_entry_s::num_value, and user_data().

Referenced by open_plugin().

## ◆ alsa_apply_speaker_arrangement()

static void alsa_apply_speaker_arrangement | ( | alsa_driver_t * | this,
|  | int | speakers
| ) |  |
| static

References _, A52_PASSTHRU, AO_CAP_16BITS, AO_CAP_24BITS, AO_CAP_8BITS, AO_CAP_FLOAT32, AO_CAP_MODE_4_1CHANNEL, AO_CAP_MODE_4CHANNEL, AO_CAP_MODE_5_1CHANNEL, AO_CAP_MODE_5CHANNEL, AO_CAP_MODE_A52, AO_CAP_MODE_AC5, AO_CAP_MODE_MONO, AO_CAP_MODE_STEREO, SURROUND4, SURROUND41, SURROUND5, SURROUND51, type, XINE_VERBOSITY_LOG, and xprintf.

Referenced by _alsa_speaker_arrangement_cb(), and open_plugin().

## ◆ ao_alsa_bytes_per_frame()

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

Referenced by open_plugin().

## ◆ ao_alsa_close()

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

References NULL.

Referenced by open_plugin().

## ◆ ao_alsa_ctrl()

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

References ao_alsa_ctrl(), AO_CTRL_FLUSH_BUFFERS, AO_CTRL_PLAY_PAUSE, AO_CTRL_PLAY_RESUME, NULL, XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by ao_alsa_ctrl(), and open_plugin().

## ◆ ao_alsa_delay()

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

References now().

Referenced by open_plugin().

## ◆ ao_alsa_exit()

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

References _x_freep(), name, NULL, and xine_config_free_string().

Referenced by open_plugin().

## ◆ ao_alsa_get_capabilities()

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

Referenced by open_plugin().

## ◆ ao_alsa_get_gap_tolerance()

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

References GAP_TOLERANCE.

Referenced by open_plugin().

## ◆ ao_alsa_get_percent_from_volume()

static int ao_alsa_get_percent_from_volume | ( | long | val,
|  | long | min,
|  | long | max
| ) |  |
| static

Referenced by ao_alsa_get_property(), and ao_alsa_handle_event_thread().

## ◆ ao_alsa_get_property()

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

References ao_alsa_get_percent_from_volume(), AO_PROP_MIXER_VOL, AO_PROP_MUTE_VOL, AO_PROP_PCM_VOL, MIXER_HAS_MUTE_SWITCH, MIXER_MASK_MUTE, XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by open_plugin().

## ◆ ao_alsa_get_volume_from_percent()

static long ao_alsa_get_volume_from_percent | ( | int | val,
|  | long | min,
|  | long | max
| ) |  |
| static

Referenced by ao_alsa_set_property().

## ◆ ao_alsa_handle_event_thread()

static void * ao_alsa_handle_event_thread | ( | void * | data | ) |
| static

References ao_alsa_get_percent_from_volume(), xine_audio_level_data_t::left, MIXER_HAS_MUTE_SWITCH, MIXER_MASK_LEFT, MIXER_MASK_MUTE, MIXER_MASK_RIGHT, MIXER_MASK_STEREO, xine_audio_level_data_t::mute, my_snd_mixer_wait(), NULL, xine_audio_level_data_t::right, XINE_EVENT_AUDIO_LEVEL, xine_event_send(), xine_list_next_value(), XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by ao_alsa_mixer_init().

## ◆ ao_alsa_mixer_init()

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

References _, ao_alsa_handle_event_thread(), AO_CAP_MIXER_VOL, AO_CAP_MUTE_VOL, AO_CAP_PCM_VOL, xine_s::config, config_values_s::free_string, LOG_MODULE, config_values_s::lookup_string, MIXER_HAS_MUTE_SWITCH, MIXER_MASK_LEFT, MIXER_MASK_MUTE, MIXER_MASK_RIGHT, MIXER_MASK_STEREO, NULL, config_values_s::register_bool, SCHED_OTHER, config_values_s::update_string, config_values_s::xine, XINE_VERBOSITY_DEBUG, XINE_VERBOSITY_LOG, and xprintf.

Referenced by open_plugin().

## ◆ ao_alsa_num_channels()

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

Referenced by open_plugin().

## ◆ ao_alsa_open()

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

References _, AO_CAP_MODE_4_1CHANNEL, AO_CAP_MODE_4CHANNEL, AO_CAP_MODE_5_1CHANNEL, AO_CAP_MODE_5CHANNEL, AO_CAP_MODE_A52, AO_CAP_MODE_AC5, AO_CAP_MODE_MONO, AO_CAP_MODE_STEREO, AO_CAP_NO_UNPAUSE, bits, BUFFER_TIME, jcd_out, mode(), NULL, xine_log(), XINE_LOG_MSG, XINE_VERBOSITY_DEBUG, XINE_VERBOSITY_LOG, and xprintf.

Referenced by open_plugin().

## ◆ ao_alsa_set_property()

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

References ao_alsa_get_volume_from_percent(), AO_PROP_MIXER_VOL, AO_PROP_MUTE_VOL, AO_PROP_PCM_VOL, MIXER_HAS_MUTE_SWITCH, MIXER_MASK_LEFT, MIXER_MASK_MUTE, MIXER_MASK_RIGHT, MIXER_MASK_STEREO, XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by open_plugin().

## ◆ ao_alsa_write()

static int ao_alsa_write | ( | ao_driver_t * | this_gen,
|  | int16_t * | data,
|  | uint32_t | count
| ) |  |
| static

References jcd_out, now(), resume(), XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by open_plugin().

## ◆ error_callback()

static void error_callback | ( | const char * | file,
|  | int | line,
|  | const char * | function,
|  | int | err,
|  | const char * | fmt,
|  |  | ...
| ) |  |
| static

References function, and NULL.

Referenced by open_plugin().

## ◆ init_class()

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

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

## ◆ my_snd_mixer_wait()

static int my_snd_mixer_wait | ( | snd_mixer_t * | mixer,
|  | int | timeout
| ) |  |
| static

References NULL.

Referenced by ao_alsa_handle_event_thread().

## ◆ open_plugin()

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

References _, _alsa_dev_name_cb(), _alsa_mmap_cb(), _alsa_query_dev(), _alsa_safe_strdup(), _alsa_speaker_arrangement_cb(), _x_freep(), A52_PASSTHRU, alsa_apply_speaker_arrangement(), ao_alsa_bytes_per_frame(), ao_alsa_close(), ao_alsa_ctrl(), ao_alsa_delay(), ao_alsa_exit(), ao_alsa_get_capabilities(), ao_alsa_get_gap_tolerance(), ao_alsa_get_property(), ao_alsa_mixer_init(), ao_alsa_num_channels(), ao_alsa_open(), ao_alsa_set_property(), ao_alsa_write(), AUDIO_DEVICE_SPEAKER_ARRANGEMENT_HELP, AUDIO_DEVICE_SPEAKER_ARRANGEMENT_TYPES, xine_s::config, error_callback(), name, NULL, STEREO, SURROUND4, SURROUND41, SURROUND5, SURROUND51, SURROUND6, SURROUND61, SURROUND71, config_values_s::xine, xine_log(), and XINE_LOG_MSG.

Referenced by init_class().

## ◆ resume()

static int resume | ( | snd_pcm_t * | pcm | ) |
| static

Referenced by ao_alsa_write().

## Variable Documentation

## ◆ ao_info_alsa

ao_info_t ao_info_alsa
| static

Initial value:
= {
.priority = 10,
}

## ◆ EXPORTED

const plugin_info_t xine_plugin_info [] EXPORTED

Initial value:
= {
{ PLUGIN_AUDIO_OUT, 9 , "alsa", XINE_VERSION_CODE, &ao_info_alsa, init_class },
{ PLUGIN_NONE, 0, NULL, 0, NULL, NULL }
}
init_class
static void * init_class(xine_t *xine, const void *data)
Definition: audio_alsa_out.c:1913
ao_info_alsa
static ao_info_t ao_info_alsa
Definition: audio_alsa_out.c:1931
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

## ◆ jcd_out

snd_output_t* jcd_out
| static

Referenced by ao_alsa_open(), and ao_alsa_write().