Skip to content

winegstreamer: Don't get stream ID wires crossed#320

Open
Alcaro wants to merge 1 commit intoValveSoftware:proton_10.0from
Alcaro:patch-1
Open

winegstreamer: Don't get stream ID wires crossed#320
Alcaro wants to merge 1 commit intoValveSoftware:proton_10.0from
Alcaro:patch-1

Conversation

@Alcaro
Copy link
Copy Markdown
Contributor

@Alcaro Alcaro commented Apr 4, 2026

Applying commit 55e5a1c to upstream Wine, then running this program

#include <stdio.h>
#include <windows.h>
#include <wmsdk.h>

int main(int argc, char** argv, char** envp)
{
	HMODULE wmvcore = LoadLibrary("wmvcore.dll");
	auto WMCreateSyncReader = (decltype(::WMCreateSyncReader)*)GetProcAddress(wmvcore, "WMCreateSyncReader");
	
	IWMSyncReader* sr;
	WMCreateSyncReader(NULL, 0, &sr);
	
	if (FAILED(sr->Open(L"Z:/home/walrus/Desktop/xarlib/nekopara.wmv")))
		if (FAILED(sr->Open(L"Z:/home/x3/nekopara.wmv")))
			exit(1);
	
puts("AAAA");
	sr->SetReadStreamSamples(1, true);
puts("BBBB");
	sr->SetReadStreamSamples(2, true);
puts("CCCC");
	
	for (int i=0;i<2;i++)
	{
		INSSBuffer* sample;
		QWORD a, b;
		DWORD c;
		sr->GetNextSample(i+1, &sample, &a, &b, &c, nullptr, nullptr);
		
		BYTE* buf;
		DWORD len;
		sample->GetBufferAndLength(&buf, &len);
		printf("sample %lu bytes\n", len);
		for (int i=0;i<64;i++) printf("%.2x ", buf[i]);
		puts("");
	}
}

returns a dlls/winegstreamer/wg_parser.c:401: wg_parser_stream_copy_buffer: Assertion `offset + size <= stream->map_info.size' failed. error, due to getting some wires crossed between the audio and video streams.

This patch re-crosses the streams, so the crossings cancel out and it stops asserting.

I originally found the issue by running https://store.steampowered.com/app/333600/NEKOPARA_Vol_1/ in a slightly modded Proton that uses Glorious Eggroll's WMV/WMA codecs, rather than the media converter. (Standard Proton also crashes at the same point; symptoms differ, but I'd suspect the same root cause. I didn't investigate standard Proton any further.)

The issue only reproduces with some WMVs; I can upload this one if you want, but it's 503MB. Probably easier to extract it from Nekopara yourself - just make reader_OpenStream dump its IStream to disk. (That's what I did.)

Since I don't know what CW-Bug-Id: #23483 refers to (and it's probably a game I don't have), I am unable to test this patch very thoroughly.

Fair chance there are better solutions - the original patch feels like a hack, and this patch is another hack on top of that. But I don't know how such a solution would look.

@Alcaro
Copy link
Copy Markdown
Contributor Author

Alcaro commented Apr 5, 2026

Another option would be ignore this PR, and make the aforementioned commit conditional on SteamGameId.

I have no opinion on which is better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant