diff --git a/libmpdemux/demux_audio.c b/libmpdemux/demux_audio.c index 6715feac52..b6ec8901a6 100644 --- a/libmpdemux/demux_audio.c +++ b/libmpdemux/demux_audio.c @@ -363,3 +363,24 @@ void demux_close_audio(demuxer_t* demuxer) { free(priv); } +int demux_audio_control(demuxer_t *demuxer,int cmd, void *arg){ + sh_audio_t *sh_audio=demuxer->audio->sh; + int audio_length = demuxer->movi_end / sh_audio->i_bps; + da_priv_t* priv = demuxer->priv; + + switch(cmd) { + case DEMUXER_CTRL_GET_TIME_LENGTH: + if (audio_length<=0) return DEMUXER_CTRL_DONTKNOW; + *((unsigned long *)arg)=(unsigned long)audio_length; + return DEMUXER_CTRL_GUESS; + + case DEMUXER_CTRL_GET_PERCENT_POS: + if (audio_length<=0) + return DEMUXER_CTRL_DONTKNOW; + *((int *)arg)=(int)( (priv->last_pts*100) / audio_length); + return DEMUXER_CTRL_OK; + + default: + return DEMUXER_CTRL_NOTIMPL; + } +} diff --git a/libmpdemux/demuxer.c b/libmpdemux/demuxer.c index 342fa44e32..907b36bcca 100644 --- a/libmpdemux/demuxer.c +++ b/libmpdemux/demuxer.c @@ -1530,6 +1530,7 @@ extern int demux_asf_control(demuxer_t *demuxer, int cmd, void *arg); extern int demux_avi_control(demuxer_t *demuxer, int cmd, void *arg); extern int demux_xmms_control(demuxer_t *demuxer, int cmd, void *arg); extern int demux_mkv_control(demuxer_t *demuxer, int cmd, void *arg); +extern int demux_audio_control(demuxer_t *demuxer, int cmd, void *arg); int demux_control(demuxer_t *demuxer, int cmd, void *arg) { switch(demuxer->type) { @@ -1547,6 +1548,8 @@ int demux_control(demuxer_t *demuxer, int cmd, void *arg) { case DEMUXER_TYPE_AVI_NI: case DEMUXER_TYPE_AVI_NINI: return demux_avi_control(demuxer,cmd,arg); + case DEMUXER_TYPE_AUDIO: + return demux_audio_control(demuxer,cmd,arg); #ifdef HAVE_XMMS case DEMUXER_TYPE_XMMS: return demux_xmms_control(demuxer,cmd,arg);