* The mixer node is now exported.

* The node is no longer allocated separately.
* Cleanup.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30060 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-04-09 11:25:23 +00:00
parent 2ff47e1785
commit 3d2abd1bc8
2 changed files with 16 additions and 16 deletions
+13 -15
View File
@@ -21,7 +21,7 @@ MixerControl::MixerControl(int32 volumeWhich, float* _value,
const char** _error)
:
fVolumeWhich(volumeWhich),
fAudioMixerNode(NULL),
fGainMediaNode(media_node::null),
fParameterWeb(NULL),
fMixerParameter(NULL),
fMin(0.0f),
@@ -29,7 +29,6 @@ MixerControl::MixerControl(int32 volumeWhich, float* _value,
fStep(0.0f)
{
bool retrying = false;
fAudioMixerNode = new media_node();
status_t err = B_OK;
/* BMediaRoster::Roster() doesn't set it if all is ok */
@@ -56,14 +55,14 @@ retry:
if (roster && err == B_OK) {
switch (volumeWhich) {
case VOLUME_USE_MIXER:
err = roster->GetAudioMixer(fAudioMixerNode);
err = roster->GetAudioMixer(&fGainMediaNode);
break;
case VOLUME_USE_PHYS_OUTPUT:
err = roster->GetAudioOutput(fAudioMixerNode);
err = roster->GetAudioOutput(&fGainMediaNode);
break;
}
if (err == B_OK) {
err = roster->GetParameterWebFor(*fAudioMixerNode, &fParameterWeb);
err = roster->GetParameterWebFor(fGainMediaNode, &fParameterWeb);
if (err == B_OK) {
// Finding the Mixer slider in the audio output ParameterWeb
int32 numParams = fParameterWeb->CountParameters();
@@ -112,11 +111,11 @@ retry:
p = NULL;
}
if (p == NULL) {
errorString = volumeWhich
? "Could not find the soundcard":"Could not find the mixer";
errorString = volumeWhich ? "Could not find the soundcard"
: "Could not find the mixer";
} else if (p->Type() != BParameter::B_CONTINUOUS_PARAMETER) {
errorString = volumeWhich
? "Soundcard control unknown":"Mixer control unknown";
errorString = volumeWhich ? "Soundcard control unknown"
: "Mixer control unknown";
} else {
fMixerParameter = dynamic_cast<BContinuousParameter*>(p);
fMin = fMixerParameter->MinValue();
@@ -150,10 +149,9 @@ retry:
errorString = "No Media Roster";
}
if (err != B_OK) {
delete fAudioMixerNode;
fAudioMixerNode = NULL;
}
if (err != B_OK)
fGainMediaNode = media_node::null;
if (errorString) {
fprintf(stderr, "MixerControl: %s.\n", errorString);
if (_error)
@@ -169,8 +167,8 @@ MixerControl::~MixerControl()
delete fParameterWeb;
BMediaRoster* roster = BMediaRoster::CurrentRoster();
if (roster != NULL && fAudioMixerNode != NULL)
roster->ReleaseNode(*fAudioMixerNode);
if (roster != NULL && fGainMediaNode != media_node::null)
roster->ReleaseNode(fGainMediaNode);
}
+3 -1
View File
@@ -37,9 +37,11 @@ public:
float Minimum() const { return fMin; }
float Maximum() const { return fMax; }
media_node GainNode() { return fGainMediaNode; }
private:
int32 fVolumeWhich;
media_node* fAudioMixerNode;
media_node fGainMediaNode;
BParameterWeb* fParameterWeb;
BContinuousParameter* fMixerParameter;
float fMin;