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.
This commit is contained in:
Tim-Philipp Müller 2009-08-31 13:00:04 +01:00
parent f3e2864f4c
commit d94d572e16
2 changed files with 5 additions and 11 deletions

View file

@ -196,8 +196,6 @@ mpegtsmux_class_init (MpegTsMuxClass * klass)
static void static void
mpegtsmux_init (MpegTsMux * mux, MpegTsMuxClass * g_class) mpegtsmux_init (MpegTsMux * mux, MpegTsMuxClass * g_class)
{ {
guint i;
mux->srcpad = mux->srcpad =
gst_pad_new_from_template (gst_static_pad_template_get gst_pad_new_from_template (gst_static_pad_template_get
(&mpegtsmux_src_factory), "src"); (&mpegtsmux_src_factory), "src");
@ -211,10 +209,7 @@ mpegtsmux_init (MpegTsMux * mux, MpegTsMuxClass * g_class)
mux->tsmux = tsmux_new (); mux->tsmux = tsmux_new ();
tsmux_set_write_func (mux->tsmux, new_packet_cb, mux); tsmux_set_write_func (mux->tsmux, new_packet_cb, mux);
mux->programs = g_ptr_array_new (); mux->programs = g_new0 (TsMuxProgram *, MAX_PROG_NUMBER);
for (i = 0; i < MAX_PROG_NUMBER; i++)
g_ptr_array_add (mux->programs, NULL);
mux->first = TRUE; mux->first = TRUE;
mux->last_flow_ret = GST_FLOW_OK; mux->last_flow_ret = GST_FLOW_OK;
mux->adapter = gst_adapter_new (); mux->adapter = gst_adapter_new ();
@ -248,7 +243,7 @@ mpegtsmux_dispose (GObject * object)
mux->prog_map = NULL; mux->prog_map = NULL;
} }
if (mux->programs) { if (mux->programs) {
g_ptr_array_free (mux->programs, TRUE); g_free (mux->programs);
mux->programs = NULL; mux->programs = NULL;
} }
@ -486,13 +481,12 @@ mpegtsmux_create_streams (MpegTsMux * mux)
} }
} }
ts_data->prog = ts_data->prog = mux->programs[ts_data->prog_id];
(TsMuxProgram *) g_ptr_array_index (mux->programs, ts_data->prog_id);
if (ts_data->prog == NULL) { if (ts_data->prog == NULL) {
ts_data->prog = tsmux_program_new (mux->tsmux); ts_data->prog = tsmux_program_new (mux->tsmux);
if (ts_data->prog == NULL) if (ts_data->prog == NULL)
goto no_program; 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) { if (ts_data->stream == NULL) {

View file

@ -109,7 +109,7 @@ struct MpegTsMux {
GstCollectPads *collect; GstCollectPads *collect;
TsMux *tsmux; TsMux *tsmux;
GPtrArray *programs; TsMuxProgram **programs;
GstStructure *prog_map; GstStructure *prog_map;
gboolean first; gboolean first;