Mercurial > mplayer.hg
annotate libao2/ao_jack.c @ 13548:661718721c92
introducing 24bit formats and make the values compliant to OSS
author | alex |
---|---|
date | Mon, 04 Oct 2004 19:05:16 +0000 |
parents | 2d188ebe0f3b |
children | adb9a0d74ca0 |
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 */ |
13012
2d188ebe0f3b
Update ao_jack for new bio2jack API, improve check in configure.
diego
parents:
12702
diff
changeset
|
37 int JACK_SetVolumeForChannel(int deviceID, unsigned int channel, unsigned int volume); |
2d188ebe0f3b
Update ao_jack for new bio2jack API, improve check in configure.
diego
parents:
12702
diff
changeset
|
38 void JACK_GetVolumeForChannel(int deviceID, unsigned int channel, unsigned int *volume); |
12662
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; |
13012
2d188ebe0f3b
Update ao_jack for new bio2jack API, improve check in configure.
diego
parents:
12702
diff
changeset
|
60 unsigned int l, r; |
12662
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
61 |
13012
2d188ebe0f3b
Update ao_jack for new bio2jack API, improve check in configure.
diego
parents:
12702
diff
changeset
|
62 JACK_GetVolumeForChannel(driver, 0, &l); |
2d188ebe0f3b
Update ao_jack for new bio2jack API, improve check in configure.
diego
parents:
12702
diff
changeset
|
63 JACK_GetVolumeForChannel(driver, 1, &r); |
12702
b6d1267f189e
1000l in GET_VOLUME. Fix by Lu Ran, hephooey (at) fastmail (dot) fm.
reimar
parents:
12662
diff
changeset
|
64 vol->left = (float )l; |
b6d1267f189e
1000l in GET_VOLUME. Fix by Lu Ran, hephooey (at) fastmail (dot) fm.
reimar
parents:
12662
diff
changeset
|
65 vol->right = (float )r; |
12662
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
66 |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
67 return CONTROL_OK; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
68 } |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
69 case AOCONTROL_SET_VOLUME: |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
70 { |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
71 ao_control_vol_t *vol = (ao_control_vol_t *)arg; |
13012
2d188ebe0f3b
Update ao_jack for new bio2jack API, improve check in configure.
diego
parents:
12702
diff
changeset
|
72 unsigned int l = (int )vol->left, |
12662
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
73 r = (int )vol->right, |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
74 err = 0; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
75 |
13012
2d188ebe0f3b
Update ao_jack for new bio2jack API, improve check in configure.
diego
parents:
12702
diff
changeset
|
76 if((err = JACK_SetVolumeForChannel(driver, 0, l))) { |
12662
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
77 mp_msg(MSGT_AO, MSGL_ERR, |
13012
2d188ebe0f3b
Update ao_jack for new bio2jack API, improve check in configure.
diego
parents:
12702
diff
changeset
|
78 "AO: [Jack] Setting left volume failed, error %d\n",err); |
12662
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
79 return CONTROL_ERROR; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
80 } |
13012
2d188ebe0f3b
Update ao_jack for new bio2jack API, improve check in configure.
diego
parents:
12702
diff
changeset
|
81 if((err = JACK_SetVolumeForChannel(driver, 1, r))) { |
2d188ebe0f3b
Update ao_jack for new bio2jack API, improve check in configure.
diego
parents:
12702
diff
changeset
|
82 mp_msg(MSGT_AO, MSGL_ERR, |
2d188ebe0f3b
Update ao_jack for new bio2jack API, improve check in configure.
diego
parents:
12702
diff
changeset
|
83 "AO: [Jack] Setting right volume failed, error %d\n",err); |
2d188ebe0f3b
Update ao_jack for new bio2jack API, improve check in configure.
diego
parents:
12702
diff
changeset
|
84 return CONTROL_ERROR; |
2d188ebe0f3b
Update ao_jack for new bio2jack API, improve check in configure.
diego
parents:
12702
diff
changeset
|
85 } |
2d188ebe0f3b
Update ao_jack for new bio2jack API, improve check in configure.
diego
parents:
12702
diff
changeset
|
86 |
12662
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
87 return CONTROL_OK; |
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 } |
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 return(CONTROL_UNKNOWN); |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
92 } |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
93 |
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 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
|
96 { |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
97 int err, m, frag_spec; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
98 unsigned long rate; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
99 unsigned int bits_per_sample; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
100 |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
101 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
|
102 JACK_Init(); |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
103 |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
104 switch (format) { |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
105 case AFMT_U8: |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
106 case AFMT_S8: |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
107 format = AFMT_U8; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
108 bits_per_sample = 8; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
109 m = 1; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
110 break; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
111 default: |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
112 format = AFMT_S16_LE; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
113 bits_per_sample = 16; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
114 m = 2; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
115 break; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
116 } |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
117 |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
118 rate = rate_hz; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
119 |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
120 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
|
121 |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
122 /* 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
|
123 * 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
|
124 if(err == ERR_RATE_MISMATCH) { |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
125 mp_msg(MSGT_AO, MSGL_INFO, |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
126 "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
|
127 |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
128 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
|
129 } |
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 /* any other error */ |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
132 if(err != ERR_SUCCESS) { |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
133 mp_msg(MSGT_AO, MSGL_ERR, |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
134 "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
|
135 return 0; |
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 |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
138 ao_data.format = format; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
139 ao_data.channels = channels; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
140 ao_data.samplerate = rate; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
141 ao_data.bps = ( rate * channels * m ); |
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 mp_msg(MSGT_AO, MSGL_INFO, |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
144 "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
|
145 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
|
146 |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
147 return 1; |
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 |
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 static void uninit(int immed) |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
152 { |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
153 int errval = 0; |
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 JACK_Reset(driver); |
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 if((errval = JACK_Close(driver))) |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
158 mp_msg(MSGT_AO, MSGL_ERR, |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
159 "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
|
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 int play(void* data,int len,int flags) |
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 return JACK_Write(driver, data, len); |
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_pause() |
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, PAUSED); |
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 audio_resume() |
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_SetState(driver, PLAYING); |
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 void reset() |
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 JACK_Reset(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 int get_space() |
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 JACK_GetBytesFreeSpace(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 |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
192 |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
193 static float get_delay() |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
194 { |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
195 return (float )JACK_GetJackLatency(driver); |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
196 } |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
diff
changeset
|
197 |