MediaPlayer: Remove unneeded MediaRoster locking.
* No idea why it was added in the first place, just keep in mind BMediaRoster does things using ports and there's no need of locking it. * Style fixes along the way.
This commit is contained in:
@@ -111,8 +111,7 @@ NodeManager::InitCheck()
|
|||||||
void
|
void
|
||||||
NodeManager::SetPlayMode(int32 mode, bool continuePlaying)
|
NodeManager::SetPlayMode(int32 mode, bool continuePlaying)
|
||||||
{
|
{
|
||||||
if (fVideoConsumer != NULL && fMediaRoster != NULL
|
if (fVideoConsumer != NULL && fMediaRoster != NULL) {
|
||||||
&& fMediaRoster->Lock()) {
|
|
||||||
BMediaNode::run_mode runMode = mode > 0 ?
|
BMediaNode::run_mode runMode = mode > 0 ?
|
||||||
BMediaNode::B_DROP_DATA : BMediaNode::B_OFFLINE;
|
BMediaNode::B_DROP_DATA : BMediaNode::B_OFFLINE;
|
||||||
status_t ret = fMediaRoster->SetRunModeNode(fVideoConnection.consumer,
|
status_t ret = fMediaRoster->SetRunModeNode(fVideoConnection.consumer,
|
||||||
@@ -121,7 +120,6 @@ NodeManager::SetPlayMode(int32 mode, bool continuePlaying)
|
|||||||
printf("NodeManager::SetPlayMode(%" B_PRId32 "), setting run mode "
|
printf("NodeManager::SetPlayMode(%" B_PRId32 "), setting run mode "
|
||||||
"failed: %s\n", mode, strerror(ret));
|
"failed: %s\n", mode, strerror(ret));
|
||||||
}
|
}
|
||||||
fMediaRoster->Unlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaybackManager::SetPlayMode(mode, continuePlaying);
|
PlaybackManager::SetPlayMode(mode, continuePlaying);
|
||||||
@@ -286,14 +284,11 @@ NodeManager::_SetUpNodes(color_space preferredVideoFormat, uint32 enabledNodes,
|
|||||||
fMediaRoster = NULL;
|
fMediaRoster = NULL;
|
||||||
return fStatus;
|
return fStatus;
|
||||||
}
|
}
|
||||||
if (!fMediaRoster->Lock())
|
|
||||||
return B_ERROR;
|
|
||||||
|
|
||||||
// find the time source
|
// find the time source
|
||||||
fStatus = fMediaRoster->GetTimeSource(&fTimeSource);
|
fStatus = fMediaRoster->GetTimeSource(&fTimeSource);
|
||||||
if (fStatus != B_OK) {
|
if (fStatus != B_OK) {
|
||||||
print_error("Can't get a time source", fStatus);
|
print_error("Can't get a time source", fStatus);
|
||||||
fMediaRoster->Unlock();
|
|
||||||
return fStatus;
|
return fStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,7 +297,6 @@ NodeManager::_SetUpNodes(color_space preferredVideoFormat, uint32 enabledNodes,
|
|||||||
fStatus = _SetUpVideoNodes(preferredVideoFormat, useOverlays);
|
fStatus = _SetUpVideoNodes(preferredVideoFormat, useOverlays);
|
||||||
if (fStatus != B_OK) {
|
if (fStatus != B_OK) {
|
||||||
print_error("Error setting up video nodes", fStatus);
|
print_error("Error setting up video nodes", fStatus);
|
||||||
fMediaRoster->Unlock();
|
|
||||||
return fStatus;
|
return fStatus;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
@@ -313,7 +307,6 @@ NodeManager::_SetUpNodes(color_space preferredVideoFormat, uint32 enabledNodes,
|
|||||||
fStatus = _SetUpAudioNodes(audioFrameRate, audioChannels);
|
fStatus = _SetUpAudioNodes(audioFrameRate, audioChannels);
|
||||||
if (fStatus != B_OK) {
|
if (fStatus != B_OK) {
|
||||||
print_error("Error setting up audio nodes", fStatus);
|
print_error("Error setting up audio nodes", fStatus);
|
||||||
fMediaRoster->Unlock();
|
|
||||||
return fStatus;
|
return fStatus;
|
||||||
}
|
}
|
||||||
fNoAudio = false;
|
fNoAudio = false;
|
||||||
@@ -322,9 +315,6 @@ fNoAudio = true;
|
|||||||
printf("running without audio node\n");
|
printf("running without audio node\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// we're done mocking with the media roster
|
|
||||||
fMediaRoster->Unlock();
|
|
||||||
|
|
||||||
return fStatus;
|
return fStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -548,10 +538,6 @@ TRACE("NodeManager::_TearDownNodes()\n");
|
|||||||
"roster: %s\n", strerror(err));
|
"roster: %s\n", strerror(err));
|
||||||
fMediaRoster = NULL;
|
fMediaRoster = NULL;
|
||||||
}
|
}
|
||||||
// begin mucking with the media roster
|
|
||||||
bool mediaRosterLocked = false;
|
|
||||||
if (fMediaRoster && fMediaRoster->Lock())
|
|
||||||
mediaRosterLocked = true;
|
|
||||||
|
|
||||||
if (fVideoConsumer && fVideoProducer && fVideoConnection.connected) {
|
if (fVideoConsumer && fVideoProducer && fVideoConnection.connected) {
|
||||||
// disconnect
|
// disconnect
|
||||||
@@ -585,7 +571,7 @@ TRACE(" releasing video consumer...\n");
|
|||||||
// Mixer is a Bad Idea (tm). So, we just disconnect from it, and
|
// Mixer is a Bad Idea (tm). So, we just disconnect from it, and
|
||||||
// release our references to the nodes that we're using. We *are*
|
// release our references to the nodes that we're using. We *are*
|
||||||
// supposed to do that even for global nodes like the Mixer.
|
// supposed to do that even for global nodes like the Mixer.
|
||||||
if (fMediaRoster && disconnect) {
|
if (fMediaRoster != NULL && disconnect) {
|
||||||
TRACE(" disconnecting audio...\n");
|
TRACE(" disconnecting audio...\n");
|
||||||
err = fMediaRoster->Disconnect(fAudioConnection.producer.node,
|
err = fMediaRoster->Disconnect(fAudioConnection.producer.node,
|
||||||
fAudioConnection.source, fAudioConnection.consumer.node,
|
fAudioConnection.source, fAudioConnection.consumer.node,
|
||||||
@@ -604,7 +590,7 @@ TRACE(" releasing audio producer...\n");
|
|||||||
fAudioProducer = NULL;
|
fAudioProducer = NULL;
|
||||||
fAudioConnection.connected = false;
|
fAudioConnection.connected = false;
|
||||||
|
|
||||||
if (fMediaRoster && disconnect) {
|
if (fMediaRoster != NULL && disconnect) {
|
||||||
TRACE(" releasing audio consumer...\n");
|
TRACE(" releasing audio consumer...\n");
|
||||||
fMediaRoster->ReleaseNode(fAudioConnection.consumer);
|
fMediaRoster->ReleaseNode(fAudioConnection.consumer);
|
||||||
} else {
|
} else {
|
||||||
@@ -612,9 +598,7 @@ TRACE(" releasing audio consumer...\n");
|
|||||||
"audio consumer (system mixer)!\n");
|
"audio consumer (system mixer)!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// we're done mucking with the media roster
|
|
||||||
if (mediaRosterLocked && fMediaRoster)
|
|
||||||
fMediaRoster->Unlock();
|
|
||||||
TRACE("NodeManager::_TearDownNodes() done\n");
|
TRACE("NodeManager::_TearDownNodes() done\n");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
@@ -626,9 +610,6 @@ NodeManager::_StartNodes()
|
|||||||
status_t status = B_NO_INIT;
|
status_t status = B_NO_INIT;
|
||||||
if (!fMediaRoster)
|
if (!fMediaRoster)
|
||||||
return status;
|
return status;
|
||||||
// begin mucking with the media roster
|
|
||||||
if (!fMediaRoster->Lock())
|
|
||||||
return B_ERROR;
|
|
||||||
|
|
||||||
bigtime_t latency = 0;
|
bigtime_t latency = 0;
|
||||||
bigtime_t initLatency = 0;
|
bigtime_t initLatency = 0;
|
||||||
@@ -723,9 +704,6 @@ NodeManager::_StartNodes()
|
|||||||
|
|
||||||
fPerformanceTimeBase = perf;
|
fPerformanceTimeBase = perf;
|
||||||
|
|
||||||
// done mucking with the media roster
|
|
||||||
fMediaRoster->Unlock();
|
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -735,7 +713,7 @@ NodeManager::_StopNodes()
|
|||||||
{
|
{
|
||||||
TRACE("NodeManager::_StopNodes()\n");
|
TRACE("NodeManager::_StopNodes()\n");
|
||||||
fMediaRoster = BMediaRoster::Roster();
|
fMediaRoster = BMediaRoster::Roster();
|
||||||
if (fMediaRoster != NULL && fMediaRoster->Lock()) {
|
if (fMediaRoster != NULL) {
|
||||||
// begin mucking with the media roster
|
// begin mucking with the media roster
|
||||||
if (fVideoProducer != NULL) {
|
if (fVideoProducer != NULL) {
|
||||||
TRACE(" stopping video producer...\n");
|
TRACE(" stopping video producer...\n");
|
||||||
@@ -751,8 +729,6 @@ NodeManager::_StopNodes()
|
|||||||
fMediaRoster->StopNode(fVideoConnection.consumer, 0, true);
|
fMediaRoster->StopNode(fVideoConnection.consumer, 0, true);
|
||||||
}
|
}
|
||||||
TRACE(" all nodes stopped\n");
|
TRACE(" all nodes stopped\n");
|
||||||
// done mucking with the media roster
|
|
||||||
fMediaRoster->Unlock();
|
|
||||||
}
|
}
|
||||||
TRACE("NodeManager::_StopNodes() done\n");
|
TRACE("NodeManager::_StopNodes() done\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user