Skip to content

Commit

Permalink
sapi: Introduce create_token_category helper in tts.
Browse files Browse the repository at this point in the history
  • Loading branch information
shaunren authored and julliard committed Feb 20, 2024
1 parent 4bbfd83 commit 0f8b59a
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions dlls/sapi/tts.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ static inline struct tts_engine_site *impl_from_ISpTTSEngineSite(ISpTTSEngineSit
return CONTAINING_RECORD(iface, struct tts_engine_site, ISpTTSEngineSite_iface);
}

static HRESULT create_token_category(const WCHAR *cat_id, ISpObjectTokenCategory **cat)
{
HRESULT hr;
if (FAILED(hr = CoCreateInstance(&CLSID_SpObjectTokenCategory, NULL, CLSCTX_INPROC_SERVER,
&IID_ISpObjectTokenCategory, (void **)cat)))
return hr;
return ISpObjectTokenCategory_SetId(*cat, cat_id, FALSE);
}

static HRESULT create_default_token(const WCHAR *cat_id, ISpObjectToken **token)
{
ISpObjectTokenCategory *cat;
Expand All @@ -90,17 +99,13 @@ static HRESULT create_default_token(const WCHAR *cat_id, ISpObjectToken **token)

TRACE("(%s, %p).\n", debugstr_w(cat_id), token);

if (FAILED(hr = CoCreateInstance(&CLSID_SpObjectTokenCategory, NULL, CLSCTX_INPROC_SERVER,
&IID_ISpObjectTokenCategory, (void **)&cat)))
if (FAILED(hr = create_token_category(cat_id, &cat)))
return hr;

if (FAILED(hr = ISpObjectTokenCategory_SetId(cat, cat_id, FALSE)) ||
FAILED(hr = ISpObjectTokenCategory_GetDefaultTokenId(cat, &default_token_id)))
{
ISpObjectTokenCategory_Release(cat);
return hr;
}
hr = ISpObjectTokenCategory_GetDefaultTokenId(cat, &default_token_id);
ISpObjectTokenCategory_Release(cat);
if (FAILED(hr))
return hr;

if (FAILED(hr = CoCreateInstance(&CLSID_SpObjectToken, NULL, CLSCTX_INPROC_SERVER,
&IID_ISpObjectToken, (void **)token)))
Expand Down

0 comments on commit 0f8b59a

Please sign in to comment.