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

xine-lib 1.2.12

Data Structures | Macros | Typedefs | Functions | Variables
audio_jack_out.c File Reference
`#include <stdio.h>`
`#include <errno.h>`
`#include <string.h>`
`#include <stdlib.h>`
`#include <fcntl.h>`
`#include <math.h>`
`#include <unistd.h>`
`#include <inttypes.h>`
`#include <xine/xine_internal.h>`
`#include <xine/xineutils.h>`
`#include <xine/audio_out.h>`
`#include <jack/jack.h>`
`#include "speakers.h"`

## Data Structures
struct | jack_driver_s
struct | jack_class_t

## Macros
#define | AO_OUT_JACK_IFACE_VERSION 9
#define | GAP_TOLERANCE AO_MAX_GAP
#define | MAX_CHANS 6
#define | CHUNK_SIZE (16 * 1024)
#define | NUM_CHUNKS 8
#define | BUFFSIZE ((NUM_CHUNKS + 1) * CHUNK_SIZE)

## Typedefs
typedef struct jack_driver_s | jack_driver_t

## Functions
static int | buf_free (jack_driver_t *this)
| get the number of free bytes in the buffer More...
static int | buf_used (jack_driver_t *this)
| get amount of data available in the buffer More...
static int | write_buffer_32 (jack_driver_t *this, unsigned char *data, int len)
| insert len bytes into buffer More...
static int | write_buffer_16 (jack_driver_t *this, unsigned char *data, int len)
static jack_nframes_t | read_buffer (jack_driver_t *this, float **bufs, jack_nframes_t cnt, unsigned num_bufs, float gain)
| read data from buffer and splitting it into channels More...
static void | silence (float **bufs, int cnt, int num_bufs)
| fill the buffers with silence More...
static void | jack_reset (jack_driver_t *this)
| stop playing and empty buffers (for seeking/pause) More...
static int | jack_callback (jack_nframes_t nframes, void *arg)
static int | jack_open_device (jack_driver_t *this, const char *jack_device, uint32_t *poutput_sample_rate, int num_channels)
static void | ao_jack_close (ao_driver_t *this_gen)
static int | ao_jack_open_int (jack_driver_t *this, const char *jack_device, uint32_t bits, uint32_t rate, int mode)
static int | ao_jack_open (ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int mode)
static int | ao_jack_num_channels (ao_driver_t *this_gen)
static int | ao_jack_bytes_per_frame (ao_driver_t *this_gen)
static int | ao_jack_get_gap_tolerance (ao_driver_t *this_gen)
static int | ao_jack_delay (ao_driver_t *this_gen)
static int | ao_jack_write (ao_driver_t *this_gen, int16_t *frame_buffer, uint32_t num_frames)
static uint32_t | ao_jack_get_capabilities (ao_driver_t *this_gen)
static void | ao_jack_exit (ao_driver_t *this_gen)
static int | ao_jack_get_property (ao_driver_t *this_gen, int property)
static int | ao_jack_set_property (ao_driver_t *this_gen, int property, int value)
static int | ao_jack_ctrl (ao_driver_t *this_gen, int cmd,...)
static void | jack_speaker_arrangement_cb (void *user_data, xine_cfg_entry_t *entry)
static ao_driver_t * | open_jack_plugin (audio_driver_class_t *class_gen, const void *data)
static void * | init_class (xine_t *xine, const void *data)

## Variables
static ao_info_t | ao_info_jack
const plugin_info_t xine_plugin_info[] | EXPORTED

## Macro Definition Documentation

## ◆ AO_OUT_JACK_IFACE_VERSION

#define AO_OUT_JACK_IFACE_VERSION 9

## ◆ BUFFSIZE

#define BUFFSIZE ((NUM_CHUNKS + 1) * CHUNK_SIZE)

## ◆ CHUNK_SIZE

#define CHUNK_SIZE (16 * 1024)

size of one chunk, if this is too small Xine will start to "stutter"

after a short time of playback

## ◆ GAP_TOLERANCE

#define GAP_TOLERANCE AO_MAX_GAP

## ◆ MAX_CHANS

#define MAX_CHANS 6

## ◆ NUM_CHUNKS

#define NUM_CHUNKS 8

number of "virtual" chunks the buffer consists of

## Typedef Documentation

## ◆ jack_driver_t

typedef struct jack_driver_s jack_driver_t

