mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
micro-optimisation: use GST_QUARK in more places
Use gst_structure_id_empty_new() in combination with GST_QUARK rather than gst_structure_id_new() when creating message, event, query and taglist structures. Mostly just because we can.
This commit is contained in:
parent
ae62089f58
commit
bc7c7e9836
6 changed files with 73 additions and 38 deletions
|
@ -602,7 +602,7 @@ gst_event_new_new_segment_full (gboolean update, gdouble rate,
|
|||
if (stop != -1)
|
||||
g_return_val_if_fail (start <= stop, NULL);
|
||||
|
||||
structure = gst_structure_empty_new ("GstEventNewsegment");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (EVENT_NEWSEGMENT));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (UPDATE), G_TYPE_BOOLEAN, update,
|
||||
GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
|
||||
|
@ -734,7 +734,7 @@ gst_event_new_buffer_size (GstFormat format, gint64 minsize,
|
|||
", maxsize %" G_GINT64_FORMAT ", async %d", gst_format_get_name (format),
|
||||
minsize, maxsize, async);
|
||||
|
||||
structure = gst_structure_empty_new ("GstEventBufferSize");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (EVENT_BUFFER_SIZE));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
|
||||
GST_QUARK (MINSIZE), G_TYPE_INT64, minsize,
|
||||
|
@ -840,7 +840,7 @@ gst_event_new_qos (gdouble proportion, GstClockTimeDiff diff,
|
|||
", timestamp %" GST_TIME_FORMAT, proportion,
|
||||
diff, GST_TIME_ARGS (timestamp));
|
||||
|
||||
structure = gst_structure_empty_new ("GstEventQOS");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (EVENT_QOS));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (PROPORTION), G_TYPE_DOUBLE, proportion,
|
||||
GST_QUARK (DIFF), G_TYPE_INT64, diff,
|
||||
|
@ -953,7 +953,7 @@ gst_event_new_seek (gdouble rate, GstFormat format, GstSeekFlags flags,
|
|||
stop);
|
||||
}
|
||||
|
||||
structure = gst_structure_empty_new ("GstEventSeek");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (EVENT_SEEK));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (RATE), G_TYPE_DOUBLE, rate,
|
||||
GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
|
||||
|
@ -1062,7 +1062,7 @@ gst_event_new_latency (GstClockTime latency)
|
|||
GST_CAT_INFO (GST_CAT_EVENT,
|
||||
"creating latency event %" GST_TIME_FORMAT, GST_TIME_ARGS (latency));
|
||||
|
||||
structure = gst_structure_empty_new ("GstEventLatency");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (EVENT_LATENCY));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (LATENCY), G_TYPE_UINT64, latency, NULL);
|
||||
event = gst_event_new_custom (GST_EVENT_LATENCY, structure);
|
||||
|
|
|
@ -381,7 +381,7 @@ gst_message_new_error (GstObject * src, GError * error, const gchar * debug)
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstMessageError");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (MESSAGE_ERROR));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (GERROR), GST_TYPE_G_ERROR, error,
|
||||
GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
|
||||
|
@ -409,7 +409,7 @@ gst_message_new_warning (GstObject * src, GError * error, const gchar * debug)
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstMessageWarning");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (MESSAGE_WARNING));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (GERROR), GST_TYPE_G_ERROR, error,
|
||||
GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
|
||||
|
@ -439,7 +439,7 @@ gst_message_new_info (GstObject * src, GError * error, const gchar * debug)
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstMessageInfo");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (MESSAGE_INFO));
|
||||
gst_structure_id_set (structure, GST_QUARK (GERROR), GST_TYPE_G_ERROR,
|
||||
error, GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL);
|
||||
message = gst_message_new_custom (GST_MESSAGE_INFO, src, structure);
|
||||
|
@ -535,7 +535,7 @@ gst_message_new_buffering (GstObject * src, gint percent)
|
|||
|
||||
g_return_val_if_fail (percent >= 0 && percent <= 100, NULL);
|
||||
|
||||
structure = gst_structure_empty_new ("GstMessageBuffering");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (MESSAGE_BUFFERING));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (BUFFER_PERCENT), G_TYPE_INT, percent,
|
||||
GST_QUARK (BUFFERING_MODE), GST_TYPE_BUFFERING_MODE, GST_BUFFERING_STREAM,
|
||||
|
@ -569,7 +569,7 @@ gst_message_new_state_changed (GstObject * src,
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstMessageState");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (MESSAGE_STATE));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (OLD_STATE), GST_TYPE_STATE, (gint) oldstate,
|
||||
GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) newstate,
|
||||
|
@ -625,7 +625,7 @@ gst_message_new_clock_provide (GstObject * src, GstClock * clock,
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstMessageClockProvide");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (MESSAGE_CLOCK_PROVIDE));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock,
|
||||
GST_QUARK (READY), G_TYPE_BOOLEAN, ready, NULL);
|
||||
|
@ -656,7 +656,7 @@ gst_message_new_clock_lost (GstObject * src, GstClock * clock)
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstMessageClockLost");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (MESSAGE_CLOCK_LOST));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
|
||||
message = gst_message_new_custom (GST_MESSAGE_CLOCK_LOST, src, structure);
|
||||
|
@ -682,7 +682,7 @@ gst_message_new_new_clock (GstObject * src, GstClock * clock)
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstMessageNewClock");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (MESSAGE_NEW_CLOCK));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (CLOCK), GST_TYPE_CLOCK, clock, NULL);
|
||||
message = gst_message_new_custom (GST_MESSAGE_NEW_CLOCK, src, structure);
|
||||
|
@ -720,7 +720,7 @@ gst_message_new_structure_change (GstObject * src, GstStructureChangeType type,
|
|||
g_return_val_if_fail (GST_PAD_DIRECTION (src) == GST_PAD_SRC, NULL);
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (owner), NULL);
|
||||
|
||||
structure = gst_structure_empty_new ("GstMessageStructureChange");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (MESSAGE_STRUCTURE_CHANGE));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (TYPE), GST_TYPE_STRUCTURE_CHANGE_TYPE, type,
|
||||
GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner,
|
||||
|
@ -754,7 +754,7 @@ gst_message_new_segment_start (GstObject * src, GstFormat format,
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstMessageSegmentStart");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (MESSAGE_SEGMENT_START));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
|
||||
GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
|
||||
|
@ -785,7 +785,7 @@ gst_message_new_segment_done (GstObject * src, GstFormat format,
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstMessageSegmentDone");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (MESSAGE_SEGMENT_DONE));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
|
||||
GST_QUARK (POSITION), G_TYPE_INT64, position, NULL);
|
||||
|
@ -858,7 +858,7 @@ gst_message_new_duration (GstObject * src, GstFormat format, gint64 duration)
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstMessageDuration");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (MESSAGE_DURATION));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
|
||||
GST_QUARK (DURATION), G_TYPE_INT64, duration, NULL);
|
||||
|
@ -888,7 +888,7 @@ gst_message_new_async_start (GstObject * src, gboolean new_base_time)
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstMessageAsyncStart");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (MESSAGE_ASYNC_START));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (NEW_BASE_TIME), G_TYPE_BOOLEAN, new_base_time, NULL);
|
||||
message = gst_message_new_custom (GST_MESSAGE_ASYNC_START, src, structure);
|
||||
|
@ -962,7 +962,7 @@ gst_message_new_request_state (GstObject * src, GstState state)
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstMessageRequestState");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (MESSAGE_REQUEST_STATE));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (NEW_STATE), GST_TYPE_STATE, (gint) state, NULL);
|
||||
message = gst_message_new_custom (GST_MESSAGE_REQUEST_STATE, src, structure);
|
||||
|
@ -1560,7 +1560,7 @@ gst_message_new_stream_status (GstObject * src, GstStreamStatusType type,
|
|||
GstMessage *message;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstMessageStreamStatus");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (MESSAGE_STREAM_STATUS));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (TYPE), GST_TYPE_STREAM_STATUS_TYPE, (gint) type,
|
||||
GST_QUARK (OWNER), GST_TYPE_ELEMENT, owner, NULL);
|
||||
|
|
|
@ -37,7 +37,16 @@ static const gchar *_quark_strings[] = {
|
|||
"max-latency", "busy", "type", "owner", "update", "applied-rate",
|
||||
"start", "stop", "minsize", "maxsize", "async", "proportion",
|
||||
"diff", "timestamp", "flags", "cur-type", "cur", "stop-type",
|
||||
"latency", "uri", "object"
|
||||
"latency", "uri", "object", "taglist", "GstEventNewsegment",
|
||||
"GstEventBufferSize", "GstEventQOS", "GstEventSeek", "GstEventLatency",
|
||||
"GstMessageError", "GstMessageWarning", "GstMessageInfo",
|
||||
"GstMessageBuffering", "GstMessageState", "GstMessageClockProvide",
|
||||
"GstMessageClockLost", "GstMessageNewClock", "GstMessageStructureChange",
|
||||
"GstMessageSegmentStart", "GstMessageSegmentDone", "GstMessageDuration",
|
||||
"GstMessageAsyncStart", "GstMessageRequestState", "GstMessageStreamStatus",
|
||||
"GstQueryPosition", "GstQueryDuration", "GstQueryLatency", "GstQueryConvert",
|
||||
"GstQuerySegment", "GstQuerySeeking", "GstQueryFormats", "GstQueryBuffering",
|
||||
"GstQueryURI"
|
||||
};
|
||||
|
||||
GQuark _priv_gst_quark_table[GST_QUARK_MAX];
|
||||
|
|
|
@ -79,8 +79,37 @@ typedef enum _GstQuarkId
|
|||
GST_QUARK_LATENCY = 50,
|
||||
GST_QUARK_URI = 51,
|
||||
GST_QUARK_OBJECT = 52,
|
||||
|
||||
GST_QUARK_MAX = 53
|
||||
GST_QUARK_TAGLIST = 53,
|
||||
GST_QUARK_EVENT_NEWSEGMENT = 54,
|
||||
GST_QUARK_EVENT_BUFFER_SIZE = 55,
|
||||
GST_QUARK_EVENT_QOS = 56,
|
||||
GST_QUARK_EVENT_SEEK = 57,
|
||||
GST_QUARK_EVENT_LATENCY = 58,
|
||||
GST_QUARK_MESSAGE_ERROR = 59,
|
||||
GST_QUARK_MESSAGE_WARNING = 60,
|
||||
GST_QUARK_MESSAGE_INFO = 61,
|
||||
GST_QUARK_MESSAGE_BUFFERING = 62,
|
||||
GST_QUARK_MESSAGE_STATE = 63,
|
||||
GST_QUARK_MESSAGE_CLOCK_PROVIDE = 64,
|
||||
GST_QUARK_MESSAGE_CLOCK_LOST = 65,
|
||||
GST_QUARK_MESSAGE_NEW_CLOCK = 66,
|
||||
GST_QUARK_MESSAGE_STRUCTURE_CHANGE = 67,
|
||||
GST_QUARK_MESSAGE_SEGMENT_START = 68,
|
||||
GST_QUARK_MESSAGE_SEGMENT_DONE = 69,
|
||||
GST_QUARK_MESSAGE_DURATION = 70,
|
||||
GST_QUARK_MESSAGE_ASYNC_START = 71,
|
||||
GST_QUARK_MESSAGE_REQUEST_STATE = 72,
|
||||
GST_QUARK_MESSAGE_STREAM_STATUS = 73,
|
||||
GST_QUARK_QUERY_POSITION = 74,
|
||||
GST_QUARK_QUERY_DURATION = 75,
|
||||
GST_QUARK_QUERY_LATENCY = 76,
|
||||
GST_QUARK_QUERY_CONVERT = 77,
|
||||
GST_QUARK_QUERY_SEGMENT = 78,
|
||||
GST_QUARK_QUERY_SEEKING = 79,
|
||||
GST_QUARK_QUERY_FORMATS = 80,
|
||||
GST_QUARK_QUERY_BUFFERING = 81,
|
||||
GST_QUARK_QUERY_URI = 82,
|
||||
GST_QUARK_MAX = 83
|
||||
} GstQuarkId;
|
||||
|
||||
extern GQuark _priv_gst_quark_table[GST_QUARK_MAX];
|
||||
|
|
|
@ -387,7 +387,7 @@ gst_query_new_position (GstFormat format)
|
|||
GstQuery *query;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstQueryPosition");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (QUERY_POSITION));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
|
||||
GST_QUARK (CURRENT), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
|
||||
|
@ -460,7 +460,7 @@ gst_query_new_duration (GstFormat format)
|
|||
GstQuery *query;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstQueryDuration");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (QUERY_DURATION));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
|
||||
GST_QUARK (DURATION), G_TYPE_INT64, G_GINT64_CONSTANT (-1), NULL);
|
||||
|
@ -535,7 +535,7 @@ gst_query_new_latency (void)
|
|||
GstQuery *query;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstQueryLatency");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (QUERY_LATENCY));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (LIVE), G_TYPE_BOOLEAN, FALSE,
|
||||
GST_QUARK (MIN_LATENCY), G_TYPE_UINT64, G_GUINT64_CONSTANT (0),
|
||||
|
@ -623,7 +623,7 @@ gst_query_new_convert (GstFormat src_format, gint64 value,
|
|||
GstQuery *query;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstQueryConvert");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (QUERY_CONVERT));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (SRC_FORMAT), GST_TYPE_FORMAT, src_format,
|
||||
GST_QUARK (SRC_VALUE), G_TYPE_INT64, value,
|
||||
|
@ -711,7 +711,7 @@ gst_query_new_segment (GstFormat format)
|
|||
GstQuery *query;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstQuerySegment");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (QUERY_SEGMENT));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (RATE), G_TYPE_DOUBLE, (gdouble) 0.0,
|
||||
GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
|
||||
|
@ -846,7 +846,7 @@ gst_query_new_seeking (GstFormat format)
|
|||
GstQuery *query;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstQuerySeeking");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (QUERY_SEEKING));
|
||||
gst_structure_id_set (structure,
|
||||
GST_QUARK (FORMAT), GST_TYPE_FORMAT, format,
|
||||
GST_QUARK (SEEKABLE), G_TYPE_BOOLEAN, FALSE,
|
||||
|
@ -935,7 +935,7 @@ gst_query_new_formats (void)
|
|||
GstQuery *query;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_new ("GstQueryFormats", NULL);
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (QUERY_FORMATS));
|
||||
query = gst_query_new (GST_QUERY_FORMATS, structure);
|
||||
|
||||
return query;
|
||||
|
@ -1096,7 +1096,7 @@ gst_query_new_buffering (GstFormat format)
|
|||
GstQuery *query;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstQueryBuffering");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (QUERY_BUFFERING));
|
||||
/* by default, we configure the answer as no buffering with a 100% buffering
|
||||
* progress */
|
||||
gst_structure_id_set (structure,
|
||||
|
@ -1306,7 +1306,7 @@ gst_query_new_uri (void)
|
|||
GstQuery *query;
|
||||
GstStructure *structure;
|
||||
|
||||
structure = gst_structure_empty_new ("GstQueryURI");
|
||||
structure = gst_structure_id_empty_new (GST_QUARK (QUERY_URI));
|
||||
gst_structure_id_set (structure, GST_QUARK (URI), G_TYPE_STRING, NULL, NULL);
|
||||
|
||||
query = gst_query_new (GST_QUERY_URI, structure);
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "gstinfo.h"
|
||||
#include "gstvalue.h"
|
||||
#include "gstbuffer.h"
|
||||
#include "gstquark.h"
|
||||
|
||||
#include <gobject/gvaluecollector.h>
|
||||
#include <string.h>
|
||||
|
@ -60,9 +61,6 @@ typedef struct
|
|||
}
|
||||
GstTagInfo;
|
||||
|
||||
#define TAGLIST "taglist"
|
||||
static GQuark gst_tag_list_quark;
|
||||
|
||||
static GMutex *__tag_mutex;
|
||||
|
||||
static GHashTable *__tags;
|
||||
|
@ -91,7 +89,6 @@ gst_tag_list_get_type (void)
|
|||
void
|
||||
_gst_tag_initialize (void)
|
||||
{
|
||||
gst_tag_list_quark = g_quark_from_static_string (TAGLIST);
|
||||
__tag_mutex = g_mutex_new ();
|
||||
__tags = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
gst_tag_register (GST_TAG_TITLE, GST_TAG_FLAG_META,
|
||||
|
@ -532,7 +529,7 @@ gst_tag_is_fixed (const gchar * tag)
|
|||
GstTagList *
|
||||
gst_tag_list_new (void)
|
||||
{
|
||||
return GST_TAG_LIST (gst_structure_new (TAGLIST, NULL));
|
||||
return GST_TAG_LIST (gst_structure_id_empty_new (GST_QUARK (TAGLIST)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -569,7 +566,7 @@ gst_is_tag_list (gconstpointer p)
|
|||
|
||||
g_return_val_if_fail (p != NULL, FALSE);
|
||||
|
||||
return (GST_IS_STRUCTURE (s) && s->name == gst_tag_list_quark);
|
||||
return (GST_IS_STRUCTURE (s) && s->name == GST_QUARK (TAGLIST));
|
||||
}
|
||||
|
||||
typedef struct
|
||||
|
|
Loading…
Reference in a new issue