summaryrefslogtreecommitdiffstats
path: root/libao2/ao_arts.c
diff options
context:
space:
mode:
authoratmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-07-26 00:02:31 +0000
committeratmos4 <atmos4@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-07-26 00:02:31 +0000
commit000819f4fe7c02c7878d0e04e7cdf81b09d040fb (patch)
tree9c5d69db1f3b6eef4cb3f33c33e73178ed84ba81 /libao2/ao_arts.c
parent9751597015d53d2559273bed6612a95c2bfc967b (diff)
downloadmpv-000819f4fe7c02c7878d0e04e7cdf81b09d040fb.tar.bz2
mpv-000819f4fe7c02c7878d0e04e7cdf81b09d040fb.tar.xz
Improved ao_arts delay and buff er handling, patch by Szombathelyi Gy|rgy <gyurco@freemail.hu>
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6808 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libao2/ao_arts.c')
-rw-r--r--libao2/ao_arts.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/libao2/ao_arts.c b/libao2/ao_arts.c
index 6fa6b88cf0..d660ebbcf3 100644
--- a/libao2/ao_arts.c
+++ b/libao2/ao_arts.c
@@ -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 @@ static int init(int rate_hz, int channels, int format, int flags)
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 void uninit()
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 int get_space()
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);
}
-
-
-
-
-
-