From a604dc12be13af547572f18b9e09222eeda193c9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 29 Sep 2019 01:39:17 +0200 Subject: recorder: don't use a magic index for mp_recorder_get_sink() Although this was sort of elegant, it just seems to complicate things slightly. Originally, the API meant that you cache mp_recorder_sink yourself (which would avoid the mess of passing an index around), but that too seems slightly roundabout. In a later change, I want to change the set of streams passed to mp_recorder_create(), and then I'd have to keep track of the index for each stream, which would suck. With this commit, I can just pass the unambiguous sh_stream to it, and it will be guaranteed to match the correct stream. The disadvantages are barely worth discussing. It's a new linear search per packet, but usually only 2 to 4 streams are active at a time. Also, in theory a user could want to write 2 streams using the same sh_stream (same metadata, just writing different packets or so), but in practice this is never done. --- player/loadfile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'player/loadfile.c') diff --git a/player/loadfile.c b/player/loadfile.c index 47b3d7a66e..8f0d091b29 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -1874,7 +1874,7 @@ void open_recorder(struct MPContext *mpctx, bool on_init) // (We expect track->stream not to be reused on other tracks.) if (track->stream == streams[n_stream]) { struct mp_recorder_sink * sink = - mp_recorder_get_sink(mpctx->recorder, n_stream); + mp_recorder_get_sink(mpctx->recorder, streams[n_stream]); assert(sink); set_track_recorder_sink(track, sink); n_stream++; -- cgit v1.2.3