Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/amstream/audiostream.c | 20 +++++++++++++++++++- dlls/amstream/tests/amstream.c | 10 +++++----- 2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index 112891eeb7..c3831544d6 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -821,6 +821,17 @@ static HRESULT WINAPI enum_media_types_Next(IEnumMediaTypes *iface, ULONG count, { struct enum_media_types *enum_media_types = impl_from_IEnumMediaTypes(iface);
+ static const WAVEFORMATEX wfx = + { + .wFormatTag = WAVE_FORMAT_PCM, + .nChannels = 1, + .nSamplesPerSec = 11025, + .nAvgBytesPerSec = 11025 * 2, + .nBlockAlign = 2, + .wBitsPerSample = 16, + .cbSize = 0, + }; + TRACE("iface %p, count %u, mts %p, ret_count %p.\n", iface, count, mts, ret_count);
if (!ret_count) @@ -831,7 +842,14 @@ static HRESULT WINAPI enum_media_types_Next(IEnumMediaTypes *iface, ULONG count, mts[0] = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); memset(mts[0], 0, sizeof(AM_MEDIA_TYPE)); mts[0]->majortype = MEDIATYPE_Audio; - mts[0]->subtype = MEDIASUBTYPE_PCM; + mts[0]->subtype = GUID_NULL; + mts[0]->bFixedSizeSamples = TRUE; + mts[0]->bTemporalCompression = FALSE; + mts[0]->lSampleSize = 2; + mts[0]->formattype = FORMAT_WaveFormatEx; + mts[0]->cbFormat = sizeof(WAVEFORMATEX); + mts[0]->pbFormat = (BYTE *)&wfx; + ++enum_media_types->index; *ret_count = 1; return count == 1 ? S_OK : S_FALSE; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 68d2b9c18f..da9633feec 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -2426,15 +2426,15 @@ static void test_media_types(void) ok(count == 1, "Got count %u.\n", count); ok(IsEqualGUID(&pmt->majortype, &MEDIATYPE_Audio), "Got major type %s\n", wine_dbgstr_guid(&pmt->majortype)); - todo_wine ok(IsEqualGUID(&pmt->subtype, &GUID_NULL), "Got subtype %s\n", + ok(IsEqualGUID(&pmt->subtype, &GUID_NULL), "Got subtype %s\n", wine_dbgstr_guid(&pmt->subtype)); - todo_wine ok(pmt->bFixedSizeSamples == TRUE, "Got fixed size %d.\n", pmt->bFixedSizeSamples); + ok(pmt->bFixedSizeSamples == TRUE, "Got fixed size %d.\n", pmt->bFixedSizeSamples); ok(!pmt->bTemporalCompression, "Got temporal compression %d.\n", pmt->bTemporalCompression); - todo_wine ok(pmt->lSampleSize == 2, "Got sample size %u.\n", pmt->lSampleSize); - todo_wine ok(IsEqualGUID(&pmt->formattype, &FORMAT_WaveFormatEx), "Got format type %s.\n", + ok(pmt->lSampleSize == 2, "Got sample size %u.\n", pmt->lSampleSize); + ok(IsEqualGUID(&pmt->formattype, &FORMAT_WaveFormatEx), "Got format type %s.\n", wine_dbgstr_guid(&pmt->formattype)); ok(!pmt->pUnk, "Got pUnk %p.\n", pmt->pUnk); - todo_wine ok(pmt->cbFormat == sizeof(WAVEFORMATEX), "Got format size %u.\n", pmt->cbFormat); + ok(pmt->cbFormat == sizeof(WAVEFORMATEX), "Got format size %u.\n", pmt->cbFormat); ok(!memcmp(pmt->pbFormat, &expect_wfx, pmt->cbFormat), "Format blocks didn't match.\n");
hr = IPin_QueryAccept(pin, pmt);
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/amstream/audiostream.c | 2 ++ dlls/amstream/tests/amstream.c | 3 +++ 2 files changed, 5 insertions(+)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index c3831544d6..193e77f755 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -201,6 +201,7 @@ static ULONG WINAPI IAudioStreamSampleImpl_Release(IAudioStreamSample *iface)
if (!ref) { + IAMMediaStream_Release(&This->parent->IAMMediaStream_iface); CloseHandle(This->update_event); HeapFree(GetProcessHeap(), 0, This); } @@ -375,6 +376,7 @@ static HRESULT audiostreamsample_create(struct audio_stream *parent, IAudioData object->IAudioStreamSample_iface.lpVtbl = &AudioStreamSample_Vtbl; object->ref = 1; object->parent = parent; + IAMMediaStream_AddRef(&parent->IAMMediaStream_iface); object->audio_data = audio_data; object->update_event = CreateEventW(NULL, FALSE, FALSE, NULL);
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index da9633feec..e2148225ce 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1421,8 +1421,11 @@ static void test_media_streams(void)
hr = IAudioMediaStream_CreateSample(audio_media_stream, NULL, 0, &audio_sample); ok(hr == E_POINTER, "IAudioMediaStream_CreateSample returned: %x\n", hr); + + EXPECT_REF(audio_stream, 3); hr = IAudioMediaStream_CreateSample(audio_media_stream, audio_data, 0, &audio_sample); ok(hr == S_OK, "IAudioMediaStream_CreateSample returned: %x\n", hr); + EXPECT_REF(audio_stream, 4);
hr = IAudioMediaStream_GetMultiMediaStream(audio_media_stream, NULL); ok(hr == E_POINTER, "Expected E_POINTER, got %x\n", hr);
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/amstream/audiostream.c | 2 ++ dlls/amstream/tests/amstream.c | 2 ++ 2 files changed, 4 insertions(+)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index 193e77f755..72cb07f8c3 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -202,6 +202,7 @@ static ULONG WINAPI IAudioStreamSampleImpl_Release(IAudioStreamSample *iface) if (!ref) { IAMMediaStream_Release(&This->parent->IAMMediaStream_iface); + IAudioData_Release(This->audio_data); CloseHandle(This->update_event); HeapFree(GetProcessHeap(), 0, This); } @@ -378,6 +379,7 @@ static HRESULT audiostreamsample_create(struct audio_stream *parent, IAudioData object->parent = parent; IAMMediaStream_AddRef(&parent->IAMMediaStream_iface); object->audio_data = audio_data; + IAudioData_AddRef(audio_data); object->update_event = CreateEventW(NULL, FALSE, FALSE, NULL);
*audio_stream_sample = &object->IAudioStreamSample_iface; diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index e2148225ce..8df8b4c011 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -1423,9 +1423,11 @@ static void test_media_streams(void) ok(hr == E_POINTER, "IAudioMediaStream_CreateSample returned: %x\n", hr);
EXPECT_REF(audio_stream, 3); + EXPECT_REF(audio_data, 1); hr = IAudioMediaStream_CreateSample(audio_media_stream, audio_data, 0, &audio_sample); ok(hr == S_OK, "IAudioMediaStream_CreateSample returned: %x\n", hr); EXPECT_REF(audio_stream, 4); + EXPECT_REF(audio_data, 2);
hr = IAudioMediaStream_GetMultiMediaStream(audio_media_stream, NULL); ok(hr == E_POINTER, "Expected E_POINTER, got %x\n", hr);
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/amstream/audiostream.c | 12 ++++++-- dlls/amstream/tests/amstream.c | 52 ++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index 72cb07f8c3..72bfd1c3a7 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -213,9 +213,17 @@ static ULONG WINAPI IAudioStreamSampleImpl_Release(IAudioStreamSample *iface) /*** IStreamSample methods ***/ static HRESULT WINAPI IAudioStreamSampleImpl_GetMediaStream(IAudioStreamSample *iface, IMediaStream **media_stream) { - FIXME("(%p)->(%p): stub\n", iface, media_stream); + IAudioStreamSampleImpl *sample = impl_from_IAudioStreamSample(iface);
- return E_NOTIMPL; + TRACE("sample %p, media_stream %p.\n", iface, media_stream); + + if (!media_stream) + return E_POINTER; + + IAMMediaStream_AddRef(&sample->parent->IAMMediaStream_iface); + *media_stream = (IMediaStream *)&sample->parent->IAMMediaStream_iface; + + return S_OK; }
static HRESULT WINAPI IAudioStreamSampleImpl_GetSampleTimes(IAudioStreamSample *iface, STREAM_TIME *start_time, diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 8df8b4c011..ddebd10c0a 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -5287,6 +5287,57 @@ static void test_ddrawstream_getsetdirectdraw(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_audiostreamsample_get_media_stream(void) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IAudioStreamSample *audio_sample; + IAudioMediaStream *audio_stream; + IMediaStream *stream, *stream2; + IAudioData *audio_data; + HRESULT hr; + ULONG ref; + + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, &stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaStream_QueryInterface(stream, &IID_IAudioMediaStream, (void **)&audio_stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = CoCreateInstance(&CLSID_AMAudioData, NULL, CLSCTX_INPROC_SERVER, &IID_IAudioData, (void **)&audio_data); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAudioMediaStream_CreateSample(audio_stream, audio_data, 0, &audio_sample); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + /* Crashes on native. */ + if (0) + { + hr = IAudioStreamSample_GetMediaStream(audio_sample, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + } + + EXPECT_REF(stream, 4); + hr = IAudioStreamSample_GetMediaStream(audio_sample, &stream2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(stream2 == stream, "Expected stream %p, got %p.\n", stream, stream2); + EXPECT_REF(stream, 5); + + IMediaStream_Release(stream2); + + IAudioMediaStream_Release(audio_stream); + ref = IAudioStreamSample_Release(audio_sample); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IAudioData_Release(audio_data); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IMediaStream_Release(stream); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + START_TEST(amstream) { const WCHAR *test_avi_path; @@ -5332,6 +5383,7 @@ START_TEST(amstream) test_audiostreamsample_update(); test_audiostreamsample_completion_status(); test_audiostreamsample_get_sample_times(); + test_audiostreamsample_get_media_stream();
test_ddrawstream_initialize(); test_ddrawstream_getsetdirectdraw();
Signed-off-by: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/amstream/audiostream.c | 12 +++++++-- dlls/amstream/tests/amstream.c | 48 ++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 2 deletions(-)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index 72bfd1c3a7..3610cd0353 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -351,9 +351,17 @@ static HRESULT WINAPI IAudioStreamSampleImpl_CompletionStatus(IAudioStreamSample /*** IAudioStreamSample methods ***/ static HRESULT WINAPI IAudioStreamSampleImpl_GetAudioData(IAudioStreamSample *iface, IAudioData **audio_data) { - FIXME("(%p)->(%p): stub\n", iface, audio_data); + IAudioStreamSampleImpl *sample = impl_from_IAudioStreamSample(iface);
- return E_NOTIMPL; + TRACE("sample %p, audio_data %p.\n", sample, audio_data); + + if (!audio_data) + return E_POINTER; + + IAudioData_AddRef(sample->audio_data); + *audio_data = sample->audio_data; + + return S_OK; }
static const struct IAudioStreamSampleVtbl AudioStreamSample_Vtbl = diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index ddebd10c0a..595abbb0f9 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -5338,6 +5338,53 @@ static void test_audiostreamsample_get_media_stream(void) ok(!ref, "Got outstanding refcount %d.\n", ref); }
+static void test_audiostreamsample_get_audio_data(void) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IAudioData *audio_data, *audio_data2; + IAudioStreamSample *audio_sample; + IAudioMediaStream *audio_stream; + IMediaStream *stream; + HRESULT hr; + ULONG ref; + + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, &stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaStream_QueryInterface(stream, &IID_IAudioMediaStream, (void **)&audio_stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = CoCreateInstance(&CLSID_AMAudioData, NULL, CLSCTX_INPROC_SERVER, &IID_IAudioData, (void **)&audio_data); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAudioMediaStream_CreateSample(audio_stream, audio_data, 0, &audio_sample); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAudioStreamSample_GetAudioData(audio_sample, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + EXPECT_REF(audio_data, 2); + hr = IAudioStreamSample_GetAudioData(audio_sample, &audio_data2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(audio_data2 == audio_data, "Expected audio data %p, got %p.\n", audio_data, audio_data2); + EXPECT_REF(audio_data, 3); + + IAudioData_Release(audio_data2); + + IAudioMediaStream_Release(audio_stream); + ref = IAudioStreamSample_Release(audio_sample); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IAudioData_Release(audio_data); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + ref = IMediaStream_Release(stream); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + START_TEST(amstream) { const WCHAR *test_avi_path; @@ -5384,6 +5431,7 @@ START_TEST(amstream) test_audiostreamsample_completion_status(); test_audiostreamsample_get_sample_times(); test_audiostreamsample_get_media_stream(); + test_audiostreamsample_get_audio_data();
test_ddrawstream_initialize(); test_ddrawstream_getsetdirectdraw();
Signed-off-by: Zebediah Figura z.figura12@gmail.com
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com --- dlls/amstream/audiostream.c | 98 ++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 51 deletions(-)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index 3610cd0353..03c32c0cf8 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -63,7 +63,8 @@ struct audio_stream struct list update_queue; };
-typedef struct { +struct audio_sample +{ IAudioStreamSample IAudioStreamSample_iface; LONG ref; struct audio_stream *parent; @@ -77,7 +78,7 @@ typedef struct { BYTE *pointer; DWORD position; HRESULT update_hr; -} IAudioStreamSampleImpl; +};
static void remove_queued_receive(struct queued_receive *receive) { @@ -86,7 +87,7 @@ static void remove_queued_receive(struct queued_receive *receive) free(receive); }
-static void remove_queued_update(IAudioStreamSampleImpl *sample) +static void remove_queued_update(struct audio_sample *sample) { HRESULT hr;
@@ -112,7 +113,7 @@ static STREAM_TIME stream_time_from_position(struct audio_stream *stream, struct return receive->start_time + (receive->position * 10000000 + format->nAvgBytesPerSec / 2) / format->nAvgBytesPerSec; }
-static void process_update(IAudioStreamSampleImpl *sample, struct queued_receive *receive) +static void process_update(struct audio_sample *sample, struct queued_receive *receive) { DWORD advance;
@@ -134,7 +135,7 @@ static void process_updates(struct audio_stream *stream) { while (!list_empty(&stream->update_queue) && !list_empty(&stream->receive_queue)) { - IAudioStreamSampleImpl *sample = LIST_ENTRY(list_head(&stream->update_queue), IAudioStreamSampleImpl, entry); + struct audio_sample *sample = LIST_ENTRY(list_head(&stream->update_queue), struct audio_sample, entry); struct queued_receive *receive = LIST_ENTRY(list_head(&stream->receive_queue), struct queued_receive, entry);
process_update(sample, receive); @@ -148,7 +149,7 @@ static void process_updates(struct audio_stream *stream) { while (!list_empty(&stream->update_queue)) { - IAudioStreamSampleImpl *sample = LIST_ENTRY(list_head(&stream->update_queue), IAudioStreamSampleImpl, entry); + struct audio_sample *sample = LIST_ENTRY(list_head(&stream->update_queue), struct audio_sample, entry);
sample->update_hr = sample->position ? S_OK : MS_S_ENDOFSTREAM; remove_queued_update(sample); @@ -156,13 +157,13 @@ static void process_updates(struct audio_stream *stream) } }
-static inline IAudioStreamSampleImpl *impl_from_IAudioStreamSample(IAudioStreamSample *iface) +static inline struct audio_sample *impl_from_IAudioStreamSample(IAudioStreamSample *iface) { - return CONTAINING_RECORD(iface, IAudioStreamSampleImpl, IAudioStreamSample_iface); + return CONTAINING_RECORD(iface, struct audio_sample, IAudioStreamSample_iface); }
/*** IUnknown methods ***/ -static HRESULT WINAPI IAudioStreamSampleImpl_QueryInterface(IAudioStreamSample *iface, +static HRESULT WINAPI audio_sample_QueryInterface(IAudioStreamSample *iface, REFIID riid, void **ret_iface) { TRACE("(%p)->(%s,%p)\n", iface, debugstr_guid(riid), ret_iface); @@ -182,38 +183,33 @@ static HRESULT WINAPI IAudioStreamSampleImpl_QueryInterface(IAudioStreamSample * return E_NOINTERFACE; }
-static ULONG WINAPI IAudioStreamSampleImpl_AddRef(IAudioStreamSample *iface) +static ULONG WINAPI audio_sample_AddRef(IAudioStreamSample *iface) { - IAudioStreamSampleImpl *This = impl_from_IAudioStreamSample(iface); - ULONG ref = InterlockedIncrement(&This->ref); - - TRACE("(%p)->(): new ref = %u\n", iface, ref); - - return ref; + struct audio_sample *sample = impl_from_IAudioStreamSample(iface); + ULONG refcount = InterlockedIncrement(&sample->ref); + TRACE("%p increasing refcount to %u.\n", sample, refcount); + return refcount; }
-static ULONG WINAPI IAudioStreamSampleImpl_Release(IAudioStreamSample *iface) +static ULONG WINAPI audio_sample_Release(IAudioStreamSample *iface) { - IAudioStreamSampleImpl *This = impl_from_IAudioStreamSample(iface); - ULONG ref = InterlockedDecrement(&This->ref); - - TRACE("(%p)->(): new ref = %u\n", iface, ref); - - if (!ref) + struct audio_sample *sample = impl_from_IAudioStreamSample(iface); + ULONG refcount = InterlockedDecrement(&sample->ref); + TRACE("%p decreasing refcount to %u.\n", sample, refcount); + if (!refcount) { - IAMMediaStream_Release(&This->parent->IAMMediaStream_iface); - IAudioData_Release(This->audio_data); - CloseHandle(This->update_event); - HeapFree(GetProcessHeap(), 0, This); + IAMMediaStream_Release(&sample->parent->IAMMediaStream_iface); + IAudioData_Release(sample->audio_data); + CloseHandle(sample->update_event); + HeapFree(GetProcessHeap(), 0, sample); } - - return ref; + return refcount; }
/*** IStreamSample methods ***/ -static HRESULT WINAPI IAudioStreamSampleImpl_GetMediaStream(IAudioStreamSample *iface, IMediaStream **media_stream) +static HRESULT WINAPI audio_sample_GetMediaStream(IAudioStreamSample *iface, IMediaStream **media_stream) { - IAudioStreamSampleImpl *sample = impl_from_IAudioStreamSample(iface); + struct audio_sample *sample = impl_from_IAudioStreamSample(iface);
TRACE("sample %p, media_stream %p.\n", iface, media_stream);
@@ -226,10 +222,10 @@ static HRESULT WINAPI IAudioStreamSampleImpl_GetMediaStream(IAudioStreamSample * return S_OK; }
-static HRESULT WINAPI IAudioStreamSampleImpl_GetSampleTimes(IAudioStreamSample *iface, STREAM_TIME *start_time, +static HRESULT WINAPI audio_sample_GetSampleTimes(IAudioStreamSample *iface, STREAM_TIME *start_time, STREAM_TIME *end_time, STREAM_TIME *current_time) { - IAudioStreamSampleImpl *sample = impl_from_IAudioStreamSample(iface); + struct audio_sample *sample = impl_from_IAudioStreamSample(iface);
TRACE("sample %p, start_time %p, end_time %p, current_time %p.\n", sample, start_time, end_time, current_time);
@@ -244,7 +240,7 @@ static HRESULT WINAPI IAudioStreamSampleImpl_GetSampleTimes(IAudioStreamSample * return S_OK; }
-static HRESULT WINAPI IAudioStreamSampleImpl_SetSampleTimes(IAudioStreamSample *iface, const STREAM_TIME *start_time, +static HRESULT WINAPI audio_sample_SetSampleTimes(IAudioStreamSample *iface, const STREAM_TIME *start_time, const STREAM_TIME *end_time) { FIXME("(%p)->(%p,%p): stub\n", iface, start_time, end_time); @@ -252,10 +248,10 @@ static HRESULT WINAPI IAudioStreamSampleImpl_SetSampleTimes(IAudioStreamSample * return E_NOTIMPL; }
-static HRESULT WINAPI IAudioStreamSampleImpl_Update(IAudioStreamSample *iface, +static HRESULT WINAPI audio_sample_Update(IAudioStreamSample *iface, DWORD flags, HANDLE event, PAPCFUNC apc_func, DWORD apc_data) { - IAudioStreamSampleImpl *sample = impl_from_IAudioStreamSample(iface); + struct audio_sample *sample = impl_from_IAudioStreamSample(iface); BYTE *pointer; DWORD length; HRESULT hr; @@ -326,9 +322,9 @@ static HRESULT WINAPI IAudioStreamSampleImpl_Update(IAudioStreamSample *iface, return sample->update_hr; }
-static HRESULT WINAPI IAudioStreamSampleImpl_CompletionStatus(IAudioStreamSample *iface, DWORD flags, DWORD milliseconds) +static HRESULT WINAPI audio_sample_CompletionStatus(IAudioStreamSample *iface, DWORD flags, DWORD milliseconds) { - IAudioStreamSampleImpl *sample = impl_from_IAudioStreamSample(iface); + struct audio_sample *sample = impl_from_IAudioStreamSample(iface); HRESULT hr;
TRACE("sample %p, flags %#x, milliseconds %u.\n", sample, flags, milliseconds); @@ -349,9 +345,9 @@ static HRESULT WINAPI IAudioStreamSampleImpl_CompletionStatus(IAudioStreamSample }
/*** IAudioStreamSample methods ***/ -static HRESULT WINAPI IAudioStreamSampleImpl_GetAudioData(IAudioStreamSample *iface, IAudioData **audio_data) +static HRESULT WINAPI audio_sample_GetAudioData(IAudioStreamSample *iface, IAudioData **audio_data) { - IAudioStreamSampleImpl *sample = impl_from_IAudioStreamSample(iface); + struct audio_sample *sample = impl_from_IAudioStreamSample(iface);
TRACE("sample %p, audio_data %p.\n", sample, audio_data);
@@ -367,26 +363,26 @@ static HRESULT WINAPI IAudioStreamSampleImpl_GetAudioData(IAudioStreamSample *if static const struct IAudioStreamSampleVtbl AudioStreamSample_Vtbl = { /*** IUnknown methods ***/ - IAudioStreamSampleImpl_QueryInterface, - IAudioStreamSampleImpl_AddRef, - IAudioStreamSampleImpl_Release, + audio_sample_QueryInterface, + audio_sample_AddRef, + audio_sample_Release, /*** IStreamSample methods ***/ - IAudioStreamSampleImpl_GetMediaStream, - IAudioStreamSampleImpl_GetSampleTimes, - IAudioStreamSampleImpl_SetSampleTimes, - IAudioStreamSampleImpl_Update, - IAudioStreamSampleImpl_CompletionStatus, + audio_sample_GetMediaStream, + audio_sample_GetSampleTimes, + audio_sample_SetSampleTimes, + audio_sample_Update, + audio_sample_CompletionStatus, /*** IAudioStreamSample methods ***/ - IAudioStreamSampleImpl_GetAudioData + audio_sample_GetAudioData };
static HRESULT audiostreamsample_create(struct audio_stream *parent, IAudioData *audio_data, IAudioStreamSample **audio_stream_sample) { - IAudioStreamSampleImpl *object; + struct audio_sample *object;
TRACE("(%p)\n", audio_stream_sample);
- object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAudioStreamSampleImpl)); + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)); if (!object) return E_OUTOFMEMORY;
Signed-off-by: Zebediah Figura z.figura12@gmail.com
On 7/29/20 5:30 AM, Gijs Vermeulen wrote:
Signed-off-by: Gijs Vermeulen gijsvrm@gmail.com
dlls/amstream/audiostream.c | 20 +++++++++++++++++++- dlls/amstream/tests/amstream.c | 10 +++++----- 2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/dlls/amstream/audiostream.c b/dlls/amstream/audiostream.c index 112891eeb7..c3831544d6 100644 --- a/dlls/amstream/audiostream.c +++ b/dlls/amstream/audiostream.c @@ -821,6 +821,17 @@ static HRESULT WINAPI enum_media_types_Next(IEnumMediaTypes *iface, ULONG count, { struct enum_media_types *enum_media_types = impl_from_IEnumMediaTypes(iface);
static const WAVEFORMATEX wfx =
{
.wFormatTag = WAVE_FORMAT_PCM,
.nChannels = 1,
.nSamplesPerSec = 11025,
.nAvgBytesPerSec = 11025 * 2,
.nBlockAlign = 2,
.wBitsPerSample = 16,
.cbSize = 0,
};
TRACE("iface %p, count %u, mts %p, ret_count %p.\n", iface, count, mts, ret_count);
if (!ret_count)
@@ -831,7 +842,14 @@ static HRESULT WINAPI enum_media_types_Next(IEnumMediaTypes *iface, ULONG count, mts[0] = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); memset(mts[0], 0, sizeof(AM_MEDIA_TYPE)); mts[0]->majortype = MEDIATYPE_Audio;
mts[0]->subtype = MEDIASUBTYPE_PCM;
mts[0]->subtype = GUID_NULL;
mts[0]->bFixedSizeSamples = TRUE;
mts[0]->bTemporalCompression = FALSE;
mts[0]->lSampleSize = 2;
mts[0]->formattype = FORMAT_WaveFormatEx;
mts[0]->cbFormat = sizeof(WAVEFORMATEX);
mts[0]->pbFormat = (BYTE *)&wfx;
This needs to be allocated with CoTaskMemAlloc().
++enum_media_types->index; *ret_count = 1; return count == 1 ? S_OK : S_FALSE;
diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 68d2b9c18f..da9633feec 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -2426,15 +2426,15 @@ static void test_media_types(void) ok(count == 1, "Got count %u.\n", count); ok(IsEqualGUID(&pmt->majortype, &MEDIATYPE_Audio), "Got major type %s\n", wine_dbgstr_guid(&pmt->majortype));
- todo_wine ok(IsEqualGUID(&pmt->subtype, &GUID_NULL), "Got subtype %s\n",
- ok(IsEqualGUID(&pmt->subtype, &GUID_NULL), "Got subtype %s\n", wine_dbgstr_guid(&pmt->subtype));
- todo_wine ok(pmt->bFixedSizeSamples == TRUE, "Got fixed size %d.\n", pmt->bFixedSizeSamples);
- ok(pmt->bFixedSizeSamples == TRUE, "Got fixed size %d.\n", pmt->bFixedSizeSamples); ok(!pmt->bTemporalCompression, "Got temporal compression %d.\n", pmt->bTemporalCompression);
- todo_wine ok(pmt->lSampleSize == 2, "Got sample size %u.\n", pmt->lSampleSize);
- todo_wine ok(IsEqualGUID(&pmt->formattype, &FORMAT_WaveFormatEx), "Got format type %s.\n",
- ok(pmt->lSampleSize == 2, "Got sample size %u.\n", pmt->lSampleSize);
- ok(IsEqualGUID(&pmt->formattype, &FORMAT_WaveFormatEx), "Got format type %s.\n", wine_dbgstr_guid(&pmt->formattype)); ok(!pmt->pUnk, "Got pUnk %p.\n", pmt->pUnk);
- todo_wine ok(pmt->cbFormat == sizeof(WAVEFORMATEX), "Got format size %u.\n", pmt->cbFormat);
ok(pmt->cbFormat == sizeof(WAVEFORMATEX), "Got format size %u.\n", pmt->cbFormat); ok(!memcmp(pmt->pbFormat, &expect_wfx, pmt->cbFormat), "Format blocks didn't match.\n");
hr = IPin_QueryAccept(pin, pmt);