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,18 +307,14 @@ 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;
|
||||||
} else {
|
} else {
|
||||||
fNoAudio = true;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,7 +530,7 @@ NodeManager::_SetUpAudioNodes(float audioFrameRate, uint32 audioChannels)
|
|||||||
status_t
|
status_t
|
||||||
NodeManager::_TearDownNodes(bool disconnect)
|
NodeManager::_TearDownNodes(bool disconnect)
|
||||||
{
|
{
|
||||||
TRACE("NodeManager::_TearDownNodes()\n");
|
TRACE("NodeManager::_TearDownNodes()\n");
|
||||||
status_t err = B_OK;
|
status_t err = B_OK;
|
||||||
fMediaRoster = BMediaRoster::Roster(&err);
|
fMediaRoster = BMediaRoster::Roster(&err);
|
||||||
if (err != B_OK) {
|
if (err != B_OK) {
|
||||||
@@ -548,15 +538,11 @@ 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
|
||||||
if (fMediaRoster) {
|
if (fMediaRoster) {
|
||||||
TRACE(" disconnecting video...\n");
|
TRACE(" disconnecting video...\n");
|
||||||
err = fMediaRoster->Disconnect(fVideoConnection.producer.node,
|
err = fMediaRoster->Disconnect(fVideoConnection.producer.node,
|
||||||
fVideoConnection.source, fVideoConnection.consumer.node,
|
fVideoConnection.source, fVideoConnection.consumer.node,
|
||||||
fVideoConnection.destination);
|
fVideoConnection.destination);
|
||||||
@@ -569,12 +555,12 @@ TRACE(" disconnecting video...\n");
|
|||||||
fVideoConnection.connected = false;
|
fVideoConnection.connected = false;
|
||||||
}
|
}
|
||||||
if (fVideoProducer) {
|
if (fVideoProducer) {
|
||||||
TRACE(" releasing video producer...\n");
|
TRACE(" releasing video producer...\n");
|
||||||
fVideoProducer->Release();
|
fVideoProducer->Release();
|
||||||
fVideoProducer = NULL;
|
fVideoProducer = NULL;
|
||||||
}
|
}
|
||||||
if (fVideoConsumer) {
|
if (fVideoConsumer) {
|
||||||
TRACE(" releasing video consumer...\n");
|
TRACE(" releasing video consumer...\n");
|
||||||
fVideoConsumer->Release();
|
fVideoConsumer->Release();
|
||||||
fVideoConsumer = NULL;
|
fVideoConsumer = NULL;
|
||||||
}
|
}
|
||||||
@@ -585,8 +571,8 @@ 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,
|
||||||
fAudioConnection.destination);
|
fAudioConnection.destination);
|
||||||
@@ -599,23 +585,21 @@ TRACE(" disconnecting audio...\n");
|
|||||||
"disconnect audio nodes, no media server!\n");
|
"disconnect audio nodes, no media server!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE(" releasing audio producer...\n");
|
TRACE(" releasing audio producer...\n");
|
||||||
fAudioProducer->Release();
|
fAudioProducer->Release();
|
||||||
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 {
|
||||||
fprintf(stderr, "NodeManager::_TearDownNodes() - cannot release "
|
fprintf(stderr, "NodeManager::_TearDownNodes() - cannot release "
|
||||||
"audio consumer (system mixer)!\n");
|
"audio consumer (system mixer)!\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// we're done mucking with the media roster
|
|
||||||
if (mediaRosterLocked && fMediaRoster)
|
TRACE("NodeManager::_TearDownNodes() done\n");
|
||||||
fMediaRoster->Unlock();
|
|
||||||
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