enhance bio2jack to capture from jack ports

This commit is contained in:
niels
2026-05-28 01:06:11 +02:00
parent 05a682fca8
commit 3c75d35b63
3 changed files with 814 additions and 306 deletions
@@ -2,3 +2,4 @@ bio2jack - a library for porting blocked io(OSS/ALSA) apps to jack
---------------------------------------------------------
Chris Morgan <cmorgan@alum.wpi.edu>
Niels Elburg
File diff suppressed because it is too large Load Diff
+53 -85
View File
@@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _H_JACK_OUT_H
#define _H_JACK_OUT_H
#ifdef HAVE_JACK
@@ -56,100 +55,69 @@ extern "C"
#define CLOSED 3
#define RESET 4
#define PLAYED 1 /* played out of the speakers(estimated value but should be close */
#define WRITTEN_TO_JACK 2 /* amount written out to jack */
#define WRITTEN 3 /* amount written to the bio2jack device */
#define PLAYED 1
#define WRITTEN_TO_JACK 2
#define WRITTEN 3
#define FRAMES_WRITTEN_TO_JACK 4
#define LINEAR 0
#define DBATTENUATION 1
/**********************/
/* External functions */
void JACK_Init(void); /* call this before any other bio2jack calls */
void JACK_Init(void);
int JACK_Open(int *deviceID, unsigned int bits_per_sample, unsigned long *rate, int channels, double SPVF);
int JACK_OpenEx(int *deviceID, unsigned int bits_per_channel, unsigned long *rate, unsigned int input_channels, unsigned int output_channels, const char **jack_port_name, unsigned int jack_port_name_count, unsigned long jack_port_flags, double SPVF);
int JACK_Close(int deviceID);
void JACK_Reset(int deviceID);
long JACK_Write(int deviceID, unsigned char *data, unsigned long bytes);
long JACK_Read(int deviceID, unsigned char *data, unsigned long bytes);
long JACK_GetPosition(int deviceID, int position, int type);
long JACK_GetUnderruns(int deviceID);
long JACK_GetInputOverruns(int deviceID);
int JACK_SetState(int deviceID, int state);
int JACK_GetState(int deviceID);
int JACK_SetVolumeEffectType(int deviceID, int type);
int JACK_SetAllVolume(int deviceID, unsigned int volume);
int JACK_SetVolumeForChannel(int deviceID, unsigned int channel, unsigned int volume);
void JACK_GetVolumeForChannel(int deviceID, unsigned int channel, unsigned int *volume);
void JACK_FreeClientName(void);
unsigned long JACK_GetOutputBytesPerSecond(int deviceID);
unsigned long JACK_GetInputBytesPerSecond(int deviceID);
unsigned long JACK_GetBytesStored(int deviceID);
unsigned long JACK_GetInputBytesStored(int deviceID);
unsigned long JACK_GetBytesFreeSpace(int deviceID);
unsigned long JACK_GetBytesPerOutputFrame(int deviceID);
unsigned long JACK_GetBytesPerInputFrame(int deviceID);
unsigned long JACK_GetPlayedFramesFromDriver(int deviceID);
void JACK_ResetBuffer(int deviceID);
void JACK_ResetInputBuffer(int deviceID);
long JACK_GetSampleRateJack(int deviceID);
long JACK_GetSampleRate(int deviceID);
long JACK_GetPeriodSize(int deviceID);
int JACK_GetRingBufferFreeFrames(int deviceID);
int JACK_GetClientToJackFrames(int deviceID, int client_frames);
int JACK_GetRingBufferSize(int deviceID);
long JACK_GetRingBufferUsed(int deviceID);
void JACK_SetClientName(char *name);
int JACK_Open(int *deviceID, unsigned int bits_per_sample, unsigned long *rate, int channels, double SPVF);
int JACK_OpenEx(int *deviceID, unsigned int bits_per_channel,
unsigned long *rate,
unsigned int input_channels, unsigned int output_channels,
const char **jack_port_name, unsigned int jack_port_name_count,
unsigned long jack_port_flags, double SPVF);
int JACK_Close(int deviceID); /* return 0 for success */
void JACK_Reset(int deviceID); /* free all buffered data and reset several values in the device */
long JACK_Write(int deviceID, unsigned char *data, unsigned long bytes); /* returns the number of bytes written */
long JACK_Read(int deviceID, unsigned char *data, unsigned long bytes); /* returns the number of bytes read */
enum JACK_PORT_CONNECTION_MODE
{
CONNECT_ALL,
CONNECT_OUTPUT,
CONNECT_NONE
};
/* state setting values */
/* set/get the written/played/buffered value based on a byte or millisecond input value */
long JACK_GetPosition(int deviceID, int position, int type);
long JACK_GetUnderruns(int deviceID);
long JACK_GetJackLatency(int deviceID); /* deprectated, you probably want JACK_GetJackOutputLatency */
int JACK_SetState(int deviceID, int state); /* playing, paused, stopped */
int JACK_GetState(int deviceID);
int JACK_SetVolumeEffectType(int deviceID, int type);
int JACK_SetAllVolume(int deviceID, unsigned int volume); /* returns 0 on success */
int JACK_SetVolumeForChannel(int deviceID, unsigned int channel, unsigned int volume);
void JACK_GetVolumeForChannel(int deviceID, unsigned int channel, unsigned int *volume);
void JACK_FreeClientName();
unsigned long JACK_GetOutputBytesPerSecond(int deviceID); /* bytes_per_output_frame * sample_rate */
unsigned long JACK_GetInputBytesPerSecond(int deviceID); /* bytes_per_input_frame * sample_rate */
unsigned long JACK_GetBytesStored(int deviceID); /* bytes currently buffered in the output buffer */
unsigned long JACK_GetBytesFreeSpace(int deviceID); /* bytes of free space in the output buffer */
unsigned long JACK_GetBytesPerOutputFrame(int deviceID);
unsigned long JACK_GetPlayedFramesFromDriver(int deviceID);
void JACK_ResetBuffer(int deviceID);
long JACK_GetSampleRateJack(int deviceID);
long JACK_GetSampleRate(int deviceID); /* samples per second */
long JACK_GetPeriodSize(int deviceID);
int JACK_GetRingBufferFreeFrames(int deviceID);
int JACK_GetClientToJackFrames(int deviceID, int client_frames);
int JACK_GetRingBufferSize(int deviceID);
long JACK_GetRingBufferUsed(int deviceID);
void JACK_SetClientName(char *name); /* sets the name that bio2jack will use when
creating a new jack client. name_%pid%_%deviceID%%counter%
will be used
NOTE: this defaults to name = bio2jack
NOTE: we limit the size of the client name to
jack_client_name_size() */
enum JACK_PORT_CONNECTION_MODE
{
CONNECT_ALL, /* connect to all avaliable ports */
CONNECT_OUTPUT, /* connect only to the ports we need for output */
CONNECT_NONE /* don't connect to any ports */
};
/* set the mode for port connections */
/* defaults to CONNECT_ALL */
void JACK_SetPortConnectionMode(enum JACK_PORT_CONNECTION_MODE mode);
long JACK_OutputStatus(int deviceID, long *sec, long *usec);
int JACK_BufferIsStarving(int deviceID);
long JACK_GetRequiredFreeFrames(int deviceID, int client_frames);
void JACK_getringbuffer(int deviceID, int skipv, int skipa);
double JACK_SetInitialOffset(int deviceID, double target_pts);
void JACK_Flush(int deviceID);
double JACK_GetTotalLatency(int deviceID);
int JACK_GetCallbackActive(int deviceID);
int JACK_XRUNHandled(int deviceID);
void JACK_SetPortConnectionMode(enum JACK_PORT_CONNECTION_MODE mode);
long JACK_OutputStatus(int deviceID, long *sec, long *usec);
int JACK_BufferIsStarving(int deviceID);
long JACK_GetRequiredFreeFrames(int deviceID, int client_frames);
void JACK_Flush(int deviceID);
double JACK_GetTotalLatency(int deviceID);
int JACK_GetCallbackActive(int deviceID);
int JACK_XRUNHandled(int deviceID);
#ifdef __cplusplus
}
#endif
#endif /* #ifndef JACK_OUT_H */
#endif
#endif