## Function Documentation

## ◆ ao_jack_bytes_per_frame()

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

Referenced by open_jack_plugin().

## ◆ ao_jack_close()

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

close the device and reset the play position

References jack_reset(), NULL, XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by ao_jack_exit(), ao_jack_open_int(), and open_jack_plugin().

## ◆ ao_jack_ctrl()

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

References AO_CTRL_FLUSH_BUFFERS, AO_CTRL_PLAY_PAUSE, AO_CTRL_PLAY_RESUME, and jack_reset().

Referenced by open_jack_plugin().

## ◆ ao_jack_delay()

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

References buf_used().

Referenced by open_jack_plugin().

## ◆ ao_jack_exit()

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

References ao_jack_close(), and NULL.

Referenced by open_jack_plugin().

## ◆ ao_jack_get_capabilities()

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

Referenced by open_jack_plugin().

## ◆ ao_jack_get_gap_tolerance()

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

References GAP_TOLERANCE.

Referenced by open_jack_plugin().

## ◆ ao_jack_get_property()

static int ao_jack_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_jack_plugin().

## ◆ ao_jack_num_channels()

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

Referenced by open_jack_plugin().

## ◆ ao_jack_open()

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

References ao_jack_open_int(), bits, mode(), xine_config_free_string(), xine_config_lookup_string(), XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by open_jack_plugin().

## ◆ ao_jack_open_int()

