Commit ed7762c1 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

mfsrcsnk/wave: Add a sink stub.

parent 73d6ca6e
......@@ -21602,6 +21602,7 @@ wine_fn_config_makefile dlls/mfplay/tests enable_tests
wine_fn_config_makefile dlls/mfreadwrite enable_mfreadwrite
wine_fn_config_makefile dlls/mfreadwrite/tests enable_tests
wine_fn_config_makefile dlls/mfsrcsnk enable_mfsrcsnk
wine_fn_config_makefile dlls/mfsrcsnk/tests enable_tests
wine_fn_config_makefile dlls/mgmtapi enable_mgmtapi
wine_fn_config_makefile dlls/midimap enable_midimap
wine_fn_config_makefile dlls/mlang enable_mlang
......
......@@ -2741,6 +2741,7 @@ WINE_CONFIG_MAKEFILE(dlls/mfplay/tests)
WINE_CONFIG_MAKEFILE(dlls/mfreadwrite)
WINE_CONFIG_MAKEFILE(dlls/mfreadwrite/tests)
WINE_CONFIG_MAKEFILE(dlls/mfsrcsnk)
WINE_CONFIG_MAKEFILE(dlls/mfsrcsnk/tests)
WINE_CONFIG_MAKEFILE(dlls/mgmtapi)
WINE_CONFIG_MAKEFILE(dlls/midimap)
WINE_CONFIG_MAKEFILE(dlls/mlang)
......
MODULE = mfsrcsnk.dll
IMPORTLIB = mfsrcsnk
IMPORTS = mfplat mfuuid uuid
EXTRADLLFLAGS = -Wb,--prefer-native
......
TESTDLL = mfsrcsnk.dll
IMPORTS = ole32 mfsrcsnk mfplat uuid mfuuid
C_SRCS = \
mfsrcsnk.c
/*
* Copyright 2022 Nikolay Sivov for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <string.h>
#define COBJMACROS
#include "windef.h"
#include "mfapi.h"
#include "mfidl.h"
#include "mferror.h"
#include "wine/test.h"
#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c)
static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported)
{
IUnknown *iface = iface_ptr;
HRESULT hr, expected_hr;
IUnknown *unk;
expected_hr = supported ? S_OK : E_NOINTERFACE;
hr = IUnknown_QueryInterface(iface, iid, (void **)&unk);
ok_(__FILE__, line)(hr == expected_hr, "Got hr %#lx, expected %#lx.\n", hr, expected_hr);
if (SUCCEEDED(hr))
IUnknown_Release(unk);
}
static void test_wave_sink(void)
{
IMFStreamSink *stream_sink;
IMFMediaSink *sink, *sink2;
IMFByteStream *bytestream;
IMFMediaType *media_type;
DWORD id, count, flags;
HRESULT hr;
hr = MFCreateWAVEMediaSink(NULL, NULL, NULL);
ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
hr = MFCreateWAVEMediaSink(NULL, NULL, &sink);
ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
hr = MFCreateMediaType(&media_type);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BLOCK_ALIGNMENT, 2);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_NUM_CHANNELS, 2);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_SetGUID(media_type, &MF_MT_MAJOR_TYPE, &MFMediaType_Audio);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_SetGUID(media_type, &MF_MT_SUBTYPE, &MFAudioFormat_PCM);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_SAMPLES_PER_SECOND, 44100);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaType_SetUINT32(media_type, &MF_MT_AUDIO_BITS_PER_SAMPLE, 8);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = MFCreateTempFile(MF_ACCESSMODE_WRITE, MF_OPENMODE_DELETE_IF_EXIST, 0, &bytestream);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = MFCreateWAVEMediaSink(bytestream, NULL, &sink);
ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
hr = MFCreateWAVEMediaSink(bytestream, media_type, &sink);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
/* Sink tests */
hr = IMFMediaSink_GetCharacteristics(sink, &flags);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(flags == (MEDIASINK_FIXED_STREAMS | MEDIASINK_RATELESS), "Unexpected flags %#lx.\n", flags);
hr = IMFMediaSink_GetStreamSinkCount(sink, NULL);
ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSink_GetStreamSinkCount(sink, &count);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(count == 1, "Unexpected count %lu.\n", count);
hr = IMFMediaSink_AddStreamSink(sink, 123, media_type, &stream_sink);
ok(hr == MF_E_STREAMSINKS_FIXED, "Unexpected hr %#lx.\n", hr);
check_interface(sink, &IID_IMFMediaEventGenerator, TRUE);
check_interface(sink, &IID_IMFFinalizableMediaSink, TRUE);
/* Stream tests */
hr = IMFMediaSink_GetStreamSinkByIndex(sink, 0, &stream_sink);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFStreamSink_GetIdentifier(stream_sink, &id);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
ok(id == 1, "Unexpected id %#lx.\n", id);
IMFStreamSink_Release(stream_sink);
hr = IMFMediaSink_GetStreamSinkById(sink, 0, &stream_sink);
ok(hr == MF_E_INVALIDSTREAMNUMBER, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSink_GetStreamSinkById(sink, id, &stream_sink);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFStreamSink_GetMediaSink(stream_sink, &sink2);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
IMFMediaSink_Release(sink2);
/* Shutdown state */
hr = IMFMediaSink_Shutdown(sink);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSink_Shutdown(sink);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
hr = IMFStreamSink_GetMediaSink(stream_sink, &sink2);
ok(hr == MF_E_STREAMSINK_REMOVED, "Unexpected hr %#lx.\n", hr);
hr = IMFStreamSink_GetIdentifier(stream_sink, &id);
ok(hr == MF_E_STREAMSINK_REMOVED, "Unexpected hr %#lx.\n", hr);
IMFStreamSink_Release(stream_sink);
hr = IMFMediaSink_AddStreamSink(sink, 123, media_type, &stream_sink);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSink_GetStreamSinkByIndex(sink, 0, &stream_sink);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSink_GetStreamSinkById(sink, 0, &stream_sink);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
hr = IMFMediaSink_GetCharacteristics(sink, &flags);
ok(hr == MF_E_SHUTDOWN, "Unexpected hr %#lx.\n", hr);
IMFMediaSink_Release(sink);
IMFMediaType_Release(media_type);
IMFByteStream_Release(bytestream);
}
START_TEST(mfsrcsnk)
{
HRESULT hr;
hr = MFStartup(MF_VERSION, MFSTARTUP_FULL);
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
test_wave_sink();
hr = MFShutdown();
ok(hr == S_OK, "Unexpected hr %#lx.\n", hr);
}
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