* 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) const char** _error)
: :
fVolumeWhich(volumeWhich), fVolumeWhich(volumeWhich),
fAudioMixerNode(NULL), fGainMediaNode(media_node::null),
fParameterWeb(NULL), fParameterWeb(NULL),
fMixerParameter(NULL), fMixerParameter(NULL),
fMin(0.0f), fMin(0.0f),
@@ -29,7 +29,6 @@ MixerControl::MixerControl(int32 volumeWhich, float* _value,
fStep(0.0f) fStep(0.0f)
{ {
bool retrying = false; bool retrying = false;
fAudioMixerNode = new media_node();
status_t err = B_OK; status_t err = B_OK;
/* BMediaRoster::Roster() doesn't set it if all is ok */ /* BMediaRoster::Roster() doesn't set it if all is ok */
@@ -56,14 +55,14 @@ retry:
if (roster && err == B_OK) { if (roster && err == B_OK) {
switch (volumeWhich) { switch (volumeWhich) {
case VOLUME_USE_MIXER: case VOLUME_USE_MIXER:
err = roster->GetAudioMixer(fAudioMixerNode); err = roster->GetAudioMixer(&fGainMediaNode);
break; break;
case VOLUME_USE_PHYS_OUTPUT: case VOLUME_USE_PHYS_OUTPUT:
err = roster->GetAudioOutput(fAudioMixerNode); err = roster->GetAudioOutput(&fGainMediaNode);
break; break;
} }
if (err == B_OK) { if (err == B_OK) {
err = roster->GetParameterWebFor(*fAudioMixerNode, &fParameterWeb); err = roster->GetParameterWebFor(fGainMediaNode, &fParameterWeb);
if (err == B_OK) { if (err == B_OK) {
// Finding the Mixer slider in the audio output ParameterWeb // Finding the Mixer slider in the audio output ParameterWeb
int32 numParams = fParameterWeb->CountParameters(); int32 numParams = fParameterWeb->CountParameters();
@@ -112,11 +111,11 @@ retry:
p = NULL; p = NULL;
} }
if (p == NULL) { if (p == NULL) {
errorString = volumeWhich errorString = volumeWhich ? "Could not find the soundcard"
? "Could not find the soundcard":"Could not find the mixer"; : "Could not find the mixer";
} else if (p->Type() != BParameter::B_CONTINUOUS_PARAMETER) { } else if (p->Type() != BParameter::B_CONTINUOUS_PARAMETER) {
errorString = volumeWhich errorString = volumeWhich ? "Soundcard control unknown"
? "Soundcard control unknown":"Mixer control unknown"; : "Mixer control unknown";
} else { } else {
fMixerParameter = dynamic_cast<BContinuousParameter*>(p); fMixerParameter = dynamic_cast<BContinuousParameter*>(p);
fMin = fMixerParameter->MinValue(); fMin = fMixerParameter->MinValue();
@@ -150,10 +149,9 @@ retry:
errorString = "No Media Roster"; errorString = "No Media Roster";
} }
if (err != B_OK) { if (err != B_OK)
delete fAudioMixerNode; fGainMediaNode = media_node::null;
fAudioMixerNode = NULL;
}
if (errorString) { if (errorString) {
fprintf(stderr, "MixerControl: %s.\n", errorString); fprintf(stderr, "MixerControl: %s.\n", errorString);
if (_error) if (_error)
@@ -169,8 +167,8 @@ MixerControl::~MixerControl()
delete fParameterWeb; delete fParameterWeb;
BMediaRoster* roster = BMediaRoster::CurrentRoster(); BMediaRoster* roster = BMediaRoster::CurrentRoster();
if (roster != NULL && fAudioMixerNode != NULL) if (roster != NULL && fGainMediaNode != media_node::null)
roster->ReleaseNode(*fAudioMixerNode); roster->ReleaseNode(fGainMediaNode);
} }
+3 -1
View File
@@ -37,9 +37,11 @@ public:
float Minimum() const { return fMin; } float Minimum() const { return fMin; }
float Maximum() const { return fMax; } float Maximum() const { return fMax; }
media_node GainNode() { return fGainMediaNode; }
private: private:
int32 fVolumeWhich; int32 fVolumeWhich;
media_node* fAudioMixerNode; media_node fGainMediaNode;
BParameterWeb* fParameterWeb; BParameterWeb* fParameterWeb;
BContinuousParameter* fMixerParameter; BContinuousParameter* fMixerParameter;
float fMin; float fMin;