1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
/*
* Copyright 2004-2005 Timo Hirvonen
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*/
#include <op.h>
#include <xmalloc.h>
#include <debug.h>
#include <artsc.h>
static arts_stream_t arts_stream;
static sample_format_t arts_sf;
static int arts_buffer_size;
static int op_arts_init(void)
{
int rc;
rc = arts_init();
if (rc < 0) {
return -1;
}
return 0;
}
static int op_arts_exit(void)
{
arts_free();
return 0;
}
static int op_arts_open(sample_format_t sf)
{
int buffer_time, server_latency, total_latency;
int blocking;
arts_sf = sf;
arts_stream = arts_play_stream(sf_get_rate(arts_sf), sf_get_bits(arts_sf),
sf_get_channels(arts_sf), "cmus");
blocking = arts_stream_set(arts_stream, ARTS_P_BLOCKING, 0);
if (blocking) {
}
arts_buffer_size = arts_stream_get(arts_stream, ARTS_P_BUFFER_SIZE);
if (arts_buffer_size < 0) {
}
buffer_time = arts_stream_get(arts_stream, ARTS_P_BUFFER_TIME);
server_latency = arts_stream_get(arts_stream, ARTS_P_SERVER_LATENCY);
total_latency = arts_stream_get(arts_stream, ARTS_P_TOTAL_LATENCY);
d_print("buffer_time: %d\n", buffer_time);
d_print("server_latency: %d\n", server_latency);
d_print("total_latency: %d\n", total_latency);
return 0;
}
static int op_arts_close(void)
{
arts_close_stream(arts_stream);
return 0;
}
static int op_arts_write(const char *buffer, int count)
{
int rc;
rc = arts_write(arts_stream, buffer, count);
if (rc < 0) {
d_print("rc = %d, count = %d\n", rc, count);
return -1;
}
return rc;
}
static int op_arts_pause(void)
{
return 0;
}
static int op_arts_unpause(void)
{
return 0;
}
static int op_arts_buffer_space(void)
{
int space;
space = arts_stream_get(arts_stream, ARTS_P_BUFFER_SPACE);
if (space < 0)
return -1;
return space;
}
static int op_arts_set_option(int key, const char *val)
{
return -OP_ERROR_NOT_OPTION;
}
static int op_arts_get_option(int key, char **val)
{
return -OP_ERROR_NOT_OPTION;
}
const struct output_plugin_ops op_pcm_ops = {
.init = op_arts_init,
.exit = op_arts_exit,
.open = op_arts_open,
.close = op_arts_close,
.write = op_arts_write,
.pause = op_arts_pause,
.unpause = op_arts_unpause,
.buffer_space = op_arts_buffer_space,
.set_option = op_arts_set_option,
.get_option = op_arts_get_option
};
const char * const op_pcm_options[] = {
NULL
};
const int op_priority = 2;
|