Skip to content

Commit

Permalink
2210 GDK QFE1 (#599)
Browse files Browse the repository at this point in the history
* 2210 GDK QFE1
  • Loading branch information
natiskan authored Dec 9, 2022
1 parent 525786e commit f1a347b
Show file tree
Hide file tree
Showing 23 changed files with 226 additions and 81 deletions.
36 changes: 36 additions & 0 deletions External/Xal/Source/Xal/Include/Xal/xal_internal_marketing.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#pragma once

#if !defined(__cplusplus)
#error C++11 required
#endif

// Attention: This file is intended for internal uses only.
// Its use is not recommended and not supported.

#include <Xal/xal_types.h>

extern "C"
{
//-----------------------------------------------------------------------------
// Marketing State
//-----------------------------------------------------------------------------

/// <summary>
/// Enum defining the various marketing states.
/// </summary>
typedef enum XalMarketingState
{
/// <summary>Existing user</summary>
XalMarketingState_ExistingUser = 0,
/// <summary>User went through account creation</summary>
XalMarketingState_NewUser = 1,
/// <summary>User went through account creation and saw the first party marketing notice</summary>
XalMarketingState_NewUserFirstPartyNotice = 2,
} XalMarketingState;

STDAPI XalUserGetMarketingState(
_In_ XalUserHandle user,
_Out_ XalMarketingState* marketingState
) noexcept;

}
2 changes: 1 addition & 1 deletion External/Xal/Source/Xal/Include/Xal/xal_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ extern "C"
/// YYYYMMDD Date string describing the date the build was created
/// rrr QFE number (000 indicates base release)
/// </summary>
#define XAL_VERSION "2022.08.20220825.000"
#define XAL_VERSION "2022.10.20221205.000"

}
22 changes: 9 additions & 13 deletions Include/xsapi-c/social_manager_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ STDAPI_(bool) XblSocialManagerPresenceRecordIsUserPlayingTitle(
/// <remarks>
/// Call this API after calling either <see cref="XblSocialManagerCreateSocialUserGroupFromFilters"/>
/// or <see cref="XblSocialManagerCreateSocialUserGroupFromList"/> to create an XblSocialManagerUserGroup.
/// Have the XblSocialManagerUserGroupHandle returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded
/// The XblSocialManagerUserGroupHandle is returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded
/// event in <see cref="XblSocialManagerDoWork"/>.
/// </remarks>
STDAPI XblSocialManagerUserGroupGetType(
Expand All @@ -482,7 +482,7 @@ STDAPI XblSocialManagerUserGroupGetType(
/// <remarks>
/// Call this API after calling either <see cref="XblSocialManagerCreateSocialUserGroupFromFilters"/>
/// or <see cref="XblSocialManagerCreateSocialUserGroupFromList"/> to create an XblSocialManagerUserGroup.
/// Have the XblSocialManagerUserGroupHandle returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event
/// The XblSocialManagerUserGroupHandle is returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event
/// in <see cref="XblSocialManagerDoWork"/>.
/// </remarks>
STDAPI XblSocialManagerUserGroupGetLocalUser(
Expand All @@ -501,7 +501,7 @@ STDAPI XblSocialManagerUserGroupGetLocalUser(
/// If the group is not a filter group, E_UNEXPECTED will be returned.
/// Call this API after either <see cref="XblSocialManagerCreateSocialUserGroupFromFilters"/>
/// or <see cref="XblSocialManagerCreateSocialUserGroupFromList"/> to create an XblSocialManagerUserGroup.
/// Have the XblSocialManagerUserGroupHandle returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded
/// The XblSocialManagerUserGroupHandle is returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded
/// event in <see cref="XblSocialManagerDoWork"/>.<br/>
/// </remarks>
STDAPI XblSocialManagerUserGroupGetFilters(
Expand Down Expand Up @@ -533,8 +533,7 @@ typedef const XblSocialManagerUser* const* XblSocialManagerUserPtrArray;
/// they are statically sized and trivially copyable.
/// Call this API after calling either <see cref="XblSocialManagerCreateSocialUserGroupFromFilters"/>
/// or <see cref="XblSocialManagerCreateSocialUserGroupFromList"/> to create an XblSocialManagerUserGroup.
/// Have the XblSocialManagerUserGroupHandle returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded
/// event in <see cref="XblSocialManagerDoWork"/>.
/// Wait for <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event in <see cref="XblSocialManagerDoWork"/>. Prior to this the group will be empty.
/// </remarks>
STDAPI XblSocialManagerUserGroupGetUsers(
_In_ XblSocialManagerUserGroupHandle group,
Expand All @@ -555,8 +554,7 @@ STDAPI XblSocialManagerUserGroupGetUsers(
/// but for filter-based groups, the set tracked users changes as the local user's relationships change.
/// Call this API after calling either <see cref="XblSocialManagerCreateSocialUserGroupFromFilters"/>
/// or <see cref="XblSocialManagerCreateSocialUserGroupFromList"/> to create an XblSocialManagerUserGroup.
/// Have the XblSocialManagerUserGroupHandle returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event
/// in <see cref="XblSocialManagerDoWork"/>.
/// Wait for <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event in <see cref="XblSocialManagerDoWork"/>. Prior to this the group will be empty.
/// </remarks>
STDAPI XblSocialManagerUserGroupGetUsersTrackedByGroup(
_In_ XblSocialManagerUserGroupHandle group,
Expand Down Expand Up @@ -630,8 +628,7 @@ STDAPI XblSocialManagerDoWork(
/// (invalidating the returned handle) if the associated user is removed from Social Manager.</param>
/// <returns>HRESULT return code for this API operation.</returns>
/// <remarks>
/// The result of a user group being loaded will be triggered through
/// the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event in <see cref="XblSocialManagerDoWork"/>.
/// Wait for <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event in <see cref="XblSocialManagerDoWork"/>. Prior to this the group will be empty.
/// </remarks>
STDAPI XblSocialManagerCreateSocialUserGroupFromFilters(
_In_ XblUserHandle user,
Expand All @@ -652,8 +649,7 @@ STDAPI XblSocialManagerCreateSocialUserGroupFromFilters(
/// (invalidating the returned handle) if the associated user is removed from Social Manager.</param>
/// <returns>HRESULT return code for this API operation.</returns>
/// <remarks>
/// The result of a user group being loaded will be triggered through
/// the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event in <see cref="XblSocialManagerDoWork"/>.
/// Wait for <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event in <see cref="XblSocialManagerDoWork"/>. Prior to this the group will be empty.
/// </remarks>
STDAPI XblSocialManagerCreateSocialUserGroupFromList(
_In_ XblUserHandle user,
Expand All @@ -671,7 +667,7 @@ STDAPI XblSocialManagerCreateSocialUserGroupFromList(
/// This will stop updaing the Xbox Social User Group and remove tracking for any users the XblSocialManagerUserGroup holds.
/// Call this API after calling either <see cref="XblSocialManagerCreateSocialUserGroupFromFilters"/>
/// or <see cref="XblSocialManagerCreateSocialUserGroupFromList"/> to create an XblSocialManagerUserGroup.
/// Have the XblSocialManagerUserGroupHandle returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event
/// The XblSocialManagerUserGroupHandle is returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded event
/// in <see cref="XblSocialManagerDoWork"/>.
/// </remarks>
STDAPI XblSocialManagerDestroySocialUserGroup(
Expand Down Expand Up @@ -722,7 +718,7 @@ STDAPI XblSocialManagerGetLocalUsers(
/// <see cref="XblSocialManagerEventType"/>::SocialUserGroupUpdated event in <see cref="XblSocialManagerDoWork"/>.
/// Call this API after calling either <see cref="XblSocialManagerCreateSocialUserGroupFromFilters"/>
/// or <see cref="XblSocialManagerCreateSocialUserGroupFromList"/> to create an XblSocialManagerUserGroup.
/// Have the XblSocialManagerUserGroupHandle returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded
/// The XblSocialManagerUserGroupHandle is returned by the <see cref="XblSocialManagerEventType"/>::SocialUserGroupLoaded
/// event in <see cref="XblSocialManagerDoWork"/>.
/// </remarks>
STDAPI XblSocialManagerUpdateSocialUserGroup(
Expand Down
2 changes: 1 addition & 1 deletion Source/Services/Multiplayer/multiplayer_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ class MultiplayerService : public std::enable_shared_from_this<MultiplayerServic
_In_ AsyncContext<Result<void>> async
) noexcept;

HRESULT SubscribeToRta() noexcept;
HRESULT SubscribeToRta(std::unique_lock<std::mutex> lock) noexcept;
HRESULT UnsubscribeFromRta() noexcept;

HRESULT WriteSessionUsingSubpath(
Expand Down
26 changes: 19 additions & 7 deletions Source/Services/Multiplayer/multiplayer_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1157,7 +1157,7 @@ HRESULT MultiplayerService::SetRtaConnectionId(
return S_OK;
}

HRESULT MultiplayerService::SubscribeToRta() noexcept
HRESULT MultiplayerService::SubscribeToRta(std::unique_lock<std::mutex> lock) noexcept
{
if (m_subscription == nullptr)
{
Expand Down Expand Up @@ -1223,6 +1223,8 @@ HRESULT MultiplayerService::SubscribeToRta() noexcept
}
});

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

HRESULT MultiplayerService::EnableMultiplayerSubscriptions() noexcept
{
std::lock_guard<std::mutex> lock{ m_mutexMultiplayerService };
std::unique_lock<std::mutex> lock{ m_mutexMultiplayerService };
m_forceEnableRtaSubscription = true;
return SubscribeToRta();
return SubscribeToRta(std::move(lock));
}

HRESULT MultiplayerService::DisableMultiplayerSubscriptions() noexcept
Expand Down Expand Up @@ -1281,11 +1283,21 @@ XblFunctionContext MultiplayerService::AddMultiplayerSessionChangedHandler(
_In_ MultiplayerSubscription::SessionChangedHandler handler
) noexcept
{
std::lock_guard<std::mutex> lock{ m_mutexMultiplayerService };
{
std::unique_lock<std::mutex> lock{ m_mutexMultiplayerService };
SubscribeToRta(std::move(lock));
}

XblFunctionContext token{};
{
std::unique_lock<std::mutex> lock{ m_mutexMultiplayerService };
if (m_subscription)
{
token = m_subscription->AddSessionChangedHandler(std::move(handler));
}
}

SubscribeToRta();
assert(m_subscription);
return m_subscription->AddSessionChangedHandler(std::move(handler));
return token;
}

void MultiplayerService::RemoveMultiplayerSessionChangedHandler(
Expand Down
2 changes: 1 addition & 1 deletion Source/Services/Presence/presence_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class PresenceService : public std::enable_shared_from_this<PresenceService>
Map<uint32_t, size_t> m_trackedTitles;
uint32_t const m_titleId;

mutable std::mutex m_mutex;
mutable std::recursive_mutex m_mutex;

friend class DevicePresenceChangeSubscription;
friend class TitlePresenceChangeSubscription;
Expand Down
30 changes: 16 additions & 14 deletions Source/Services/Presence/presence_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ XblFunctionContext PresenceService::AddTitlePresenceChangedHandler(
TitlePresenceChangedHandler handler
) noexcept
{
std::lock_guard<std::mutex> lock{ m_mutex };
std::unique_lock<std::recursive_mutex> lock{ m_mutex };

m_titlePresenceChangedHandlers[m_nextHandlerToken] = std::move(handler);
auto token = m_nextHandlerToken++;

// Add subs to RTA manager if needed
if (m_titlePresenceChangedHandlers.empty())
Expand All @@ -70,15 +73,14 @@ XblFunctionContext PresenceService::AddTitlePresenceChangedHandler(
}
}

m_titlePresenceChangedHandlers[m_nextHandlerToken] = std::move(handler);
return m_nextHandlerToken++;
return token;
}

void PresenceService::RemoveTitlePresenceChangedHandler(
_In_ XblFunctionContext context
) noexcept
{
std::lock_guard<std::mutex> lock{ m_mutex };
std::lock_guard<std::recursive_mutex> lock{ m_mutex };

auto removed{ m_titlePresenceChangedHandlers.erase(context) };
if (removed && m_titlePresenceChangedHandlers.empty())
Expand All @@ -98,7 +100,7 @@ XblFunctionContext PresenceService::AddDevicePresenceChangedHandler(
DevicePresenceChangedHandler handler
) noexcept
{
std::lock_guard<std::mutex> lock{ m_mutex };
std::lock_guard<std::recursive_mutex> lock{ m_mutex };

// Add subs to RTA manager if needed
if (m_devicePresenceChangedHandlers.empty())
Expand All @@ -118,7 +120,7 @@ void PresenceService::RemoveDevicePresenceChangedHandler(
_In_ XblFunctionContext context
) noexcept
{
std::lock_guard<std::mutex> lock{ m_mutex };
std::lock_guard<std::recursive_mutex> lock{ m_mutex };

auto removed{ m_devicePresenceChangedHandlers.erase(context) };
if (removed && m_devicePresenceChangedHandlers.empty())
Expand All @@ -135,7 +137,7 @@ HRESULT PresenceService::TrackUsers(
const Vector<uint64_t>& xuids
) noexcept
{
std::lock_guard<std::mutex> lock{ m_mutex };
std::lock_guard<std::recursive_mutex> lock{ m_mutex };

if (!m_resyncHandlerToken)
{
Expand Down Expand Up @@ -188,7 +190,7 @@ HRESULT PresenceService::StopTrackingUsers(
const Vector<uint64_t>& xuids
) noexcept
{
std::lock_guard<std::mutex> lock{ m_mutex };
std::lock_guard<std::recursive_mutex> lock{ m_mutex };

for (auto& xuid : xuids)
{
Expand Down Expand Up @@ -217,7 +219,7 @@ HRESULT PresenceService::TrackAdditionalTitles(
const Vector<uint32_t>& titleIds
) noexcept
{
std::lock_guard<std::mutex> lock{ m_mutex };
std::lock_guard<std::recursive_mutex> lock{ m_mutex };

for (auto& titleId : titleIds)
{
Expand Down Expand Up @@ -251,7 +253,7 @@ HRESULT PresenceService::StopTrackingAdditionalTitles(
const Vector<uint32_t>& titleIds
) noexcept
{
std::lock_guard<std::mutex> lock{ m_mutex };
std::lock_guard<std::recursive_mutex> lock{ m_mutex };

List<uint32_t> removedTitles{};
for (auto& titleId : titleIds)
Expand Down Expand Up @@ -415,7 +417,7 @@ void PresenceService::HandleDevicePresenceChanged(
_In_ bool isUserLoggedOnDevice
) const noexcept
{
std::unique_lock<std::mutex> lock{ m_mutex };
std::unique_lock<std::recursive_mutex> lock{ m_mutex };
auto handlers{ m_devicePresenceChangedHandlers };
lock.unlock();

Expand All @@ -431,7 +433,7 @@ void PresenceService::HandleTitlePresenceChanged(
_In_ XblPresenceTitleState state
) const noexcept
{
std::unique_lock<std::mutex> lock{ m_mutex };
std::unique_lock<std::recursive_mutex> lock{ m_mutex };
auto handlers{ m_titlePresenceChangedHandlers };
lock.unlock();

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

void PresenceService::HandleRTAResync()
{
std::unique_lock<std::mutex> lock{ m_mutex };
std::unique_lock<std::recursive_mutex> lock{ m_mutex };

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

Expand All @@ -456,7 +458,7 @@ void PresenceService::HandleRTAResync()
return;
}

std::unique_lock<std::mutex> lock{ m_mutex };
std::unique_lock<std::recursive_mutex> lock{ m_mutex };

if(Succeeded(result))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ struct ServiceSubscription
Set<std::shared_ptr<Subscription>> clientSubscriptions;
List<AsyncContext<Result<void>>> subscribeAsyncContexts;
List<AsyncContext<Result<void>>> unsubscribeAsyncContexts;

// OnSubscribe data payload
JsonDocument onSubscribeData{ rapidjson::kNullType };
};

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

m_subsByServiceId[serviceSub->serviceId] = serviceSub;
List<AsyncContext<Result<void>>> subscribeAsyncContexts{ std::move(serviceSub->subscribeAsyncContexts) };
Expand Down Expand Up @@ -470,7 +475,7 @@ void Connection::SubscribeResponseHandler(_In_ const JsonValue& message) noexcep
}
for (auto& clientSub : clientSubs)
{
clientSub->OnSubscribe(data);
clientSub->OnSubscribe(serviceSub->onSubscribeData);
}

return;
Expand Down
14 changes: 10 additions & 4 deletions Source/Services/Social/Manager/social_manager_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,15 @@ try
auto group{ socialManager.GetUserGroup(groupHandle) };
if (!group)
{
*users = nullptr;
*usersCount = 0;
return E_UNEXPECTED;
}

*users = group->Users().data();
*usersCount = group->Users().size();
auto& groupUsers = group->Users();
*users = groupUsers.data();
*usersCount = groupUsers.size();

return S_OK;
});
}
Expand All @@ -170,12 +173,15 @@ try
auto group{ socialManager.GetUserGroup(groupHandle) };
if (!group)
{
*trackedUsers = nullptr;
*trackedUsersCount = 0;
return E_UNEXPECTED;
}

*trackedUsers = group->TrackedUsers().data();
*trackedUsersCount = group->TrackedUsers().size();
const auto& groupTrackedUsers = group->TrackedUsers();
*trackedUsers = groupTrackedUsers.data();
*trackedUsersCount = groupTrackedUsers.size();

return S_OK;
});
}
Expand Down
Loading

0 comments on commit f1a347b

Please sign in to comment.