avifil32: Implement AVISave[A|W] by forwarding to AVISaveV

Andrew Eikum aeikum at codeweavers.com
Fri Oct 23 15:05:18 CDT 2015


Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>

On Fri, Oct 23, 2015 at 04:12:53AM +0800, Bruno Jesus wrote:
> Signed-off-by: Bruno Jesus <00cpxxx at gmail.com>
> 
> Used by Google Sketchup 6 codec tests in the codec selection window.
> 
> Both functions are identical with the exception of one debugstr and
> the forwarded call to AVISaveV[A|W].
> 
> I don't know if it'is possible to forward a va_list to other function,
> if that was possible we could make AVISaveA call AVISaveW.

> diff --git a/dlls/avifil32/api.c b/dlls/avifil32/api.c
> index 20985cd..4612611 100644
> --- a/dlls/avifil32/api.c
> +++ b/dlls/avifil32/api.c
> @@ -2278,17 +2278,85 @@ HRESULT WINAPI AVIPutFileOnClipboard(PAVIFILE pfile)
>  HRESULT WINAPIV AVISaveA(LPCSTR szFile, CLSID * pclsidHandler, AVISAVECALLBACK lpfnCallback,
>                          int nStreams, PAVISTREAM pavi, LPAVICOMPRESSOPTIONS lpOptions, ...)
>  {
> -    FIXME("(%s,%p,%p,0x%08x,%p,%p), stub!\n", debugstr_a(szFile), pclsidHandler, lpfnCallback,
> +    va_list vl;
> +    int i;
> +    HRESULT ret;
> +    PAVISTREAM *streams;
> +    LPAVICOMPRESSOPTIONS *options;
> +
> +    TRACE("(%s,%p,%p,%d,%p,%p)\n", debugstr_a(szFile), pclsidHandler, lpfnCallback,
>            nStreams, pavi, lpOptions);
>  
> -    return AVIERR_UNSUPPORTED;
> +    if (nStreams <= 0) return AVIERR_BADPARAM;
> +
> +    streams = HeapAlloc(GetProcessHeap(), 0, nStreams * sizeof(void *));
> +    options = HeapAlloc(GetProcessHeap(), 0, nStreams * sizeof(void *));
> +    if (!streams || !options)
> +    {
> +        ret = AVIERR_MEMORY;
> +        goto error;
> +    }
> +
> +    streams[0] = pavi;
> +    options[0] = lpOptions;
> +
> +    va_start(vl, lpOptions);
> +    for (i = 1; i < nStreams; i++)
> +    {
> +        streams[i] = va_arg(vl, void *);
> +        options[i] = va_arg(vl, void *);
> +    }
> +    va_end(vl);
> +
> +    for (i = 0; i < nStreams; i++)
> +        TRACE("Pair[%d] - Stream = %p, Options = %p\n", i, streams[i], options[i]);
> +
> +    ret = AVISaveVA(szFile, pclsidHandler, lpfnCallback, nStreams, streams, options);
> +error:
> +    HeapFree(GetProcessHeap(), 0, streams);
> +    HeapFree(GetProcessHeap(), 0, options);
> +    return ret;
>  }
>  
>  HRESULT WINAPIV AVISaveW(LPCWSTR szFile, CLSID * pclsidHandler, AVISAVECALLBACK lpfnCallback,
>                          int nStreams, PAVISTREAM pavi, LPAVICOMPRESSOPTIONS lpOptions, ...)
>  {
> -    FIXME("(%s,%p,%p,0x%08x,%p,%p), stub!\n", debugstr_w(szFile), pclsidHandler, lpfnCallback,
> +    va_list vl;
> +    int i;
> +    HRESULT ret;
> +    PAVISTREAM *streams;
> +    LPAVICOMPRESSOPTIONS *options;
> +
> +    TRACE("(%s,%p,%p,%d,%p,%p)\n", debugstr_w(szFile), pclsidHandler, lpfnCallback,
>            nStreams, pavi, lpOptions);
>  
> -    return AVIERR_UNSUPPORTED;
> +    if (nStreams <= 0) return AVIERR_BADPARAM;
> +
> +    streams = HeapAlloc(GetProcessHeap(), 0, nStreams * sizeof(void *));
> +    options = HeapAlloc(GetProcessHeap(), 0, nStreams * sizeof(void *));
> +    if (!streams || !options)
> +    {
> +        ret = AVIERR_MEMORY;
> +        goto error;
> +    }
> +
> +    streams[0] = pavi;
> +    options[0] = lpOptions;
> +
> +    va_start(vl, lpOptions);
> +    for (i = 1; i < nStreams; i++)
> +    {
> +        streams[i] = va_arg(vl, void *);
> +        options[i] = va_arg(vl, void *);
> +    }
> +    va_end(vl);
> +
> +    for (i = 0; i < nStreams; i++)
> +        TRACE("Pair[%d] - Stream = %p, Options = %p\n", i, streams[i], options[i]);
> +
> +    ret = AVISaveVW(szFile, pclsidHandler, lpfnCallback, nStreams, streams, options);
> +error:
> +    HeapFree(GetProcessHeap(), 0, streams);
> +    HeapFree(GetProcessHeap(), 0, options);
> +    return ret;
>  }

> 




More information about the wine-patches mailing list