2
0
mirror of synced 2025-02-23 14:58:12 +00:00

25 Commits

Author SHA1 Message Date
Burcu Dogan
3b82ab44aa mobile/audio: document WAV header size and its format
Change-Id: I438480b861b4537116f995daaf04ee076560e6ec
Reviewed-on: https://go-review.googlesource.com/9877
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-05-08 23:40:00 +00:00
Burcu Dogan
f3d33d5ec9 mobile/example/audio: fix the broken Android build
Fixes golang/go#10758

Change-Id: I6e2084a817789fcadbe61e257446ed5a17b77a1d
Reviewed-on: https://go-review.googlesource.com/9878
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-05-08 16:20:44 +00:00
Burcu Dogan
e33b2cee97 mobile/audio: determine the format and sample rate from the WAV format
Change-Id: Ieca37d7785e0608160728716654ceb6650799f3e
Reviewed-on: https://go-review.googlesource.com/9874
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-05-08 15:51:42 +00:00
Burcu Dogan
d861c4af68 mobile/audio: rename (*Player).Destroy to (*Player).Close
Destroy sounds like C, we should use Close in Go.

Change-Id: I73da732300a955e458513f15ad898b7f34c8ed7c
Reviewed-on: https://go-review.googlesource.com/9875
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-05-08 04:27:49 +00:00
Burcu Dogan
2aa4da50c5 mobile/audio: skip RIFF WAVE header if exists
PCM data may contain a header, we need to skip it and stream the
audio data to the underlying OpenAL player. Otherwise, we will play
the header bytes as well and the sound will click.

The future work will include auto detecting the number of channels,
the bitrate and the sample rate from the header.

Fixes golang/go#10728

Change-Id: Ie09e4c59a08207838d0c8f4c5d4d0cb08deb27cd
Reviewed-on: https://go-review.googlesource.com/9860
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-05-07 21:31:08 +00:00
Burcu Dogan
a18cedb28d mobile/audio: player should close its audio source
The most common use case to init a player is to open an asset and provide
it to NewPlayer. Currently, we require use to keep a reference to the source
and close it after the player is destroyed. It's tedious. We may improve
the usability by freeing the source asset on Destroy. And if the user
wants to play a ReadSeeker, they can implement a trivial ReadSeekCloser
with a noop Close.

Change-Id: Ie6bdea468da484f785bc0c283f13203cad3a1a68
Reviewed-on: https://go-review.googlesource.com/9693
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-05-07 01:16:26 +00:00
Burcu Dogan
a8aa7bbd72 audio: have a global audio device and context
On mobile devices, there is typically only a single audio device. We may
open it once and reuse it to stream audio buffers from multiple sources.
This assumption also applies to the context since OpenAL contextes are
process-wide. A shared global pointer is reusable across multiple
OpenAL sources.

This CL also removes the Device and Context types and the unexpected
garbage collection issue introduced by Context's finalizer.

Fixes golang/go#10636

Change-Id: I82e6e6e6a1500ba91d66a7848cf37d1a5e01af9b
Reviewed-on: https://go-review.googlesource.com/9782
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-06 19:07:41 +00:00
David Crawshaw
5cddc1460e app: introduce Config and start registration
Config provides a way to concurrently access Width and Height.

Register provides a way for packages to run code on app state change
without plumbing changes all the way to the process main function.
This is motivated by gl/glutil.Image which needs to rebuild its
textures on start/stop and can be deeply nested.
(See golang.org/cl/9707 for the followup.)

Tested manually on android and darwin/amd64. Doing this kind makes it
clear any CL modifying this code needs a lot of manual testing right
now, so some kind of trybot support is something I'm going to
prioritise.

Fixes golang/go#10686
Fixes golang/go#10461
Fixes golang/go#10442
Fixes golang/go#10226
Updates golang/go#10327

Change-Id: I2882ebf3995b6ed857cda823e94fbb17c54b43a8
Reviewed-on: https://go-review.googlesource.com/9708
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-06 17:32:53 +00:00
Burcu Dogan
1718de6fe6 mobile: add missing canonical import paths
Change-Id: I71d38a6494b8235f5669ff53e6bd29e7045d0409
Reviewed-on: https://go-review.googlesource.com/9697
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-05-05 03:13:45 +00:00
Burcu Dogan
cd5954b705 audio: add notice about the OpenAL license
OpenAL Soft is licensed with LGPL which requires users to add a notice
about its license under their open source notices screen.

Change-Id: Ic3c3bcc4a38896508b19d54a8c526bcd1fa9d5b3
Reviewed-on: https://go-review.googlesource.com/8868
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-13 22:34:15 +00:00
Burcu Dogan
bf1596d2ef audio/al: destroy the internal context while finalizing Context
The necessity to destroy an ALC context is not to leave a leaking
context as Context instances are being collected. If the user doesn't
Destroy, do it when finalizing. If a context is destroyed by the user,
a finalizer is no more needed.

