Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/detection/cpu/cpu_haiku.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/detection/disk/disk_haiku.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;)
{
Expand Down
52 changes: 52 additions & 0 deletions src/detection/initsystem/initsystem_haiku.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
extern "C" {
#include "initsystem.h"
#include "common/processing.h"
#include "util/binary.h"
#include "util/stringUtils.h"
};

#include <AppFileInfo.h>
#include <File.h>
#include <libgen.h>
#include <OS.h>
#include <Path.h>
#include <unistd.h>

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;
}
69 changes: 62 additions & 7 deletions src/detection/sound/sound_haiku.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,76 @@ extern "C"
{
#include "sound.h"
}
#include <MediaAddOn.h>
#include <MediaNode.h>
#include <MediaRoster.h>
#include <ParameterWeb.h>

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<BContinuousParameter *>(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;
}
Loading