[MPlayer-dev-eng] [PATCH] Switch audio control in OGG demuxer

ubitux ubitux at gmail.com
Sun Apr 11 20:42:44 CEST 2010


Hi,

Here is a patch to get the switch audio control working in OGG files,
without the need of the lavf demuxer. I anyone can review it...

Thanks

-- 
ubitux
-------------- next part --------------
Index: libmpdemux/demux_ogg.c
===================================================================
--- libmpdemux/demux_ogg.c	(revision 31029)
+++ libmpdemux/demux_ogg.c	(working copy)
@@ -1568,8 +1568,31 @@
 	    *(int *)arg=((os->lastpos - ogg_d->initial_granulepos)*100) / ogg_d->duration;
 	    return DEMUXER_CTRL_OK;
 
-	default:
-	    return DEMUXER_CTRL_NOTIMPL;
+        case DEMUXER_CTRL_SWITCH_AUDIO:
+        {
+            int current_stream_id = demuxer->audio->id;
+            int next_stream_id = current_stream_id;
+            int n;
+
+            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 (ostream->vorbis || ostream->flac || ostream->speex)
+                    break;
+            }
+
+            if (current_stream_id != next_stream_id)
+                demuxer->audio->id = next_stream_id;
+
+            return DEMUXER_CTRL_OK;
+        }
+
+        default:
+            return DEMUXER_CTRL_NOTIMPL;
     }
 }
 


More information about the MPlayer-dev-eng mailing list