Commit c46b9277 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

mp3dmod: Implement IMediaObject::Flush().

parent 1673af4c
...@@ -358,9 +358,20 @@ static HRESULT WINAPI MediaObject_SetInputMaxLatency(IMediaObject *iface, DWORD ...@@ -358,9 +358,20 @@ static HRESULT WINAPI MediaObject_SetInputMaxLatency(IMediaObject *iface, DWORD
static HRESULT WINAPI MediaObject_Flush(IMediaObject *iface) static HRESULT WINAPI MediaObject_Flush(IMediaObject *iface)
{ {
FIXME("(%p)->() stub!\n", iface); struct mp3_decoder *dmo = impl_from_IMediaObject(iface);
return E_NOTIMPL; TRACE("iface %p.\n", iface);
if (dmo->buffer)
IMediaBuffer_Release(dmo->buffer);
dmo->buffer = NULL;
dmo->timestamp = 0;
/* mpg123 doesn't give us a way to flush, so just close and reopen the feed. */
mpg123_close(dmo->mh);
mpg123_open_feed(dmo->mh);
return S_OK;
} }
static HRESULT WINAPI MediaObject_Discontinuity(IMediaObject *iface, DWORD index) static HRESULT WINAPI MediaObject_Discontinuity(IMediaObject *iface, DWORD index)
......
...@@ -230,6 +230,7 @@ static void test_convert(void) ...@@ -230,6 +230,7 @@ static void test_convert(void)
"got %s\n", wine_dbgstr_longlong(output.rtTimelength)); "got %s\n", wine_dbgstr_longlong(output.rtTimelength));
ok(inbuf.refcount == 1, "Got refcount %d.\n", inbuf.refcount); ok(inbuf.refcount == 1, "Got refcount %d.\n", inbuf.refcount);
ok(outbuf.refcount == 1, "Got refcount %d.\n", inbuf.refcount); ok(outbuf.refcount == 1, "Got refcount %d.\n", inbuf.refcount);
written += outbuf.len;
hr = IMediaObject_ProcessOutput(dmo, 0, 1, &output, &status); hr = IMediaObject_ProcessOutput(dmo, 0, 1, &output, &status);
ok(hr == S_FALSE, "got %#x\n", hr); ok(hr == S_FALSE, "got %#x\n", hr);
...@@ -277,7 +278,41 @@ static void test_convert(void) ...@@ -277,7 +278,41 @@ static void test_convert(void)
outbuf.maxlen = 5000; outbuf.maxlen = 5000;
hr = IMediaObject_ProcessOutput(dmo, 0, 1, &output, &status); hr = IMediaObject_ProcessOutput(dmo, 0, 1, &output, &status);
ok(hr == S_OK, "Got hr %#x.\n", hr); ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(outbuf.len > 1152 && outbuf.len <= 5000, "got %u\n", written); ok(outbuf.len > 1152 && outbuf.len <= 5000, "Got length %u.\n", outbuf.len);
ok(output.dwStatus == (O_SYNCPOINT | O_TIME | O_TIMELENGTH | O_INCOMPLETE),
"Got status %#x.\n", output.dwStatus);
ok(output.rtTimestamp == samplelen(written, 48000), "Got timestamp %s.\n",
wine_dbgstr_longlong(output.rtTimestamp));
ok(output.rtTimelength == samplelen(outbuf.len, 48000),
"Got length %s.\n", wine_dbgstr_longlong(output.rtTimelength));
ok(inbuf.refcount == 2, "Got refcount %d.\n", inbuf.refcount);
ok(outbuf.refcount == 1, "Got refcount %d.\n", inbuf.refcount);
hr = IMediaObject_Flush(dmo);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(inbuf.refcount == 1, "Got refcount %d.\n", inbuf.refcount);
outbuf.len = 0;
outbuf.maxlen = 5000;
hr = IMediaObject_ProcessOutput(dmo, 0, 1, &output, &status);
ok(hr == S_FALSE, "Got hr %#x.\n", hr);
hr = IMediaObject_Flush(dmo);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IMediaObject_ProcessInput(dmo, 0, &inbuf.IMediaBuffer_iface, 0, 0, 0);
ok(hr == S_OK, "got %#x\n", hr);
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 length %u.\n", outbuf.len);
ok(output.dwStatus == (O_SYNCPOINT | O_TIME | O_TIMELENGTH | O_INCOMPLETE),
"Got status %#x.\n", output.dwStatus);
ok(!output.rtTimestamp, "Got timestamp %s.\n", wine_dbgstr_longlong(output.rtTimestamp));
ok(output.rtTimelength == samplelen(outbuf.len, 48000),
"Got length %s.\n", wine_dbgstr_longlong(output.rtTimelength));
ok(inbuf.refcount == 2, "Got refcount %d.\n", inbuf.refcount);
ok(outbuf.refcount == 1, "Got refcount %d.\n", inbuf.refcount);
IMediaObject_Release(dmo); IMediaObject_Release(dmo);
ok(inbuf.refcount == 1, "Got outstanding refcount %d.\n", inbuf.refcount); ok(inbuf.refcount == 1, "Got outstanding refcount %d.\n", inbuf.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