Change-Id: If6330361f7983ec8ede0e93b7f6e3a440de9fd6c
Reviewed-on: https://go-review.googlesource.com/8497
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-07 15:24:13 +00:00
Burcu Dogan
6544820032 audio/al: don't define MakeContextCurrent on the pointer
It's a common requirement to call MakeContextCurrent with a nil value
before destroying a context. Nil value as a reciever is not as user-
friendly as a standalone MakeContextCurrent.

Change-Id: I537ec0330657ef134f97a3c3b0d32793012eee86
Reviewed-on: https://go-review.googlesource.com/8500
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-06 22:23:13 +00:00
Burcu Dogan
c2bf90dc60 audio/al: add bindings for alcDestroyContext
Fixes #10330.

Change-Id: Ib5c379593ac4afef11b465773f6373dd5775ce98
Reviewed-on: https://go-review.googlesource.com/8492
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-06 16:20:40 +00:00
Burcu Dogan
6ed9b243b1 mobile/audio: use AL_TRUE and ALC_TRUE
Change-Id: I8c1a3e72f06a02c18bff3a348e86e78040007867
Reviewed-on: https://go-review.googlesource.com/7770
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-18 20:10:10 +00:00
Burcu Dogan
33ee14d530 mobile/audio: add instructions how to install OpenAL on Linux desktop
Change-Id: I47b42db1443040bcd9c77cd1d19a0e0f8c5119ec
Reviewed-on: https://go-review.googlesource.com/7090
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-03-07 01:01:31 +00:00
David Crawshaw
c30f429855 audio/al: replace strcat with strlcat
Comment from golang.org/cl/6642. As bionic (surprisingly) has strlcat,
using it instead of strncat. If you're not familiar with the l-variants,
see http://www.sudo.ws/todd/papers/strlcpy.html

Change-Id: I69958ee99917903f9d10dda0ec99111c4793db71
Reviewed-on: https://go-review.googlesource.com/7011
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-03-06 17:18:06 +00:00
Burcu Dogan
c94142eb97 mobile/audio: add android support
Due to licensing limitations, OpenAL should be dynamically
loaded. Android apps that needs to import the audio package
needs to be packed with libopenal.so as an extenal lib
dependency.

Instructions to build OpenAL for Android is available at
http://repo.or.cz/w/openal-soft.git/blob/HEAD:/XCompile-Android.txt

The packed libopenal.so is exported to
/data/data/<package_name>/lib/libopenal.so at installation.
The audio package dlopens libopenal.so from this location and
dlsym to dispatch the OpenAL functions.

Change-Id: I7aa36bb8dd0ae8e101ae4aa5366c3d426b2569a9
Reviewed-on: https://go-review.googlesource.com/6642
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-04 18:58:40 +00:00
Burcu Dogan
a49d80e2cf audio/al: make MakeCurrentContext a method of Context
There is no good reason for MakeCurrentContext to be a standalone
function since we don't allow nil contextes to be the current.

Change-Id: I4483c30a2ed78262b67c96e73739188a22f685b9
Reviewed-on: https://go-review.googlesource.com/6640
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-03 18:09:34 +00:00
Burcu Dogan
b7c27d1a66 mobile/audio: reorg the package to allow multiple implementations of bindings
Change-Id: I68dcc392b0ae7c539c12c6306d9b312d02603b5b
Reviewed-on: https://go-review.googlesource.com/6570
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-03-03 17:53:35 +00:00
Nigel Tao
fc5f7c74c8 audio: use int constants (C style enums) instead of string.
Change-Id: Ifb6db04c4bbf6c66e5a63dcaeee704ab02e711b0
Reviewed-on: https://go-review.googlesource.com/6423
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-03 00:02:05 +00:00
Nigel Tao
333098d850 audio: build on linux, not just darwin.
Change-Id: Ie10c29012bf6769591a1ad1c1e9ee322d780608e
Reviewed-on: https://go-review.googlesource.com/6392
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-03-02 00:52:08 +00:00
Burcu Dogan
7b45e52f8c mobile/audio: avoid locks during IO and fix seek precision
Change-Id: Ida8d07f87fe118094bc36c6be5c576fd0999abdf
Reviewed-on: https://go-review.googlesource.com/6080
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-02-27 04:52:35 +00:00
Hyang-Ah Hana Kim
25b15a705f audio: skip build for non-darwin.
Change-Id: If382b517a21b90412ced3bfa543575055df8de3a
Reviewed-on: https://go-review.googlesource.com/5510
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-02-20 23:43:34 +00:00
Burcu Dogan
7e40b31538 mobile/audio: add a basic audio player
Fixes #9551.

Change-Id: I83311afc2d2fd67a883c70d83c6a498d9e033f2c
Reviewed-on: https://go-review.googlesource.com/3262
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-02-12 17:24:23 +00:00
Burcu Dogan
c67709898b mobile/audio: adding OpenAL bindings
The bindings are not working on Android currently. We may require
the users to build their own OpenAL library that is targetting
Android or may distribute a shared object.

Change-Id: Ibcfa3482aa53e9b3ec9bfddf5dd1622ad07b7b7e
Reviewed-on: https://go-review.googlesource.com/3115
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-02-04 14:48:47 +00:00