11extern " C"
22{
33#include " sound.h"
4+ #include " util/stringUtils.h"
45}
56#include < MediaAddOn.h>
67#include < MediaNode.h>
@@ -13,49 +14,49 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */)
1314 media_node mediaNode;
1415 live_node_info liveInfo;
1516 dormant_node_info dormantInfo;
16- status_t status;
1717
1818 if (roster->GetAudioOutput (&mediaNode) != B_OK)
1919 return NULL ;
2020
2121 FFSoundDevice* device = (FFSoundDevice*)ffListAdd (devices);
22+ ffStrbufInit (&device->identifier );
2223 if (roster->GetDormantNodeFor (mediaNode, &dormantInfo) == B_OK)
23- {
24- ffStrbufInitS (&device->identifier , dormantInfo.name );
25- }
24+ ffStrbufAppendS (&device->identifier , dormantInfo.name );
25+ ffStrbufInit (&device->name );
2626 if (roster->GetLiveNodeInfo (mediaNode, &liveInfo) == B_OK)
2727 {
28- ffStrbufInitS (&device->name , liveInfo.name );
28+ ffStrbufAppendS (&device->name , liveInfo.name );
2929 ffStrbufTrimRightSpace (&device->name );
3030 }
31- ffStrbufInitF (&device->platformApi , " %s " , " MediaKit" );
31+ ffStrbufInitStatic (&device->platformApi , " MediaKit" );
3232 // We'll check the Mixer actually
33- device->volume = ( uint8_t ) 100 ;
33+ device->volume = 0 ;
3434 device->active = true ;
3535 device->main = true ;
3636
3737 roster->ReleaseNode (mediaNode);
3838
3939 media_node mixer;
40- status = roster->GetAudioMixer (&mixer);
41- if (status != B_OK)
40+ if (roster->GetAudioMixer (&mixer) != B_OK)
4241 return NULL ;
4342
4443 BParameterWeb *web;
45- status = roster->GetParameterWebFor (mixer, &web);
44+ status_t status = roster->GetParameterWebFor (mixer, &web);
4645 roster->ReleaseNode (mixer); // the web is all we need :-)
4746 if (status != B_OK)
4847 return NULL ;
4948
5049 BContinuousParameter *gain = NULL ;
5150 BParameter *mute = NULL ;
5251 BParameter *parameter;
53- for (int32 index = 0 ; (parameter = web->ParameterAt (index)) != NULL ; index++) {
52+ for (int32 index = 0 ; (parameter = web->ParameterAt (index)) != NULL ; index++)
53+ {
5454 // assume the mute preceding master gain control
55- if (! strcmp (parameter->Kind (), B_MUTE))
55+ if (ffStrEquals (parameter->Kind (), B_MUTE))
5656 mute = parameter;
5757
58- if (!strcmp (parameter->Kind (), B_MASTER_GAIN)) {
58+ if (ffStrEquals (parameter->Kind (), B_MASTER_GAIN))
59+ {
5960 // Can not use dynamic_cast due to fno-rtti
6061 // gain = dynamic_cast<BContinuousParameter *>(parameter);
6162 gain = (BContinuousParameter *)(parameter);
@@ -66,12 +67,21 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */)
6667 if (gain == NULL )
6768 return NULL ;
6869
69- float volume = 0.0 ;
7070 bigtime_t when;
71- size_t size = sizeof (volume);
72- gain->GetValue (&volume, &size, &when);
71+ size_t size;
7372
74- device->volume = (uint8_t ) (100 * (volume - gain->MinValue ()) / (gain->MaxValue () - gain->MinValue ()));
73+ if (mute)
74+ {
75+ bool isMute = false ;
76+ size = sizeof (isMute);
77+ if (mute->GetValue (&isMute, &size, &when) == B_OK && isMute)
78+ return NULL ;
79+ }
80+
81+ float volume = 0.0 ;
82+ size = sizeof (volume);
83+ if (gain->GetValue (&volume, &size, &when) == B_OK)
84+ device->volume = (uint8_t ) (100 * (volume - gain->MinValue ()) / (gain->MaxValue () - gain->MinValue ()));
7585
7686 return NULL ;
7787}
0 commit comments