mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:26:14 +00:00
queue2: consolidate buffering message posting code
No need to copy paste the code, simply call the common gst_queue2_post_buffering function. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6165>
This commit is contained in:
parent
54aa6b66d8
commit
517498dd11
1 changed files with 4 additions and 29 deletions
|
@ -2249,37 +2249,12 @@ gst_queue2_create_write (GstQueue2 * queue, GstBuffer * buffer)
|
||||||
update_cur_level (queue, queue->current);
|
update_cur_level (queue, queue->current);
|
||||||
|
|
||||||
/* update the buffering status */
|
/* update the buffering status */
|
||||||
if (queue->use_buffering) {
|
if (queue->use_buffering)
|
||||||
GstMessage *msg;
|
|
||||||
gint percent = -1;
|
|
||||||
update_buffering (queue);
|
update_buffering (queue);
|
||||||
msg = gst_queue2_get_buffering_message (queue, &percent);
|
|
||||||
if (msg) {
|
|
||||||
gboolean post_ok;
|
|
||||||
|
|
||||||
GST_QUEUE2_MUTEX_UNLOCK (queue);
|
GST_QUEUE2_MUTEX_UNLOCK (queue);
|
||||||
|
gst_queue2_post_buffering (queue);
|
||||||
g_mutex_lock (&queue->buffering_post_lock);
|
GST_QUEUE2_MUTEX_LOCK (queue);
|
||||||
post_ok = gst_element_post_message (GST_ELEMENT_CAST (queue), msg);
|
|
||||||
|
|
||||||
GST_QUEUE2_MUTEX_LOCK (queue);
|
|
||||||
|
|
||||||
if (post_ok) {
|
|
||||||
/* Set these states only if posting the message succeeded. Otherwise,
|
|
||||||
* this post attempt failed, and the next one won't be done, because
|
|
||||||
* gst_queue2_get_buffering_message() checks these states and decides
|
|
||||||
* based on their values that it won't produce a message. */
|
|
||||||
queue->last_posted_buffering_percent = percent;
|
|
||||||
if (percent == queue->buffering_percent)
|
|
||||||
queue->percent_changed = FALSE;
|
|
||||||
GST_DEBUG_OBJECT (queue, "successfully posted %d%% buffering message",
|
|
||||||
percent);
|
|
||||||
} else {
|
|
||||||
GST_DEBUG_OBJECT (queue, "could not post buffering message");
|
|
||||||
}
|
|
||||||
g_mutex_unlock (&queue->buffering_post_lock);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GST_INFO_OBJECT (queue, "cur_level.bytes %u (max %" G_GUINT64_FORMAT ")",
|
GST_INFO_OBJECT (queue, "cur_level.bytes %u (max %" G_GUINT64_FORMAT ")",
|
||||||
queue->cur_level.bytes, QUEUE_MAX_BYTES (queue));
|
queue->cur_level.bytes, QUEUE_MAX_BYTES (queue));
|
||||||
|
|
Loading…
Reference in a new issue