| 1 |
/* |
| 2 |
out123_int: internal header for libout123 |
| 3 |
|
| 4 |
copyright ?-2023 by the mpg123 project - free software under the terms of the LGPL 2.1 |
| 5 |
see COPYING and AUTHORS files in distribution or http://mpg123.org |
| 6 |
initially written by Michael Hipp (some traces left) |
| 7 |
*/ |
| 8 |
|
| 9 |
#ifndef _MPG123_OUT123_INT_H_ |
| 10 |
#define _MPG123_OUT123_INT_H_ |
| 11 |
|
| 12 |
#define MPG123_ENUM_API |
| 13 |
|
| 14 |
#include "config.h" |
| 15 |
#include "../common/abi_align.h" |
| 16 |
#include "../compat/compat.h" |
| 17 |
#include "out123.h" |
| 18 |
#include "module.h" |
| 19 |
|
| 20 |
#ifndef NOXFERMEM |
| 21 |
#include "xfermem.h" |
| 22 |
#endif |
| 23 |
|
| 24 |
/* 3% rate tolerance */ |
| 25 |
#define AUDIO_RATE_TOLERANCE 3 |
| 26 |
|
| 27 |
/* Keep those internally? To the outside, it's just a selection of |
| 28 |
driver modules. */ |
| 29 |
enum { |
| 30 |
DECODE_TEST, /* "test" */ |
| 31 |
DECODE_AUDIO, /* gone */ |
| 32 |
DECODE_FILE, /* "raw" */ |
| 33 |
DECODE_BUFFER, /* internal use only, if at all */ |
| 34 |
DECODE_WAV, /* wav */ |
| 35 |
DECODE_AU, /* au */ |
| 36 |
DECODE_CDR, /* cdr */ |
| 37 |
DECODE_AUDIOFILE /* internal use only, if at all */ |
| 38 |
}; |
| 39 |
|
| 40 |
/* Playback states mostly for the buffer process. |
| 41 |
Maybe also used in main program. */ |
| 42 |
enum playstate |
| 43 |
{ |
| 44 |
play_dead = 0 /* nothing playing, nothing loaded */ |
| 45 |
, play_stopped /* driver present, but no device configured/opened */ |
| 46 |
/* The ordering is used, state > play_stopped means some device is opened. */ |
| 47 |
, play_paused /* paused, ready to continue, device still active */ |
| 48 |
, play_live /* playing right now */ |
| 49 |
}; |
| 50 |
|
| 51 |
struct out123_struct |
| 52 |
{ |
| 53 |
enum out123_error errcode; |
| 54 |
#ifndef NOXFERMEM |
| 55 |
/* If buffer_pid >= 0, there is a separate buffer process actually |
| 56 |
handling everything, this instance here is then only a proxy. */ |
| 57 |
int buffer_pid; |
| 58 |
int buffer_fd[2]; |
| 59 |
txfermem *buffermem; |
| 60 |
#endif |
| 61 |
|
| 62 |
int fn; /* filenumber */ |
| 63 |
void *userptr; /* driver specific pointer */ |
| 64 |
|
| 65 |
/* Callbacks */ |
| 66 |
int (*open)(out123_handle *); |
| 67 |
int (*get_formats)(out123_handle *); |
| 68 |
int (*write)(out123_handle *, unsigned char *,int); |
| 69 |
void (*flush)(out123_handle *); /* flush == drop != drain */ |
| 70 |
void (*drain)(out123_handle *); |
| 71 |
int (*close)(out123_handle *); |
| 72 |
void (*deinit)(out123_handle *); |
| 73 |
// Enumerate the available devices, if possible. NULL pointer if module doesn't support this. |
| 74 |
int (*enumerate)(out123_handle *, int (*store_device)(void *devlist |
| 75 |
, const char *name, const char *description), void *devlist); |
| 76 |
|
| 77 |
/* the loaded that has set the above */ |
| 78 |
mpg123_module_t *module; |
| 79 |
|
| 80 |
char *name; /* optional name of this instance */ |
| 81 |
char *realname; /* name possibly changed by backend */ |
| 82 |
char *driver; /* driver (module) name */ |
| 83 |
char *device; /* device name */ |
| 84 |
int flags; /* some bits; namely headphone/speaker/line */ |
| 85 |
long rate; /* sample rate */ |
| 86 |
long gain; /* output gain */ |
| 87 |
int channels; /* number of channels */ |
| 88 |
int format; /* encoding (TODO: rename this to "encoding"!) */ |
| 89 |
int framesize; /* Output needs data in chunks of framesize bytes. */ |
| 90 |
unsigned char zerosample[8]; /* Zero in current encoding, max 64 bit. */ |
| 91 |
enum playstate state; /* ... */ |
| 92 |
int auxflags; /* For now just one: quiet mode (for probing). */ |
| 93 |
int propflags; /* Property flags, set by driver. */ |
| 94 |
double preload; /* buffer fraction to preload before play */ |
| 95 |
int verbose; /* verbosity to stderr */ |
| 96 |
double device_buffer; /* device buffer in seconds */ |
| 97 |
char *bindir; /* OUT123_BINDIR */ |
| 98 |
/* TODO int intflag; ... is it really useful/necessary from the outside? */ |
| 99 |
}; |
| 100 |
|
| 101 |
/* Lazy. */ |
| 102 |
#define AOQUIET ((ao->auxflags | ao->flags) & OUT123_QUIET) |
| 103 |
#define AOVERBOSE(v) (!AOQUIET && ao->verbose >= (v)) |
| 104 |
#define GOOD_WRITEVAL(fd, val) (INT123_unintr_write(fd, &(val), sizeof((val))) == sizeof((val))) |
| 105 |
#define GOOD_WRITEBUF(fd, addr, n) (INT123_unintr_write(fd, (addr), (n)) == (n)) |
| 106 |
#define GOOD_READVAL(fd, val) (INT123_unintr_read(fd, &(val), sizeof((val))) == sizeof((val))) |
| 107 |
#define GOOD_READBUF(fd, addr, n) (INT123_unintr_read(fd, (addr), (n)) == (n)) |
| 108 |
|
| 109 |
struct audio_format_name { |
| 110 |
int val; |
| 111 |
char *name; |
| 112 |
char *sname; |
| 113 |
}; |
| 114 |
|
| 115 |
#endif |
| 116 |
|