From d94d572e16c590ed619bfaed23100b80516ce6f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 31 Aug 2009 13:00:04 +0100 Subject: [PATCH] mpegtsmux: use an old-fashioned array instead of GPtrArray for mux->programs Using GPtrArray for a fixed-sized array is a bit pointless and makes for ugly code. --- gst/mpegtsmux/mpegtsmux.c | 14 ++++---------- gst/mpegtsmux/mpegtsmux.h | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/gst/mpegtsmux/mpegtsmux.c b/gst/mpegtsmux/mpegtsmux.c index c5abe57474..6b9b632557 100644 --- a/gst/mpegtsmux/mpegtsmux.c +++ b/gst/mpegtsmux/mpegtsmux.c @@ -196,8 +196,6 @@ mpegtsmux_class_init (MpegTsMuxClass * klass) static void mpegtsmux_init (MpegTsMux * mux, MpegTsMuxClass * g_class) { - guint i; - mux->srcpad = gst_pad_new_from_template (gst_static_pad_template_get (&mpegtsmux_src_factory), "src"); @@ -211,10 +209,7 @@ mpegtsmux_init (MpegTsMux * mux, MpegTsMuxClass * g_class) mux->tsmux = tsmux_new (); tsmux_set_write_func (mux->tsmux, new_packet_cb, mux); - mux->programs = g_ptr_array_new (); - for (i = 0; i < MAX_PROG_NUMBER; i++) - g_ptr_array_add (mux->programs, NULL); - + mux->programs = g_new0 (TsMuxProgram *, MAX_PROG_NUMBER); mux->first = TRUE; mux->last_flow_ret = GST_FLOW_OK; mux->adapter = gst_adapter_new (); @@ -248,7 +243,7 @@ mpegtsmux_dispose (GObject * object) mux->prog_map = NULL; } if (mux->programs) { - g_ptr_array_free (mux->programs, TRUE); + g_free (mux->programs); mux->programs = NULL; } @@ -486,13 +481,12 @@ mpegtsmux_create_streams (MpegTsMux * mux) } } - ts_data->prog = - (TsMuxProgram *) g_ptr_array_index (mux->programs, ts_data->prog_id); + ts_data->prog = mux->programs[ts_data->prog_id]; if (ts_data->prog == NULL) { ts_data->prog = tsmux_program_new (mux->tsmux); if (ts_data->prog == NULL) goto no_program; - g_ptr_array_index (mux->programs, ts_data->prog_id) = ts_data->prog; + mux->programs[ts_data->prog_id] = ts_data->prog; } if (ts_data->stream == NULL) { diff --git a/gst/mpegtsmux/mpegtsmux.h b/gst/mpegtsmux/mpegtsmux.h index f4536fdf07..2ebb7251dc 100644 --- a/gst/mpegtsmux/mpegtsmux.h +++ b/gst/mpegtsmux/mpegtsmux.h @@ -109,7 +109,7 @@ struct MpegTsMux { GstCollectPads *collect; TsMux *tsmux; - GPtrArray *programs; + TsMuxProgram **programs; GstStructure *prog_map; gboolean first;