xine-lib 1.2.13-20230125hg15249
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
 
static int buf_used (jack_driver_t *this)
 get amount of data available in the buffer
 
static int write_buffer_32 (jack_driver_t *this, unsigned char *data, int len)
 insert len bytes into buffer
 
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
 
static void silence (float **bufs, int cnt, int num_bufs)
 fill the buffers with silence
 
static void jack_reset (jack_driver_t *this)
 stop playing and empty buffers (for seeking/pause)
 
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_topen_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

Referenced by buf_free().

◆ GAP_TOLERANCE

#define GAP_TOLERANCE   AO_MAX_GAP

◆ MAX_CHANS

#define MAX_CHANS   6

Referenced by jack_callback(), and jack_open_device().

◆ 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

◆ 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

◆ 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

◆ 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

◆ ao_jack_set_property()

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

◆ ao_jack_write()

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

◆ 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

◆ jack_callback()

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

◆ 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

◆ 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

◆ open_jack_plugin()

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

◆ 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
bufsnum_bufs float buffers, each will contain the data of one channel
cntnumber of samples to read per channel
num_bufsnumber 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
bufsnum_bufs float buffers, each will contain the data of one channel
cntnumber of samples in each buffer
num_bufsnumber 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
datadata to insert
lenlength 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_NONE, 0, NULL, 0, NULL, NULL }
}
static void * init_class(xine_t *xine, const void *data)
Definition audio_jack_out.c:892
static ao_info_t ao_info_jack
Definition audio_jack_out.c:914
#define XINE_VERSION_CODE
Definition xine_internal.h:57
NULL
Definition xine_plugin.c:78
#define PLUGIN_NONE
Definition xine_plugin.h:29
#define PLUGIN_AUDIO_OUT
Definition xine_plugin.h:35