Mercurial > mplayer.hg
annotate libao2/ao_arts.c @ 6713:cc917a581b6e
add simple playlist support
author | pontscho |
---|---|
date | Fri, 12 Jul 2002 00:53:26 +0000 |
parents | 0398cb49fe5e |
children | ae2f3cdcb462 |
rev | line source |
---|---|
6214
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
1 /* |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
2 * ao_arts - aRts audio output driver for MPlayer |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
3 * |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
4 * Michele Balistreri <brain87@gmx.net> |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
5 * |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
6 * This driver is distribuited under terms of GPL |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
7 * |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
8 */ |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
9 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
10 #include <artsc.h> |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
11 #include <stdio.h> |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
12 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
13 #include "audio_out.h" |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
14 #include "audio_out_internal.h" |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
15 #include "afmt.h" |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
16 #include "../config.h" |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
17 #include "../mp_msg.h" |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
18 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
19 #define OBTAIN_BITRATE(a) (((a != AFMT_U8) || (a != AFMT_S8)) ? 16 : 8) |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
20 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
21 static arts_stream_t stream; |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
22 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
23 static ao_info_t info = |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
24 { |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
25 "aRts audio output", |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
26 "arts", |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
27 "Michele Balistreri <brain87@gmx.net>", |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
28 "" |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
29 }; |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
30 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
31 LIBAO_EXTERN(arts) |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
32 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
33 static int control(int cmd, int arg) |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
34 { |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
35 return(CONTROL_UNKNOWN); |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
36 } |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
37 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
38 static int init(int rate_hz, int channels, int format, int flags) |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
39 { |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
40 int err; |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
41 int frag_spec; |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
42 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
43 if(err=arts_init()) { |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
44 mp_msg(MSGT_AO, MSGL_ERR, "AO: [arts] %s\n", arts_error_text(err)); |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
45 return 0; |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
46 } |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
47 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
48 else |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
49 mp_msg(MSGT_AO, MSGL_INFO, "AO: [arts] Connected to sound server\n"); |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
50 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
51 ao_data.format = format; |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
52 ao_data.channels = channels; |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
53 ao_data.samplerate = rate_hz; |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
54 ao_data.bps = (rate_hz*channels); |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
55 ao_data.buffersize = 4096; |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
56 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
57 if(format != AFMT_U8 && format != AFMT_S8) |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
58 ao_data.bps*=2; |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
59 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
60 for (frag_spec = 0; (0x01<<frag_spec) < ao_data.buffersize; ++frag_spec) |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
61 ; |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
62 frag_spec |= 0x00020000; |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
63 stream=arts_play_stream(rate_hz, OBTAIN_BITRATE(format), channels, "Mplayer"); |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
64 arts_stream_set(stream, ARTS_P_PACKET_SETTINGS, frag_spec); |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
65 arts_stream_set(stream, ARTS_P_BLOCKING, 0); |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
66 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
67 if(stream == NULL) { |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
68 mp_msg(MSGT_AO, MSGL_ERR, "AO: [arts] Unable to open a stream\n"); |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
69 return 0; |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
70 } |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
71 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
72 else |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
73 mp_msg(MSGT_AO, MSGL_INFO, "AO: [arts] Stream opened\n"); |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
74 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
75 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
76 return 1; |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
77 } |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
78 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
79 static void uninit() |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
80 { |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
81 arts_close_stream(stream); |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
82 arts_free(); |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
83 } |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
84 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
85 static int play(void* data,int len,int flags) |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
86 { |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
87 arts_write(stream, data, len); |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
88 } |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
89 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
90 static void audio_pause() |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
91 { |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
92 } |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
93 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
94 static void audio_resume() |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
95 { |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
96 } |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
97 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
98 static void reset() |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
99 { |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
100 } |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
101 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
102 static int get_space() |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
103 { |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
104 return arts_stream_get(stream, ARTS_P_BUFFER_SPACE); |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
105 } |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
106 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
107 static float get_delay() |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
108 { |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
109 return ((float) arts_stream_get(stream, ARTS_P_BUFFER_SIZE) / (float) ao_data.bps); |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
110 } |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
111 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
112 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
113 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
114 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
115 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
116 |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
diff
changeset
|
117 |