static int ao_jack_open_int | ( | jack_driver_t * | this,
|  | const char * | jack_device,
|  | 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_jack_close(), bits, jack_open_device(), mode(), XINE_VERBOSITY_DEBUG, XINE_VERBOSITY_LOG, and xprintf.

Referenced by ao_jack_open().

## ◆ ao_jack_set_property()

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

References AO_PROP_MIXER_VOL, AO_PROP_MUTE_VOL, and AO_PROP_PCM_VOL.

Referenced by open_jack_plugin().

## ◆ ao_jack_write()

static int ao_jack_write | ( | ao_driver_t * | this_gen,
|  | int16_t * | frame_buffer,
|  | uint32_t | num_frames
| ) |  |
| static

References write_buffer_16(), write_buffer_32(), xine_usec_sleep(), XINE_VERBOSITY_DEBUG, and xprintf.

Referenced by open_jack_plugin().

## ◆ buf_free()

static int buf_free | ( | jack_driver_t * | this | ) |
| static

get the number of free bytes in the buffer

Returns
  number of free bytes in buffer

may only be called by Xine's thread return value may change between immediately following two calls, and the real number of free bytes might be larger!

References BUFFSIZE, and CHUNK_SIZE.

Referenced by _meta_info_set_encoding(), write_buffer_16(), and write_buffer_32().

## ◆ buf_used()

static int buf_used | ( | jack_driver_t * | this | ) |
| static

get amount of data available in the buffer

Returns
  number of bytes available in buffer

may only be called by the playback thread return value may change between immediately following two calls, and the real number of buffered bytes might be larger!

References BUFFSIZE.

Referenced by ao_jack_delay(), demux_asf_parse_asx_references(), demux_asf_read_file(), demux_real_parse_references(), and read_buffer().

## ◆ init_class()

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

References default_audio_driver_class_dispose, audio_driver_class_s::description, audio_driver_class_s::dispose, jack_class_t::driver_class, audio_driver_class_s::identifier, N_, NULL, open_jack_plugin(), audio_driver_class_s::open_plugin, and jack_class_t::xine.

## ◆ jack_callback()

static int jack_callback | ( | jack_nframes_t | nframes,
|  | void * | arg
| ) |  |
| static

References MAX_CHANS, read_buffer(), silence(), XINE_VERBOSITY_LOG, and xprintf.

Referenced by jack_open_device().

## ◆ jack_open_device()

static int jack_open_device | ( | jack_driver_t * | this,
|  | const char * | jack_device,
|  | uint32_t * | poutput_sample_rate,
|  | int | num_channels
| ) |  |
| static

References jack_callback(), jack_reset(), MAX_CHANS, NULL, XINE_VERBOSITY_LOG, and xprintf.

Referenced by ao_jack_open_int().

## ◆ jack_reset()

static void jack_reset | ( | jack_driver_t * | this | ) |
| static

stop playing and empty buffers (for seeking/pause)

Referenced by ao_jack_close(), ao_jack_ctrl(), jack_open_device(), and open_jack_plugin().

## ◆ jack_speaker_arrangement_cb()

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

References AO_CAP_MODE_4_1CHANNEL, AO_CAP_MODE_4CHANNEL, AO_CAP_MODE_5_1CHANNEL, AO_CAP_MODE_5CHANNEL, xine_cfg_entry_s::num_value, SURROUND4, SURROUND41, SURROUND5, SURROUND51, and user_data().

Referenced by open_jack_plugin().

## ◆ open_jack_plugin()

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

References _, AO_CAP_FLOAT32, AO_CAP_MIXER_VOL, AO_CAP_MODE_4CHANNEL, AO_CAP_MODE_5_1CHANNEL, AO_CAP_MODE_5CHANNEL, AO_CAP_MODE_STEREO, AO_CAP_MUTE_VOL, ao_jack_bytes_per_frame(), ao_jack_close(), ao_jack_ctrl(), ao_jack_delay(), ao_jack_exit(), ao_jack_get_capabilities(), ao_jack_get_gap_tolerance(), ao_jack_get_property(), ao_jack_num_channels(), ao_jack_open(), ao_jack_set_property(), ao_jack_write(), AUDIO_DEVICE_SPEAKER_ARRANGEMENT_HELP, AUDIO_DEVICE_SPEAKER_ARRANGEMENT_TYPES, BUFFSIZE, xine_s::config, jack_reset(), jack_speaker_arrangement_cb(), NULL, STEREO, SURROUND4, SURROUND5, SURROUND51, config_values_s::xine, jack_class_t::xine, XINE_VERBOSITY_DEBUG, XINE_VERBOSITY_LOG, and xprintf.

Referenced by init_class().

## ◆ read_buffer()

static jack_nframes_t read_buffer | ( | jack_driver_t * | this,
|  | float ** | bufs,
|  | jack_nframes_t | cnt,
|  | unsigned | num_bufs,
|  | float | gain
| ) |  |
| static

read data from buffer and splitting it into channels

Parameters

  bufs | num_bufs float buffers, each will contain the data of one channel
  cnt | number of samples to read per channel
  num_bufs | number of channels to split the data into

Returns
  number of samples read per channel, equals cnt unless there was too little data in the buffer

Assumes the data in the buffer is of type float, the number of bytes read is res * num_bufs * sizeof(float), where res is the return value. If there is not enough data in the buffer remaining parts will be filled with silence.

References buf_used(), and BUFFSIZE.

Referenced by jack_callback().

## ◆ silence()

static void silence | ( | float ** | bufs,
|  | int | cnt,
|  | int | num_bufs
| ) |  |
| static

fill the buffers with silence

Parameters

  bufs | num_bufs float buffers, each will contain the data of one channel
  cnt | number of samples in each buffer
  num_bufs | number of buffers

Referenced by jack_callback(), and realtime_samplecounter_available().

## ◆ write_buffer_16()

static int write_buffer_16 | ( | jack_driver_t * | this,
|  | unsigned char * | data,
|  | int | len
| ) |  |
| static

References buf_free(), and BUFFSIZE.

Referenced by ao_jack_write().

## ◆ write_buffer_32()

static int write_buffer_32 | ( | jack_driver_t * | this,
|  | unsigned char * | data,
|  | int | len
| ) |  |
| static

insert len bytes into buffer

Parameters

  data | data to insert
  len | length of data

Returns
  number of bytes inserted into buffer

If there is not enough room, the buffer is filled up

TODO: Xine should really pass data as float, perhaps in V1.2?

References buf_free(), and BUFFSIZE.

Referenced by ao_jack_write().

## Variable Documentation

## ◆ ao_info_jack

ao_info_t ao_info_jack
| static

Initial value:
= {
.priority = 6,
}

## ◆ EXPORTED

const plugin_info_t xine_plugin_info [] EXPORTED

Initial value:
= {
{ PLUGIN_AUDIO_OUT, 9 , "jack", XINE_VERSION_CODE , &ao_info_jack, init_class },
{ PLUGIN_NONE, 0, NULL, 0, NULL, NULL }
}
init_class
static void * init_class(xine_t *xine, const void *data)
Definition: audio_jack_out.c:892
ao_info_jack
static ao_info_t ao_info_jack
Definition: audio_jack_out.c:914
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