<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 9, 2016 at 9:23 PM, Henri Verbeet <span dir="ltr"><<a href="mailto:hverbeet@gmail.com" target="_blank">hverbeet@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 9 August 2016 at 03:16, Aaryaman Vasishta <<a href="mailto:jem456.vasishta@gmail.com" target="_blank">jem456.vasishta@gmail.com</a>> wrote:<br>
>  static HRESULT WINAPI d3drm_frame3_GetScene(IDirect3<wbr>DRMFrame3 *iface, IDirect3DRMFrame3 **scene)<br>
>  {<br>
> -    FIXME("iface %p, scene %p stub!\n", iface, scene);<br>
> +    HRESULT hr;<br>
> +    IDirect3DRMFrame3 *frame = iface, *parent_frame = NULL;<br>
><br>
> -    return E_NOTIMPL;<br>
> +    TRACE("iface %p, scene %p.\n", iface, scene);<br>
> +<br>
> +    if (!scene)<br>
> +        return D3DRMERR_BADVALUE;<br>
> +<br>
> +    for (;;)<br>
> +    {<br>
> +        if (FAILED(hr = IDirect3DRMFrame3_GetParent(fr<wbr>ame, &parent_frame)))<br>
> +            return hr;<br>
> +        if (parent_frame)<br>
> +        {<br>
> +            frame = parent_frame;<br>
> +            IDirect3DRMFrame3_Release(pare<wbr>nt_frame);<br>
> +        }<br>
> +        else<br>
> +            break;<br>
> +    }<br>
</span>You could just do<br>
<br>
    if (!parent_frame)<br>
        break;<br>
<br>
More importantly though, as Stefan already mentioned, the reference<br>
counting is weird. I think the code would be much nicer if you just<br>
used impl_from_IDirect3DRMFrame3() and then followed the frame->parent<br>
pointers.<br></blockquote><div>Right, since we have internal access to the struct, why not take advantage of it? Using the approach you described is just like traversing through a linked list, simple and easier to read.<br><br></div><div>Cheers,<br></div><div>Aaryaman <br></div></div><br></div></div>