Skip to content

Commit 861eea5

Browse files
committed
Sound (FreeBSD): new impl; drop pulseaudio dep
1 parent 1227799 commit 861eea5

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ cmake_dependent_option(ENABLE_OSMESA "Enable osmesa" ON "LINUX OR BSD" OFF)
6666
cmake_dependent_option(ENABLE_OPENCL "Enable opencl" ON "LINUX OR BSD OR WIN32" OFF)
6767
cmake_dependent_option(ENABLE_LIBNM "Enable libnm" ON "LINUX" OFF)
6868
cmake_dependent_option(ENABLE_FREETYPE "Enable freetype" ON "ANDROID" OFF)
69-
cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX OR BSD" OFF)
69+
cmake_dependent_option(ENABLE_PULSE "Enable pulse" ON "LINUX" OFF)
7070
cmake_dependent_option(ENABLE_DDCUTIL "Enable ddcutil" ON "LINUX" OFF)
7171
cmake_dependent_option(ENABLE_DIRECTX_HEADERS "Enable DirectX headers for WSL" ON "LINUX" OFF)
7272
cmake_dependent_option(ENABLE_THREADS "Enable multithreading" ON "Threads_FOUND" OFF)
@@ -533,7 +533,7 @@ elseif(BSD)
533533
src/detection/poweradapter/poweradapter_nosupport.c
534534
src/detection/processes/processes_bsd.c
535535
src/detection/gtk_qt/qt.c
536-
src/detection/sound/sound_linux.c
536+
src/detection/sound/sound_bsd.c
537537
src/detection/swap/swap_bsd.c
538538
src/detection/temps/temps_bsd.c
539539
src/detection/terminalfont/terminalfont_linux.c
@@ -954,6 +954,7 @@ elseif(BSD)
954954
PRIVATE "m"
955955
PRIVATE "usbhid"
956956
PRIVATE "geom"
957+
PRIVATE "mixer"
957958
)
958959
elseif(ANDROID)
959960
CHECK_LIBRARY_EXISTS(-l:libandroid-wordexp.a wordexp "" HAVE_LIBANDROID_WORDEXP_STATIC)

src/detection/sound/sound_bsd.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#include "sound.h"
2+
3+
#include <mixer.h>
4+
5+
const char* ffDetectSound(FFlist* devices)
6+
{
7+
int nmixers = mixer_get_nmixers();
8+
if (nmixers == 0) return "No mixers found";
9+
10+
if (__builtin_expect(nmixers > 9, false)) nmixers = 9;
11+
12+
char path[] = "/dev/mixer0";
13+
14+
for (int idev = 0; idev < nmixers; ++idev)
15+
{
16+
path[strlen("/dev/mixer")] = (char) ('0' + idev);
17+
struct mixer* m = mixer_open(path);
18+
if (!m) continue;
19+
20+
if (m->mode & MIX_MODE_PLAY)
21+
{
22+
struct mix_dev* dev = mixer_get_dev_byname(m, "vol");
23+
if (dev)
24+
{
25+
FFSoundDevice* device = ffListAdd(devices);
26+
ffStrbufInitS(&device->identifier, path);
27+
ffStrbufInitF(&device->name, "%s %s", m->ci.longname, m->ci.hw_info);
28+
device->volume = MIX_ISMUTE(m, dev->devno) ? 0 : (uint8_t) MIX_VOLDENORM((dev->vol.left + dev->vol.right) / 2);
29+
device->active = true;
30+
device->main = !!m->f_default;
31+
}
32+
}
33+
34+
mixer_close(m);
35+
}
36+
37+
return NULL;
38+
}

0 commit comments

Comments
 (0)