[PATCH 1/4] winegstreamer: Use WG_MAJOR_TYPE_UNKNOWN to mark a stream that should not be forced into a certain format.

Zebediah Figura zfigura at codeweavers.com
Fri Apr 8 12:11:06 CDT 2022


Instead of checking the enabled state.

The reasoning here is that we would like to keep the stream enabled—that is,
buffer samples instead of discarding them—even when the client is not yet
reading samples from it, so that we can avoid wasting CPU power in decoding.

Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
 dlls/winegstreamer/wg_format.c |  2 +-
 dlls/winegstreamer/wg_parser.c | 11 ++++-------
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/dlls/winegstreamer/wg_format.c b/dlls/winegstreamer/wg_format.c
index b4455a6e6d0..84163f1e5d7 100644
--- a/dlls/winegstreamer/wg_format.c
+++ b/dlls/winegstreamer/wg_format.c
@@ -495,7 +495,7 @@ GstCaps *wg_format_to_caps(const struct wg_format *format)
     switch (format->major_type)
     {
         case WG_MAJOR_TYPE_UNKNOWN:
-            return NULL;
+            return gst_caps_new_any();
         case WG_MAJOR_TYPE_WMA:
             return wg_format_to_caps_wma(format);
         case WG_MAJOR_TYPE_H264:
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c
index e7a60ec158a..9b3a5ca796d 100644
--- a/dlls/winegstreamer/wg_parser.c
+++ b/dlls/winegstreamer/wg_parser.c
@@ -254,6 +254,7 @@ static NTSTATUS wg_parser_stream_disable(void *args)
 
     pthread_mutex_lock(&parser->mutex);
     stream->enabled = false;
+    stream->current_format.major_type = WG_MAJOR_TYPE_UNKNOWN;
     pthread_mutex_unlock(&parser->mutex);
     pthread_cond_signal(&stream->event_empty_cond);
     return S_OK;
@@ -601,12 +602,7 @@ static gboolean sink_query_cb(GstPad *pad, GstObject *parent, GstQuery *query)
             gst_query_parse_caps(query, &filter);
 
             pthread_mutex_lock(&parser->mutex);
-
-            if (stream->enabled)
-                caps = wg_format_to_caps(&stream->current_format);
-            else
-                caps = gst_caps_new_any();
-
+            caps = wg_format_to_caps(&stream->current_format);
             pthread_mutex_unlock(&parser->mutex);
 
             if (!caps)
@@ -636,7 +632,7 @@ static gboolean sink_query_cb(GstPad *pad, GstObject *parent, GstQuery *query)
 
             pthread_mutex_lock(&parser->mutex);
 
-            if (!stream->enabled)
+            if (stream->current_format.major_type == WG_MAJOR_TYPE_UNKNOWN)
             {
                 pthread_mutex_unlock(&parser->mutex);
                 gst_query_set_accept_caps_result(query, TRUE);
@@ -689,6 +685,7 @@ static struct wg_parser_stream *create_stream(struct wg_parser *parser)
     gst_segment_init(&stream->segment, GST_FORMAT_UNDEFINED);
 
     stream->parser = parser;
+    stream->current_format.major_type = WG_MAJOR_TYPE_UNKNOWN;
     pthread_cond_init(&stream->event_cond, NULL);
     pthread_cond_init(&stream->event_empty_cond, NULL);
 
-- 
2.35.1




More information about the wine-devel mailing list