[Mplayer-cvslog] CVS: main/libao2 ao_arts.c,1.1,1.2
Atmosfear
atmos4 at mplayerhq.hu
Fri Jul 26 02:02:34 CEST 2002
Update of /cvsroot/mplayer/main/libao2
In directory mail:/var/tmp.root/cvs-serv10062/libao2
Modified Files:
ao_arts.c
Log Message:
Improved ao_arts delay and buff er handling, patch by Szombathelyi Gy|rgy <gyurco at freemail.hu>
Index: ao_arts.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_arts.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ao_arts.c 28 May 2002 01:52:40 -0000 1.1
+++ ao_arts.c 26 Jul 2002 00:02:31 -0000 1.2
@@ -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);
}
-
-
-
-
-
-
More information about the MPlayer-cvslog
mailing list