[MPlayer-dev-eng] [PATCH] Switch audio control in OGG demuxer
ubitux
ubitux at gmail.com
Tue Apr 13 00:02:37 CEST 2010
On Mon, Apr 12, 2010 at 07:03:43PM +0200, Reimar Döffinger wrote:
> On Sun, Apr 11, 2010 at 09:49:04PM +0200, ubitux wrote:
> > + /* Select specified audio stream */
> > + int n_audio = 0;
> > +
> > + for (n = 0; n < ogg_d->num_sub; n++) {
> > + ogg_stream_t *ostream = &ogg_d->subs[n];
> > +
> > + if (STREAM_IS_AUDIO(ostream)) {
> > + if (n_audio == id) {
> > + demuxer->audio->id = n;
> > + break;
> > + }
> > + n_audio++;
> > + }
> > + }
>
> Get rid of n_audio and check for ostream->id == id
Ok, so here is a new version of the patch. It now also call
ds_free_packs().
But there is still the weird issue about the sound, and I found another
one: when switching audio, subtitles are disabled and even calling the
subtitle switch they never appear again...
--
ubitux
-------------- next part --------------
Index: libmpdemux/demux_ogg.c
===================================================================
--- libmpdemux/demux_ogg.c (revision 31034)
+++ libmpdemux/demux_ogg.c (working copy)
@@ -39,6 +39,8 @@
#define FOURCC_SPEEX mmioFOURCC('s', 'p', 'x', ' ')
#define FOURCC_THEORA mmioFOURCC('t', 'h', 'e', 'o')
+#define STREAM_IS_AUDIO(stream) ((stream)->vorbis || (stream)->speex || (stream)->flac)
+
#ifdef CONFIG_TREMOR
#include <tremor/ogg.h>
#include <tremor/ivorbiscodec.h>
@@ -1568,6 +1570,44 @@
*(int *)arg=((os->lastpos - ogg_d->initial_granulepos)*100) / ogg_d->duration;
return DEMUXER_CTRL_OK;
+ case DEMUXER_CTRL_SWITCH_AUDIO:
+ {
+ int n;
+ int id = *(int*)arg;
+ int next_stream_id = demuxer->audio->id;
+
+ if (id == -1) {
+ /* Select next audio stream */
+ for (n = 0; n < ogg_d->num_sub; n++) {
+ ogg_stream_t *ostream;
+
+ next_stream_id++;
+ if (next_stream_id == ogg_d->num_sub)
+ next_stream_id = 0;
+ ostream = &ogg_d->subs[next_stream_id];
+ if (STREAM_IS_AUDIO(ostream))
+ break;
+ }
+ } else {
+ /* Select specified audio stream */
+ for (n = 0; n < ogg_d->num_sub; n++) {
+ ogg_stream_t *ostream = &ogg_d->subs[n];
+
+ if (ostream->id == id && STREAM_IS_AUDIO(ostream)) {
+ next_stream_id = n;
+ break;
+ }
+ }
+ }
+
+ if (next_stream_id != demuxer->audio->id) {
+ ds_free_packs(demuxer->audio);
+ demuxer->audio->id = next_stream_id;
+ }
+
+ return DEMUXER_CTRL_OK;
+ }
+
default:
return DEMUXER_CTRL_NOTIMPL;
}
More information about the MPlayer-dev-eng
mailing list