2 * Seeking passthrough object
4 * Copyright 2020 Zebediah Figura for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "quartz_private.h"
23 WINE_DEFAULT_DEBUG_CHANNEL(quartz
);
25 struct seeking_passthrough
27 struct strmbase_passthrough passthrough
;
29 IUnknown IUnknown_inner
;
34 static struct seeking_passthrough
*impl_from_IUnknown(IUnknown
*iface
)
36 return CONTAINING_RECORD(iface
, struct seeking_passthrough
, IUnknown_inner
);
39 static HRESULT WINAPI
seeking_passthrough_QueryInterface(IUnknown
*iface
, REFIID iid
, void **out
)
41 struct seeking_passthrough
*passthrough
= impl_from_IUnknown(iface
);
43 TRACE("passthrough %p, iid %s, out %p.\n", passthrough
, debugstr_guid(iid
), out
);
45 if (IsEqualGUID(iid
, &IID_IUnknown
))
47 else if (IsEqualGUID(iid
, &IID_IMediaPosition
))
48 *out
= &passthrough
->passthrough
.IMediaPosition_iface
;
49 else if (IsEqualGUID(iid
, &IID_IMediaSeeking
))
50 *out
= &passthrough
->passthrough
.IMediaSeeking_iface
;
51 else if (IsEqualGUID(iid
, &IID_ISeekingPassThru
))
52 *out
= &passthrough
->passthrough
.ISeekingPassThru_iface
;
56 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid
));
60 IUnknown_AddRef((IUnknown
*)*out
);
64 static ULONG WINAPI
seeking_passthrough_AddRef(IUnknown
*iface
)
66 struct seeking_passthrough
*passthrough
= impl_from_IUnknown(iface
);
67 ULONG refcount
= InterlockedIncrement(&passthrough
->refcount
);
69 TRACE("%p increasing refcount to %lu.\n", passthrough
, refcount
);
73 static ULONG WINAPI
seeking_passthrough_Release(IUnknown
*iface
)
75 struct seeking_passthrough
*passthrough
= impl_from_IUnknown(iface
);
76 ULONG refcount
= InterlockedDecrement(&passthrough
->refcount
);
78 TRACE("%p decreasing refcount to %lu.\n", passthrough
, refcount
);
81 strmbase_passthrough_cleanup(&passthrough
->passthrough
);
87 static const IUnknownVtbl seeking_passthrough_vtbl
=
89 seeking_passthrough_QueryInterface
,
90 seeking_passthrough_AddRef
,
91 seeking_passthrough_Release
,
94 HRESULT
seeking_passthrough_create(IUnknown
*outer
, IUnknown
**out
)
96 struct seeking_passthrough
*object
;
98 TRACE("outer %p, out %p.\n", outer
, out
);
100 if (!(object
= calloc(1, sizeof(*object
))))
101 return E_OUTOFMEMORY
;
103 object
->IUnknown_inner
.lpVtbl
= &seeking_passthrough_vtbl
;
104 object
->outer_unk
= outer
? outer
: &object
->IUnknown_inner
;
105 object
->refcount
= 1;
107 strmbase_passthrough_init(&object
->passthrough
, object
->outer_unk
);
109 TRACE("Created seeking passthrough %p.\n", object
);
110 *out
= &object
->IUnknown_inner
;