Skip to content

Commit f1a347b

Browse files
authored
2210 GDK QFE1 (#599)
* 2210 GDK QFE1
1 parent 525786e commit f1a347b

23 files changed

+226
-81
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#pragma once
2+
3+
#if !defined(__cplusplus)
4+
#error C++11 required
5+
#endif
6+
7+
// Attention: This file is intended for internal uses only.
8+
// Its use is not recommended and not supported.
9+
10+
#include <Xal/xal_types.h>
11+
12+
extern "C"
13+
{
14+
//-----------------------------------------------------------------------------
15+
// Marketing State
16+
//-----------------------------------------------------------------------------
17+
18+
/// <summary>
19+
/// Enum defining the various marketing states.
20+
/// </summary>
21+
typedef enum XalMarketingState
22+
{
23+
/// <summary>Existing user</summary>
24+
XalMarketingState_ExistingUser = 0,
25+
/// <summary>User went through account creation</summary>
26+
XalMarketingState_NewUser = 1,
27+
/// <summary>User went through account creation and saw the first party marketing notice</summary>
28+
XalMarketingState_NewUserFirstPartyNotice = 2,
29+
} XalMarketingState;
30+
31+
STDAPI XalUserGetMarketingState(
32+
_In_ XalUserHandle user,
33+
_Out_ XalMarketingState* marketingState
34+
) noexcept;
35+
36+
}

External/Xal/Source/Xal/Include/Xal/xal_version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ extern "C"
2020
/// YYYYMMDD Date string describing the date the build was created
2121
/// rrr QFE number (000 indicates base release)
2222
/// </summary>
23-
#define XAL_VERSION "2022.08.20220825.000"
23+
#define XAL_VERSION "2022.10.20221205.000"
2424

2525
}

