[haiku-commits] haiku: hrev49589 - in src: servers/media bin/desklink kits/media

  • From: b.vitruvio@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Fri, 28 Aug 2015 18:39:54 +0200 (CEST)

hrev49589 adds 4 changesets to branch 'master'
old head: be7d9d3f5d23570f02de6853c781a9a56b13397b
new head: 8a28f8496597f67b9e0f80c1143398763062239b
overview:
http://cgit.haiku-os.org/haiku/log/?qt=range&q=8a28f8496597+%5Ebe7d9d3f5d23

----------------------------------------------------------------------------

d15321ff907a: BMediaRoster::Roster Use BAutolock

1c3d7e0c6886: MixerControl: Add more safeness for Roster() errors

5d8765c0af90: media_server: No need to call Roster() every time

8a28f8496597: Media: Fix restart button alignment

[ Dario Casalinuovo <b.vitruvio@xxxxxxxxx> ]

----------------------------------------------------------------------------

6 files changed, 71 insertions(+), 50 deletions(-)
src/bin/desklink/MixerControl.cpp | 24 ++++++----
src/bin/desklink/MixerControl.h | 1 +
src/kits/media/MediaRoster.cpp | 11 +++--
src/preferences/media/MediaViews.cpp | 1 +
src/servers/media/DefaultManager.cpp | 82 ++++++++++++++++++--------------
src/servers/media/DefaultManager.h | 2 +

############################################################################

Commit: d15321ff907a1203836c9f5ecedd977fe1d9720a
URL: http://cgit.haiku-os.org/haiku/commit/?id=d15321ff907a
Author: Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
Date: Fri Aug 28 15:25:17 2015 UTC

BMediaRoster::Roster Use BAutolock

----------------------------------------------------------------------------

diff --git a/src/kits/media/MediaRoster.cpp b/src/kits/media/MediaRoster.cpp
index 6799b01..4268720 100644
--- a/src/kits/media/MediaRoster.cpp
+++ b/src/kits/media/MediaRoster.cpp
@@ -44,6 +44,7 @@ char __dont_remove_copyright_from_binary[] = "Copyright (c)
2002-2006 Marcus "

#include <new>

+#include <Autolock.h>
#include <BufferConsumer.h>
#include <BufferProducer.h>
#include <Locker.h>
@@ -83,6 +84,7 @@ struct RosterNotification {

static bool sServerIsUp = false;
static List<RosterNotification> sNotificationList;
+static BLocker sInitLocker("BMediaRoster::Roster locker");

} // namespace media
} // namespace BPrivate
@@ -2188,10 +2190,14 @@ BMediaRoster::UnregisterNode(BMediaNode* node)
/*static*/ BMediaRoster*
BMediaRoster::Roster(status_t* out_error)
{
- static BLocker locker("BMediaRoster::Roster locker");
- locker.Lock();
+ BAutolock lock(sInitLocker);
+
+ if (!lock.IsLocked())
+ return NULL;
+
if (out_error)
*out_error = B_OK;
+
if (sDefaultInstance == NULL) {
status_t err;
sDefaultInstance = new (std::nothrow) BMediaRosterEx(&err);
@@ -2207,7 +2213,6 @@ BMediaRoster::Roster(status_t* out_error)
*out_error = err;
}
}
- locker.Unlock();
return sDefaultInstance;
}


############################################################################

Commit: 1c3d7e0c688650e6b100f36a0472a7a5d45358b0
URL: http://cgit.haiku-os.org/haiku/commit/?id=1c3d7e0c6886
Author: Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
Date: Fri Aug 28 15:30:52 2015 UTC

MixerControl: Add more safeness for Roster() errors

----------------------------------------------------------------------------

