From 3f5483c79b52ee74da056700fa56fe7fbb7805d4 Mon Sep 17 00:00:00 2001 From: Dario Casalinuovo Date: Mon, 27 Jul 2015 18:07:12 +0200 Subject: [PATCH] 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. --- src/bin/desklink/MixerControl.cpp | 42 ++++++------------------------- 1 file changed, 8 insertions(+), 34 deletions(-) diff --git a/src/bin/desklink/MixerControl.cpp b/src/bin/desklink/MixerControl.cpp index 54665cb079..dea3fa52e6 100644 --- a/src/bin/desklink/MixerControl.cpp +++ b/src/bin/desklink/MixerControl.cpp @@ -7,6 +7,7 @@ * François Revol * Axel Dörfler, axeld@pinc-software.de. * Puck Meerburg, puck@puckipedia.nl + * Dario Casalinuovo, b.vitruvio@gmail.com */ @@ -45,31 +46,13 @@ MixerControl::Connect(int32 volumeWhich, float* _value, const char** _error) _Disconnect(); - bool retrying = false; - 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; BMediaRoster* roster = BMediaRoster::Roster(&status); -retry: - // Here we release the BMediaRoster once if we can't access the system - // 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) { + if (BMediaRoster::IsRunning() && roster != NULL + && status == B_OK) { switch (volumeWhich) { case VOLUME_USE_MIXER: status = roster->GetAudioMixer(&fGainMediaNode); @@ -160,20 +143,11 @@ retry: errorString = "No parameter web"; fParameterWeb = NULL; } - } else { - if (!retrying) { - retrying = true; - goto retry; - } + } else errorString = volumeWhich ? "No Audio output" : "No Mixer"; - } - } else { - if (!retrying) { - retrying = true; - goto retry; - } - errorString = "No Media Roster"; - } + + } else + errorString = "Media services not running"; if (status != B_OK) fGainMediaNode = media_node::null;