Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register and unregister clients with proxy to fix data race, and tidy the surrounding code #55

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/source/OpenCDMSystemPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ OpenCDMSystemPrivate::OpenCDMSystemPrivate(const std::string &system, const std:
return;
}
firebolt::rialto::ApplicationState initialState{firebolt::rialto::ApplicationState::UNKNOWN};
m_control->registerClient(m_cdmBackend, initialState);
m_control->registerClientAndUnregisterOnDestruction(m_cdmBackend, initialState);
m_cdmBackend->initialize(initialState);
}

Expand Down
3 changes: 2 additions & 1 deletion tests/mocks/ControlMock.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class ControlFactoryMock : public IControlFactory
class ControlMock : public IControl
{
public:
MOCK_METHOD(bool, registerClient, (std::weak_ptr<IControlClient> client, ApplicationState &appState), (override));
MOCK_METHOD(bool, registerClientAndUnregisterOnDestruction,
(std::weak_ptr<IControlClient> client, ApplicationState &appState), (override));
};
} // namespace firebolt::rialto

Expand Down
3 changes: 2 additions & 1 deletion tests/ut/OpenCdmSystemTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ class OpenCdmSystemTests : public testing::Test
void createValidSut()
{
EXPECT_CALL(*m_controlFactoryMock, createControl()).WillOnce(Return(m_controlMock));
EXPECT_CALL(*m_controlMock, registerClient(_, _)).WillOnce(DoAll(SetArgReferee<1>(kAppState), Return(true)));
EXPECT_CALL(*m_controlMock, registerClientAndUnregisterOnDestruction(_, _))
.WillOnce(DoAll(SetArgReferee<1>(kAppState), Return(true)));
EXPECT_CALL(*m_mediaKeysFactoryMock, createMediaKeys(kKeySystem)).WillOnce(Return(ByMove(std::move(m_mediaKeys))));

auto messageDispatcher = std::make_shared<MessageDispatcher>();
Expand Down
2 changes: 1 addition & 1 deletion tests/ut/OpenCdmTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class OpenCdmTests : public testing::Test
TEST_F(OpenCdmTests, ShouldCreateAndDestroySystem)
{
EXPECT_CALL(*m_controlFactoryMock, createControl()).WillOnce(Return(m_controlMock));
EXPECT_CALL(*m_controlMock, registerClient(_, _)).WillOnce(Return(true));
EXPECT_CALL(*m_controlMock, registerClientAndUnregisterOnDestruction(_, _)).WillOnce(Return(true));
auto *system{opencdm_create_system(kNetflixKeySystem.c_str())};
EXPECT_NE(nullptr, system);
EXPECT_EQ(ERROR_NONE, opencdm_destruct_system(system));
Expand Down
Loading