Mercurial > mplayer.hg
changeset 6807:ae2f3cdcb462
Improved ao_arts delay and buff er handling, patch by Szombathelyi Gy|rgy <gyurco@freemail.hu>
author | atmos4 |
---|---|
date | Fri, 26 Jul 2002 00:02:31 +0000 |
parents | 994d3729b0d1 |
children | e595ea5b471d |
files | libao2/ao_arts.c |
diffstat | 1 files changed, 20 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/libao2/ao_arts.c Thu Jul 25 22:54:03 2002 +0000 +++ b/libao2/ao_arts.c Fri Jul 26 00:02:31 2002 +0000 @@ -18,6 +18,10 @@ #define OBTAIN_BITRATE(a) (((a != AFMT_U8) || (a != AFMT_S8)) ? 16 : 8) +/* Feel free to experiment with the following values: */ +#define ARTS_PACKETS 10 /* Number of audio packets */ +#define ARTS_PACKET_SIZE_LOG2 11 /* Log2 of audio packet size */ + static arts_stream_t stream; static ao_info_t info = @@ -44,34 +48,36 @@ mp_msg(MSGT_AO, MSGL_ERR, "AO: [arts] %s\n", arts_error_text(err)); return 0; } - - else - mp_msg(MSGT_AO, MSGL_INFO, "AO: [arts] Connected to sound server\n"); + mp_msg(MSGT_AO, MSGL_INFO, "AO: [arts] Connected to sound server\n"); ao_data.format = format; ao_data.channels = channels; ao_data.samplerate = rate_hz; ao_data.bps = (rate_hz*channels); - ao_data.buffersize = 4096; if(format != AFMT_U8 && format != AFMT_S8) ao_data.bps*=2; - for (frag_spec = 0; (0x01<<frag_spec) < ao_data.buffersize; ++frag_spec) - ; - frag_spec |= 0x00020000; stream=arts_play_stream(rate_hz, OBTAIN_BITRATE(format), channels, "Mplayer"); - arts_stream_set(stream, ARTS_P_PACKET_SETTINGS, frag_spec); - arts_stream_set(stream, ARTS_P_BLOCKING, 0); if(stream == NULL) { mp_msg(MSGT_AO, MSGL_ERR, "AO: [arts] Unable to open a stream\n"); + arts_free(); return 0; } - else - mp_msg(MSGT_AO, MSGL_INFO, "AO: [arts] Stream opened\n"); + /* Set the stream to blocking: it will not block anyway, but it seems */ + /* to be working better */ + arts_stream_set(stream, ARTS_P_BLOCKING, 1); + frag_spec = ARTS_PACKET_SIZE_LOG2 | ARTS_PACKETS << 16; + arts_stream_set(stream, ARTS_P_PACKET_SETTINGS, frag_spec); + ao_data.buffersize = arts_stream_get(stream, ARTS_P_BUFFER_SIZE); + mp_msg(MSGT_AO, MSGL_INFO, "AO: [arts] Stream opened\n"); + mp_msg(MSGT_AO, MSGL_INFO,"AO: [arts] buffer size: %d\n", + ao_data.buffersize); + mp_msg(MSGT_AO, MSGL_INFO,"AO: [arts] packet size: %d\n", + arts_stream_get(stream, ARTS_P_PACKET_SIZE)); return 1; } @@ -84,7 +90,7 @@ static int play(void* data,int len,int flags) { - arts_write(stream, data, len); + return arts_write(stream, data, len); } static void audio_pause() @@ -106,12 +112,7 @@ static float get_delay() { - return ((float) arts_stream_get(stream, ARTS_P_BUFFER_SIZE) / (float) ao_data.bps); + return ((float) (ao_data.buffersize - arts_stream_get(stream, + ARTS_P_BUFFER_SPACE))) / ((float) ao_data.bps); } - - - - - -