Commit 1673af4c authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

mp3dmod: Handle a NULL buffer passed to IMediaObject::ProcessOutput().

parent 88357e92
......@@ -456,6 +456,20 @@ static HRESULT WINAPI MediaObject_ProcessOutput(IMediaObject *iface, DWORD flags
buffers[0].dwStatus = 0;
if (!buffers[0].pBuffer)
{
while ((err = mpg123_read(This->mh, NULL, 0, &written)) == MPG123_NEW_FORMAT);
if (err == MPG123_NEED_MORE)
return S_OK;
else if (err == MPG123_ERR)
ERR("mpg123_read() failed: %s\n", mpg123_strerror(This->mh));
else if (err != MPG123_OK)
ERR("mpg123_read() returned %d\n", err);
buffers[0].dwStatus = DMO_OUTPUT_DATA_BUFFERF_INCOMPLETE;
return S_OK;
}
if (!This->buffer)
return S_FALSE;
......
......@@ -235,9 +235,50 @@ static void test_convert(void)
ok(hr == S_FALSE, "got %#x\n", hr);
ok(output.dwStatus == 0, "got %#x\n", output.dwStatus);
output.pBuffer = NULL;
output.dwStatus = 0xdeadbeef;
output.rtTimestamp = 0xdeadbeef;
output.rtTimelength = 0xdeadbeef;
hr = IMediaObject_ProcessOutput(dmo, DMO_PROCESS_OUTPUT_DISCARD_WHEN_NO_BUFFER, 1, &output, &status);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(!output.pBuffer, "Got buffer %p.\n", output.pBuffer);
ok(!output.dwStatus, "Got status %#x.\n", output.dwStatus);
ok(output.rtTimestamp == 0xdeadbeef, "Got timestamp %s.\n", wine_dbgstr_longlong(output.rtTimestamp));
ok(output.rtTimelength == 0xdeadbeef, "Got length %s.\n", wine_dbgstr_longlong(output.rtTimelength));
hr = IMediaObject_ProcessInput(dmo, 0, &inbuf.IMediaBuffer_iface, 0, 0, 0);
ok(hr == S_OK, "got %#x\n", hr);
hr = IMediaObject_ProcessInput(dmo, 0, &inbuf.IMediaBuffer_iface, 0, 0, 0);
ok(hr == DMO_E_NOTACCEPTING, "Got hr %#x.\n", hr);
output.pBuffer = NULL;
output.dwStatus = 0xdeadbeef;
output.rtTimestamp = 0xdeadbeef;
output.rtTimelength = 0xdeadbeef;
hr = IMediaObject_ProcessOutput(dmo, DMO_PROCESS_OUTPUT_DISCARD_WHEN_NO_BUFFER, 1, &output, &status);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(!output.pBuffer, "Got buffer %p.\n", output.pBuffer);
ok(output.dwStatus == O_INCOMPLETE, "Got status %#x.\n", output.dwStatus);
ok(output.rtTimestamp == 0xdeadbeef, "Got timestamp %s.\n", wine_dbgstr_longlong(output.rtTimestamp));
ok(output.rtTimelength == 0xdeadbeef, "Got length %s.\n", wine_dbgstr_longlong(output.rtTimelength));
ok(inbuf.refcount == 2, "Got refcount %d.\n", inbuf.refcount);
hr = IMediaObject_ProcessOutput(dmo, 0, 1, &output, &status);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(!output.pBuffer, "Got buffer %p.\n", output.pBuffer);
ok(output.dwStatus == O_INCOMPLETE, "Got status %#x.\n", output.dwStatus);
ok(output.rtTimestamp == 0xdeadbeef, "Got timestamp %s.\n", wine_dbgstr_longlong(output.rtTimestamp));
ok(output.rtTimelength == 0xdeadbeef, "Got length %s.\n", wine_dbgstr_longlong(output.rtTimelength));
ok(inbuf.refcount == 2, "Got refcount %d.\n", inbuf.refcount);
output.pBuffer = &outbuf.IMediaBuffer_iface;
outbuf.len = 0;
outbuf.maxlen = 5000;
hr = IMediaObject_ProcessOutput(dmo, 0, 1, &output, &status);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(outbuf.len > 1152 && outbuf.len <= 5000, "got %u\n", written);
IMediaObject_Release(dmo);
ok(inbuf.refcount == 1, "Got outstanding refcount %d.\n", inbuf.refcount);
ok(outbuf.refcount == 1, "Got outstanding refcount %d.\n", outbuf.refcount);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment