OpenAL and microphone on macos using the mobile pkg

147 views
Skip to first unread message

whiteh...@googlemail.com

unread,
Mar 7, 2019, 1:13:56 PM3/7/19
to golang-nuts
go1.12  macos 10.12.4

I haven't been able to find a Go example of this being used so far.  However I found a C example that I'm porting over to Go that access the microphone.

All I'm doing so far is 'al.OpenDevice()'

running 'gomobile build' generates this error:

...golang.org/x/mobile/exp/audio/al/al_android.go:13:10: fatal error: 'AL/al.h' file not found

Working on the assumption that the openal might be missing on my system, I have run this: 'brew install openal-soft'

That hasn't solved the problem.  I took note of the following when doing the brew install, but it also hasn't helped.

For compilers to find openal-soft you may need to set:
  export LDFLAGS="-L/usr/local/opt/openal-soft/lib"
  export CPPFLAGS="-I/usr/local/opt/openal-soft/include"


Any tips please? the file does appear to be in that location.

btw Since I'm new here, is it okay to ask for help here?  or do you prefer stackoverflow?


ma...@eliasnaur.com

unread,
Mar 7, 2019, 4:08:50 PM3/7/19
to golang-nuts
I don't use the openal package myself, but I believe you need to set CGO_CFLAGS=-I/usr/local/opt/openal-soft/include.

- elias

whiteh...@googlemail.com

unread,
Mar 7, 2019, 5:11:01 PM3/7/19
to golang-nuts
Thanks! That got me some steps further down the rabbit hole :)

gomobile: the Android requires the golang.org/x/mobile/exp/audio/al, but the OpenAL libraries was not found. Please run gomobile init with the -openal flag pointing to an OpenAL source directory.

So first I tried 'brew reinstall --build-from-source openal-soft'  but there were still no sources in that directory (although everything built fine).

Next I located the downloaded brew .bz2 file, which was located in: '~/Library/Caches/Homebrew' and using a symlink of 'openal-soft--1.19.1.tar.bz2'

Manually unpacking that, and then running a new gomobile init pointing to that directory got me some distance further before sadly failing.

[  2%] Building C object CMakeFiles/common.dir/common/alcomplex.c.o
In file included from /Users/me/openal-soft-1.19.1/common/alcomplex.c:5:
/Users/me/openal-soft-1.19.1/common/math_defs.h:36:21: error: static declaration of 'log2f' follows non-static declaration
static inline float log2f(float f)
                    ^
/Users/me/go/pkg/gomobile/ndk-toolchains/arm/bin/../sysroot/usr/local/include/math.h:38:15: note: previous declaration is here
float         log2f(float);

Is there anyway to bypass this step of having to rebuild OpenAL?

Elias Naur

unread,
Mar 8, 2019, 4:36:41 AM3/8/19
to whiteh...@googlemail.com, golang-nuts
On Thu, Mar 7, 2019 at 11:11 PM whitehexagon via golang-nuts
<golan...@googlegroups.com> wrote:
>
> Thanks! That got me some steps further down the rabbit hole :)
>
> gomobile: the Android requires the golang.org/x/mobile/exp/audio/al, but the OpenAL libraries was not found. Please run gomobile init with the -openal flag pointing to an OpenAL source directory.
>
> So first I tried 'brew reinstall --build-from-source openal-soft' but there were still no sources in that directory (although everything built fine).
>
> Next I located the downloaded brew .bz2 file, which was located in: '~/Library/Caches/Homebrew' and using a symlink of 'openal-soft--1.19.1.tar.bz2'
>
> Manually unpacking that, and then running a new gomobile init pointing to that directory got me some distance further before sadly failing.
>
> [ 2%] Building C object CMakeFiles/common.dir/common/alcomplex.c.o
> In file included from /Users/me/openal-soft-1.19.1/common/alcomplex.c:5:
> /Users/me/openal-soft-1.19.1/common/math_defs.h:36:21: error: static declaration of 'log2f' follows non-static declaration
> static inline float log2f(float f)
> ^
> /Users/me/go/pkg/gomobile/ndk-toolchains/arm/bin/../sysroot/usr/local/include/math.h:38:15: note: previous declaration is here
> float log2f(float);
>
> Is there anyway to bypass this step of having to rebuild OpenAL?
>
>

I don't think there's a way around it, unfortunately. As far as I
know, there are no prebuilt openal libraries for Android available.

I'm not even sure openal builds with a recent NDK where gcc is gone
and replaced with clang.

- elias

whiteh...@googlemail.com

unread,
Mar 8, 2019, 7:17:55 AM3/8/19
to golang-nuts
Ah of course, it has to rebuild per target platform.  Looking further at the mobile API I'm not sure it includes the Capture part of OpenAL anyway. 
I'll have a look at kotlin-native for this part of my functionality.  Thank you for your help. Peter
Reply all
Reply to author
Forward
0 new messages