Commit 5b5cfda7 authored by Vitaly Lipatov's avatar Vitaly Lipatov

commit 14.1.0 upon wine-1.7.25

parent 8108a14b
......@@ -364,6 +364,12 @@ static HRESULT WINAPI ddrawex4_CreateSurface(IDirectDraw4 *iface, DDSURFACEDESC2
}
hr = IDirectDraw4_CreateSurface(ddrawex->parent, desc, &inner_surface, outer_unknown);
if (FAILED(hr))
{
*surface = NULL;
return hr;
}
*surface = dds_get_outer(inner_surface);
/* The wrapper created by dds_get_outer holds a reference to its inner surface. */
IDirectDrawSurface4_Release(inner_surface);
......
......@@ -2029,6 +2029,14 @@ static void AddFaceToList(FT_Face ft_face, const char *file, void *font_data_ptr
face = create_face( ft_face, face_index, file, font_data_ptr, font_data_size, flags );
family = get_family( ft_face, flags & ADDFONT_VERTICAL_FONT );
if (strlenW(family->FamilyName) >= LF_FACESIZE)
{
WARN("Ignoring %s because name is too long\n", debugstr_w(family->FamilyName));
release_face( face );
release_family( family );
return;
}
if (insert_face_in_family_list( face, family ))
{
if (flags & ADDFONT_ADD_TO_CACHE)
......
......@@ -205,6 +205,11 @@ static HRESULT invoke_source(script_ctx_t *ctx, FunctionInstance *function, IDis
scope_chain_t *scope;
HRESULT hres;
if(ctx->state == SCRIPTSTATE_UNINITIALIZED || ctx->state == SCRIPTSTATE_CLOSED) {
WARN("Script engine state does not allow running code.\n");
return E_UNEXPECTED;
}
if(!function->func_code) {
FIXME("no source\n");
return E_FAIL;
......
......@@ -3607,13 +3607,21 @@ BOOL WINAPI GetProcessAffinityMask( HANDLE hProcess, PDWORD_PTR process_mask, PD
{
NTSTATUS status = STATUS_SUCCESS;
if (system_mask) *system_mask = (1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
if (process_mask)
{
if ((status = NtQueryInformationProcess( hProcess, ProcessAffinityMask,
process_mask, sizeof(*process_mask), NULL )))
SetLastError( RtlNtStatusToDosError(status) );
}
if (system_mask && status == STATUS_SUCCESS)
{
SYSTEM_BASIC_INFORMATION info;
if ((status = NtQuerySystemInformation( SystemBasicInformation, &info, sizeof(info), NULL )))
SetLastError( RtlNtStatusToDosError(status) );
else
*system_mask = info.ActiveProcessorsAffinityMask;
}
return !status;
}
......
......@@ -3047,10 +3047,17 @@ static HRESULT WINAPI fnIMultiLanguage3_DetectOutboundCodePage(
{
MLang_impl *This = impl_from_IMultiLanguage3( iface );
FIXME("(%p)->(%08x %s %u %p %u %p %p %p)\n", This, dwFlags, debugstr_w(lpWideCharStr),
cchWideChar, puiPreferredCodePages, nPreferredCodePages, puiDetectedCodePages,
pnDetectedCodePages, lpSpecialChar);
return E_NOTIMPL;
FIXME("(%p)->(%08x %s %p %u %p %p(%u) %s)\n", This, dwFlags, debugstr_w(lpWideCharStr),
puiPreferredCodePages, nPreferredCodePages, puiDetectedCodePages,
pnDetectedCodePages, pnDetectedCodePages ? *pnDetectedCodePages : 0,
debugstr_w(lpSpecialChar));
if (!puiDetectedCodePages || !pnDetectedCodePages || !*pnDetectedCodePages)
return E_INVALIDARG;
puiDetectedCodePages[0] = CP_UTF8;
*pnDetectedCodePages = 1;
return S_OK;
}
static HRESULT WINAPI fnIMultiLanguage3_DetectOutboundCodePageInIStream(
......@@ -3065,10 +3072,17 @@ static HRESULT WINAPI fnIMultiLanguage3_DetectOutboundCodePageInIStream(
{
MLang_impl *This = impl_from_IMultiLanguage3( iface );
FIXME("(%p)->(%08x %p %p %u %p %p %p)\n", This, dwFlags, pStrIn,
FIXME("(%p)->(%08x %p %p %u %p %p(%u) %s)\n", This, dwFlags, pStrIn,
puiPreferredCodePages, nPreferredCodePages, puiDetectedCodePages,
pnDetectedCodePages, lpSpecialChar);
return E_NOTIMPL;
pnDetectedCodePages, pnDetectedCodePages ? *pnDetectedCodePages : 0,
debugstr_w(lpSpecialChar));
if (!puiDetectedCodePages || !pnDetectedCodePages || !*pnDetectedCodePages)
return E_INVALIDARG;
puiDetectedCodePages[0] = CP_UTF8;
*pnDetectedCodePages = 1;
return S_OK;
}
static const IMultiLanguage3Vtbl IMultiLanguage3_vtbl =
......
......@@ -1973,10 +1973,214 @@ todo_wine
IMLangConvertCharset_Release(convert);
}
static const char stream_data[] = "VCARD2.1test;test";
static ULONG stream_pos;
static HRESULT WINAPI stream_QueryInterface(IStream *iface, REFIID riid, void **obj)
{
ok(FALSE, "unexpected call\n");
return E_NOINTERFACE;
}
static ULONG WINAPI stream_AddRef(IStream *iface)
{
ok(FALSE, "unexpected call\n");
return 2;
}
static ULONG WINAPI stream_Release(IStream *iface)
{
ok(FALSE, "unexpected call\n");
return 1;
}
static HRESULT WINAPI stream_Read(IStream *iface, void *buf, ULONG len, ULONG *read)
{
ULONG size;
if (stream_pos == sizeof(stream_data) - 1)
{
*read = 0;
return S_FALSE;
}
size = min(sizeof(stream_data) - 1 - stream_pos, len);
memcpy(buf, stream_data + stream_pos, size);
stream_pos += size;
*read = size;
return S_OK;
}
static HRESULT WINAPI stream_Write(IStream *iface, const void *buf, ULONG len, ULONG *written)
{
ok(FALSE, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI stream_Seek(IStream *iface, LARGE_INTEGER move, DWORD origin,
ULARGE_INTEGER *newpos)
{
if (origin == STREAM_SEEK_SET)
stream_pos = move.QuadPart;
else if (origin == STREAM_SEEK_CUR)
stream_pos += move.QuadPart;
else if (origin == STREAM_SEEK_END)
stream_pos = sizeof(stream_data) - 1 - move.QuadPart;
if (newpos) newpos->QuadPart = stream_pos;
return S_OK;
}
static HRESULT WINAPI stream_SetSize(IStream *iface, ULARGE_INTEGER newsize)
{
ok(FALSE, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI stream_CopyTo(IStream *iface, IStream *stream, ULARGE_INTEGER len,
ULARGE_INTEGER *read, ULARGE_INTEGER *written)
{
ok(FALSE, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI stream_Commit(IStream *iface, DWORD flags)
{
ok(FALSE, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI stream_Revert(IStream *iface)
{
ok(FALSE, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI stream_LockRegion(IStream *iface, ULARGE_INTEGER offset,
ULARGE_INTEGER len, DWORD locktype)
{
ok(FALSE, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI stream_UnlockRegion(IStream *iface, ULARGE_INTEGER offset,
ULARGE_INTEGER len, DWORD locktype)
{
ok(FALSE, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI stream_Stat(IStream *iface, STATSTG *stg, DWORD flag)
{
ok(FALSE, "unexpected call\n");
return E_NOTIMPL;
}
static HRESULT WINAPI stream_Clone(IStream *iface, IStream **stream)
{
ok(FALSE, "unexpected call\n");
return E_NOTIMPL;
}
static const IStreamVtbl stream_vtbl =
{
stream_QueryInterface,
stream_AddRef,
stream_Release,
stream_Read,
stream_Write,
stream_Seek,
stream_SetSize,
stream_CopyTo,
stream_Commit,
stream_Revert,
stream_LockRegion,
stream_UnlockRegion,
stream_Stat,
stream_Clone
};
static IStream test_stream = { &stream_vtbl };
static void test_DetectOutboundCodePageInIStream(IMultiLanguage3 *ml)
{
HRESULT hr;
UINT nb_detected, detected[4];
UINT preferred[] = {1250,1251,1252,65001};
UINT preferred2[] = {1250,1251,1252};
nb_detected = 0;
memset(detected, 0, sizeof(detected));
hr = IMultiLanguage3_DetectOutboundCodePageInIStream(ml,
MLDETECTF_PRESERVE_ORDER, &test_stream, preferred,
sizeof(preferred)/sizeof(preferred[0]), detected, &nb_detected, NULL);
ok(hr == E_INVALIDARG, "got %08x\n", hr);
nb_detected = 1;
memset(detected, 0, sizeof(detected));
hr = IMultiLanguage3_DetectOutboundCodePageInIStream(ml,
MLDETECTF_PRESERVE_ORDER, &test_stream, preferred,
sizeof(preferred)/sizeof(preferred[0]), NULL, &nb_detected, NULL);
ok(hr == E_INVALIDARG, "got %08x\n", hr);
nb_detected = 1;
memset(detected, 0, sizeof(detected));
hr = IMultiLanguage3_DetectOutboundCodePageInIStream(ml,
MLDETECTF_PRESERVE_ORDER, &test_stream, preferred,
sizeof(preferred)/sizeof(preferred[0]), detected, &nb_detected, NULL);
ok(hr == S_OK, "got %08x\n", hr);
ok(nb_detected == 1, "got %u\n", nb_detected);
ok(detected[0] == 65001, "got %u\n", detected[0]);
nb_detected = 2;
memset(detected, 0, sizeof(detected));
hr = IMultiLanguage3_DetectOutboundCodePageInIStream(ml,
MLDETECTF_PRESERVE_ORDER, &test_stream, preferred,
sizeof(preferred)/sizeof(preferred[0]), detected, &nb_detected, NULL);
ok(hr == S_OK, "got %08x\n", hr);
todo_wine ok(nb_detected == 2, "got %u\n", nb_detected);
ok(detected[0] == 65001, "got %u\n", detected[0]);
todo_wine ok(detected[1] == 65000, "got %u\n", detected[1]);
nb_detected = 3;
memset(detected, 0, sizeof(detected));
hr = IMultiLanguage3_DetectOutboundCodePageInIStream(ml,
MLDETECTF_PRESERVE_ORDER, &test_stream, preferred,
sizeof(preferred)/sizeof(preferred[0]), detected, &nb_detected, NULL);
ok(hr == S_OK, "got %08x\n", hr);
todo_wine ok(nb_detected == 3, "got %u\n", nb_detected);
ok(detected[0] == 65001, "got %u\n", detected[0]);
todo_wine ok(detected[1] == 65000, "got %u\n", detected[1]);
todo_wine ok(detected[2] == 1200, "got %u\n", detected[2]);
nb_detected = 4;
memset(detected, 0, sizeof(detected));
hr = IMultiLanguage3_DetectOutboundCodePageInIStream(ml,
MLDETECTF_PRESERVE_ORDER, &test_stream, preferred,
sizeof(preferred)/sizeof(preferred[0]), detected, &nb_detected, NULL);
ok(hr == S_OK, "got %08x\n", hr);
todo_wine ok(nb_detected == 3, "got %u\n", nb_detected);
ok(detected[0] == 65001, "got %u\n", detected[0]);
todo_wine ok(detected[1] == 65000, "got %u\n", detected[1]);
todo_wine ok(detected[2] == 1200, "got %u\n", detected[2]);
ok(detected[3] == 0, "got %u\n", detected[3]);
nb_detected = 3;
memset(detected, 0, sizeof(detected));
hr = IMultiLanguage3_DetectOutboundCodePageInIStream(ml,
MLDETECTF_PRESERVE_ORDER, &test_stream, preferred2,
sizeof(preferred2)/sizeof(preferred2[0]), detected, &nb_detected, NULL);
ok(hr == S_OK, "got %08x\n", hr);
todo_wine ok(nb_detected == 3, "got %u\n", nb_detected);
ok(detected[0] == 65001, "got %u\n", detected[0]);
todo_wine ok(detected[1] == 65000, "got %u\n", detected[1]);
todo_wine ok(detected[2] == 1200, "got %u\n", detected[2]);
}
START_TEST(mlang)
{
IMultiLanguage *iML = NULL;
IMultiLanguage2 *iML2 = NULL;
IMultiLanguage3 *iML3 = NULL;
IMLangFontLink *iMLFL = NULL;
IMLangFontLink2 *iMLFL2 = NULL;
HRESULT ret;
......@@ -2058,5 +2262,14 @@ START_TEST(mlang)
test_CodePageToScriptID(iMLFL2);
IMLangFontLink2_Release(iMLFL2);
trace("IMultiLanguage3\n");
ret = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
&IID_IMultiLanguage3, (void **)&iML3);
if (ret == S_OK)
{
test_DetectOutboundCodePageInIStream(iML3);
IMultiLanguage3_Release(iML3);
}
CoUninitialize();
}
......@@ -1020,7 +1020,7 @@ static void test_clock(int share)
ok(hr == S_OK, "GetPosition failed: %08x\n", hr);
ok(pos >= last, "Position %u vs. last %u\n", (UINT)pos,(UINT)last);
last = pos;
if(/*share &&*/ winetest_debug>1) todo_wine
if(/*share &&*/ winetest_debug>1)
ok(pos*1000/freq <= slept*1.1, "Position %u too far after stop %ums\n", (UINT)pos, slept);
hr = IAudioClient_Start(ac); /* #2 */
......@@ -1054,7 +1054,7 @@ static void test_clock(int share)
ok(pos * pwfx->nSamplesPerSec <= sum * freq, "Position %u > written %u\n", (UINT)pos, sum);
/* Prove that Stop must not drop frames (in shared mode). */
ok(pad ? pos > last : pos >= last, "Position %u vs. last %u\n", (UINT)pos,(UINT)last);
if (share && pad > 0 && winetest_debug>1) todo_wine
if (share && pad > 0 && winetest_debug>1)
ok(pos*1000/freq <= slept*1.1, "Position %u too far after playing %ums\n", (UINT)pos, slept);
/* in exclusive mode, testbot's w7 machines yield pos > sum-pad */
if(/*share &&*/ winetest_debug>1)
......@@ -1133,7 +1133,7 @@ static void test_clock(int share)
ok(pos >= last, "Position %u vs. last %u\n", (UINT)pos,(UINT)last);
ok(pcpos > pcpos0, "pcpos should increase\n");
ok(pos * pwfx->nSamplesPerSec <= sum * freq, "Position %u > written %u\n", (UINT)pos, sum);
if (pad > 0 && winetest_debug>1) todo_wine
if (pad > 0 && winetest_debug>1)
ok(pos*1000/freq <= slept*1.1, "Position %u too far after stop %ums\n", (UINT)pos, slept);
if(winetest_debug>1)
ok(pos * pwfx->nSamplesPerSec == (sum-pad) * freq,
......@@ -1223,7 +1223,7 @@ static void test_clock(int share)
ok(pos*1000/freq <= slept*1.1, "Position %u too far after %ums\n", (UINT)pos, slept);
if (pad) /* not in case of underrun */
ok((pos-last)*1000/freq >= 90 && 110 >= (pos-last)*1000/freq,
"Position delta %ld not regular\n", (long)(pos-last));
"Position delta %ld not regular: %ld ms\n", (long)(pos-last), (long)((pos-last)*1000/freq));
}
last = pos;
......@@ -1237,7 +1237,7 @@ static void test_clock(int share)
/* ok(hr == AUDCLNT_E_BUFFER_TOO_LARGE || (hr == S_OK && i==0) without todo_wine */
ok(hr == S_OK || hr == AUDCLNT_E_BUFFER_TOO_LARGE,
"GetBuffer large (%u) failed: %08x\n", avail, hr);
if(hr == S_OK && i) todo_wine ok(FALSE, "GetBuffer large (%u) at iteration %d\n", avail, i);
if(hr == S_OK && i) ok(FALSE, "GetBuffer large (%u) at iteration %d\n", avail, i);
/* Only the first iteration should allow that large a buffer
* as prefill was drained during the first 350+100ms sleep.
* Afterwards, only 100ms of data should find room per iteration. */
......
......@@ -138,11 +138,25 @@ static HRESULT WINAPI HTMLDOMAttribute_get_nodeName(IHTMLDOMAttribute *iface, BS
return IDispatchEx_GetMemberName(&This->elem->node.dispex.IDispatchEx_iface, This->dispid, p);
}
static HRESULT WINAPI HTMLDOMAttribute_put_nodeName(IHTMLDOMAttribute *iface, VARIANT v)
static HRESULT WINAPI HTMLDOMAttribute_put_nodeValue(IHTMLDOMAttribute *iface, VARIANT v)
{
HTMLDOMAttribute *This = impl_from_IHTMLDOMAttribute(iface);
FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
return E_NOTIMPL;
DISPID dispidNamed = DISPID_PROPERTYPUT;
DISPPARAMS dp = {&v, &dispidNamed, 1, 1};
EXCEPINFO ei;
VARIANT ret;
TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
if(!This->elem) {
FIXME("NULL This->elem\n");
return E_UNEXPECTED;
}
memset(&ei, 0, sizeof(ei));
return IDispatchEx_InvokeEx(&This->elem->node.dispex.IDispatchEx_iface, This->dispid, LOCALE_SYSTEM_DEFAULT,
DISPATCH_PROPERTYPUT, &dp, &ret, &ei, NULL);
}
static HRESULT WINAPI HTMLDOMAttribute_get_nodeValue(IHTMLDOMAttribute *iface, VARIANT *p)
......@@ -216,7 +230,7 @@ static const IHTMLDOMAttributeVtbl HTMLDOMAttributeVtbl = {
HTMLDOMAttribute_GetIDsOfNames,
HTMLDOMAttribute_Invoke,
HTMLDOMAttribute_get_nodeName,
HTMLDOMAttribute_put_nodeName,
HTMLDOMAttribute_put_nodeValue,
HTMLDOMAttribute_get_nodeValue,
HTMLDOMAttribute_get_specified
};
......
......@@ -4236,10 +4236,19 @@ static void _get_attr_node_value(unsigned line, IHTMLDOMAttribute *attr, VARIANT
HRESULT hres;
hres = IHTMLDOMAttribute_get_nodeValue(attr, v);
ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x, expected VT_BSTR\n", hres);
ok_(__FILE__,line) (hres == S_OK, "get_nodeValue failed: %08x\n", hres);
ok_(__FILE__,line) (V_VT(v) == vt, "vt=%d, expected %d\n", V_VT(v), vt);
}
#define put_attr_node_value(a,b) _put_attr_node_value(__LINE__,a,b)
static void _put_attr_node_value(unsigned line, IHTMLDOMAttribute *attr, VARIANT v)
{
HRESULT hres;
hres = IHTMLDOMAttribute_put_nodeValue(attr, v);
ok_(__FILE__,line) (hres == S_OK, "put_nodeValue failed: %08x\n", hres);
}
#define get_window_doc(e) _get_window_doc(__LINE__,e)
static IHTMLDocument2 *_get_window_doc(unsigned line, IHTMLWindow2 *window)
{
......@@ -7511,12 +7520,31 @@ static void test_attr(IHTMLElement *elem)
ok(!strcmp_wa(V_BSTR(&v), "divid"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
VariantClear(&v);
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = a2bstr("divid2");
put_attr_node_value(attr, v);
get_attr_node_value(attr, &v, VT_BSTR);
ok(!strcmp_wa(V_BSTR(&v), "divid2"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
VariantClear(&v);
IHTMLDOMAttribute_Release(attr);
attr = get_elem_attr_node((IUnknown*)elem, "emptyattr", TRUE);
get_attr_node_value(attr, &v, VT_BSTR);
ok(!V_BSTR(&v), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
VariantClear(&v);
V_VT(&v) = VT_BSTR;
V_BSTR(&v) = a2bstr("newvalue");
put_attr_node_value(attr, v);
VariantClear(&v);
attr = get_elem_attr_node((IUnknown*)elem, "emptyattr", TRUE);
get_attr_node_value(attr, &v, VT_BSTR);
ok(!strcmp_wa(V_BSTR(&v), "newvalue"), "V_BSTR(v) = %s\n", wine_dbgstr_w(V_BSTR(&v)));
VariantClear(&v);
test_attr_specified(attr, VARIANT_TRUE);
IHTMLDOMAttribute_Release(attr);
......@@ -7527,6 +7555,14 @@ static void test_attr(IHTMLElement *elem)
get_attr_node_value(attr, &v, VT_I4);
ok(V_I4(&v) == 100, "V_I4(v) = %d\n", V_I4(&v));
test_attr_specified(attr, VARIANT_TRUE);
V_VT(&v) = VT_I4;
V_I4(&v) = 150;
put_attr_node_value(attr, v);
get_attr_node_value(attr, &v, VT_I4);
ok(V_I4(&v) == 150, "V_I4(v) = %d\n", V_I4(&v));
IHTMLDOMAttribute_Release(attr);
attr = get_elem_attr_node((IUnknown*)elem, "tabIndex", TRUE);
......
......@@ -439,7 +439,7 @@ int xmlnode_get_inst_cnt(xmlnode *node)
/* Duplicates logic used by xmlAddChild() to determine if node will be merged with
existing text node. */
static int xmlnode_will_merge(const xmlnode *parent_node, const xmlnode *child_node)
static int xmlAddChild_will_merge(const xmlnode *parent_node, const xmlnode *child_node)
{
xmlNodePtr cur = child_node->node;
xmlNodePtr parent = parent_node->node;
......@@ -461,6 +461,25 @@ static int xmlnode_will_merge(const xmlnode *parent_node, const xmlnode *child_n
return 0;
}
/* Duplicates logic used by xmlAddPrevSibling() to determine if node will be merged with
existing text node. */
static int xmlAddPrevSibling_will_merge(const xmlnode *before_node, const xmlnode *child_node)
{
xmlNodePtr elem = child_node->node;
xmlNodePtr cur = before_node->node;
if (elem->type == XML_TEXT_NODE) {
if (cur->type == XML_TEXT_NODE)
return 1;
if (cur->prev && cur->prev->type == XML_TEXT_NODE &&
cur->name == cur->prev->name)
return 1;
}
return 0;
}
/* Crossover HACK for bug 10953 */
static int is_dotnet35sp1(void)
{
......@@ -546,7 +565,35 @@ HRESULT node_insert_before(xmlnode *This, IXMLDOMNode *new_child, const VARIANT
refcount = xmlnode_get_inst_cnt(node_obj);
if (refcount) xmldoc_add_refs(before_node_obj->node->doc, refcount);
if (!is_dotnet35sp1())
xmlAddPrevSibling(before_node_obj->node, node_obj->node);
else
{
xmlNodePtr clone = NULL;
/* currently only makes sense for a one instance per xmlNode case */
if (xmlAddPrevSibling_will_merge(before_node_obj, node_obj) && refcount == 1)
{
clone = xmlCopyNode(node_obj->node, 2);
*(LONG*)&clone->_private = refcount;
}
if (xmlAddPrevSibling(before_node_obj->node, node_obj->node) == node_obj->node)
{
xmlFreeNode(clone);
}
else
{
/* so libxml2 freed our node at this point, add a clone of it as an orphan */
if (clone)
{
xmlSetTreeDoc(clone, This->node->doc);
node_obj->node = clone;
xmldoc_add_orphan(node_obj->node->doc, node_obj->node);
}
}
}
if (refcount) xmldoc_release_refs(doc, refcount);
node_obj->parent = This->parent;
}
......@@ -574,7 +621,7 @@ HRESULT node_insert_before(xmlnode *This, IXMLDOMNode *new_child, const VARIANT
xmlNodePtr clone = NULL;
/* currently only makes sense for a one instance per xmlNode case */
if (xmlnode_will_merge(This, node_obj) && refcount == 1)
if (xmlAddChild_will_merge(This, node_obj) && refcount == 1)
{
clone = xmlCopyNode(node_obj->node, 2);
*(LONG*)&clone->_private = refcount;
......
......@@ -46,6 +46,7 @@ struct drive_info
};
extern NTSTATUS close_handle( HANDLE ) DECLSPEC_HIDDEN;
extern ULONG_PTR get_system_affinity_mask(void) DECLSPEC_HIDDEN;
/* exceptions */
extern void wait_suspend( CONTEXT *context ) DECLSPEC_HIDDEN;
......
......@@ -111,6 +111,13 @@ static UINT process_error_mode;
ret = STATUS_INVALID_INFO_CLASS; \
break
ULONG_PTR get_system_affinity_mask(void)
{
ULONG num_cpus = NtCurrentTeb()->Peb->NumberOfProcessors;
if (num_cpus >= sizeof(ULONG_PTR) * 8) return ~(ULONG_PTR)0;
return ((ULONG_PTR)1 << num_cpus) - 1;
}
/******************************************************************************
* NtQueryInformationProcess [NTDLL.@]
* ZwQueryInformationProcess [NTDLL.@]
......@@ -158,7 +165,7 @@ NTSTATUS WINAPI NtQueryInformationProcess(
case ProcessBasicInformation:
{
PROCESS_BASIC_INFORMATION pbi;
const ULONG_PTR affinity_mask = ((ULONG_PTR)1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
const ULONG_PTR affinity_mask = get_system_affinity_mask();
if (ProcessInformationLength >= sizeof(PROCESS_BASIC_INFORMATION))
{
......@@ -408,7 +415,7 @@ NTSTATUS WINAPI NtQueryInformationProcess(
len = sizeof(ULONG_PTR);
if (ProcessInformationLength == len)
{
const ULONG_PTR system_mask = ((ULONG_PTR)1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
const ULONG_PTR system_mask = get_system_affinity_mask();
SERVER_START_REQ(get_process_info)
{
......@@ -504,8 +511,11 @@ NTSTATUS WINAPI NtSetInformationProcess(
process_error_mode = *(UINT *)ProcessInformation;
break;
case ProcessAffinityMask:
{
const ULONG_PTR system_mask = get_system_affinity_mask();
if (ProcessInformationLength != sizeof(DWORD_PTR)) return STATUS_INVALID_PARAMETER;
if (*(PDWORD_PTR)ProcessInformation & ~(((DWORD_PTR)1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1))
if (*(PDWORD_PTR)ProcessInformation & ~system_mask)
return STATUS_INVALID_PARAMETER;
if (!*(PDWORD_PTR)ProcessInformation)
return STATUS_INVALID_PARAMETER;
......@@ -518,6 +528,7 @@ NTSTATUS WINAPI NtSetInformationProcess(
}
SERVER_END_REQ;
break;
}
case ProcessPriorityClass:
if (ProcessInformationLength != sizeof(PROCESS_PRIORITY_CLASS))
return STATUS_INVALID_PARAMETER;
......
......@@ -902,7 +902,7 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class,
case ThreadBasicInformation:
{
THREAD_BASIC_INFORMATION info;
const ULONG_PTR affinity_mask = ((ULONG_PTR)1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
const ULONG_PTR affinity_mask = get_system_affinity_mask();
SERVER_START_REQ( get_thread_info )
{
......@@ -929,7 +929,7 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class,
return status;
case ThreadAffinityMask:
{
const ULONG_PTR affinity_mask = ((ULONG_PTR)1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
const ULONG_PTR affinity_mask = get_system_affinity_mask();
ULONG_PTR affinity = 0;
SERVER_START_REQ( get_thread_info )
......@@ -1172,7 +1172,7 @@ NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class,
return status;
case ThreadAffinityMask:
{
const ULONG_PTR affinity_mask = ((ULONG_PTR)1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
const ULONG_PTR affinity_mask = get_system_affinity_mask();
ULONG_PTR req_aff;
if (length != sizeof(ULONG_PTR)) return STATUS_INVALID_PARAMETER;
......
......@@ -1402,7 +1402,7 @@ void virtual_get_system_info( SYSTEM_BASIC_INFORMATION *info )
info->AllocationGranularity = get_mask(0) + 1;
info->LowestUserAddress = (void *)0x10000;
info->HighestUserAddress = (char *)user_space_limit - 1;
info->ActiveProcessorsAffinityMask = (1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
info->ActiveProcessorsAffinityMask = get_system_affinity_mask();
info->NumberOfProcessors = NtCurrentTeb()->Peb->NumberOfProcessors;
}
......
......@@ -2524,7 +2524,7 @@ ShellLink_InvokeCommand( IContextMenu* iface, LPCMINVOKECOMMANDINFO lpici )
args[0] = 0;
if ( This->sArgs )
lstrcatW( args, This->sArgs );
if ( iciex->lpParametersW )
if ( iciex->lpParametersW && iciex->lpParametersW[0] )
{
static const WCHAR space[] = { ' ', 0 };
lstrcatW( args, space );
......
......@@ -169,7 +169,7 @@ typedef struct {
OUTLINETEXTMETRICW *otm;
SCRIPT_FONTPROPERTIES sfp;
BOOL sfnt;
CacheGlyphPage *page[0x10];
CacheGlyphPage *page[0x11];
ABC *widths[GLYPH_MAX / GLYPH_BLOCK_SIZE];
LPVOID GSUB_Table;
LPVOID GDEF_Table;
......
......@@ -95,10 +95,12 @@ struct ACImpl {
LONG ref;
snd_pcm_t *pcm_handle;
snd_pcm_uframes_t alsa_bufsize_frames, alsa_period_frames;
snd_pcm_uframes_t alsa_bufsize_frames, alsa_period_frames, safe_rewind_frames;
snd_pcm_hw_params_t *hw_params; /* does not hold state between calls */
snd_pcm_format_t alsa_format;
LARGE_INTEGER last_period_time;
IMMDevice *parent;
IUnknown *pUnkFTMarshal;
......@@ -121,9 +123,10 @@ struct ACImpl {
UINT32 lcl_offs_frames; /* offs into local_buffer where valid data starts */
UINT32 wri_offs_frames; /* where to write fresh data in local_buffer */
UINT32 hidden_frames; /* ALSA reserve to ensure continuous rendering */
UINT32 data_in_alsa_frames;
HANDLE timer;
BYTE *local_buffer, *tmp_buffer, *remapping_buf;
BYTE *local_buffer, *tmp_buffer, *remapping_buf, *silence_buf;
LONG32 getbuf_last; /* <0 when using tmp_buffer */
CRITICAL_SECTION lock;
......@@ -1218,6 +1221,18 @@ static HRESULT map_channels(ACImpl *This, const WAVEFORMATEX *fmt)
return S_OK;
}
static void silence_buffer(ACImpl *This, BYTE *buffer, UINT32 frames)
{
WAVEFORMATEXTENSIBLE *fmtex = (WAVEFORMATEXTENSIBLE*)This->fmt;
if((This->fmt->wFormatTag == WAVE_FORMAT_PCM ||
(This->fmt->wFormatTag == WAVE_FORMAT_EXTENSIBLE &&
IsEqualGUID(&fmtex->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM))) &&
This->fmt->wBitsPerSample == 8)
memset(buffer, 128, frames * This->fmt->nBlockAlign);
else
memset(buffer, 0, frames * This->fmt->nBlockAlign);
}
static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
AUDCLNT_SHAREMODE mode, DWORD flags, REFERENCE_TIME duration,
REFERENCE_TIME period, const WAVEFORMATEX *fmt,
......@@ -1397,7 +1412,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
if((err = snd_pcm_sw_params_set_start_threshold(This->pcm_handle,
sw_params, 1)) < 0){
WARN("Unable set start threshold to 0: %d (%s)\n", err, snd_strerror(err));
WARN("Unable set start threshold to 1: %d (%s)\n", err, snd_strerror(err));
hr = AUDCLNT_E_ENDPOINT_CREATE_FAILED;
goto exit;
}
......@@ -1432,6 +1447,8 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
This->bufsize_frames -= This->bufsize_frames % This->mmdev_period_frames;
This->hidden_frames = This->alsa_period_frames + This->mmdev_period_frames +
MulDiv(fmt->nSamplesPerSec, EXTRA_SAFE_RT, 10000000);
/* leave no less than about 1.33ms or 256 bytes of data after a rewind */
This->safe_rewind_frames = max(256 / fmt->nBlockAlign, MulDiv(133, fmt->nSamplesPerSec, 100000));
/* Check if the ALSA buffer is so small that it will run out before
* the next MMDevAPI period tick occurs. Allow a little wiggle room
......@@ -1440,22 +1457,27 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
FIXME("ALSA buffer time is too small. Expect underruns. (%lu < %u * 1.2)\n",
This->alsa_bufsize_frames, This->mmdev_period_frames);
This->fmt = clone_format(fmt);
if(!This->fmt){
hr = E_OUTOFMEMORY;
goto exit;
}
This->local_buffer = HeapAlloc(GetProcessHeap(), 0,
This->bufsize_frames * fmt->nBlockAlign);
if(!This->local_buffer){
hr = E_OUTOFMEMORY;
goto exit;
}
if (fmt->wBitsPerSample == 8)
memset(This->local_buffer, 128, This->bufsize_frames * fmt->nBlockAlign);
else
memset(This->local_buffer, 0, This->bufsize_frames * fmt->nBlockAlign);
silence_buffer(This, This->local_buffer, This->bufsize_frames);
This->fmt = clone_format(fmt);
if(!This->fmt){
This->silence_buf = HeapAlloc(GetProcessHeap(), 0,
This->alsa_period_frames * This->fmt->nBlockAlign);
if(!This->silence_buf){
hr = E_OUTOFMEMORY;
goto exit;
}
silence_buffer(This, This->silence_buf, This->alsa_period_frames);
This->vols = HeapAlloc(GetProcessHeap(), 0, fmt->nChannels * sizeof(float));
if(!This->vols){
......@@ -1870,7 +1892,7 @@ static HRESULT WINAPI AudioClient_GetDevicePeriod(IAudioClient *iface,
if(defperiod)
*defperiod = DefaultPeriod;
if(minperiod)
*minperiod = MinimumPeriod;
*minperiod = DefaultPeriod;
return S_OK;
}
......@@ -1952,8 +1974,8 @@ static BYTE *remap_channels(ACImpl *This, BYTE *buf, snd_pcm_uframes_t frames)
return This->remapping_buf;
}
static snd_pcm_sframes_t alsa_write_best_effort(snd_pcm_t *handle, BYTE *buf,
snd_pcm_uframes_t frames, ACImpl *This, BOOL mute)
static snd_pcm_sframes_t alsa_write_best_effort(ACImpl *This, BYTE *buf,
snd_pcm_uframes_t frames, BOOL mute)
{
snd_pcm_sframes_t written;
......@@ -1967,7 +1989,7 @@ static snd_pcm_sframes_t alsa_write_best_effort(snd_pcm_t *handle, BYTE *buf,
buf = remap_channels(This, buf, frames);
written = snd_pcm_writei(handle, buf, frames);
written = snd_pcm_writei(This->pcm_handle, buf, frames);
if(written < 0){
int ret;
......@@ -1978,47 +2000,94 @@ static snd_pcm_sframes_t alsa_write_best_effort(snd_pcm_t *handle, BYTE *buf,
WARN("writei failed, recovering: %ld (%s)\n", written,
snd_strerror(written));
ret = snd_pcm_recover(handle, written, 0);
ret = snd_pcm_recover(This->pcm_handle, written, 0);
if(ret < 0){
WARN("Could not recover: %d (%s)\n", ret, snd_strerror(ret));
return ret;
}
written = snd_pcm_writei(handle, buf, frames);
written = snd_pcm_writei(This->pcm_handle, buf, frames);
}
return written;
}
/* The callback and mmdevapi API functions execute concurrently.
* Shared state & life time after Start:
* This constant until _Release
*->pcm_handle likewise
*->fmt likewise
*->alsa_format, hidden_frames likewise
*->local_buffer, bufsize_frames, alsa_bufsize_frames likewise
*->event Read Only, even constant until _Release(!)
*->started Read Only from cb POV, constant if _Stop kills the cb
static snd_pcm_sframes_t alsa_write_buffer_wrap(ACImpl *This, BYTE *buf,
snd_pcm_uframes_t buflen, snd_pcm_uframes_t offs,
snd_pcm_uframes_t to_write)
{
snd_pcm_sframes_t ret = 0;
while(to_write){
snd_pcm_uframes_t chunk;
snd_pcm_sframes_t tmp;
if(offs + to_write > buflen)
chunk = buflen - offs;
else
chunk = to_write;
tmp = alsa_write_best_effort(This, buf + offs * This->fmt->nBlockAlign, chunk, This->session->mute);
if(tmp < 0)
return ret;
if(!tmp)
break;
ret += tmp;
to_write -= tmp;
offs += tmp;
offs %= buflen;
}
return ret;
}
static UINT buf_ptr_diff(UINT left, UINT right, UINT bufsize)
{
if(left <= right)
return right - left;
return bufsize - (left - right);
}
static UINT data_not_in_alsa(ACImpl *This)
{
UINT32 diff;
diff = buf_ptr_diff(This->lcl_offs_frames, This->wri_offs_frames, This->bufsize_frames);
if(diff)
return diff;
return This->held_frames - This->data_in_alsa_frames;
}
/* Here's the buffer setup:
*
* vvvvvvvv sent to HW already
* vvvvvvvv in ALSA buffer but rewindable
* [dddddddddddddddd] ALSA buffer
* [dddddddddddddddd--------] mmdevapi buffer
* ^^^^^^^^ data_in_alsa_frames
* ^^^^^^^^^^^^^^^^ held_frames
* ^ lcl_offs_frames
* ^ wri_offs_frames
*
*->held_frames is the only R/W object.
*->lcl_offs_frames/wri_offs_frames are written by one side exclusively:
* lcl_offs_frames by CaptureClient & write callback
* wri_offs_frames by read callback & RenderClient
* GetCurrentPadding is held_frames
*
* During period callback, we decrement held_frames, fill ALSA buffer, and move
* lcl_offs forward
*
* During Stop, we rewind the ALSA buffer
*/
static void alsa_write_data(ACImpl *This)
{
snd_pcm_sframes_t written, in_alsa;
snd_pcm_uframes_t to_write, avail, write_limit, max_period;
snd_pcm_sframes_t written;
snd_pcm_uframes_t avail, max_copy_frames, data_frames_played;
int err;
BYTE *buf =
This->local_buffer + This->lcl_offs_frames * This->fmt->nBlockAlign;
/* this call seems to be required to get an accurate snd_pcm_state() */
avail = snd_pcm_avail_update(This->pcm_handle);
if(snd_pcm_state(This->pcm_handle) == SND_PCM_STATE_XRUN ||
avail > This->alsa_bufsize_frames){
TRACE("XRun state avail %ld, recovering\n", avail);
if(snd_pcm_state(This->pcm_handle) == SND_PCM_STATE_XRUN){
TRACE("XRun state, recovering\n");
avail = This->alsa_bufsize_frames;
......@@ -2030,81 +2099,48 @@ static void alsa_write_data(ACImpl *This)
if((err = snd_pcm_prepare(This->pcm_handle)) < 0)
WARN("snd_pcm_prepare failed: %d (%s)\n", err, snd_strerror(err));
}else
TRACE("pad: %ld\n", This->alsa_bufsize_frames - avail);
if(This->held_frames == 0)
return;
}
if(This->lcl_offs_frames + This->held_frames > This->bufsize_frames)
to_write = This->bufsize_frames - This->lcl_offs_frames;
else
to_write = This->held_frames;
TRACE("avail: %ld\n", avail);
max_period = max(This->mmdev_period_frames, This->alsa_period_frames);
/* Add a lead-in when starting with too few frames to ensure
* continuous rendering. Additional benefit: Force ALSA to start. */
if(This->data_in_alsa_frames == 0 && This->held_frames < This->alsa_period_frames)
alsa_write_best_effort(This, This->silence_buf, This->alsa_period_frames - This->held_frames, FALSE);
/* try to keep 3 ALSA periods or 3 MMDevAPI periods in the ALSA buffer and
* no more */
write_limit = 0;
in_alsa = This->alsa_bufsize_frames - avail;
while(in_alsa + write_limit < max_period * 3)
write_limit += max_period;
if(write_limit == 0)
return;
if(This->started)
max_copy_frames = data_not_in_alsa(This);
else
max_copy_frames = 0;
to_write = min(to_write, write_limit);
data_frames_played = min(This->data_in_alsa_frames, avail);
This->data_in_alsa_frames -= data_frames_played;
/* Add a lead-in when starting with too few frames to ensure
* continuous rendering. Additional benefit: Force ALSA to start.
* GetPosition continues to reflect the speaker position because
* snd_pcm_delay includes buffered frames in its total delay
* and last_pos_frames prevents moving backwards. */
if(!in_alsa && This->held_frames < This->hidden_frames){
UINT32 s_frames = This->hidden_frames - This->held_frames;
BYTE *silence = HeapAlloc(GetProcessHeap(), 0,
s_frames * This->fmt->nBlockAlign);
if(silence){
in_alsa = alsa_write_best_effort(This->pcm_handle,
silence, s_frames, This, TRUE);
TRACE("lead-in %ld\n", in_alsa);
HeapFree(GetProcessHeap(), 0, silence);
if(in_alsa <= 0)
return;
if(This->held_frames > data_frames_played){
if(This->started)
This->held_frames -= data_frames_played;
}else
WARN("Couldn't allocate lead-in, expect underrun\n");
}
written = alsa_write_best_effort(This->pcm_handle, buf, to_write, This,
This->session->mute);
if(written < 0){
WARN("Couldn't write: %ld (%s)\n", written, snd_strerror(written));
return;
}
This->held_frames = 0;
This->lcl_offs_frames += written;
This->lcl_offs_frames %= This->bufsize_frames;
This->held_frames -= written;
while(avail && max_copy_frames){
snd_pcm_uframes_t to_write;
if(written < to_write){
/* ALSA buffer probably full */
return;
}
to_write = min(avail, max_copy_frames);
if(This->held_frames && (written < write_limit)){
/* wrapped and have some data back at the start to write */
written = alsa_write_best_effort(This->pcm_handle, This->local_buffer,
min(This->held_frames, write_limit - written), This,
This->session->mute);
if(written < 0){
WARN("Couldn't write: %ld (%s)\n", written, snd_strerror(written));
return;
}
written = alsa_write_buffer_wrap(This, This->local_buffer,
This->bufsize_frames, This->lcl_offs_frames, to_write);
if(written <= 0)
break;
avail -= written;
This->lcl_offs_frames += written;
This->lcl_offs_frames %= This->bufsize_frames;
This->held_frames -= written;
This->data_in_alsa_frames += written;
max_copy_frames -= written;
}
if(This->event)
SetEvent(This->event);
}
static void alsa_read_data(ACImpl *This)
......@@ -2112,6 +2148,9 @@ static void alsa_read_data(ACImpl *This)
snd_pcm_sframes_t nread;
UINT32 pos = This->wri_offs_frames, limit = This->held_frames;
if(!This->started)
goto exit;
/* FIXME: Detect overrun and signal DATA_DISCONTINUITY
* How to count overrun frames and report them as position increase? */
limit = This->bufsize_frames - max(limit, pos);
......@@ -2153,6 +2192,10 @@ static void alsa_read_data(ACImpl *This)
This->wri_offs_frames += nread;
This->wri_offs_frames %= This->bufsize_frames;
This->held_frames += nread;
exit:
if(This->event)
SetEvent(This->event);
}
static void CALLBACK alsa_push_buffer_data(void *user, BOOLEAN timer)
......@@ -2161,17 +2204,55 @@ static void CALLBACK alsa_push_buffer_data(void *user, BOOLEAN timer)
EnterCriticalSection(&This->lock);
if(This->started){
QueryPerformanceCounter(&This->last_period_time);
if(This->dataflow == eRender)
alsa_write_data(This);
else if(This->dataflow == eCapture)
alsa_read_data(This);
}
LeaveCriticalSection(&This->lock);
}
if(This->event)
SetEvent(This->event);
static snd_pcm_uframes_t interp_elapsed_frames(ACImpl *This)
{
LARGE_INTEGER time_freq, current_time, time_diff;
QueryPerformanceFrequency(&time_freq);
QueryPerformanceCounter(&current_time);
time_diff.QuadPart = current_time.QuadPart - This->last_period_time.QuadPart;
return MulDiv(time_diff.QuadPart, This->fmt->nSamplesPerSec, time_freq.QuadPart);
}
static int alsa_rewind_best_effort(ACImpl *This)
{
snd_pcm_uframes_t len, leave;
/* we can't use snd_pcm_rewindable, some PCM devices crash. so follow
* PulseAudio's example and rewind as much data as we believe is in the
* buffer, minus 1.33ms for safety. */
/* amount of data to leave in ALSA buffer */
leave = interp_elapsed_frames(This) + This->safe_rewind_frames;
if(This->held_frames < leave)
This->held_frames = 0;
else
This->held_frames -= leave;
if(This->data_in_alsa_frames < leave)
len = 0;
else
len = This->data_in_alsa_frames - leave;
TRACE("rewinding %lu frames, now held %u\n", len, This->held_frames);
if(len)
/* snd_pcm_rewind return value is often broken, assume it succeeded */
snd_pcm_rewind(This->pcm_handle, len);
This->data_in_alsa_frames = 0;
return len;
}
static HRESULT WINAPI AudioClient_Start(IAudioClient *iface)
......@@ -2201,6 +2282,29 @@ static HRESULT WINAPI AudioClient_Start(IAudioClient *iface)
/* dump any data that might be leftover in the ALSA capture buffer */
snd_pcm_readi(This->pcm_handle, This->local_buffer,
This->bufsize_frames);
}else{
snd_pcm_sframes_t avail, written;
snd_pcm_uframes_t offs;
avail = snd_pcm_avail_update(This->pcm_handle);
avail = min(avail, This->held_frames);
if(This->wri_offs_frames < This->held_frames)
offs = This->bufsize_frames - This->held_frames + This->wri_offs_frames;
else
offs = This->wri_offs_frames - This->held_frames;
/* fill it with data */
written = alsa_write_buffer_wrap(This, This->local_buffer,
This->bufsize_frames, offs, avail);
if(written > 0){
This->lcl_offs_frames = (offs + written) % This->bufsize_frames;
This->data_in_alsa_frames = written;
}else{
This->lcl_offs_frames = offs;
This->data_in_alsa_frames = 0;
}
}
if(!This->timer){
......@@ -2237,6 +2341,9 @@ static HRESULT WINAPI AudioClient_Stop(IAudioClient *iface)
return S_FALSE;
}
if(This->dataflow == eRender)
alsa_rewind_best_effort(This);
This->started = FALSE;
LeaveCriticalSection(&This->lock);
......@@ -2466,18 +2573,6 @@ static ULONG WINAPI AudioRenderClient_Release(IAudioRenderClient *iface)
return AudioClient_Release(&This->IAudioClient_iface);
}
static void silence_buffer(ACImpl *This, BYTE *buffer, UINT32 frames)
{
WAVEFORMATEXTENSIBLE *fmtex = (WAVEFORMATEXTENSIBLE*)This->fmt;
if((This->fmt->wFormatTag == WAVE_FORMAT_PCM ||
(This->fmt->wFormatTag == WAVE_FORMAT_EXTENSIBLE &&
IsEqualGUID(&fmtex->SubFormat, &KSDATAFORMAT_SUBTYPE_PCM))) &&
This->fmt->wBitsPerSample == 8)
memset(buffer, 128, frames * This->fmt->nBlockAlign);
else
memset(buffer, 0, frames * This->fmt->nBlockAlign);
}
static HRESULT WINAPI AudioRenderClient_GetBuffer(IAudioRenderClient *iface,
UINT32 frames, BYTE **data)
{
......@@ -2832,12 +2927,8 @@ static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos,
UINT64 *qpctime)
{
ACImpl *This = impl_from_IAudioClock(iface);
UINT64 written_frames, position;
UINT32 held_frames;
int err;
UINT64 position;
snd_pcm_state_t alsa_state;
snd_pcm_uframes_t avail_frames;
snd_pcm_sframes_t delay_frames;
TRACE("(%p)->(%p, %p)\n", This, pos, qpctime);
......@@ -2846,40 +2937,37 @@ static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos,
EnterCriticalSection(&This->lock);
/* call required to get accurate snd_pcm_state() */
avail_frames = snd_pcm_avail_update(This->pcm_handle);
/* avail_update required to get accurate snd_pcm_state() */
snd_pcm_avail_update(This->pcm_handle);
alsa_state = snd_pcm_state(This->pcm_handle);
written_frames = This->written_frames;
held_frames = This->held_frames;
err = snd_pcm_delay(This->pcm_handle, &delay_frames);
if(err < 0){
/* old Pulse, shortly after start */
WARN("snd_pcm_delay failed in state %u: %d (%s)\n", alsa_state, err, snd_strerror(err));
}
if(This->dataflow == eRender){
position = written_frames - held_frames; /* maximum */
if(!This->started || alsa_state > SND_PCM_STATE_RUNNING)
; /* mmdevapi stopped or ALSA underrun: pretend everything was played */
else if(err<0 || delay_frames > position - This->last_pos_frames)
/* Pulse bug: past underrun, despite recovery, avail_frames & delay
* may be larger than alsa_bufsize_frames, as if cumulating frames. */
/* Pulse bug: EIO(-5) shortly after starting: nothing played */
position = This->last_pos_frames;
else if(delay_frames > 0)
position -= delay_frames;
position = This->written_frames - This->held_frames;
if(This->started && alsa_state == SND_PCM_STATE_RUNNING && This->held_frames)
/* we should be using snd_pcm_delay here, but it is broken
* especially during ALSA device underrun. instead, let's just
* interpolate between periods with the system timer. */
position += interp_elapsed_frames(This);
position = min(position, This->written_frames - This->held_frames + This->mmdev_period_frames);
position = min(position, This->written_frames);
}else
position = written_frames + held_frames;
position = This->written_frames + This->held_frames;
/* ensure monotic growth */
if(position < This->last_pos_frames)
position = This->last_pos_frames;
else
This->last_pos_frames = position;
TRACE("frames written: %u, held: %u, state: 0x%x, position: %u\n",
(UINT32)(This->written_frames%1000000000), This->held_frames,
alsa_state, (UINT32)(position%1000000000));
LeaveCriticalSection(&This->lock);
TRACE("frames written: %u, held: %u, avail: %ld, delay: %ld state %d, pos: %u\n",
(UINT32)(written_frames%1000000000), held_frames,
avail_frames, delay_frames, alsa_state, (UINT32)(position%1000000000));
if(This->share == AUDCLNT_SHAREMODE_SHARED)
*pos = position * This->fmt->nBlockAlign;
else
......
......@@ -1964,7 +1964,7 @@ static enum wined3d_d3d_level d3d_level_from_gl_info(const struct wined3d_gl_inf
{
/* Wine can not use SM 4 on mesa drivers as the necessary functionality is not exposed
* on compatibility contexts */
if (gl_info->glsl_version >= MAKEDWORD_VERSION(1, 30))
if (gl_info->glsl_version >= MAKEDWORD_VERSION(1, 30) || gl_info->supported[EXT_GPU_SHADER4])
return WINED3D_D3D_LEVEL_10;
return WINED3D_D3D_LEVEL_9_SM3;
}
......
......@@ -1660,16 +1660,16 @@ int macdrv_err_on;
{
WineWindow* window = (WineWindow*)[theEvent window];
NSEventType type = [theEvent type];
BOOL broughtWindowForward = FALSE;
WineWindow* windowBroughtForward = nil;
BOOL process = FALSE;
if ([window isKindOfClass:[WineWindow class]] &&
!window.disabled && !window.noActivate &&
type == NSLeftMouseDown &&
(([theEvent modifierFlags] & (NSShiftKeyMask | NSControlKeyMask| NSAlternateKeyMask | NSCommandKeyMask)) != NSCommandKeyMask))
{
NSWindowButton windowButton;
broughtWindowForward = TRUE;
windowBroughtForward = window;
/* Any left-click on our window anyplace other than the close or
minimize buttons will bring it forward. */
......@@ -1683,7 +1683,7 @@ int macdrv_err_on;
NSPoint point = [button convertPoint:[theEvent locationInWindow] fromView:nil];
if ([button mouse:point inRect:[button bounds]])
{
broughtWindowForward = FALSE;
windowBroughtForward = nil;
break;
}
}
......@@ -1699,7 +1699,6 @@ int macdrv_err_on;
{
BOOL pressed = (type == NSLeftMouseDown || type == NSRightMouseDown || type == NSOtherMouseDown);
CGPoint pt = CGEventGetLocation([theEvent CGEvent]);
BOOL process;
if (clippingCursor)
[self clipCursorLocation:&pt];
......@@ -1766,12 +1765,13 @@ int macdrv_err_on;
macdrv_release_event(event);
}
else if (broughtWindowForward)
{
[[window ancestorWineWindow] postBroughtForwardEvent];
if (![window isKeyWindow])
[self windowGotFocus:window];
}
if (!process && windowBroughtForward)
{
[[windowBroughtForward ancestorWineWindow] postBroughtForwardEvent];
if (![windowBroughtForward isKeyWindow] && !windowBroughtForward.disabled && !windowBroughtForward.noActivate)
[self windowGotFocus:windowBroughtForward];
}
// Since mouse button events deliver absolute cursor position, the
......
......@@ -195,6 +195,8 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
@property (retain, nonatomic) NSTimer* liveResizeDisplayTimer;
@property (readonly, copy, nonatomic) NSArray* childWineWindows;
- (void) updateColorSpace;
- (BOOL) becameEligibleParentOrChild;
......@@ -263,6 +265,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
CGContextSetBlendMode(context, kCGBlendModeCopy);
CGContextSetInterpolationQuality(context, kCGInterpolationNone);
for (i = 0; i < count; i++)
{
......@@ -691,7 +694,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
NSUInteger style = [self styleMask];
if (behavior & NSWindowCollectionBehaviorParticipatesInCycle &&
style & NSResizableWindowMask && !(style & NSUtilityWindowMask))
style & NSResizableWindowMask && !(style & NSUtilityWindowMask) && !maximized)
{
behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
behavior &= ~NSWindowCollectionBehaviorFullScreenAuxiliary;
......@@ -701,7 +704,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
behavior |= NSWindowCollectionBehaviorFullScreenAuxiliary;
if (style & NSFullScreenWindowMask)
[self toggleFullScreen:nil];
[super toggleFullScreen:nil];
}
}
......@@ -783,7 +786,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
if (captured)
level = CGShieldingWindowLevel() + 1; /* Need +1 or we don't get mouse moves */
else
level = NSMainMenuWindowLevel + 1;
level = NSStatusWindowLevel + 1;
if (self.floating)
level++;
......@@ -829,7 +832,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
// Became non-floating. If parent of floating children, make that
// relationship latent.
WineWindow* child;
for (child in [[[self childWindows] copy] autorelease])
for (child in [self childWineWindows])
{
if (child.floating)
[child becameIneligibleChild];
......@@ -844,25 +847,6 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
[[WineApplicationController sharedController] adjustWindowLevels];
}
behavior = NSWindowCollectionBehaviorDefault;
if (state->excluded_by_expose)
behavior |= NSWindowCollectionBehaviorTransient;
else
behavior |= NSWindowCollectionBehaviorManaged;
if (state->excluded_by_cycle)
{
behavior |= NSWindowCollectionBehaviorIgnoresCycle;
if ([self isOrderedIn])
[NSApp removeWindowsItem:self];
}
else
{
behavior |= NSWindowCollectionBehaviorParticipatesInCycle;
if ([self isOrderedIn])
[NSApp addWindowsItem:self title:[self title] filename:NO];
}
[self adjustFullScreenBehavior:behavior];
if (state->minimized_valid)
{
macdrv_event_mask discard = event_mask_for_type(WINDOW_DID_UNMINIMIZE);
......@@ -904,6 +888,25 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
maximized = state->maximized;
[self adjustFeaturesForState];
}
behavior = NSWindowCollectionBehaviorDefault;
if (state->excluded_by_expose)
behavior |= NSWindowCollectionBehaviorTransient;
else
behavior |= NSWindowCollectionBehaviorManaged;
if (state->excluded_by_cycle)
{
behavior |= NSWindowCollectionBehaviorIgnoresCycle;
if ([self isOrderedIn])
[NSApp removeWindowsItem:self];
}
else
{
behavior |= NSWindowCollectionBehaviorParticipatesInCycle;
if ([self isOrderedIn])
[NSApp addWindowsItem:self title:[self title] filename:NO];
}
[self adjustFullScreenBehavior:behavior];
}
- (BOOL) addChildWineWindow:(WineWindow*)child assumeVisible:(BOOL)assumeVisible
......@@ -1007,7 +1010,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
- (void) becameIneligibleParentOrChild
{
NSArray* childWindows = [self childWindows];
NSArray* childWindows = [self childWineWindows];
[self becameIneligibleChild];
......@@ -1015,7 +1018,6 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
{
WineWindow* child;
childWindows = [[childWindows copy] autorelease];
for (child in childWindows)
{
child.latentParentWindow = self;
......@@ -1096,7 +1098,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
// Get our child windows and sort them in the reverse of the desired
// z-order (back-to-front).
origChildren = [self childWindows];
origChildren = [self childWineWindows];
children = [[origChildren mutableCopy] autorelease];
[children sortWithOptions:NSSortStable
usingComparator:^NSComparisonResult(id obj1, id obj2){
......@@ -1310,7 +1312,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
[self setContentMaxSize:NSMakeSize(FLT_MAX, FLT_MAX)];
}
if (equalSizes && [[self childWindows] count])
if (equalSizes && [[self childWineWindows] count])
{
// If we change the window frame such that the origin moves
// but the size doesn't change, then Cocoa moves child
......@@ -1565,7 +1567,7 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
ret = [self isKeyWindow] || (!self.disabled && !self.noActivate);
else if ([menuItem action] == @selector(undo:)) // CrossOver Hack 10912: Mac Edit menu
ret = TRUE;
if ([menuItem action] == @selector(toggleFullScreen:) && self.disabled)
if ([menuItem action] == @selector(toggleFullScreen:) && (self.disabled || maximized))
ret = NO;
return ret;
......@@ -1667,10 +1669,19 @@ static inline NSUInteger adjusted_modifiers_for_option_behavior(NSUInteger modif
- (void) toggleFullScreen:(id)sender
{
if (!self.disabled)
if (!self.disabled && !maximized)
[super toggleFullScreen:sender];
}
- (NSArray*) childWineWindows
{
NSArray* childWindows = self.childWindows;
NSIndexSet* indexes = [childWindows indexesOfObjectsPassingTest:^BOOL(id child, NSUInteger idx, BOOL *stop){
return [child isKindOfClass:[WineWindow class]];
}];
return [childWindows objectsAtIndexes:indexes];
}
// We normally use the generic/calibrated RGB color space for the window,
// rather than the device color space, to avoid expensive color conversion
// which slows down drawing. However, for windows displaying OpenGL, having
......
......@@ -50,7 +50,9 @@ extern const char* debugstr_cf(CFTypeRef t) DECLSPEC_HIDDEN;
static inline CGRect cgrect_from_rect(RECT rect)
{
return CGRectMake(rect.left, rect.top, max(0, rect.right - rect.left), max(0, rect.bottom - rect.top));
if (rect.left >= rect.right || rect.top >= rect.bottom)
return CGRectMake(rect.left, rect.top, 0, 0);
return CGRectMake(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
}
static inline RECT rect_from_cgrect(CGRect cgrect)
......
......@@ -117,7 +117,7 @@ struct ACImpl {
BOOL initted, playing;
UINT64 written_frames, last_pos_frames;
UINT32 period_us, period_frames, bufsize_frames, held_frames, tmp_buffer_frames;
UINT32 period_us, period_frames, bufsize_frames, held_frames, tmp_buffer_frames, in_oss_frames;
UINT32 oss_bufsize_bytes, lcl_offs_frames; /* offs into local_buffer where valid data starts */
BYTE *local_buffer, *tmp_buffer;
......@@ -1396,19 +1396,10 @@ static void silence_buffer(ACImpl *This, BYTE *buffer, UINT32 frames)
static void oss_write_data(ACImpl *This)
{
ssize_t written_bytes;
UINT32 written_frames, in_oss_frames, write_limit, max_period;
size_t to_write_frames, to_write_bytes;
UINT32 written_frames, in_oss_frames, write_limit, max_period, write_offs_frames, new_frames;
size_t to_write_frames, to_write_bytes, advanced;
audio_buf_info bi;
BYTE *buf =
This->local_buffer + (This->lcl_offs_frames * This->fmt->nBlockAlign);
if(This->held_frames == 0)
return;
if(This->lcl_offs_frames + This->held_frames > This->bufsize_frames)
to_write_frames = This->bufsize_frames - This->lcl_offs_frames;
else
to_write_frames = This->held_frames;
BYTE *buf;
if(ioctl(This->fd, SNDCTL_DSP_GETOSPACE, &bi) < 0){
WARN("GETOSPACE failed: %d (%s)\n", errno, strerror(errno));
......@@ -1433,9 +1424,38 @@ static void oss_write_data(ACImpl *This)
if(write_limit == 0)
return;
/* vvvvvv - in_oss_frames
* [--xxxxxxxxxx]
* [xxxxxxxxxx--]
* ^^^^^^^^^^ - held_frames
* ^ - lcl_offs_frames
*/
advanced = This->in_oss_frames - in_oss_frames;
if(advanced > This->held_frames)
advanced = This->held_frames;
This->lcl_offs_frames += advanced;
This->lcl_offs_frames %= This->bufsize_frames;
This->held_frames -= advanced;
This->in_oss_frames = in_oss_frames;
if(This->held_frames == This->in_oss_frames)
return;
write_offs_frames = (This->lcl_offs_frames + This->in_oss_frames) % This->bufsize_frames;
new_frames = This->held_frames - This->in_oss_frames;
if(write_offs_frames + new_frames > This->bufsize_frames)
to_write_frames = This->bufsize_frames - write_offs_frames;
else
to_write_frames = new_frames;
to_write_frames = min(to_write_frames, write_limit);
to_write_bytes = to_write_frames * This->fmt->nBlockAlign;
buf = This->local_buffer + write_offs_frames * This->fmt->nBlockAlign;
if(This->session->mute)
silence_buffer(This, buf, to_write_frames);
......@@ -1447,19 +1467,17 @@ static void oss_write_data(ACImpl *This)
}
written_frames = written_bytes / This->fmt->nBlockAlign;
This->lcl_offs_frames += written_frames;
This->lcl_offs_frames %= This->bufsize_frames;
This->held_frames -= written_frames;
This->in_oss_frames += written_frames;
if(written_frames < to_write_frames){
/* OSS buffer probably full */
return;
}
if(This->held_frames && written_frames < write_limit){
if(new_frames > written_frames && written_frames < write_limit){
/* wrapped and have some data back at the start to write */
to_write_frames = min(write_limit - written_frames, This->held_frames);
to_write_frames = min(write_limit - written_frames, new_frames - written_frames);
to_write_bytes = to_write_frames * This->fmt->nBlockAlign;
if(This->session->mute)
......@@ -1471,30 +1489,18 @@ static void oss_write_data(ACImpl *This)
return;
}
written_frames = written_bytes / This->fmt->nBlockAlign;
This->lcl_offs_frames += written_frames;
This->lcl_offs_frames %= This->bufsize_frames;
This->held_frames -= written_frames;
This->in_oss_frames += written_frames;
}
}
static void oss_read_data(ACImpl *This)
{
UINT64 pos, readable;
audio_buf_info bi;
ssize_t nread;
if(ioctl(This->fd, SNDCTL_DSP_GETISPACE, &bi) < 0){
WARN("GETISPACE failed: %d (%s)\n", errno, strerror(errno));
return;
}
pos = (This->held_frames + This->lcl_offs_frames) % This->bufsize_frames;
readable = (This->bufsize_frames - pos) * This->fmt->nBlockAlign;
if(bi.bytes < readable)
readable = bi.bytes;
nread = read(This->fd, This->local_buffer + pos * This->fmt->nBlockAlign,
readable);
if(nread < 0){
......@@ -1587,6 +1593,7 @@ static HRESULT WINAPI AudioClient_Stop(IAudioClient *iface)
}
This->playing = FALSE;
This->in_oss_frames = 0;
LeaveCriticalSection(&This->lock);
......@@ -1624,6 +1631,7 @@ static HRESULT WINAPI AudioClient_Reset(IAudioClient *iface)
}
This->held_frames = 0;
This->lcl_offs_frames = 0;
This->in_oss_frames = 0;
LeaveCriticalSection(&This->lock);
......@@ -2159,7 +2167,6 @@ static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos,
UINT64 *qpctime)
{
ACImpl *This = impl_from_IAudioClock(iface);
int delay;
TRACE("(%p)->(%p, %p)\n", This, pos, qpctime);
......@@ -2169,18 +2176,9 @@ static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos,
EnterCriticalSection(&This->lock);
if(This->dataflow == eRender){
if(!This->playing || !This->held_frames ||
ioctl(This->fd, SNDCTL_DSP_GETODELAY, &delay) < 0)
delay = 0;
else
delay /= This->fmt->nBlockAlign;
if(This->held_frames + delay >= This->written_frames)
*pos = This->last_pos_frames;
else{
*pos = This->written_frames - This->held_frames - delay;
*pos = This->written_frames - This->held_frames;
if(*pos < This->last_pos_frames)
*pos = This->last_pos_frames;
}
}else if(This->dataflow == eCapture){
audio_buf_info bi;
UINT32 held;
......@@ -2200,6 +2198,7 @@ static HRESULT WINAPI AudioClock_GetPosition(IAudioClock *iface, UINT64 *pos,
This->last_pos_frames = *pos;
TRACE("returning: %s\n", wine_dbgstr_longlong(*pos));
if(This->share == AUDCLNT_SHAREMODE_SHARED)
*pos *= This->fmt->nBlockAlign;
......
......@@ -386,6 +386,18 @@ interface IMLangConvertCharset : IUnknown
MLCONVCHARF_DETECTJPN = 32
} MLCONVCHAR;
typedef enum tagMLCPF
{
MLDETECTF_MAILNEWS = 0x0001,
MLDETECTF_BROWSER = 0x0002,
MLDETECTF_VALID = 0x0004,
MLDETECTF_VALID_NLS = 0x0008,
MLDETECTF_PRESERVE_ORDER = 0x0010,
MLDETECTF_PREFERRED_ONLY = 0x0020,
MLDETECTF_FILTER_SPECIALCHAR = 0x0040,
MLDETECTF_EURO_UTF8 = 0x0080
} MLCP;
HRESULT Initialize(
[in] UINT uiSrcCodePage,
[in] UINT uiDstCodePage,
......
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