[MPlayer-dev-eng] [PATCH] Switch audio control in OGG demuxer
ubitux
ubitux at gmail.com
Sun Apr 11 21:49:04 CEST 2010
On Sun, Apr 11, 2010 at 09:07:33PM +0200, Reimar Döffinger wrote:
> That's wrong, only if the argument is -1 it should switch to the "next",
> otherwise it should switch to the one specified.
Oh sorry about that. Is this better?
--
ubitux
-------------- next part --------------
Index: libmpdemux/demux_ogg.c
===================================================================
--- libmpdemux/demux_ogg.c (revision 31029)
+++ 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,48 @@
*(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;
+
+ if (id == -1) {
+ /* Select next audio stream */
+ int next_stream_id = demuxer->audio->id;
+
+ 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)) {
+ demuxer->audio->id = next_stream_id;
+ break;
+ }
+ }
+
+ } else {
+ /* 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++;
+ }
+ }
+ }
+
+ return DEMUXER_CTRL_OK;
+ }
+
default:
return DEMUXER_CTRL_NOTIMPL;
}
More information about the MPlayer-dev-eng
mailing list