annotate libao2/ao_jack.c @ 12702:b6d1267f189e

1000l in GET_VOLUME. Fix by Lu Ran, hephooey (at) fastmail (dot) fm.
author reimar
date Sun, 27 Jun 2004 13:18:06 +0000
parents 05d46af5e2bf
children 2d188ebe0f3b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12662
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
1 /*
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
2 * ao_jack - JACK audio output driver for MPlayer
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
3 *
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
4 * Kamil Strzelecki < esack at browarek.net >
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
5 *
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
6 * This driver is distribuited under terms of GPL
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
7 *
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
8 * It uses bio2jack (http://bio2jack.sf.net/).
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
9 *
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
10 */
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
11
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
12 #include <stdio.h>
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
13
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
14 #include "audio_out.h"
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
15 #include "audio_out_internal.h"
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
16 #include "afmt.h"
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
17 #include "../config.h"
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
18 #include "../mp_msg.h"
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
19
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
20 //#include "bio2jack.h"
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
21
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
22 static int driver = 0;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
23
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
24 //bio2jack stuff:
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
25 #define ERR_SUCCESS 0
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
26 #define ERR_OPENING_JACK 1
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
27 #define ERR_RATE_MISMATCH 2
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
28 #define ERR_BYTES_PER_FRAME_INVALID 3
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
29 enum status_enum { PLAYING, PAUSED, STOPPED, CLOSED, RESET };
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
30 void JACK_Init(void);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
31 int JACK_Open(int* deviceID, unsigned int bits_per_sample, unsigned long *rate, int channels);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
32 int JACK_Close(int deviceID); /* return 0 for success */
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
33 void JACK_Reset(int deviceID); /* free all buffered data and reset several values in the device */
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
34 long JACK_Write(int deviceID, char *data, unsigned long bytes); /* returns the number of bytes written */
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
35 long JACK_GetJackLatency(int deviceID); /* return the latency in milliseconds of jack */
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
36 int JACK_SetState(int deviceID, enum status_enum state); /* playing, paused, stopped */
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
37 int JACK_SetVolume(int deviceID, int left, int right); /* returns 0 on success */
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
38 void JACK_GetVolume(int deviceID, int *left, int *right);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
39 //
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
40
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
41
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
42 static ao_info_t info =
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
43 {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
44 "JACK audio output",
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
45 "jack",
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
46 "Kamil Strzelecki <esack@browarek.net>",
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
47 ""
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
48 };
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
49
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
50
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
51 LIBAO_EXTERN(jack)
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
52
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
53
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
54 static int control(int cmd, void *arg)
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
55 {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
56 switch(cmd) {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
57 case AOCONTROL_GET_VOLUME:
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
58 {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
59 ao_control_vol_t *vol = (ao_control_vol_t *)arg;
12702
b6d1267f189e 1000l in GET_VOLUME. Fix by Lu Ran, hephooey (at) fastmail (dot) fm.
reimar
parents: 12662
diff changeset
60 int l, r;
12662
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
61
12702
b6d1267f189e 1000l in GET_VOLUME. Fix by Lu Ran, hephooey (at) fastmail (dot) fm.
reimar
parents: 12662
diff changeset
62 JACK_GetVolume(driver, &l, &r);
b6d1267f189e 1000l in GET_VOLUME. Fix by Lu Ran, hephooey (at) fastmail (dot) fm.
reimar
parents: 12662
diff changeset
63 vol->left = (float )l;
b6d1267f189e 1000l in GET_VOLUME. Fix by Lu Ran, hephooey (at) fastmail (dot) fm.
reimar
parents: 12662
diff changeset
64 vol->right = (float )r;
12662
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
65
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
66 return CONTROL_OK;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
67 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
68 case AOCONTROL_SET_VOLUME:
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
69 {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
70 ao_control_vol_t *vol = (ao_control_vol_t *)arg;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
71 int l = (int )vol->left,
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
72 r = (int )vol->right,
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
73 err = 0;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
74
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
75 if((err = JACK_SetVolume(driver, l, r))) {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
76 mp_msg(MSGT_AO, MSGL_ERR,
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
77 "AO: [Jack] Setting volume failed, error %d\n",err);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
78 return CONTROL_ERROR;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
79 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
80
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
81 return CONTROL_OK;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
82 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
83 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
84
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
85 return(CONTROL_UNKNOWN);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
86 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
87
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
88
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
89 static int init(int rate_hz, int channels, int format, int flags)
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
90 {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
91 int err, m, frag_spec;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
92 unsigned long rate;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
93 unsigned int bits_per_sample;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
94
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
95 mp_msg(MSGT_AO, MSGL_INFO, "AO: [Jack] Initialising library.\n");
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
96 JACK_Init();
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
97
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
98 switch (format) {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
99 case AFMT_U8:
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
100 case AFMT_S8:
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
101 format = AFMT_U8;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
102 bits_per_sample = 8;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
103 m = 1;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
104 break;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
105 default:
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
106 format = AFMT_S16_LE;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
107 bits_per_sample = 16;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
108 m = 2;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
109 break;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
110 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
111
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
112 rate = rate_hz;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
113
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
114 err = JACK_Open(&driver, bits_per_sample, &rate, channels);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
115
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
116 /* if sample rates doesn't match try to open device with jack's rate and
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
117 * let mplayer convert it (rate now contains that which jackd use) */
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
118 if(err == ERR_RATE_MISMATCH) {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
119 mp_msg(MSGT_AO, MSGL_INFO,
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
120 "AO: [Jack] Sample rate mismatch, trying to resample.\n");
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
121
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
122 err = JACK_Open(&driver, bits_per_sample, &rate, channels);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
123 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
124
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
125 /* any other error */
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
126 if(err != ERR_SUCCESS) {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
127 mp_msg(MSGT_AO, MSGL_ERR,
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
128 "AO: [Jack] JACK_Open() failed, error %d\n", err);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
129 return 0;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
130 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
131
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
132 ao_data.format = format;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
133 ao_data.channels = channels;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
134 ao_data.samplerate = rate;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
135 ao_data.bps = ( rate * channels * m );
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
136
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
137 mp_msg(MSGT_AO, MSGL_INFO,
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
138 "AO: [Jack] OK. I'm ready to go (%d Hz/%d channels/%d bit)\n",
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
139 ao_data.samplerate, ao_data.channels, bits_per_sample);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
140
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
141 return 1;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
142 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
143
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
144
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
145 static void uninit(int immed)
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
146 {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
147 int errval = 0;
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
148
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
149 JACK_Reset(driver);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
150
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
151 if((errval = JACK_Close(driver)))
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
152 mp_msg(MSGT_AO, MSGL_ERR,
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
153 "AO: [Jack] error closing device, error %d\n", errval);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
154 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
155
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
156
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
157 static int play(void* data,int len,int flags)
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
158 {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
159 return JACK_Write(driver, data, len);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
160 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
161
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
162
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
163 static void audio_pause()
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
164 {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
165 JACK_SetState(driver, PAUSED);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
166 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
167
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
168
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
169 static void audio_resume()
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
170 {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
171 JACK_SetState(driver, PLAYING);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
172 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
173
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
174
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
175 static void reset()
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
176 {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
177 JACK_Reset(driver);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
178 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
179
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
180
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
181 static int get_space()
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
182 {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
183 return JACK_GetBytesFreeSpace(driver);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
184 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
185
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
186
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
187 static float get_delay()
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
188 {
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
189 return (float )JACK_GetJackLatency(driver);
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
190 }
05d46af5e2bf JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff changeset
191