mirror of https://github.com/mpv-player/mpv
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
This commit is contained in:
parent
9751597015
commit
000819f4fe
|
@ -18,6 +18,10 @@
|
||||||
|
|
||||||
#define OBTAIN_BITRATE(a) (((a != AFMT_U8) || (a != AFMT_S8)) ? 16 : 8)
|
#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 arts_stream_t stream;
|
||||||
|
|
||||||
static ao_info_t info =
|
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));
|
mp_msg(MSGT_AO, MSGL_ERR, "AO: [arts] %s\n", arts_error_text(err));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
mp_msg(MSGT_AO, MSGL_INFO, "AO: [arts] Connected to sound server\n");
|
||||||
else
|
|
||||||
mp_msg(MSGT_AO, MSGL_INFO, "AO: [arts] Connected to sound server\n");
|
|
||||||
|
|
||||||
ao_data.format = format;
|
ao_data.format = format;
|
||||||
ao_data.channels = channels;
|
ao_data.channels = channels;
|
||||||
ao_data.samplerate = rate_hz;
|
ao_data.samplerate = rate_hz;
|
||||||
ao_data.bps = (rate_hz*channels);
|
ao_data.bps = (rate_hz*channels);
|
||||||
ao_data.buffersize = 4096;
|
|
||||||
|
|
||||||
if(format != AFMT_U8 && format != AFMT_S8)
|
if(format != AFMT_U8 && format != AFMT_S8)
|
||||||
ao_data.bps*=2;
|
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");
|
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) {
|
if(stream == NULL) {
|
||||||
mp_msg(MSGT_AO, MSGL_ERR, "AO: [arts] Unable to open a stream\n");
|
mp_msg(MSGT_AO, MSGL_ERR, "AO: [arts] Unable to open a stream\n");
|
||||||
|
arts_free();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
/* Set the stream to blocking: it will not block anyway, but it seems */
|
||||||
mp_msg(MSGT_AO, MSGL_INFO, "AO: [arts] Stream opened\n");
|
/* 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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -84,7 +90,7 @@ static void uninit()
|
||||||
|
|
||||||
static int play(void* data,int len,int flags)
|
static int play(void* data,int len,int flags)
|
||||||
{
|
{
|
||||||
arts_write(stream, data, len);
|
return arts_write(stream, data, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void audio_pause()
|
static void audio_pause()
|
||||||
|
@ -106,12 +112,7 @@ static int get_space()
|
||||||
|
|
||||||
static float get_delay()
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue