From: Conor McCarthy cmccarthy@codeweavers.com
Other methods for the video object return DMO_E_TYPE_NOT_SET if wg_transform is null. A race condition in Nioh can result in Flush() being called when the transform is not set. --- dlls/winegstreamer/video_decoder.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/dlls/winegstreamer/video_decoder.c b/dlls/winegstreamer/video_decoder.c index 891066dac3b..ce716dd0004 100644 --- a/dlls/winegstreamer/video_decoder.c +++ b/dlls/winegstreamer/video_decoder.c @@ -1315,6 +1315,9 @@ static HRESULT WINAPI media_object_Flush(IMediaObject *iface)
TRACE("iface %p.\n", iface);
+ if (!decoder->wg_transform) + return DMO_E_TYPE_NOT_SET; + if (FAILED(hr = wg_transform_flush(decoder->wg_transform))) return hr;
From: Conor McCarthy cmccarthy@codeweavers.com
ProcessMessage() can return MF_E_TRANSFORM_TYPE_NOT_SET if necessary. --- dlls/winegstreamer/video_decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/winegstreamer/video_decoder.c b/dlls/winegstreamer/video_decoder.c index ce716dd0004..d071b009a49 100644 --- a/dlls/winegstreamer/video_decoder.c +++ b/dlls/winegstreamer/video_decoder.c @@ -791,7 +791,7 @@ static HRESULT WINAPI transform_ProcessMessage(IMFTransform *iface, MFT_MESSAGE_ return S_OK;
case MFT_MESSAGE_COMMAND_DRAIN: - return wg_transform_drain(decoder->wg_transform); + return decoder->wg_transform ? wg_transform_drain(decoder->wg_transform) : MF_E_TRANSFORM_TYPE_NOT_SET;
case MFT_MESSAGE_COMMAND_FLUSH: return wg_transform_flush(decoder->wg_transform);
From: Conor McCarthy cmccarthy@codeweavers.com
--- dlls/winegstreamer/video_decoder.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/winegstreamer/video_decoder.c b/dlls/winegstreamer/video_decoder.c index d071b009a49..83fb713d5da 100644 --- a/dlls/winegstreamer/video_decoder.c +++ b/dlls/winegstreamer/video_decoder.c @@ -794,7 +794,7 @@ static HRESULT WINAPI transform_ProcessMessage(IMFTransform *iface, MFT_MESSAGE_ return decoder->wg_transform ? wg_transform_drain(decoder->wg_transform) : MF_E_TRANSFORM_TYPE_NOT_SET;
case MFT_MESSAGE_COMMAND_FLUSH: - return wg_transform_flush(decoder->wg_transform); + return decoder->wg_transform ? wg_transform_flush(decoder->wg_transform) : MF_E_TRANSFORM_TYPE_NOT_SET;
case MFT_MESSAGE_NOTIFY_START_OF_STREAM: decoder->sample_time = -1;
From: Conor McCarthy cmccarthy@codeweavers.com
--- dlls/winegstreamer/wma_decoder.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/dlls/winegstreamer/wma_decoder.c b/dlls/winegstreamer/wma_decoder.c index c141b7e26fe..09b2ee647b3 100644 --- a/dlls/winegstreamer/wma_decoder.c +++ b/dlls/winegstreamer/wma_decoder.c @@ -897,6 +897,9 @@ static HRESULT WINAPI media_object_Flush(IMediaObject *iface)
TRACE("iface %p.\n", iface);
+ if (!decoder->wg_transform) + return DMO_E_TYPE_NOT_SET; + if (FAILED(hr = wg_transform_flush(decoder->wg_transform))) return hr;
A race condition in Nioh can result in Flush() being called when the transform is not set.
Should we consider adding a CS to these objects?
On Wed Dec 4 00:34:31 2024 +0000, Rémi Bernon wrote:
A race condition in Nioh can result in Flush() being called when the
transform is not set. Should we consider adding a CS to these objects?
Implement the `Lock()` and `Unlock()` methods? From my understanding of the documentation, all locking should go through these, but they are never called.
On Wed Dec 4 00:34:30 2024 +0000, Conor McCarthy wrote:
Implement the `Lock()` and `Unlock()` methods? From my understanding of the documentation, all locking should go through these, but they are never called.
No, I meant: if there's a race condition does this mean that functions are called concurrently from two different threads? In which case we should maybe add a CS. Or if it's just the consequence of a race condition elsewhere but functions still called from a single thread, these fixes are enough.
On Wed Dec 4 09:07:24 2024 +0000, Rémi Bernon wrote:
No, I meant: if there's a race condition does this mean that functions are called concurrently from two different threads? In which case we should maybe add a CS. Or if it's just the consequence of a race condition elsewhere but functions still called from a single thread, these fixes are enough.
Functions are not called concurrently. The game creates a media object, never sets a transform output type, and eventually calls `Flush()` on the object. For some reason this doesn't happen when tracing is not enabled. Not a race condition that causes invalid behaviour, since it's not invalid to call `Flush()`.
This merge request was approved by Rémi Bernon.