desklink: Fix problems with BMediaRoster Quit
* Improved the situation so that it should be always synchronized. Improved error message, and detection of media services not being run.
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
* François Revol
|
* François Revol
|
||||||
* Axel Dörfler, [email protected].
|
* Axel Dörfler, [email protected].
|
||||||
* Puck Meerburg, [email protected]
|
* Puck Meerburg, [email protected]
|
||||||
|
* Dario Casalinuovo, [email protected]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -45,31 +46,13 @@ MixerControl::Connect(int32 volumeWhich, float* _value, const char** _error)
|
|||||||
|
|
||||||
_Disconnect();
|
_Disconnect();
|
||||||
|
|
||||||
bool retrying = false;
|
|
||||||
|
|
||||||
status_t status = B_OK;
|
status_t status = B_OK;
|
||||||
// BMediaRoster::Roster() doesn't set it if all is ok
|
// BMediaRoster::Roster() doesn't set it if all is ok
|
||||||
const char* errorString = NULL;
|
const char* errorString = NULL;
|
||||||
BMediaRoster* roster = BMediaRoster::Roster(&status);
|
BMediaRoster* roster = BMediaRoster::Roster(&status);
|
||||||
|
|
||||||
retry:
|
if (BMediaRoster::IsRunning() && roster != NULL
|
||||||
// Here we release the BMediaRoster once if we can't access the system
|
&& status == B_OK) {
|
||||||
// mixer, to make sure it really isn't there, and it's not BMediaRoster
|
|
||||||
// that is messed up.
|
|
||||||
if (retrying) {
|
|
||||||
errorString = NULL;
|
|
||||||
PRINT(("retrying to get a Media Roster\n"));
|
|
||||||
/* BMediaRoster looks doomed */
|
|
||||||
roster = BMediaRoster::CurrentRoster();
|
|
||||||
if (roster) {
|
|
||||||
roster->Lock();
|
|
||||||
roster->Quit();
|
|
||||||
}
|
|
||||||
snooze(10000);
|
|
||||||
roster = BMediaRoster::Roster(&status);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (roster != NULL && status == B_OK) {
|
|
||||||
switch (volumeWhich) {
|
switch (volumeWhich) {
|
||||||
case VOLUME_USE_MIXER:
|
case VOLUME_USE_MIXER:
|
||||||
status = roster->GetAudioMixer(&fGainMediaNode);
|
status = roster->GetAudioMixer(&fGainMediaNode);
|
||||||
@@ -160,20 +143,11 @@ retry:
|
|||||||
errorString = "No parameter web";
|
errorString = "No parameter web";
|
||||||
fParameterWeb = NULL;
|
fParameterWeb = NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else
|
||||||
if (!retrying) {
|
|
||||||
retrying = true;
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
errorString = volumeWhich ? "No Audio output" : "No Mixer";
|
errorString = volumeWhich ? "No Audio output" : "No Mixer";
|
||||||
}
|
|
||||||
} else {
|
} else
|
||||||
if (!retrying) {
|
errorString = "Media services not running";
|
||||||
retrying = true;
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
errorString = "No Media Roster";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
fGainMediaNode = media_node::null;
|
fGainMediaNode = media_node::null;
|
||||||
|
|||||||
Reference in New Issue
Block a user