mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
Sound (Haiku): Init variables unconditionally; fix mute handling
Some checks are pending
CI / spellcheck (push) Waiting to run
CI / No-features-test (push) Waiting to run
CI / Linux-amd64 (push) Waiting to run
CI / Linux-aarch64 (push) Waiting to run
CI / Linux-armv7l (push) Waiting to run
CI / Linux-armv6l (push) Waiting to run
CI / Linux-riscv64 (push) Waiting to run
CI / Linux-ppc64le (push) Waiting to run
CI / Linux-s390x (push) Waiting to run
CI / Musl-amd64 (push) Waiting to run
CI / macOS-universal (push) Waiting to run
CI / SunOS-amd64 (push) Waiting to run
CI / FreeBSD-amd64 (push) Waiting to run
CI / DragonFly-amd64 (push) Waiting to run
CI / OpenBSD-amd64 (push) Waiting to run
CI / NetBSD-amd64 (push) Waiting to run
CI / Windows-amd64 (push) Waiting to run
CI / Release (push) Blocked by required conditions
Some checks are pending
CI / spellcheck (push) Waiting to run
CI / No-features-test (push) Waiting to run
CI / Linux-amd64 (push) Waiting to run
CI / Linux-aarch64 (push) Waiting to run
CI / Linux-armv7l (push) Waiting to run
CI / Linux-armv6l (push) Waiting to run
CI / Linux-riscv64 (push) Waiting to run
CI / Linux-ppc64le (push) Waiting to run
CI / Linux-s390x (push) Waiting to run
CI / Musl-amd64 (push) Waiting to run
CI / macOS-universal (push) Waiting to run
CI / SunOS-amd64 (push) Waiting to run
CI / FreeBSD-amd64 (push) Waiting to run
CI / DragonFly-amd64 (push) Waiting to run
CI / OpenBSD-amd64 (push) Waiting to run
CI / NetBSD-amd64 (push) Waiting to run
CI / Windows-amd64 (push) Waiting to run
CI / Release (push) Blocked by required conditions
This commit is contained in:
parent
1c858ae835
commit
437006f5f1
@ -1,6 +1,7 @@
|
||||
extern "C"
|
||||
{
|
||||
#include "sound.h"
|
||||
#include "util/stringUtils.h"
|
||||
}
|
||||
#include <MediaAddOn.h>
|
||||
#include <MediaNode.h>
|
||||
@ -13,36 +14,34 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */)
|
||||
media_node mediaNode;
|
||||
live_node_info liveInfo;
|
||||
dormant_node_info dormantInfo;
|
||||
status_t status;
|
||||
|
||||
if (roster->GetAudioOutput(&mediaNode) != B_OK)
|
||||
return NULL;
|
||||
|
||||
FFSoundDevice* device = (FFSoundDevice*)ffListAdd(devices);
|
||||
ffStrbufInit(&device->identifier);
|
||||
if (roster->GetDormantNodeFor(mediaNode, &dormantInfo) == B_OK)
|
||||
{
|
||||
ffStrbufInitS(&device->identifier, dormantInfo.name);
|
||||
}
|
||||
ffStrbufAppendS(&device->identifier, dormantInfo.name);
|
||||
ffStrbufInit(&device->name);
|
||||
if (roster->GetLiveNodeInfo(mediaNode, &liveInfo) == B_OK)
|
||||
{
|
||||
ffStrbufInitS(&device->name, liveInfo.name);
|
||||
ffStrbufAppendS(&device->name, liveInfo.name);
|
||||
ffStrbufTrimRightSpace(&device->name);
|
||||
}
|
||||
ffStrbufInitF(&device->platformApi, "%s", "MediaKit");
|
||||
ffStrbufInitStatic(&device->platformApi, "MediaKit");
|
||||
// We'll check the Mixer actually
|
||||
device->volume = (uint8_t) 100;
|
||||
device->volume = 0;
|
||||
device->active = true;
|
||||
device->main = true;
|
||||
|
||||
roster->ReleaseNode(mediaNode);
|
||||
|
||||
media_node mixer;
|
||||
status = roster->GetAudioMixer(&mixer);
|
||||
if (status != B_OK)
|
||||
if (roster->GetAudioMixer(&mixer) != B_OK)
|
||||
return NULL;
|
||||
|
||||
BParameterWeb *web;
|
||||
status = roster->GetParameterWebFor(mixer, &web);
|
||||
status_t status = roster->GetParameterWebFor(mixer, &web);
|
||||
roster->ReleaseNode(mixer); // the web is all we need :-)
|
||||
if (status != B_OK)
|
||||
return NULL;
|
||||
@ -50,12 +49,14 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */)
|
||||
BContinuousParameter *gain = NULL;
|
||||
BParameter *mute = NULL;
|
||||
BParameter *parameter;
|
||||
for (int32 index = 0; (parameter = web->ParameterAt(index)) != NULL; index++) {
|
||||
for (int32 index = 0; (parameter = web->ParameterAt(index)) != NULL; index++)
|
||||
{
|
||||
// assume the mute preceding master gain control
|
||||
if (!strcmp(parameter->Kind(), B_MUTE))
|
||||
if (ffStrEquals(parameter->Kind(), B_MUTE))
|
||||
mute = parameter;
|
||||
|
||||
if (!strcmp(parameter->Kind(), B_MASTER_GAIN)) {
|
||||
if (ffStrEquals(parameter->Kind(), B_MASTER_GAIN))
|
||||
{
|
||||
// Can not use dynamic_cast due to fno-rtti
|
||||
//gain = dynamic_cast<BContinuousParameter *>(parameter);
|
||||
gain = (BContinuousParameter *)(parameter);
|
||||
@ -66,12 +67,21 @@ const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */)
|
||||
if (gain == NULL)
|
||||
return NULL;
|
||||
|
||||
float volume = 0.0;
|
||||
bigtime_t when;
|
||||
size_t size = sizeof(volume);
|
||||
gain->GetValue(&volume, &size, &when);
|
||||
size_t size;
|
||||
|
||||
device->volume = (uint8_t) (100 * (volume - gain->MinValue()) / (gain->MaxValue() - gain->MinValue()));
|
||||
if (mute)
|
||||
{
|
||||
bool isMute = false;
|
||||
size = sizeof(isMute);
|
||||
if (mute->GetValue(&isMute, &size, &when) == B_OK && isMute)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
float volume = 0.0;
|
||||
size = sizeof(volume);
|
||||
if (gain->GetValue(&volume, &size, &when) == B_OK)
|
||||
device->volume = (uint8_t) (100 * (volume - gain->MinValue()) / (gain->MaxValue() - gain->MinValue()));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user