2 * Copyright 2004-2005 Timo Hirvonen
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
26 static arts_stream_t arts_stream
;
27 static sample_format_t arts_sf
;
28 static int arts_buffer_size
;
30 static int op_arts_init(void)
41 static int op_arts_exit(void)
47 static int op_arts_open(sample_format_t sf
)
49 int buffer_time
, server_latency
, total_latency
;
53 arts_stream
= arts_play_stream(sf_get_rate(arts_sf
), sf_get_bits(arts_sf
),
54 sf_get_channels(arts_sf
), "cmus");
55 blocking
= arts_stream_set(arts_stream
, ARTS_P_BLOCKING
, 0);
58 arts_buffer_size
= arts_stream_get(arts_stream
, ARTS_P_BUFFER_SIZE
);
59 if (arts_buffer_size
< 0) {
61 buffer_time
= arts_stream_get(arts_stream
, ARTS_P_BUFFER_TIME
);
62 server_latency
= arts_stream_get(arts_stream
, ARTS_P_SERVER_LATENCY
);
63 total_latency
= arts_stream_get(arts_stream
, ARTS_P_TOTAL_LATENCY
);
64 d_print("buffer_time: %d\n", buffer_time
);
65 d_print("server_latency: %d\n", server_latency
);
66 d_print("total_latency: %d\n", total_latency
);
70 static int op_arts_close(void)
72 arts_close_stream(arts_stream
);
76 static int op_arts_write(const char *buffer
, int count
)
80 rc
= arts_write(arts_stream
, buffer
, count
);
82 d_print("rc = %d, count = %d\n", rc
, count
);
88 static int op_arts_pause(void)
93 static int op_arts_unpause(void)
98 static int op_arts_buffer_space(void)
102 space
= arts_stream_get(arts_stream
, ARTS_P_BUFFER_SPACE
);
108 static int op_arts_set_option(int key
, const char *val
)
110 return -OP_ERROR_NOT_OPTION
;
113 static int op_arts_get_option(int key
, char **val
)
115 return -OP_ERROR_NOT_OPTION
;
118 const struct output_plugin_ops op_pcm_ops
= {
119 .init
= op_arts_init
,
120 .exit
= op_arts_exit
,
121 .open
= op_arts_open
,
122 .close
= op_arts_close
,
123 .write
= op_arts_write
,
124 .pause
= op_arts_pause
,
125 .unpause
= op_arts_unpause
,
126 .buffer_space
= op_arts_buffer_space
,
127 .set_option
= op_arts_set_option
,
128 .get_option
= op_arts_get_option
131 const char * const op_pcm_options
[] = {
135 const int op_priority
= 2;