From 38bb55c472233174f6c1beb5e4977f06f78d0a17 Mon Sep 17 00:00:00 2001 From: Mark Nauwelaerts Date: Tue, 5 Jun 2012 14:18:34 +0200 Subject: [PATCH] mpegtsmux: avoid PID collision for auto-generated PID --- gst/mpegtsmux/tsmux/tsmux.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gst/mpegtsmux/tsmux/tsmux.c b/gst/mpegtsmux/tsmux/tsmux.c index 4e5a196d1f..838c48a0c9 100644 --- a/gst/mpegtsmux/tsmux/tsmux.c +++ b/gst/mpegtsmux/tsmux/tsmux.c @@ -356,9 +356,13 @@ tsmux_get_new_pid (TsMux * mux) { g_return_val_if_fail (mux != NULL, -1); - /* FIXME: It's possible that this next PID is already taken if a - * specific PID was requested earlier. We should find a free PID */ - return mux->next_stream_pid++; + /* make sure this PID is free + * (and not taken by a specific earlier request) */ + do { + mux->next_stream_pid++; + } while (tsmux_find_stream (mux, mux->next_stream_pid)); + + return mux->next_stream_pid; } /**