Include/xsapi-c/social_manager_c.h

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ STDAPI_(bool) XblSocialManagerPresenceRecordIsUserPlayingTitle(
463463
/// <remarks>
464464
/// Call this API after calling either <see cref="XblSocialManagerCreateSocialUserGroupFromFilters"/>
465465
/// or <see cref="XblSocialManagerCreateSocialUserGroupFromList"/> to create an XblSocialManagerUserGroup.
466-
/// Have the XblSocialManagerUserGroupHandle returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded
466+
/// The XblSocialManagerUserGroupHandle is returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded
467467
/// event in <see cref="XblSocialManagerDoWork"/>.
468468
/// </remarks>
469469
STDAPI XblSocialManagerUserGroupGetType(
@@ -482,7 +482,7 @@ STDAPI XblSocialManagerUserGroupGetType(
482482
/// <remarks>
483483
/// Call this API after calling either <see cref="XblSocialManagerCreateSocialUserGroupFromFilters"/>
484484
/// or <see cref="XblSocialManagerCreateSocialUserGroupFromList"/> to create an XblSocialManagerUserGroup.
485-
/// Have the XblSocialManagerUserGroupHandle returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event
485+
/// The XblSocialManagerUserGroupHandle is returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event
486486
/// in <see cref="XblSocialManagerDoWork"/>.
487487
/// </remarks>
488488
STDAPI XblSocialManagerUserGroupGetLocalUser(
@@ -501,7 +501,7 @@ STDAPI XblSocialManagerUserGroupGetLocalUser(
501501
/// If the group is not a filter group, E_UNEXPECTED will be returned.
502502
/// Call this API after either <see cref="XblSocialManagerCreateSocialUserGroupFromFilters"/>
503503
/// or <see cref="XblSocialManagerCreateSocialUserGroupFromList"/> to create an XblSocialManagerUserGroup.
504-
/// Have the XblSocialManagerUserGroupHandle returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded
504+
/// The XblSocialManagerUserGroupHandle is returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded
505505
/// event in <see cref="XblSocialManagerDoWork"/>.<br/>
506506
/// </remarks>
507507
STDAPI XblSocialManagerUserGroupGetFilters(
@@ -533,8 +533,7 @@ typedef const XblSocialManagerUser* const* XblSocialManagerUserPtrArray;
533533
/// they are statically sized and trivially copyable.
534534
/// Call this API after calling either <see cref="XblSocialManagerCreateSocialUserGroupFromFilters"/>
535535
/// or <see cref="XblSocialManagerCreateSocialUserGroupFromList"/> to create an XblSocialManagerUserGroup.
536-
/// Have the XblSocialManagerUserGroupHandle returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded
537-
/// event in <see cref="XblSocialManagerDoWork"/>.
536+
/// Wait for <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event in <see cref="XblSocialManagerDoWork"/>. Prior to this the group will be empty.
538537
/// </remarks>
539538
STDAPI XblSocialManagerUserGroupGetUsers(
540539
_In_ XblSocialManagerUserGroupHandle group,
@@ -555,8 +554,7 @@ STDAPI XblSocialManagerUserGroupGetUsers(
555554
/// but for filter-based groups, the set tracked users changes as the local user's relationships change.
556555
/// Call this API after calling either <see cref="XblSocialManagerCreateSocialUserGroupFromFilters"/>
557556
/// or <see cref="XblSocialManagerCreateSocialUserGroupFromList"/> to create an XblSocialManagerUserGroup.
558-
/// Have the XblSocialManagerUserGroupHandle returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event
559-
/// in <see cref="XblSocialManagerDoWork"/>.
557+
/// Wait for <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event in <see cref="XblSocialManagerDoWork"/>. Prior to this the group will be empty.
560558
/// </remarks>
561559
STDAPI XblSocialManagerUserGroupGetUsersTrackedByGroup(
562560
_In_ XblSocialManagerUserGroupHandle group,
@@ -630,8 +628,7 @@ STDAPI XblSocialManagerDoWork(
630628
/// (invalidating the returned handle) if the associated user is removed from Social Manager.</param>
631629
/// <returns>HRESULT return code for this API operation.</returns>
632630
/// <remarks>
633-
/// The result of a user group being loaded will be triggered through
634-
/// the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event in <see cref="XblSocialManagerDoWork"/>.
631+
/// Wait for <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event in <see cref="XblSocialManagerDoWork"/>. Prior to this the group will be empty.
635632
/// </remarks>
636633
STDAPI XblSocialManagerCreateSocialUserGroupFromFilters(
637634
_In_ XblUserHandle user,
@@ -652,8 +649,7 @@ STDAPI XblSocialManagerCreateSocialUserGroupFromFilters(
652649
/// (invalidating the returned handle) if the associated user is removed from Social Manager.</param>
653650
/// <returns>HRESULT return code for this API operation.</returns>
654651
/// <remarks>
655-
/// The result of a user group being loaded will be triggered through
656-
/// the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event in <see cref="XblSocialManagerDoWork"/>.
652+
/// Wait for <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event in <see cref="XblSocialManagerDoWork"/>. Prior to this the group will be empty.
657653
/// </remarks>
658654
STDAPI XblSocialManagerCreateSocialUserGroupFromList(
659655
_In_ XblUserHandle user,
@@ -671,7 +667,7 @@ STDAPI XblSocialManagerCreateSocialUserGroupFromList(
671667
/// This will stop updaing the Xbox Social User Group and remove tracking for any users the XblSocialManagerUserGroup holds.
672668
/// Call this API after calling either <see cref="XblSocialManagerCreateSocialUserGroupFromFilters"/>
673669
/// or <see cref="XblSocialManagerCreateSocialUserGroupFromList"/> to create an XblSocialManagerUserGroup.
674-
/// Have the XblSocialManagerUserGroupHandle returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event
670+
/// The XblSocialManagerUserGroupHandle is returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event
675671
/// in <see cref="XblSocialManagerDoWork"/>.
676672
/// </remarks>
677673
STDAPI XblSocialManagerDestroySocialUserGroup(
@@ -722,7 +718,7 @@ STDAPI XblSocialManagerGetLocalUsers(
722718
/// <see cref="XblSocialManagerEventType"/>::SocialUserGroupUpdated event in <see cref="XblSocialManagerDoWork"/>.
723719
/// Call this API after calling either <see cref="XblSocialManagerCreateSocialUserGroupFromFilters"/>
724720
/// or <see cref="XblSocialManagerCreateSocialUserGroupFromList"/> to create an XblSocialManagerUserGroup.
725-
/// Have the XblSocialManagerUserGroupHandle returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded
721+
/// The XblSocialManagerUserGroupHandle is returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded
726722
/// event in <see cref="XblSocialManagerDoWork"/>.
727723
/// </remarks>
728724
STDAPI XblSocialManagerUpdateSocialUserGroup(

Source/Services/Multiplayer/multiplayer_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ class MultiplayerService : public std::enable_shared_from_this<MultiplayerServic
501501
_In_ AsyncContext<Result<void>> async
502502
) noexcept;
503503

504-
HRESULT SubscribeToRta() noexcept;
504+
HRESULT SubscribeToRta(std::unique_lock<std::mutex> lock) noexcept;
505505
HRESULT UnsubscribeFromRta() noexcept;
506506

507507
HRESULT WriteSessionUsingSubpath(

Source/Services/Multiplayer/multiplayer_service.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ HRESULT MultiplayerService::SetRtaConnectionId(
11571157
return S_OK;
11581158
}
11591159

1160-
HRESULT MultiplayerService::SubscribeToRta() noexcept
1160+
HRESULT MultiplayerService::SubscribeToRta(std::unique_lock<std::mutex> lock) noexcept
11611161
{
11621162
if (m_subscription == nullptr)
11631163
{
@@ -1223,6 +1223,8 @@ HRESULT MultiplayerService::SubscribeToRta() noexcept
12231223
}
12241224
});
12251225

1226+
// Unlock before adding subscription as it can synchronously call back into our ConnectionIdChanged handler
1227+
lock.unlock();
12261228
return m_rtaManager->AddSubscription(m_user, m_subscription);
12271229
}
12281230
return S_OK;
@@ -1248,9 +1250,9 @@ HRESULT MultiplayerService::UnsubscribeFromRta() noexcept
12481250

12491251
HRESULT MultiplayerService::EnableMultiplayerSubscriptions() noexcept
12501252
{
1251-
std::lock_guard<std::mutex> lock{ m_mutexMultiplayerService };
1253+
std::unique_lock<std::mutex> lock{ m_mutexMultiplayerService };
12521254
m_forceEnableRtaSubscription = true;
1253-
return SubscribeToRta();
1255+
return SubscribeToRta(std::move(lock));
12541256
}
12551257

12561258
HRESULT MultiplayerService::DisableMultiplayerSubscriptions() noexcept
@@ -1281,11 +1283,21 @@ XblFunctionContext MultiplayerService::AddMultiplayerSessionChangedHandler(
12811283
_In_ MultiplayerSubscription::SessionChangedHandler handler
12821284
) noexcept
12831285
{
1284-
std::lock_guard<std::mutex> lock{ m_mutexMultiplayerService };
1286+
{
1287+
std::unique_lock<std::mutex> lock{ m_mutexMultiplayerService };
1288+
SubscribeToRta(std::move(lock));
1289+
}
1290+
1291+
XblFunctionContext token{};
1292+
{
1293+
std::unique_lock<std::mutex> lock{ m_mutexMultiplayerService };
1294+
if (m_subscription)
1295+
{
1296+
token = m_subscription->AddSessionChangedHandler(std::move(handler));
1297+
}
1298+
}
12851299

1286-
SubscribeToRta();
1287-
assert(m_subscription);
1288-
return m_subscription->AddSessionChangedHandler(std::move(handler));
1300+
return token;
12891301
}
12901302

12911303
void MultiplayerService::RemoveMultiplayerSessionChangedHandler(

Source/Services/Presence/presence_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ class PresenceService : public std::enable_shared_from_this<PresenceService>
235235
Map<uint32_t, size_t> m_trackedTitles;
236236
uint32_t const m_titleId;
237237

238-
mutable std::mutex m_mutex;
238+
mutable std::recursive_mutex m_mutex;
239239

240240
friend class DevicePresenceChangeSubscription;
241241
friend class TitlePresenceChangeSubscription;

Source/Services/Presence/presence_service.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ XblFunctionContext PresenceService::AddTitlePresenceChangedHandler(
5454
TitlePresenceChangedHandler handler
5555
) noexcept
5656
{
57-
std::lock_guard<std::mutex> lock{ m_mutex };
57+
std::unique_lock<std::recursive_mutex> lock{ m_mutex };
58+
59+
m_titlePresenceChangedHandlers[m_nextHandlerToken] = std::move(handler);
60+
auto token = m_nextHandlerToken++;
5861

5962
// Add subs to RTA manager if needed
6063
if (m_titlePresenceChangedHandlers.empty())
@@ -70,15 +73,14 @@ XblFunctionContext PresenceService::AddTitlePresenceChangedHandler(
7073
}
7174
}
7275

73-
m_titlePresenceChangedHandlers[m_nextHandlerToken] = std::move(handler);
74-
return m_nextHandlerToken++;
76+
return token;
7577
}
7678

7779
void PresenceService::RemoveTitlePresenceChangedHandler(
7880
_In_ XblFunctionContext context
7981
) noexcept
8082
{
81-
std::lock_guard<std::mutex> lock{ m_mutex };
83+
std::lock_guard<std::recursive_mutex> lock{ m_mutex };
8284

8385
auto removed{ m_titlePresenceChangedHandlers.erase(context) };
8486
if (removed && m_titlePresenceChangedHandlers.empty())
@@ -98,7 +100,7 @@ XblFunctionContext PresenceService::AddDevicePresenceChangedHandler(
98100
DevicePresenceChangedHandler handler
99101
) noexcept
100102
{
101-
std::lock_guard<std::mutex> lock{ m_mutex };
103+
std::lock_guard<std::recursive_mutex> lock{ m_mutex };
102104

103105
// Add subs to RTA manager if needed
104106
if (m_devicePresenceChangedHandlers.empty())
@@ -118,7 +120,7 @@ void PresenceService::RemoveDevicePresenceChangedHandler(
118120
_In_ XblFunctionContext context
119121
) noexcept
120122
{
121-
std::lock_guard<std::mutex> lock{ m_mutex };
123+
std::lock_guard<std::recursive_mutex> lock{ m_mutex };
122124

123125
auto removed{ m_devicePresenceChangedHandlers.erase(context) };
124126
if (removed && m_devicePresenceChangedHandlers.empty())
@@ -135,7 +137,7 @@ HRESULT PresenceService::TrackUsers(
135137
const Vector<uint64_t>& xuids
136138
) noexcept
137139
{
138-
std::lock_guard<std::mutex> lock{ m_mutex };
140+
std::lock_guard<std::recursive_mutex> lock{ m_mutex };
139141

140142
if (!m_resyncHandlerToken)
141143
{
@@ -188,7 +190,7 @@ HRESULT PresenceService::StopTrackingUsers(
188190
const Vector<uint64_t>& xuids
189191
) noexcept
190192
{
191-
std::lock_guard<std::mutex> lock{ m_mutex };
193+
std::lock_guard<std::recursive_mutex> lock{ m_mutex };
192194

193195
for (auto& xuid : xuids)
194196
{
@@ -217,7 +219,7 @@ HRESULT PresenceService::TrackAdditionalTitles(
217219
const Vector<uint32_t>& titleIds
218220
) noexcept
219221
{
220-
std::lock_guard<std::mutex> lock{ m_mutex };
222+
std::lock_guard<std::recursive_mutex> lock{ m_mutex };
221223

222224
for (auto& titleId : titleIds)
223225
{
@@ -251,7 +253,7 @@ HRESULT PresenceService::StopTrackingAdditionalTitles(
251253
const Vector<uint32_t>& titleIds
252254
) noexcept
253255
{
254-
std::lock_guard<std::mutex> lock{ m_mutex };
256+
std::lock_guard<std::recursive_mutex> lock{ m_mutex };
255257

256258
List<uint32_t> removedTitles{};
257259
for (auto& titleId : titleIds)
@@ -415,7 +417,7 @@ void PresenceService::HandleDevicePresenceChanged(
415417
_In_ bool isUserLoggedOnDevice
416418
) const noexcept
417419
{
418-
std::unique_lock<std::mutex> lock{ m_mutex };
420+
std::unique_lock<std::recursive_mutex> lock{ m_mutex };
419421
auto handlers{ m_devicePresenceChangedHandlers };
420422
lock.unlock();
421423

@@ -431,7 +433,7 @@ void PresenceService::HandleTitlePresenceChanged(
431433
_In_ XblPresenceTitleState state
432434
) const noexcept
433435
{
434-
std::unique_lock<std::mutex> lock{ m_mutex };
436+
std::unique_lock<std::recursive_mutex> lock{ m_mutex };
435437
auto handlers{ m_titlePresenceChangedHandlers };
436438
lock.unlock();
437439

@@ -443,7 +445,7 @@ void PresenceService::HandleTitlePresenceChanged(
443445

444446
void PresenceService::HandleRTAResync()
445447
{
446-
std::unique_lock<std::mutex> lock{ m_mutex };
448+
std::unique_lock<std::recursive_mutex> lock{ m_mutex };
447449

448450
LOGS_DEBUG << "Resyncing " << m_trackedXuids.size() << " Presence Subscriptions";
449451

@@ -456,7 +458,7 @@ void PresenceService::HandleRTAResync()
456458
return;
457459
}
458460

459-
std::unique_lock<std::mutex> lock{ m_mutex };
461+
std::unique_lock<std::recursive_mutex> lock{ m_mutex };
460462

461463
if(Succeeded(result))
462464
{

Source/Services/RealTimeActivityManager/real_time_activity_connection.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ struct ServiceSubscription
4848
Set<std::shared_ptr<Subscription>> clientSubscriptions;
4949
List<AsyncContext<Result<void>>> subscribeAsyncContexts;
5050
List<AsyncContext<Result<void>>> unsubscribeAsyncContexts;
51+
52+
// OnSubscribe data payload
53+
JsonDocument onSubscribeData{ rapidjson::kNullType };
5154
};
5255

5356
// RTA message types and error codes define by service here http://xboxwiki/wiki/Real_Time_Activity
@@ -229,6 +232,8 @@ HRESULT Connection::AddSubscription(
229232
{
230233
// Subscription is already active, trivially complete
231234
lock.unlock();
235+
// Pass along original OnSubscribe payload for this subscription
236+
sub->OnSubscribe(serviceSub->onSubscribeData);
232237
async.Complete(S_OK);
233238
return S_OK;
234239
}
@@ -431,7 +436,7 @@ void Connection::SubscribeResponseHandler(_In_ const JsonValue& message) noexcep
431436
case ErrorCode::Success:
432437
{
433438
serviceSub->serviceId = message[3].GetInt();
434-
const auto& data = message[4];
439+
serviceSub->onSubscribeData.CopyFrom(message[4], serviceSub->onSubscribeData.GetAllocator());
435440

436441
m_subsByServiceId[serviceSub->serviceId] = serviceSub;
437442
List<AsyncContext<Result<void>>> subscribeAsyncContexts{ std::move(serviceSub->subscribeAsyncContexts) };
@@ -470,7 +475,7 @@ void Connection::SubscribeResponseHandler(_In_ const JsonValue& message) noexcep
470475
}
471476
for (auto& clientSub : clientSubs)
472477
{
473-
clientSub->OnSubscribe(data);
478+
clientSub->OnSubscribe(serviceSub->onSubscribeData);
474479
}
475480

476481
return;

Source/Services/Social/Manager/social_manager_api.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,12 +144,15 @@ try
144144
auto group{ socialManager.GetUserGroup(groupHandle) };
145145
if (!group)
146146
{
147+
*users = nullptr;
147148
*usersCount = 0;
148149
return E_UNEXPECTED;
149150
}
150151

151-
*users = group->Users().data();
152-
*usersCount = group->Users().size();
152+
auto& groupUsers = group->Users();
153+
*users = groupUsers.data();
154+
*usersCount = groupUsers.size();
155+
153156
return S_OK;
154157
});
155158
}
@@ -170,12 +173,15 @@ try
170173
auto group{ socialManager.GetUserGroup(groupHandle) };
171174
if (!group)
172175
{
176+
*trackedUsers = nullptr;
173177
*trackedUsersCount = 0;
174178
return E_UNEXPECTED;
175179
}
176180

177-
*trackedUsers = group->TrackedUsers().data();
178-
*trackedUsersCount = group->TrackedUsers().size();
181+
const auto& groupTrackedUsers = group->TrackedUsers();
182+
*trackedUsers = groupTrackedUsers.data();
183+
*trackedUsersCount = groupTrackedUsers.size();
184+
179185
return S_OK;
180186
});
181187
}

0 commit comments

Comments
 (0)