Open kenz-gelsoft opened 1 month ago
cubeb implementing source files with sorted by its size
kenz@KENZnoMacBook-Air src % ls -l *.c | sort -k 5
-rw-r--r-- 1 kenz staff 2859 10 24 06:05 cubeb_strings.c
-rw-r--r-- 1 kenz staff 8783 10 24 06:05 cubeb_kai.c
-rw-r--r-- 1 kenz staff 14742 10 24 06:05 cubeb_audiotrack.c
-rw-r--r-- 1 kenz staff 18364 10 24 06:05 cubeb.c
-rw-r--r-- 1 kenz staff 18820 10 24 06:05 cubeb_sndio.c
-rw-r--r-- 1 kenz staff 19285 10 24 06:05 cubeb_sun.c
-rw-r--r-- 1 kenz staff 34400 10 24 06:05 cubeb_oss.c
-rw-r--r-- 1 kenz staff 34478 10 24 06:05 cubeb_winmm.c
-rw-r--r-- 1 kenz staff 40461 10 24 06:05 cubeb_alsa.c
-rw-r--r-- 1 kenz staff 52402 10 24 06:05 cubeb_pulse.c
Can we feed RAW_FLOAT format into cubeb?
it seems
at least they have 32bit float sampling format
https://github.com/kenz-gelsoft/cubeb/blob/haiku_backend/include/cubeb/cubeb.h#L137
firefox uses 32bit float for audio output too
https://searchfox.org/mozilla-esr128/source/dom/media/AudioSampleFormat.h#32
We can forward buffer request like kai backend
https://github.com/kenz-gelsoft/cubeb/blob/haiku_backend/src/cubeb_haiku.c#L136
BSoundPlayer BufferProc to cubeb_streams' data_callback.
queries should be transferred to BMediaRoster ::GetAudioMixer()
AudioBufferSizeFor()
may be usefulGetInitialLatencyFor()
GetLatencyFor()
orGetStartLatencyFor()
may be usefulstream abstracts BSoundPlayer
Start()
Stop()
CurrentTime()
SetVolume()
or SetVolumeDB()
Latency()
There is a simpler temporary solution. I have a more or less working backend for cubeb via OpenAL library. Cubeb tests pass, device is detected, test_tone plays sound. Native audio input and output module I can make soon.
It turned out to be much easier. The native sound output is ready and works fine. Now I will prepare patches and post them.
yes I investigated that and was going to implement that tonight.
it should be 200 lines of code or so.
Right now, it only supports audio output. Tomorrow I will add sound capture from microphone, which is a bit more complicated, but I think I can do it in a day.
cmake .. -DLAZY_LOAD_LIBS=OFF
https://searchfox.org/mozilla-central/source/media/libcubeb/src/moz.build
Firefox has no configuration with standalone built libcubeb. So I will apply your patch in-tree source and consult build system to use haiku backend.
To upstream, smaller patch is better, and we don't use audio input until we enable webrtc or other advanced features. So I think output only support is enough and good for now.
So I think output only support is enough and good for now.
You're going to need it sooner or later. I hope so ;)
Hmm, link error...
0:05.71 toolkit/library/build/libxul.so
0:12.24 ld.lld: error: undefined hidden symbol: BSoundPlayer::BSoundPlayer(media_raw_audio_format const*, char const*, void (*)(void*, void*, unsigned long, media_raw_audio_format const&), void (*)(void*, BSoundPlayer::sound_player_notification, ...), void*)
0:12.24 >>> referenced by cubeb_haiku.cpp:310 (/boot/home/src/gecko-dev/media/libcubeb/src/cubeb_haiku.cpp:310)
0:12.24 >>> ../../../media/libcubeb/src/cubeb_haiku.o:(haiku_stream_init(cubeb*, cubeb_stream**, char const*, void const*, cubeb_stream_params*, void const*, cubeb_stream_params*, unsigned int, long (*)(cubeb_stream*, void*, void const*, void*, long), void (*)(cubeb_stream*, void*, cubeb_state), void*))
0:12.24 >>> did you mean: BSoundPlayer::BSoundPlayer(media_raw_audio_format const*, char const*, void (*)(void*, void*, unsigned long, media_raw_audio_format const&), void (*)(void*, BSoundPlayer::sound_player_notification, ...), void*)
0:12.24 >>> defined in: /packages/libffi-3.4.2-2/.self/develop/lib/libmedia.so
It's not linking library error, libmedia.so path seems weird, but it is same content with /boot/system/lib's one.
~/src/gecko-dev> diff /packages/libffi-3.4.2-2/.self/lib/libmedia.so /boot/system/lib/libmedia.so
~/src/gecko-dev>
~/src/gecko-dev> ./mach build
0:00.41 W Clobber not needed.
0:00.45 W Adding make options from /boot/home/src/gecko-dev/mozconfig
MOZ_OBJDIR=/boot/home/src/gecko-dev/obj-ff-dbg
OBJDIR=/boot/home/src/gecko-dev/obj-ff-dbg
FOUND_MOZCONFIG=/boot/home/src/gecko-dev/mozconfig
export FOUND_MOZCONFIG
0:00.47 /bin/make -f client.mk -j12 -s
0:00.85 Elapsed: 0.00s; From dist/private: Kept 0 existing; Added/updated 0; Removed 0 files and 0 directories.
0:00.87 Elapsed: 0.00s; From dist/public: Kept 0 existing; Added/updated 0; Removed 0 files and 0 directories.
0:00.96 Elapsed: 0.08s; From _tests: Kept 681 existing; Added/updated 0; Removed 0 files and 0 directories.
0:01.02 Elapsed: 0.17s; From dist/bin: Kept 2908 existing; Added/updated 0; Removed 0 files and 0 directories.
0:01.03 Elapsed: 0.20s; From dist/include: Kept 6561 existing; Added/updated 0; Removed 0 files and 0 directories.
0:05.77 toolkit/library/build/libxul.so
0:11.55 ld.lld: error: undefined hidden symbol: BSoundPlayer::BSoundPlayer(media_raw_audio_format const*, char const*, void (*)(void*, void*, unsigned long, media_raw_audio_format const&), void (*)(void*, BSoundPlayer::sound_player_notification, ...), void*)
0:11.55 >>> referenced by cubeb_haiku.cpp:310 (/boot/home/src/gecko-dev/media/libcubeb/src/cubeb_haiku.cpp:310)
0:11.56 >>> ../../../media/libcubeb/src/cubeb_haiku.o:(haiku_stream_init(cubeb*, cubeb_stream**, char const*, void const*, cubeb_stream_params*, void const*, cubeb_stream_params*, unsigned int, long (*)(cubeb_stream*, void*, void const*, void*, long), void (*)(cubeb_stream*, void*, cubeb_state), void*))
0:11.56 >>> did you mean: BSoundPlayer::BSoundPlayer(media_raw_audio_format const*, char const*, void (*)(void*, void*, unsigned long, media_raw_audio_format const&), void (*)(void*, BSoundPlayer::sound_player_notification, ...), void*)
0:11.56 >>> defined in: /packages/libffi-3.4.2-2/.self/develop/lib/libmedia.so
0:11.57 ld.lld: error: undefined hidden symbol: BSoundPlayer::InitCheck()
0:11.57 >>> referenced by cubeb_haiku.cpp:316 (/boot/home/src/gecko-dev/media/libcubeb/src/cubeb_haiku.cpp:316)
0:11.57 >>> ../../../media/libcubeb/src/cubeb_haiku.o:(haiku_stream_init(cubeb*, cubeb_stream**, char const*, void const*, cubeb_stream_params*, void const*, cubeb_stream_params*, unsigned int, long (*)(cubeb_stream*, void*, void const*, void*, long), void (*)(cubeb_stream*, void*, cubeb_state), void*))
0:11.57 ld.lld: error: undefined hidden symbol: BSoundPlayer::Stop(bool, bool)
0:11.58 >>> referenced by cubeb_haiku.cpp:356 (/boot/home/src/gecko-dev/media/libcubeb/src/cubeb_haiku.cpp:356)
0:11.58 >>> ../../../media/libcubeb/src/cubeb_haiku.o:(haiku_stream_init(cubeb*, cubeb_stream**, char const*, void const*, cubeb_stream_params*, void const*, cubeb_stream_params*, unsigned int, long (*)(cubeb_stream*, void*, void const*, void*, long), void (*)(cubeb_stream*, void*, cubeb_state), void*))
0:11.58 >>> referenced by cubeb_haiku.cpp:356 (/boot/home/src/gecko-dev/media/libcubeb/src/cubeb_haiku.cpp:356)
0:11.59 >>> ../../../media/libcubeb/src/cubeb_haiku.o:(haiku_stream_destroy(cubeb_stream*))
0:11.59 >>> referenced by cubeb_haiku.cpp:391 (/boot/home/src/gecko-dev/media/libcubeb/src/cubeb_haiku.cpp:391)
0:11.59 >>> ../../../media/libcubeb/src/cubeb_haiku.o:(haiku_stream_stop(cubeb_stream*))
0:11.59 ld.lld: error: undefined hidden symbol: cubeb_resampler_destroy
0:11.59 >>> referenced by cubeb_haiku.cpp:362 (/boot/home/src/gecko-dev/media/libcubeb/src/cubeb_haiku.cpp:362)
0:11.60 >>> ../../../media/libcubeb/src/cubeb_haiku.o:(haiku_stream_init(cubeb*, cubeb_stream**, char const*, void const*, cubeb_stream_params*, void const*, cubeb_stream_params*, unsigned int, long (*)(cubeb_stream*, void*, void const*, void*, long), void (*)(cubeb_stream*, void*, cubeb_state), void*))
0:11.60 >>> referenced by cubeb_haiku.cpp:362 (/boot/home/src/gecko-dev/media/libcubeb/src/cubeb_haiku.cpp:362)
0:11.60 >>> ../../../media/libcubeb/src/cubeb_haiku.o:(haiku_stream_destroy(cubeb_stream*))
0:11.60 ld.lld: error: undefined hidden symbol: cubeb_resampler_create
0:11.61 >>> referenced by cubeb_haiku.cpp:323 (/boot/home/src/gecko-dev/media/libcubeb/src/cubeb_haiku.cpp:323)
0:11.61 >>> ../../../media/libcubeb/src/cubeb_haiku.o:(haiku_stream_init(cubeb*, cubeb_stream**, char const*, void const*, cubeb_stream_params*, void const*, cubeb_stream_params*, unsigned int, long (*)(cubeb_stream*, void*, void const*, void*, long), void (*)(cubeb_stream*, void*, cubeb_state), void*))
0:11.61 ld.lld: error: undefined hidden symbol: BSoundPlayer::Start()
0:11.61 >>> referenced by cubeb_haiku.cpp:378 (/boot/home/src/gecko-dev/media/libcubeb/src/cubeb_haiku.cpp:378)
0:11.62 >>> ../../../media/libcubeb/src/cubeb_haiku.o:(haiku_stream_start(cubeb_stream*))
0:11.94 clang++: error: linker command failed with exit code 1 (use -v to see invocation)
0:11.94 /boot/home/src/gecko-dev/config/rules.mk:538: recipe for target '../../../dist/bin/libxul.so' failed
0:11.94 make[4]: *** [../../../dist/bin/libxul.so] Error 1
0:11.94 /boot/home/src/gecko-dev/config/recurse.mk:72: recipe for target 'toolkit/library/build/target' failed
0:11.94 make[3]: *** [toolkit/library/build/target] Error 2
0:11.95 /boot/home/src/gecko-dev/config/recurse.mk:32: recipe for target 'compile' failed
0:11.95 make[2]: *** [compile] Error 2
0:11.95 /boot/home/src/gecko-dev/config/rules.mk:361: recipe for target 'default' failed
0:11.95 make[1]: *** [default] Error 2
0:11.95 client.mk:59: recipe for target 'build' failed
0:11.95 make: *** [build] Error 2
0:11.95 W 195 compiler warnings present.
Of course I added 'media' lib to linker input like
https://github.com/kenz-gelsoft/gecko-dev/pull/69/commits/a35893580702792b7e631b396b272c655869478e
but something wrong there. will investigate...
This happens because of broken pkgconfig files in various packages, which in the list of libraries return unnecessary libraries that they were linked to when built (but the package versions have changed and the paths have become broken). This is why there are many different sed
recipes to fix such problems. Apparently, one of the pkgconfig files from the libffi related packages returns libmedia on the libs request.
Thank yor for advice. I have no idea now how I can controll libffi pkgconig output here, I will try adding -L or prepending full path to OS_LIBS or so.
I checked, it's not libffi - it doesn't have libmedia in pkgconfig.pc.
grep through all files in /develop/lib/pkgconfig and /system/data/pkgconfig and look for libmedia or -lmedia.
./mach build -vv
without specifying media library
0:07.91 /bin/clang++
-U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE=2
-fstack-protector-strong
-fstack-clash-protection
-ftrivial-auto-var-init=pattern
-fno-rtti
-pthread
-fno-sized-deallocation
-fno-aligned-new
-ffunction-sections
-fdata-sections
-fno-math-errno
-fno-exceptions
-fno-exceptions
-fPIC
-gdwarf-4
-O
-fno-omit-frame-pointer
-funwind-tables
-shared
-Wl,-z,defs
-Wl,--gc-sections
-Wl,-h,libxul.so
-o ../../../dist/bin/libxul.so
-Wl,@/boot/home/src/gecko-dev/obj-ff-dbg/toolkit/library/build/libxul_so.list
-fuse-ld=lld
-Wl,--build-id=sha1
-Wl,-z,noexecstack
-Wl,-z,text
-Wl,-z,relro
-Wl,-z,now
-Wl,-z,nocopyreloc
-fstack-protector-strong
-fstack-clash-protection
-Wl,-rpath-link,/boot/home/src/gecko-dev/obj-ff-dbg/dist/bin
-Wl,-rpath-link,/usr/local/lib ../../../js/src/build/libjs_static.a ../../../build/pure_virtual/libpure_virtual.a ../../../x86_64-unknown-haiku/debug/libgkrust.a ../../../dist/bin/libgkcodecs.so ../../../dist/bin/liblgpllibs.so ../../../dist/bin/libnss3.so ../../../dist/bin/libnssutil3.so ../../../dist/bin/libsmime3.so ../../../dist/bin/libmozsqlite3.so ../../../dist/bin/libssl3.so ../../../dist/bin/libmozgtk.so ../../../dist/bin/libmozwayland.so
-Wl,--version-script,libxul.so.symbols
-lnetwork
-lpthread
-lgnu
-L/packages/libffi-3.4.2-2/.self/develop/lib
-lffi
-L/packages/nspr-4.34.1-3/.self/lib
-lplds4
-lplc4
-lnspr4
-L/packages/zlib-1.3.1-4/.self/develop/lib
-L/packages/zlib-1.3.1-4/.self/lib
-lz
-lm
-L/packages/freetype-2.13.2-1/.self/develop/lib
-lfreetype
-L/packages/fontconfig-2.13.96-2/.self/develop/lib
-lfontconfig
-L/packages/gtk3-3.24.36-1/.self/develop/lib
-L/packages/pango-1.54.0-2/.self/develop/lib
-L/packages/harfbuzz-8.3.0-2/.self/develop/lib
-L/packages/atk-2.38.0-3/.self/develop/lib
-L/packages/cairo1.18-1.18.0-1/.self/develop/lib
-L/packages/gdk_pixbuf-2.42.9-5/.self/develop/lib
-L/packages/glib2-2.78.0-2/.self/develop/lib
-lgtk-3
-lgdk-3
-lpangocairo-1.0
-lpango-1.0
-lharfbuzz
-latk-1.0
-lcairo-gobject
-lcairo
-lgdk_pixbuf-2.0
-lgio-2.0
-lgobject-2.0
-lglib-2.0
-lintl
-ljpeg
-L/packages/libwebp-1.4.0-1/.self/develop/lib
-lwebp
-lwebpdemux
-L/packages/libevent-2.1.12-5/.self/develop/lib
-levent
-L/packages/libvpx-1.13.1-1/.self/develop/lib
-lvpx
-L/packages/dbus-1.12.20-6/.self/develop/lib
-ldbus-1
0:13.41 ld.lld: error: undefined hidden symbol: BSoundPlayer::BSoundPlayer(media_raw_audio_format const*, char const*, void (*)(void*, void*, unsigned long, media_raw_audio_format const&), void (*)(void*, BSoundPlayer::sound_player_notification, ...), void*)
./mach build -vv
with specifying OS_LIBS += ['media']
in libcubeb/src/moz.build
--- 1.txt 2024-10-26 01:51:19.993001472 +0900
+++ 2.txt 2024-10-26 01:51:33.406847488 +0900
@@ -1,4 +1,4 @@
- 0:07.91 /bin/clang++
+ 0:08.16 /bin/clang++
-U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE=2
-fstack-protector-strong
@@ -36,6 +36,7 @@
-Wl,-rpath-link,/boot/home/src/gecko-dev/obj-ff-dbg/dist/bin
-Wl,-rpath-link,/usr/local/lib ../../../js/src/build/libjs_static.a ../../../build/pure_virtual/libpure_virtual.a ../../../x86_64-unknown-haiku/debug/libgkrust.a ../../../dist/bin/libgkcodecs.so ../../../dist/bin/liblgpllibs.so ../../../dist/bin/libnss3.so ../../../dist/bin/libnssutil3.so ../../../dist/bin/libsmime3.so ../../../dist/bin/libmozsqlite3.so ../../../dist/bin/libssl3.so ../../../dist/bin/libmozgtk.so ../../../dist/bin/libmozwayland.so
-Wl,--version-script,libxul.so.symbols
+-lmedia
-lnetwork
-lpthread
-lgnu
@@ -83,4 +84,4 @@
-lvpx
-L/packages/dbus-1.12.20-6/.self/develop/lib
-ldbus-1
- 0:13.41 ld.lld: error: undefined hidden symbol: BSoundPlayer::BSoundPlayer(media_raw_audio_format const*, char const*, void (*)(void*, void*, unsigned long, media_raw_audio_format const&), void (*)(void*, BSoundPlayer::sound_player_notification, ...), void*)
+ 0:13.59 ld.lld: error: undefined hidden symbol: BSoundPlayer::BSoundPlayer(media_raw_audio_format const*, char const*, void (*)(void*, void*, unsigned long, media_raw_audio_format const&), void (*)(void*, BSoundPlayer::sound_player_notification, ...), void*)
./mach build -vv
with specifyling in toolkit/library/moz.build
--- 1.txt 2024-10-26 01:51:19.993001472 +0900
+++ 3.txt 2024-10-26 01:51:46.540540928 +0900
@@ -1,4 +1,4 @@
- 0:07.91 /bin/clang++
+ 0:08.04 /bin/clang++
-U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE=2
-fstack-protector-strong
@@ -83,4 +83,5 @@
-lvpx
-L/packages/dbus-1.12.20-6/.self/develop/lib
-ldbus-1
- 0:13.41 ld.lld: error: undefined hidden symbol: BSoundPlayer::BSoundPlayer(media_raw_audio_format const*, char const*, void (*)(void*, void*, unsigned long, media_raw_audio_format const&), void (*)(void*, BSoundPlayer::sound_player_notification, ...), void*)
+-lmedia
+ 0:13.38 ld.lld: error: undefined hidden symbol: BSoundPlayer::BSoundPlayer(media_raw_audio_format const*, char const*, void (*)(void*, void*, unsigned long, media_raw_audio_format const&), void (*)(void*, BSoundPlayer::sound_player_notification, ...), void*)
This doesn't work too.
diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build
index a9feb0b1612a..05242e0840ee 100644
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -87,6 +87,10 @@ def Libxul(name, output_category=None):
Libxul_defines()
OS_LIBS += CONFIG["LIBATOMIC_LIBS"]
+ OS_LIBS += [
+ '-L/boot/system/develop/lib',
+ 'media',
+ ]
# TouchBar-related classes are only available in the 10.12.2 SDK and later.
# We need to weak link these classes until we've upgraded our SDK to at
--- 1.txt 2024-10-26 01:51:19.993001472 +0900
+++ 4.txt 2024-10-26 02:02:10.989331456 +0900
@@ -1,4 +1,4 @@
- 0:07.91 /bin/clang++
+ 0:07.27 /bin/clang++
-U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE=2
-fstack-protector-strong
@@ -83,4 +83,6 @@
-lvpx
-L/packages/dbus-1.12.20-6/.self/develop/lib
-ldbus-1
- 0:13.41 ld.lld: error: undefined hidden symbol: BSoundPlayer::BSoundPlayer(media_raw_audio_format const*, char const*, void (*)(void*, void*, unsigned long, media_raw_audio_format const&), void (*)(void*, BSoundPlayer::sound_player_notification, ...), void*)
+-L/boot/system/develop/lib
+-lmedia
+ 0:13.54 ld.lld: error: undefined hidden symbol: BSoundPlayer::BSoundPlayer(media_raw_audio_format const*, char const*, void (*)(void*, void*, unsigned long, media_raw_audio_format const&), void (*)(void*, BSoundPlayer::sound_player_notification, ...), void*)
grep through all files in /develop/lib/pkgconfig and /system/data/pkgconfig and look for libmedia or -lmedia.
I did this, but no pkgconfig files contains media in it
~/src/cubeb> grep -R media /system/develop/lib/pkgconfig/
~/src/cubeb> grep -R media /system/data/pkgconfig/
~/src/cubeb>
We use g++ rather than clang++ when building cubeb
[ 92%] Linking CXX executable cubeb-test
/boot/system/bin/cmake -E cmake_link_script CMakeFiles/cubeb-test.dir/link.txt --verbose=1
/bin/c++ -Wall -Wextra -Wno-unused-parameter -fno-exceptions -fno-rtti -O2 -g -DNDEBUG "CMakeFiles/cubeb-test.dir/tools/cubeb-test.cpp.o" -o cubeb-test libcubeb.a -lmedia
~/src/cubeb/build> /bin/c++ --version
c++ (2023_08_10) 13.3.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
libcubeb standalone build with your patch succeed with CC=clang CXX=clang++ so, it seems not simple toolchain problem
~/src/cubeb/build> export CC=/bin/clang
~/src/cubeb/build> export CXX=/bin/clang++
~/src/cubeb/build> cmake .. -DLAZY_LOAD_LIBS=OFF
-- The C compiler identification is Clang 18.1.7
-- The CXX compiler identification is Clang 18.1.7
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /bin/clang++ - skipped
(snip)
[ 98%] Building CXX object googletest/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o
[100%] Linking CXX static library ../../lib/libgmock_main.a
[100%] Built target gmock_main
~/src/cubeb/build>
This doesn't work too.
Could it be a problem with character visibility? It might make sense to try:
OS_LIBS += [
'-L/boot/system/develop/lib',
'-Wl,--no-as-needed',
'media',
]
or
CXXFLAGS += ['-fvisibility=hidden']
OS_LIBS += [
'-L/boot/system/develop/lib',
'media',
]
The former didn't work. We need to use LDFLAGS rather than OS_LIBS for -Wl,
options
diff --git a/media/libcubeb/src/moz.build b/media/libcubeb/src/moz.build
index 2b35a695c2a9..e730adbff9a6 100644
--- a/media/libcubeb/src/moz.build
+++ b/media/libcubeb/src/moz.build
@@ -30,6 +30,7 @@ if CONFIG['MOZ_SUNAUDIO']:
if (
CONFIG["MOZ_PULSEAUDIO"]
+ or CONFIG["MOZ_HAIKU"]
or CONFIG["MOZ_JACK"]
or CONFIG["MOZ_AAUDIO"]
or CONFIG["MOZ_OPENSL"]
@@ -107,8 +108,10 @@ if CONFIG['MOZ_HAIKU']:
'cubeb_haiku.cpp',
]
DEFINES['USE_HAIKU'] = True
- OS_LIBS += [
- 'media',
+ LDFLAGS += [
+ '-L/boot/system/develop/lib',
+ '-Wl,--no-as-needed',
+ '-lmedia',
]
FINAL_LIBRARY = 'xul'
diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build
index a9feb0b1612a..e491f713e657 100644
--- a/toolkit/library/moz.build
+++ b/toolkit/library/moz.build
@@ -87,6 +87,11 @@ def Libxul(name, output_category=None):
Libxul_defines()
OS_LIBS += CONFIG["LIBATOMIC_LIBS"]
+ LDFLAGS += [
+ '-L/boot/system/develop/lib',
+ '-Wl,--no-as-needed',
+ '-lmedia',
+ ]
# TouchBar-related classes are only available in the 10.12.2 SDK and later.
# We need to weak link these classes until we've upgraded our SDK to at
OS_LIBS += [
'-L/boot/system/lib',
'-Wl,--no-as-needed',
'-lmedia',
]
Ther latter didn't work too
diff --git a/media/libcubeb/src/moz.build b/media/libcubeb/src/moz.build
index 2b35a695c2a9..7ee395441b04 100644
--- a/media/libcubeb/src/moz.build
+++ b/media/libcubeb/src/moz.build
@@ -30,6 +30,7 @@ if CONFIG['MOZ_SUNAUDIO']:
if (
CONFIG["MOZ_PULSEAUDIO"]
+ or CONFIG["MOZ_HAIKU"]
or CONFIG["MOZ_JACK"]
or CONFIG["MOZ_AAUDIO"]
or CONFIG["MOZ_OPENSL"]
@@ -107,7 +108,9 @@ if CONFIG['MOZ_HAIKU']:
'cubeb_haiku.cpp',
]
DEFINES['USE_HAIKU'] = True
+ CXXFLAGS += ['-fvisibility=hidden']
OS_LIBS += [
+ '-L/boot/system/develop/lib',
'media',
]
@threedeyes Hey! Finally it builds! I appreciate your help!
Will test if sound actually works...
It plays HTML5 audio
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio
but when playback finished, it crashes the tab
[16214] Assertion failure: false (MOZ_ASSERT_UNREACHABLE: Current thread was not registered), at /boot/home/src/gecko-dev/dom/media/CallbackThreadRegistry.cpp:99
#01: mozilla::detail::ConditionVariableImpl::notify_one()[/boot/home/src/gecko-dev/obj-ff-dbg/dist/bin/libxul.so +0x6f7e45a]
#02: mozilla::detail::ConditionVariableImpl::notify_one()[/boot/home/src/gecko-dev/obj-ff-dbg/dist/bin/libxul.so +0x6f61a7a]
#03: mozilla::detail::ConditionVariableImpl::notify_one()[/boot/home/src/gecko-dev/obj-ff-dbg/dist/bin/libxul.so +0x3c85be6]
#04: BSoundPlayer::PlayBuffer(void*, unsigned long, media_raw_audio_format const&)[/boot/system/lib/libmedia.so +0x80728]
#05: BPrivate::SoundPlayNode::FillNextBuffer(long)[/boot/system/lib/libmedia.so +0x96db5]
#06: BPrivate::SoundPlayNode::SendNewBuffer(media_timed_event const*, long, bool)[/boot/system/lib/libmedia.so +0x96eec]
#07: BMediaEventLooper::DispatchEvent(media_timed_event const*, long, bool)[/boot/system/lib/libmedia.so +0x6cbd6]
#08: BMediaEventLooper::ControlLoop()[/boot/system/lib/libmedia.so +0x6ce6d]
#09: BMediaEventLooper::_ControlThreadStart(void*)[/boot/system/lib/libmedia.so +0x6c9ef]
#10: _thread_do_exit_work[/boot/system/lib/libroot.so +0x3ef29]
#11: ??? (???:???)
dom/media/CallbackThreadRegistrcy.cpp
void CallbackThreadRegistry::Unregister(ProfilerThreadId aThreadId) {
if (!aThreadId.IsSpecified()) {
// profiler_current_thread_id is unspedified on unsupported platforms.
return;
}
if (CanLeak()) {
return;
}
auto threadIds = mThreadIds.Lock();
for (uint32_t i = 0; i < threadIds->Length(); i++) {
if ((*threadIds)[i].mId == aThreadId) {
MOZ_ASSERT((*threadIds)[i].mUserCount > 0);
(*threadIds)[i].mUserCount--;
if ((*threadIds)[i].mUserCount == 0) {
PROFILER_UNREGISTER_THREAD();
threadIds->RemoveElementAt(i);
}
return;
}
}
MOZ_ASSERT_UNREACHABLE("Current thread was not registered");
}
I guess we (BSoundPlayer) continued feeding after receiving side (gecko) was discarded.
Apparently, either I am incorrectly deleting an object in the backend or incorrectly stopping playback. This problem is not observed by built-in cubeb tests - test_tone and test_audio. Apparently I need to build firefox for testing ).
Also I have actually finished support for recording sound from microphone, but it is still raw and requires improvement and additional testing.
haiku_stream_init() called when start playing audio. callstack:
1 haiku_stream_init cubeb_haiku.cpp 287 0x41cf1df881
2 cubeb_stream_init cubeb.c 403 0x41cf1defa6
3 mozilla::CubebUtils::CubebStreamInit CubebUtils.cpp 447 0x41d2499bd4
4 mozilla::AudioStream::OpenCubeb AudioStream.cpp 278 0x41d24b46be
5 mozilla::AudioStream::Init AudioStream.cpp 261 0x41d24b447f
6 mozilla::AudioSink::InitializeAudioStream AudioSink.cpp 129 0x41d284adec
7 mozilla::AudioSinkWrapper::SyncCreateAudioSink AudioSinkWrapper.cpp 480 0x41d2851764
8 mozilla::AudioSinkWrapper::Start AudioSinkWrapper.cpp 321 0x41d2851d21
9 mozilla::VideoSink::Start VideoSink.cpp 233 0x41d285ce7a
10 mozilla::MediaDecoderStateMachine::StartMediaSink MediaDecoderStateMachine.cpp 4139 0x41d254920d
11 mozilla::MediaDecoderStateMachine::MaybeStartPlayback MediaDecoderStateMachine.cpp 3730 0x41d253e44f
12 mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)())::{lambda((auto:1&&)...)#1}::operator()<>() const nsThreadUtils.h 1085 0x41d25f1fe7
13 std::__invoke_impl<void, mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)())::{lambda((auto:1&&)...)#1}>(std::__invoke_other, mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)())::{lambda((auto:1&&)...)#1}&&) invoke.h 61 0x41d25f1fe7
14 std::__invoke<mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)())::{lambda((auto:1&&)...)#1}>(mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)())::{lambda((auto:1&&)...)#1}&&) invoke.h 96 0x41d25f1fe7
15 _ZSt12__apply_implIZN7mozilla6detail23RunnableMethodArgumentsIJEE5applyINS0_24MediaDecoderStateMachineEMS5_FvvEEEDcPT_T0_EUlDpOT_E_RSt5tupleIJEETpTnmJEEDcOS8_OSA_St16integer_sequenceImJXspT1_EEE tuple 2302 0x41d25f1fe7
16 std::apply<mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)())::{lambda((auto:1&&)...)#1}, std::tuple<>&>(mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)())::{lambda((auto:1&&)...)#1}&&, std::tuple<>&) tuple 2313 0x41d25f1fe7
17 mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)()) nsThreadUtils.h 1083 0x41d25f1fe7
18 mozilla::detail::RunnableMethodImpl<mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)(), true, (mozilla::RunnableKind)0>::Run nsThreadUtils.h 1134 0x41d25f1fe7
19 mozilla::AutoTaskDispatcher::TaskGroupRunnable::Run TaskDispatcher.h 230 0x41cf2fe70b
20 mozilla::TaskQueue::Runner::Run TaskQueue.cpp 257 0x41cf2f901d
... <More>
Unregister() same audio thread id called twice for some reason
First DataCallback
1 mozilla::AudioStream::DataCallback AudioStream.cpp 606 0x130c7bf5f4f
2 haiku_audio_callback cubeb_haiku.cpp 151 0x130c491fd2d
3 BSoundPlayer::PlayBuffer(void *, unsigned long, media_raw_audio_format const&) 0xed2ed7a728
4 BPrivate::SoundPlayNode::FillNextBuffer(long) 0xed2ed90db5
5 BPrivate::SoundPlayNode::SendNewBuffer(media_timed_event const *, long, bool) 0xed2ed90eec
6 BMediaEventLooper::DispatchEvent(media_timed_event const *, long, bool) 0xed2ed66bd6
7 BMediaEventLooper::ControlLoop() 0xed2ed66e6d
8 BMediaEventLooper::_ControlThreadStart(void *) 0xed2ed669ef
9 thread_entry 0x5ca0695f29
10 ?? 0x7fffff8f8258
11 ??
Second
1 mozilla::AudioStream::DataCallback AudioStream.cpp 610 0x130c7bf5fa2
2 haiku_audio_callback cubeb_haiku.cpp 151 0x130c491fd2d
3 BSoundPlayer::PlayBuffer(void *, unsigned long, media_raw_audio_format const&) 0xed2ed7a728
4 BPrivate::SoundPlayNode::FillNextBuffer(long) 0xed2ed90db5
5 BPrivate::SoundPlayNode::SendNewBuffer(media_timed_event const *, long, bool) 0xed2ed90eec
6 BMediaEventLooper::DispatchEvent(media_timed_event const *, long, bool) 0xed2ed66bd6
7 BMediaEventLooper::ControlLoop() 0xed2ed66e6d
8 BMediaEventLooper::_ControlThreadStart(void *) 0xed2ed669ef
9 thread_entry 0x5ca0695f29
10 ?? 0x7fffff8f8258
11 ??
Third
1 mozilla::AudioStream::DataCallback AudioStream.cpp 610 0x130c7bf5fa2
2 haiku_audio_callback cubeb_haiku.cpp 151 0x130c491fd2d
3 BSoundPlayer::PlayBuffer(void *, unsigned long, media_raw_audio_format const&) 0xed2ed7a728
4 BPrivate::SoundPlayNode::FillNextBuffer(long) 0xed2ed90db5
5 BPrivate::SoundPlayNode::SendNewBuffer(media_timed_event const *, long, bool) 0xed2ed90eec
6 BMediaEventLooper::DispatchEvent(media_timed_event const *, long, bool) 0xed2ed66bd6
7 BMediaEventLooper::ControlLoop() 0xed2ed66e6d
8 BMediaEventLooper::_ControlThreadStart(void *) 0xed2ed669ef
9 thread_entry 0x5ca0695f29
10 ?? 0x7fffff8f8258
11 ??
Fourth
1 mozilla::AudioStream::DataCallback AudioStream.cpp 610 0x130c7bf5fa2
2 haiku_audio_callback cubeb_haiku.cpp 151 0x130c491fd2d
3 BSoundPlayer::PlayBuffer(void *, unsigned long, media_raw_audio_format const&) 0xed2ed7a728
4 BPrivate::SoundPlayNode::FillNextBuffer(long) 0xed2ed90db5
5 BPrivate::SoundPlayNode::SendNewBuffer(media_timed_event const *, long, bool) 0xed2ed90eec
6 BMediaEventLooper::DispatchEvent(media_timed_event const *, long, bool) 0xed2ed66bd6
7 BMediaEventLooper::ControlLoop() 0xed2ed66e6d
8 BMediaEventLooper::_ControlThreadStart(void *) 0xed2ed669ef
9 thread_entry 0x5ca0695f29
10 ?? 0x7fffff8f8258
11 ??
And fifth looks same
I'm building firefox right now. I'll check it myself soon, so I think I'll be able to figure out the problem faster.
Thanks, I'm looking at how firefox calls (and what is unexpected)
haiku_stream_start callstack
1 mozilla::AudioStream::StateCallback AudioStream.cpp 673 0xe54cc045f0
2 haiku_stream_start cubeb_haiku.cpp 385 0xe54992db3e
3 mozilla::AudioStream::InvokeCubeb<int ( *)(cubeb_stream *)> AudioStream.cpp 230 0xe54cc02db1
4 mozilla::AudioStream::Start AudioStream.cpp 343 0xe54cc02db1
5 mozilla::AudioSink::Start AudioSink.cpp 162 0xe54cf99142
6 mozilla::AudioSinkWrapper::StartAudioSink AudioSinkWrapper.cpp 335 0xe54cf9fff3
7 mozilla::AudioSinkWrapper::SyncCreateAudioSink AudioSinkWrapper.cpp 496 0xe54cf9f78e
8 mozilla::AudioSinkWrapper::Start AudioSinkWrapper.cpp 321 0xe54cf9fd21
9 mozilla::VideoSink::Start VideoSink.cpp 233 0xe54cfaae7a
10 mozilla::MediaDecoderStateMachine::StartMediaSink MediaDecoderStateMachine.cpp 4139 0xe54cc9720d
11 mozilla::MediaDecoderStateMachine::MaybeStartPlayback MediaDecoderStateMachine.cpp 3730 0xe54cc8c44f
12 mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)())::{lambda((auto:1&&)...)#1}::operator()<>() const nsThreadUtils.h 1085 0xe54cd3ffe7
13 std::__invoke_impl<void, mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)())::{lambda((auto:1&&)...)#1}>(std::__invoke_other, mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)())::{lambda((auto:1&&)...)#1}&&) invoke.h 61 0xe54cd3ffe7
14 std::__invoke<mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)())::{lambda((auto:1&&)...)#1}>(mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)())::{lambda((auto:1&&)...)#1}&&) invoke.h 96 0xe54cd3ffe7
15 _ZSt12__apply_implIZN7mozilla6detail23RunnableMethodArgumentsIJEE5applyINS0_24MediaDecoderStateMachineEMS5_FvvEEEDcPT_T0_EUlDpOT_E_RSt5tupleIJEETpTnmJEEDcOS8_OSA_St16integer_sequenceImJXspT1_EEE tuple 2302 0xe54cd3ffe7
16 std::apply<mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)())::{lambda((auto:1&&)...)#1}, std::tuple<>&>(mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)())::{lambda((auto:1&&)...)#1}&&, std::tuple<>&) tuple 2313 0xe54cd3ffe7
17 mozilla::detail::RunnableMethodArguments<>::apply<mozilla::MediaDecoderStateMachine, void (mozilla::MediaDecoderStateMachine:: *)()>(mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)()) nsThreadUtils.h 1083 0xe54cd3ffe7
18 mozilla::detail::RunnableMethodImpl<mozilla::MediaDecoderStateMachine *, void (mozilla::MediaDecoderStateMachine:: *)(), true, (mozilla::RunnableKind)0>::Run nsThreadUtils.h 1134 0xe54cd3ffe7
19 mozilla::AutoTaskDispatcher::TaskGroupRunnable::Run TaskDispatcher.h 230 0xe549a4c70b
20 mozilla::TaskQueue::Runner::Run TaskQueue.cpp 257 0xe549a4701d
... <More>
Unregister called before other cubeb's haiku_ methods
1 mozilla::CallbackThreadRegistry::Unregister CallbackThreadRegistry.cpp 77 0xe54cc20d09
2 mozilla::AudioStream::DataCallback AudioStream.cpp 668 0xe54cc0438a
3 haiku_audio_callback cubeb_haiku.cpp 151 0xe54992dd2d
4 BSoundPlayer::PlayBuffer(void *, unsigned long, media_raw_audio_format const&) 0x13b40dee728
5 BPrivate::SoundPlayNode::FillNextBuffer(long) 0x13b40e04db5
6 BPrivate::SoundPlayNode::SendNewBuffer(media_timed_event const *, long, bool) 0x13b40e04eec
7 BMediaEventLooper::DispatchEvent(media_timed_event const *, long, bool) 0x13b40ddabd6
8 BMediaEventLooper::ControlLoop() 0x13b40ddae6d
9 BMediaEventLooper::_ControlThreadStart(void *) 0x13b40dda9ef
10 thread_entry 0x111571a0f29
11 ?? 0x7ffffd5f3258
12 ??
How to debug firefox child process
Firefox has extremely large debug info, so some operations take a few minutes, you may want to prepare some drink and books to read.
When debugger or debuggee has no response, you can kill gdb process and reload web page and start from step 1.
Firefox is multiprocess browser, killing GDB process results child process kill, but newly process spawned for reloaded tab or sub (i)frames, And we can attach debugger on that again. (Not so much time will be saved though...)
I presumed you found my PR on this
https://github.com/kenz-gelsoft/gecko-dev/pull/69
you can switch to enable_audio_playback
branch and (re-)build to test cubeb integrated firefox.
Very strange, but I do not have this problem. I built the enable_audio_playback brunch and I can switch YouTube videos, pause, stop and start again without any problems. No crashes. Everything plays smoothly, with sound.
Very strange, but I do not have this problem. I built the enable_audio_playback brunch and I can switch YouTube videos, pause, stop and start again without any problems. No crashes. Everything plays smoothly, with sound.
Are your build is debug config? Crash comes form assertion error, so non-debug build may work.
I didnt test with youtube, so it may be site specfic.
Are your build is debug config? Crash comes form assertion error, so non-debug build may work.
No, I built the release build.
I didnt test with youtube, so it may be site specfic.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio - works fine
Added debug printf to all backend functions to better understand the order in which the browser calls them. I found a strange thing that when closing a tab or the whole browser, it only calls stream_stop() but does not call stream_destroy(). I want to redesign the backend tomorrow so that the BSoundPlayer object is created not at stream_init(), but at stream_start() and deleted at stream_stop().
If we can adopt BSoundPlayer to cubeb, it should be trivial.