diff --git a/CMakeLists.txt b/CMakeLists.txt index 875f35a253..64a5bed207 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1148,7 +1148,7 @@ elseif(Haiku) src/detection/gtk_qt/gtk.c src/detection/host/host_windows.c src/detection/icons/icons_nosupport.c - src/detection/initsystem/initsystem_linux.c + src/detection/initsystem/initsystem_haiku.cpp src/detection/keyboard/keyboard_nosupport.c src/detection/libc/libc_nosupport.c src/detection/lm/lm_nosupport.c diff --git a/src/detection/cpu/cpu_haiku.c b/src/detection/cpu/cpu_haiku.c index ec993a05c1..17dc1385cf 100644 --- a/src/detection/cpu/cpu_haiku.c +++ b/src/detection/cpu/cpu_haiku.c @@ -10,7 +10,7 @@ const char* ffDetectCPUImpl(FF_MAYBE_UNUSED const FFCPUOptions* options, FFCPURe if (get_system_info(&sysInfo) != B_OK) return "get_system_info() failed"; - uint32_t topoNodeCount = 0; + uint32 topoNodeCount = 0; get_cpu_topology_info(NULL, &topoNodeCount); if (topoNodeCount == 0) return "get_cpu_topology_info(NULL) failed"; diff --git a/src/detection/disk/disk_haiku.cpp b/src/detection/disk/disk_haiku.cpp index 0782847401..504ec797d9 100644 --- a/src/detection/disk/disk_haiku.cpp +++ b/src/detection/disk/disk_haiku.cpp @@ -8,7 +8,7 @@ extern "C" const char* ffDetectDisksImpl(FF_MAYBE_UNUSED FFDiskOptions* options, FF_MAYBE_UNUSED FFlist* disks) { - int pos = 0; + int32 pos = 0; for (dev_t dev; (dev = next_dev(&pos)) >= B_OK;) { diff --git a/src/detection/initsystem/initsystem_haiku.cpp b/src/detection/initsystem/initsystem_haiku.cpp new file mode 100644 index 0000000000..7714133afa --- /dev/null +++ b/src/detection/initsystem/initsystem_haiku.cpp @@ -0,0 +1,52 @@ +extern "C" { +#include "initsystem.h" +#include "common/processing.h" +#include "util/binary.h" +#include "util/stringUtils.h" +}; + +#include +#include +#include +#include +#include +#include + +const char* ffDetectInitSystem(FFInitSystemResult* result) +{ + team_info teamInfo; + int32 cookie = 0; + + // Since it runs first, registrar does not know about it, + // so we can't query be_roster for it. + BPath path("/boot/system/servers/launch_daemon"); + if (path.InitCheck() != B_OK) + return NULL; + + ffStrbufSetS(&result->exe, path.Path()); + ffStrbufSetStatic(&result->name, "launch_daemon"); + + while (get_next_team_info(&cookie, &teamInfo) == B_OK) + { + if (strcmp(teamInfo.args, path.Path()) == 0) + { + result->pid = (int)teamInfo.team; + break; + } + } + + BFile f(path.Path(), B_READ_ONLY); + if (f.InitCheck() != B_OK) + return NULL; + BAppFileInfo fileInfo(&f); + if (f.InitCheck() != B_OK) + return NULL; + + version_info version; + if (fileInfo.GetVersionInfo(&version, B_SYSTEM_VERSION_KIND) != B_OK) + return NULL; + + ffStrbufSetF(&result->version, "%d.%d.%d", (int)version.major, (int)version.middle, (int)version.minor); + + return NULL; +} diff --git a/src/detection/sound/sound_haiku.cpp b/src/detection/sound/sound_haiku.cpp index 04dce76d54..16cfbf341b 100644 --- a/src/detection/sound/sound_haiku.cpp +++ b/src/detection/sound/sound_haiku.cpp @@ -2,21 +2,76 @@ extern "C" { #include "sound.h" } +#include +#include #include +#include -const char* ffDetectSound(FF_MAYBE_UNUSED FFlist* devices /* List of FFSoundDevice */) +const char* ffDetectSound(FFlist* devices /* List of FFSoundDevice */) { BMediaRoster* roster = BMediaRoster::Roster(); media_node mediaNode; + live_node_info liveInfo; + dormant_node_info dormantInfo; + status_t status; - roster->GetAudioOutput(&mediaNode); + if (roster->GetAudioOutput(&mediaNode) != B_OK) + return NULL; + + FFSoundDevice* device = (FFSoundDevice*)ffListAdd(devices); + if (roster->GetDormantNodeFor(mediaNode, &dormantInfo) == B_OK) + { + ffStrbufInitS(&device->identifier, dormantInfo.name); + } + if (roster->GetLiveNodeInfo(mediaNode, &liveInfo) == B_OK) + { + ffStrbufInitS(&device->name, liveInfo.name); + ffStrbufTrimRightSpace(&device->name); + } + ffStrbufInitF(&device->platformApi, "%s", "MediaKit"); + // We'll check the Mixer actually + device->volume = (uint8_t) 100; + device->active = true; + device->main = true; + + roster->ReleaseNode(mediaNode); + + media_node mixer; + status = roster->GetAudioMixer(&mixer); + if (status != B_OK) + return NULL; - int32_t mediaOutputCount = 0; - roster->GetAllOutputsFor(mediaNode, NULL, 0, &mediaOutputCount); - if (mediaOutputCount == 0) + BParameterWeb *web; + status = roster->GetParameterWebFor(mixer, &web); + roster->ReleaseNode(mixer); // the web is all we need :-) + if (status != B_OK) return NULL; - // TODO: Implement the rest of the function + BContinuousParameter *gain = NULL; + BParameter *mute = NULL; + BParameter *parameter; + for (int32 index = 0; (parameter = web->ParameterAt(index)) != NULL; index++) { + // assume the mute preceding master gain control + if (!strcmp(parameter->Kind(), B_MUTE)) + mute = parameter; + + if (!strcmp(parameter->Kind(), B_MASTER_GAIN)) { + // Can not use dynamic_cast due to fno-rtti + //gain = dynamic_cast(parameter); + gain = (BContinuousParameter *)(parameter); + break; + } + } + + if (gain == NULL) + return NULL; + + float volume = 0.0; + bigtime_t when; + size_t size = sizeof(volume); + gain->GetValue(&volume, &size, &when); + + device->volume = (uint8_t) (100 * (volume - gain->MinValue()) / (gain->MaxValue() - gain->MinValue())); - return "Not supported on this platform"; + return NULL; }