diff --git a/src/bin/desklink/MixerControl.cpp
b/src/bin/desklink/MixerControl.cpp
index dea3fa5..81cb36c 100644
--- a/src/bin/desklink/MixerControl.cpp
+++ b/src/bin/desklink/MixerControl.cpp
@@ -28,8 +28,10 @@ MixerControl::MixerControl(int32 volumeWhich)
fMuteParameter(NULL),
fMin(0.0f),
fMax(0.0f),
- fStep(0.0f)
+ fStep(0.0f),
+ fRoster(NULL)
{
+ fRoster = BMediaRoster::Roster();
}


@@ -47,22 +49,22 @@ MixerControl::Connect(int32 volumeWhich, float* _value,
const char** _error)
_Disconnect();

status_t status = B_OK;
- // BMediaRoster::Roster() doesn't set it if all is ok
const char* errorString = NULL;
- BMediaRoster* roster = BMediaRoster::Roster(&status);
+ if (fRoster == NULL)
+ fRoster = BMediaRoster::Roster(&status);

- if (BMediaRoster::IsRunning() && roster != NULL
+ if (BMediaRoster::IsRunning() && fRoster != NULL
&& status == B_OK) {
switch (volumeWhich) {
case VOLUME_USE_MIXER:
- status = roster->GetAudioMixer(&fGainMediaNode);
+ status =
fRoster->GetAudioMixer(&fGainMediaNode);
break;
case VOLUME_USE_PHYS_OUTPUT:
- status =
roster->GetAudioOutput(&fGainMediaNode);
+ status =
fRoster->GetAudioOutput(&fGainMediaNode);
break;
}
if (status == B_OK) {
- status = roster->GetParameterWebFor(fGainMediaNode,
&fParameterWeb);
+ status = fRoster->GetParameterWebFor(fGainMediaNode,
&fParameterWeb);
if (status == B_OK) {
// Finding the Mixer slider in the audio output
ParameterWeb
int32 numParams =
fParameterWeb->CountParameters();
@@ -252,9 +254,11 @@ MixerControl::_Disconnect()
fParameterWeb = NULL;
fMixerParameter = NULL;

- BMediaRoster* roster = BMediaRoster::CurrentRoster();
- if (roster != NULL && fGainMediaNode != media_node::null)
- roster->ReleaseNode(fGainMediaNode);
+ if (fRoster == NULL)
+ fRoster = BMediaRoster::Roster();
+
+ if (fRoster != NULL && fGainMediaNode != media_node::null)
+ fRoster->ReleaseNode(fGainMediaNode);

fGainMediaNode = media_node::null;
}
diff --git a/src/bin/desklink/MixerControl.h b/src/bin/desklink/MixerControl.h
index 62d2dca..68fd125 100644
--- a/src/bin/desklink/MixerControl.h
+++ b/src/bin/desklink/MixerControl.h
@@ -56,6 +56,7 @@ private:
float fMin;
float fMax;
float fStep;
+ BMediaRoster* fRoster;
};

#endif // MIXER_CONTROL_H

############################################################################

Commit: 5d8765c0af90461ec6f9278592c000940db2b46e
URL: http://cgit.haiku-os.org/haiku/commit/?id=5d8765c0af90
Author: Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
Date: Fri Aug 28 15:32:14 2015 UTC

media_server: No need to call Roster() every time

----------------------------------------------------------------------------

diff --git a/src/servers/media/DefaultManager.cpp
b/src/servers/media/DefaultManager.cpp
index 6354189..6e00e93 100644
--- a/src/servers/media/DefaultManager.cpp
+++ b/src/servers/media/DefaultManager.cpp
@@ -11,7 +11,6 @@
#include <File.h>
#include <FindDirectory.h>
#include <MediaNode.h>
-#include <MediaRoster.h>
#include <OS.h>
#include <Path.h>
#include <TimeSource.h>
@@ -46,7 +45,8 @@ const char *kDefaultManagerSettingsFile
= "MDefaultManager";


DefaultManager::DefaultManager()
- : fMixerConnected(false),
+ :
+ fMixerConnected(false),
fPhysicalVideoOut(-1),
fPhysicalVideoIn(-1),
fPhysicalAudioOut(-1),
@@ -57,7 +57,8 @@ DefaultManager::DefaultManager()
fPhysicalAudioOutInputID(0),
fRescanThread(-1),
fRescanRequested(0),
- fRescanLock("rescan default manager")
+ fRescanLock("rescan default manager"),
+ fRoster(NULL)
{
strcpy(fPhysicalAudioOutInputName, "default");
fBeginHeader[0] = 0xab00150b;
@@ -66,6 +67,10 @@ DefaultManager::DefaultManager()
fEndHeader[0] = 0x7465726d;
fEndHeader[1] = 0x6d666c67;
fEndHeader[2] = 0x00000002;
+
+ fRoster = BMediaRoster::Roster();
+ if (fRoster == NULL)
+ TRACE("DefaultManager: The roster is NULL\n");
}


@@ -393,7 +398,7 @@ DefaultManager::_RescanThread()

// Connect the mixer and physical audio out (soundcard)
if (!fMixerConnected && fAudioMixer != -1 && fPhysicalAudioOut
!= -1) {
- fMixerConnected = B_OK == _ConnectMixerToOutput();
+ fMixerConnected = _ConnectMixerToOutput() == B_OK;
if (!fMixerConnected)
TRACE("DefaultManager: failed to connect mixer
and "
"soundcard\n");
@@ -455,7 +460,7 @@ DefaultManager::_FindPhysical(volatile media_node_id *id,
uint32 default_type,
memset(&format, 0, sizeof(format));
format.type = type;
count = MAX_NODE_INFOS;
- rv = BMediaRoster::Roster()->GetLiveNodes(&info[0], &count,
+ rv = fRoster->GetLiveNodes(&info[0], &count,
isInput ? NULL : &format, isInput ? &format : NULL, NULL,
isInput ? B_BUFFER_PRODUCER | B_PHYSICAL_INPUT
: B_BUFFER_CONSUMER | B_PHYSICAL_OUTPUT);
@@ -493,7 +498,7 @@ DefaultManager::_FindPhysical(volatile media_node_id *id,
uint32 default_type,
}
if (msg) { // we have a default info msg
dormant_node_info dninfo;
- if
(BMediaRoster::Roster()->GetDormantNodeFor(info[i].node,
+ if (fRoster->GetDormantNodeFor(info[i].node,
&dninfo) != B_OK) {
ERROR("Couldn't GetDormantNodeFor\n");
continue;
@@ -533,17 +538,17 @@ DefaultManager::_FindTimeSource()
*/
if (fPhysicalAudioOut != -1) {
media_node clone;
- if (B_OK ==
BMediaRoster::Roster()->GetNodeFor(fPhysicalAudioOut,
- &clone)) {
+ if (fRoster->GetNodeFor(fPhysicalAudioOut,
+ &clone) == B_OK) {
if (clone.kind & B_TIME_SOURCE) {
fTimeSource = clone.node;
- BMediaRoster::Roster()->StartTimeSource(clone,
+ fRoster->StartTimeSource(clone,
system_time() + 1000);
- BMediaRoster::Roster()->ReleaseNode(clone);
+ fRoster->ReleaseNode(clone);
TRACE("Default DAC timesource created!\n");
return;
}
- BMediaRoster::Roster()->ReleaseNode(clone);
+ fRoster->ReleaseNode(clone);
} else {
TRACE("Default DAC is not a timesource!\n");
}
@@ -556,7 +561,7 @@ DefaultManager::_FindTimeSource()
memset(&input, 0, sizeof(input));
input.type = B_MEDIA_RAW_AUDIO;
count = MAX_NODE_INFOS;
- rv = BMediaRoster::Roster()->GetLiveNodes(&info[0], &count, &input,
NULL, NULL,
+ rv = fRoster->GetLiveNodes(&info[0], &count, &input, NULL, NULL,
B_TIME_SOURCE | B_PHYSICAL_OUTPUT);
if (rv == B_OK && count >= 1) {
for (int i = 0; i < count; i++)
@@ -573,7 +578,7 @@ DefaultManager::_FindTimeSource()
continue;
TRACE("Default DAC timesource \"%s\" created!\n",
info[i].name);
fTimeSource = info[i].node.node;
- BMediaRoster::Roster()->StartTimeSource(info[i].node,
+ fRoster->StartTimeSource(info[i].node,
system_time() + 1000);
return;
}
@@ -593,8 +598,11 @@ DefaultManager::_FindAudioMixer()
int32 count;
status_t rv;

+ if (fRoster == NULL)
+ fRoster = BMediaRoster::Roster();
+
count = 1;
- rv = BMediaRoster::Roster()->GetLiveNodes(&info, &count, NULL, NULL,
NULL,
+ rv = fRoster->GetLiveNodes(&info, &count, NULL, NULL, NULL,
B_BUFFER_PRODUCER | B_BUFFER_CONSUMER | B_SYSTEM_MIXER);
if (rv != B_OK || count != 1) {
TRACE("Couldn't find audio mixer node\n");
@@ -608,7 +616,6 @@ DefaultManager::_FindAudioMixer()
status_t
DefaultManager::_ConnectMixerToOutput()
{
- BMediaRoster *roster;
media_node timesource;
media_node mixer;
media_node soundcard;
@@ -623,18 +630,19 @@ DefaultManager::_ConnectMixerToOutput()
int32 count;
status_t rv;

- roster = BMediaRoster::Roster();
+ if (fRoster == NULL)
+ fRoster = BMediaRoster::Roster();

- rv = roster->GetNodeFor(fPhysicalAudioOut, &soundcard);
+ rv = fRoster->GetNodeFor(fPhysicalAudioOut, &soundcard);
if (rv != B_OK) {
TRACE("DefaultManager: failed to find soundcard (physical audio
"
"output)\n");
return B_ERROR;
}

- rv = roster->GetNodeFor(fAudioMixer, &mixer);
+ rv = fRoster->GetNodeFor(fAudioMixer, &mixer);
if (rv != B_OK) {
- roster->ReleaseNode(soundcard);
+ fRoster->ReleaseNode(soundcard);
TRACE("DefaultManager: failed to find mixer\n");
return B_ERROR;
}
@@ -642,7 +650,7 @@ DefaultManager::_ConnectMixerToOutput()
// we now have the mixer and soundcard nodes,
// find a free input/output and connect them

- rv = roster->GetFreeOutputsFor(mixer, &output, 1, &count,
+ rv = fRoster->GetFreeOutputsFor(mixer, &output, 1, &count,
B_MEDIA_RAW_AUDIO);
if (rv != B_OK || count != 1) {
TRACE("DefaultManager: can't find free mixer output\n");
@@ -650,7 +658,7 @@ DefaultManager::_ConnectMixerToOutput()
goto finish;
}

- rv = roster->GetFreeInputsFor(soundcard, inputs, MAX_INPUT_INFOS,
&count,
+ rv = fRoster->GetFreeInputsFor(soundcard, inputs, MAX_INPUT_INFOS,
&count,
B_MEDIA_RAW_AUDIO);
if (rv != B_OK || count < 1) {
TRACE("DefaultManager: can't find free soundcard inputs\n");
@@ -668,7 +676,7 @@ DefaultManager::_ConnectMixerToOutput()
switch (i) {
case 0:
TRACE("DefaultManager: Trying connect in native
format (1)\n");
- if (B_OK != roster->GetFormatFor(input,
&format)) {
+ if (fRoster->GetFormatFor(input, &format) !=
B_OK) {
ERROR("DefaultManager: GetFormatFor
failed\n");
continue;
}
@@ -706,7 +714,7 @@ DefaultManager::_ConnectMixerToOutput()
case 4:
// BeOS R5 multiaudio node bug workaround
TRACE("DefaultManager: Trying connect in native
format (2)\n");
- if (B_OK != roster->GetFormatFor(input,
&format)) {
+ if (fRoster->GetFormatFor(input, &format) !=
B_OK) {
ERROR("DefaultManager: GetFormatFor
failed\n");
continue;
}
@@ -718,7 +726,7 @@ DefaultManager::_ConnectMixerToOutput()
break;

}
- rv = roster->Connect(output.source, input.destination, &format,
+ rv = fRoster->Connect(output.source, input.destination, &format,
&newoutput, &newinput);
if (rv == B_OK)
break;
@@ -728,25 +736,25 @@ DefaultManager::_ConnectMixerToOutput()
goto finish;
}

- roster->SetRunModeNode(mixer, BMediaNode::B_INCREASE_LATENCY);
- roster->SetRunModeNode(soundcard, BMediaNode::B_RECORDING);
+ fRoster->SetRunModeNode(mixer, BMediaNode::B_INCREASE_LATENCY);
+ fRoster->SetRunModeNode(soundcard, BMediaNode::B_RECORDING);

- roster->GetTimeSource(&timesource);
- roster->SetTimeSourceFor(mixer.node, timesource.node);
- roster->SetTimeSourceFor(soundcard.node, timesource.node);
- roster->PrerollNode(mixer);
- roster->PrerollNode(soundcard);
+ fRoster->GetTimeSource(&timesource);
+ fRoster->SetTimeSourceFor(mixer.node, timesource.node);
+ fRoster->SetTimeSourceFor(soundcard.node, timesource.node);
+ fRoster->PrerollNode(mixer);
+ fRoster->PrerollNode(soundcard);

- ts = roster->MakeTimeSourceFor(mixer);
+ ts = fRoster->MakeTimeSourceFor(mixer);
start_at = ts->Now() + 50000;
- roster->StartNode(mixer, start_at);
- roster->StartNode(soundcard, start_at);
+ fRoster->StartNode(mixer, start_at);
+ fRoster->StartNode(soundcard, start_at);
ts->Release();

finish:
- roster->ReleaseNode(mixer);
- roster->ReleaseNode(soundcard);
- roster->ReleaseNode(timesource);
+ fRoster->ReleaseNode(mixer);
+ fRoster->ReleaseNode(soundcard);
+ fRoster->ReleaseNode(timesource);
return rv;
}

diff --git a/src/servers/media/DefaultManager.h
b/src/servers/media/DefaultManager.h
index 826b31d..a4becac 100644
--- a/src/servers/media/DefaultManager.h
+++ b/src/servers/media/DefaultManager.h
@@ -21,6 +21,7 @@
#include "DataExchange.h"

#include <Autolock.h>
+#include <MediaRoster.h>
#include <Message.h>

class NodeManager;
@@ -76,6 +77,7 @@ private:
thread_id fRescanThread;
int32 fRescanRequested;
BLocker fRescanLock;
+ BMediaRoster* fRoster;
};

#endif // _DEFAULT_MANAGER_H

############################################################################

Revision: hrev49589
Commit: 8a28f8496597f67b9e0f80c1143398763062239b
URL: http://cgit.haiku-os.org/haiku/commit/?id=8a28f8496597
Author: Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
Date: Fri Aug 28 16:22:36 2015 UTC

Media: Fix restart button alignment

----------------------------------------------------------------------------

diff --git a/src/preferences/media/MediaViews.cpp
b/src/preferences/media/MediaViews.cpp
index 87e8696..f8bb697 100644
--- a/src/preferences/media/MediaViews.cpp
+++ b/src/preferences/media/MediaViews.cpp
@@ -284,6 +284,7 @@ AudioSettingsView::AudioSettingsView()
.Add(defaultsBox)
.AddGroup(B_HORIZONTAL)
.Add(_MakeVolumeCheckBox())
+ .AddGlue()
.Add(MakeRestartButton())
.End()
.AddGlue();


Other related posts: