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

495 Commits

Author SHA1 Message Date
Hyang-Ah (Hana) Kim
fd342d15ab bind/objc: implement byte array read/write support.
Change-Id: I01ff7369c653bc7d57a3357c8f936d30ca5c0beb
Reviewed-on: https://go-review.googlesource.com/9922
Reviewed-by: Damien Neil <dneil@google.com>
2015-05-13 22:32:52 +00:00
Hyang-Ah (Hana) Kim
5c3e18f08f bind/objc: obj-c binding for functions using numeric, string types.
test.bash is a simple script that builds the c-shared library from
test_main.go, compiles SeqTest.m and the objective-c bindings of testpkg
(testpkg/objc_testpkg/GoTestpkg.*), and runs the output. Eventually this
will be replaced with coed that runs gomobile bind & xcodebuild.

The code under testpkg/go_testpkg and testpkg/objc_testpkg is the output
of gobind (now manually-generated). I am adding it to repo now in order
to get the testpkg/objc_tstpkg reviewed. Eventually, this will be
removed from the repo.

Change-Id: I8d6af3732337992af922cb4615a63f385e19d489
Reviewed-on: https://go-review.googlesource.com/9826
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-13 22:28:22 +00:00
Hyang-Ah (Hana) Kim
ec112d8787 bind: mention the supported binding rules.
Change-Id: I4760042871b2ccb7b24ee79ef9adef54cfb9303b
Reviewed-on: https://go-review.googlesource.com/9996
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-05-13 21:10:50 +00:00
Hyang-Ah (Hana) Kim
4f4272d70b bind: fix Java code generation that takes reference type params.
Also fixes a parameter name handling problem when processing a
function signature that omits parameter names.

Fixes golang/go#10788.

Change-Id: I65273d330bbf3a836ec9e4ffb691927970d795d8
Reviewed-on: https://go-review.googlesource.com/9926
Reviewed-by: Alan Donovan <adonovan@google.com>
2015-05-12 22:05:40 +00:00
Hyang-Ah (Hana) Kim
910c3fc64e bind/java: find jbytearray class info using jbytearray object.
The previous way (JNIEnv's FindClass with "[B") does not work
in Android-L for some reason.

Change-Id: I5cccb7bbf651df981a923ecade863302521d5c5c
Reviewed-on: https://go-review.googlesource.com/9783
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-05-12 17:43:40 +00:00
Burcu Dogan
ddfab7d990 mobile: add instructions about filing an issue and discussing FRs
Change-Id: Ic7dad34ec242910540da4d6bae94f45907b3d0dd
Reviewed-on: https://go-review.googlesource.com/9898
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-11 21:43:06 +00:00
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
David Crawshaw
ddd3a9e786 cmd/gomobile: check version with working cmd/dist
Fixes golang/go#10760 maybe, I have been unable to reproduce it.

Change-Id: Iaeec631f5a6be29b312969df12f6bd6b95bc2aa1
Reviewed-on: https://go-review.googlesource.com/9880
Reviewed-by: Burcu Dogan <jbd@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-08 19:08:54 +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
David Crawshaw
a7a3501c10 cmd/gomobile: simpler download caching
Instead of trying to preserve the unpacked NDK, this stores the
downloaded archives in GOPATH/pkg/gomobile/dl and completely
rebuilds on reinitialization.

Also introduce checking that the version of Go we are using to do
the build matches the GOROOT we are building from.

Fixes golang/go#10187

Change-Id: I4a861718d8a413855917a5b1f1073e2cd84c9bb1
Reviewed-on: https://go-review.googlesource.com/9685
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-07 17:19:57 +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
cf8de59746 example/audio: add sample audio app
This app makes a sound as the gopher hits the edges of the screen.

Change-Id: I85c7d55ec88b1a9faec5dfb7b29e03d1149f5d65
Reviewed-on: https://go-review.googlesource.com/9698
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-05-07 01:05:33 +00:00
Elias Naur
383d14d1a3 mobile/cmd/gomobile: add proguard.txt to gomobile bind .aar files
The gomobile bind command outputs an .aar file ready to include in an
Android project. If the including project use the minifyEnabled gradle
option  the field go.Seq.memptr will be removed since it is only referenced
from C code.

Instruct the minifier to keep all go.* java code by adding an appropriate
proguard.txt file to the .aar file.

Change-Id: Ia1e89a5d8f4b4f349f9c2cf4d0dba2628557fdf9
Reviewed-on: https://go-review.googlesource.com/9802
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-05-06 22:49:45 +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
Hyang-Ah (Hana) Kim
601608a0e0 bind/java: use the class loader cached during JNI_OnLoad call.
This allows the application class loader to be used when
the bind/java package or other part of JNI dynamically
loads java classes from a non-Java thread.

http://developer.android.com/training/articles/perf-jni.html#faq_FindClass

Fixes golang/go#10668.

Change-Id: I44df3a9362617fa6dd26ddf88247e4fdaee7c7e8
Reviewed-on: https://go-review.googlesource.com/9732
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-05-06 03:41:18 +00:00
Burcu Dogan
696139153c mobile: add gomobile to README
Change-Id: Ica709ed74b014feb21e632cd967279da3ebd41ad
Reviewed-on: https://go-review.googlesource.com/9730
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-05 17:44:58 +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
a849359c3b mobile: deprecate Dockerfile and document gomobile
Keeping the Dockerfile as a reference to setup a working dev env
without gomobile init.

Fixes #10523

Change-Id: Ie5a359baff2c3b65ac34045fb8ab5560a23c0e22
Reviewed-on: https://go-review.googlesource.com/9686
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-04 21:07:04 +00:00
David Crawshaw
66ea9e5b49 app: simplify and document init sequence
The global constructor added for -buildmode=c-shared takes care
of a lot of the messier steps that were being done here.

Change-Id: I00525765855b2ad0fcecb0639d6a7ee3feea9ed9
Reviewed-on: https://go-review.googlesource.com/9648
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-04 12:09:13 +00:00
David Crawshaw
b364bb0348 cmd/gomobile: print error messages from javac
Useful if you are running an old unsupported Java 1.6.

Change-Id: I794bacc22a09ee339730ef7b600475eba09a3a9d
Reviewed-on: https://go-review.googlesource.com/9649
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-04 12:06:30 +00:00
Burcu Dogan
88e68e02f0 example/basic,example/sprite: give a reference to gomobile installation
Removing the duplicate installation instructions and giving a reference
to the gomobile godoc.

Change-Id: I476e4a4f4545eeb17d9ba18f471076d63c1f15d1
Reviewed-on: https://go-review.googlesource.com/9631
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-01 20:58:37 +00:00
Hyang-Ah (Hana) Kim
812950cfd1 bind/objc: GoSeq for obj-c and go communication.
duplicate code from bind/java/seq_android.c to use for obj-c/go binding.

Change-Id: Iefd5d4171cca3a30c5d56f9b37647463e6fd0c5a
Reviewed-on: https://go-review.googlesource.com/9409
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-05-01 19:28:10 +00:00
Burcu Dogan
d9a820a72b cmd/gomobile: expand the docs with instructions to build Go from tip
Change-Id: Ie7bd43cdf8d759e6d739824c59cac0e01d1a4b95
Reviewed-on: https://go-review.googlesource.com/9630
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-05-01 19:24:26 +00:00
Gordon Klaus
253eb63b86 mobile/app: identify touches by ID to enable multitouch
An example of how to handle multiple concurrent touches using this design:

var touched = map[event.TouchSequenceID]*Widget{}
func touch(t event.Touch) {
    if t.Type == event.TouchStart {
        if w := widgetAt(t.Loc); w != nil {
            touched[t.ID] = w
        }
    }
    if w, ok := touched[t.ID]; ok {
         // move/scroll widget, etc
    }
    if t.Type == event.TouchEnd {
        delete(touched, t.ID)
    }
}

Change-Id: I79910ef30abe9a41bc0720783022b1af081fbd43
Reviewed-on: https://go-review.googlesource.com/1895
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Burcu Dogan <jbd@google.com>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-29 16:53:16 +00:00
Hyang-Ah (Hana) Kim
74be7c24e4 cmd/gomobile: update the doc.
Change-Id: Ie654ad9aaaf5a1c0394731161194a1358a075e97
Reviewed-on: https://go-review.googlesource.com/8245
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-29 16:05:14 +00:00
Hyang-Ah (Hana) Kim
30559f84c5 bind/java: add mising copyright statements.
Change-Id: Ifb120cba013d48fa83af41a43ccbbe7de87b26c8
Reviewed-on: https://go-review.googlesource.com/9408
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-28 18:08:06 +00:00
Burcu Dogan
1cb3b97c74 example/sprite: switch to gomobile build
Fixes #10523.

Change-Id: Ic0bf345624f6584757e2af5cb91a679827ee3b13
Reviewed-on: https://go-review.googlesource.com/9340
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-25 00:22:47 +00:00
Burcu Dogan
717c2c4312 example/basic: add build instructions for gomobile
This CL also removes Android build system required files and keeping
it to the bare minimum to what gomobile requires.

Fixes #10523.

Change-Id: Iabf16e7ea040a74eaf64746e7cc4e23ef3683af2
Reviewed-on: https://go-review.googlesource.com/9204
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-24 23:59:43 +00:00
Nigel Tao
a4bb1057ff app: fix tabs vs spaces.
Change-Id: I50035006af8358ef2d794ae2c75dddc835f99f3d
Reviewed-on: https://go-review.googlesource.com/9141
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-21 00:10:36 +00:00
Hyang-Ah (Hana) Kim
1ab6893162 cmd/gomobile: fix init_test.go to pass on windows/darwin.
Change-Id: I03a18267ddd35ce432a394732185dab0283f2da6
Reviewed-on: https://go-review.googlesource.com/9170
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-20 21:32:12 +00:00
Hyang-Ah (Hana) Kim
094aefd3b8 Dockerfile: update go version to 3f4de49.
Change-Id: Icf2fa718236810086b85a19d4f3826884c03630f
Reviewed-on: https://go-review.googlesource.com/9077
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-20 17:34:49 +00:00
Hyang-Ah Hana Kim
f0c91fa51b cmd/gomobile: copy old5a to the tool chain.
The app/internal/callfn package requires old5a.

Change-Id: Id0e084dc5c1dd1275d0043412ab9ea0423e7651d
Reviewed-on: https://go-review.googlesource.com/9034
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-17 19:43:10 +00:00
David Crawshaw
d77bba0a9f app: call main.main on app startup
There is some cleanup to be done in this package now, but I'm
deferring it until later in the cycle.

We should probably also change the semantics slightly: main should
be called for all-Go apps (that is, apps that use NativeActivity),
but it would be more consistent with buildmode=c-shared and c-archive
if we did not call main for Go shared libraries being included in
Java android apps.

Change-Id: I13ca797a478edb22b0c602c1ee6e616fe4fea1e6
Reviewed-on: https://go-review.googlesource.com/9016
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-17 16:08:58 +00:00
Hyang-Ah Hana Kim
47553f4d42 cmd/gobind: fix a typo.
This addresses the reviewer's comment from change 8986.

Change-Id: Ibeec45fa9b8ab2ee68ebcc98f38f3538d992024d
Reviewed-on: https://go-review.googlesource.com/8987
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-16 18:47:12 +00:00
Hyang-Ah Hana Kim
5f5a5fa270 cmd/gobind: list byte slice as a supported type.
Fixes golang/go#10481.

Change-Id: I8cee771c32347c2ef641b416dbc1967dc52a0f46
Reviewed-on: https://go-review.googlesource.com/8986
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-04-16 18:19:58 +00:00
Hyang-Ah (Hana) Kim
bdbc727b12 bind/java: convert test.bash to go test.
This change deletes unnecessary files - they are auto-generated by
the gomobile bind command.

Change-Id: I490664dfcf52683dd8d2ea821d0b7e458bc06671
Reviewed-on: https://go-review.googlesource.com/8925
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-15 12:57:12 +00:00
Hyang-Ah (Hana) Kim
0150454fb3 bind/seq: add Buffer.{Read,Write}UTF8.
Change-Id: I204dd9c9080c9c1e350210932397a500247aea28
Reviewed-on: https://go-review.googlesource.com/8896
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-14 18:50:33 +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
2952048198 mobile/app: update the window width and height after rotation
Orientation invokes onNativeWindowRedrawNeeded.
Requery the window width and height when redraw needed.

Change-Id: I45816f13b42db38e71d28cb05bf7cfffda75882c
Reviewed-on: https://go-review.googlesource.com/8700
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-11 11:51:47 +00:00
Hyang-Ah (Hana) Kim
334412418f bind: replace {Read,Write}UTF16 with {Read,Write}String for string.
This is to enable more flexible encoding/decoding of Go string.
For Java, we use UTF16 to be compatible with java string.
For other languages, we will want other way to represent a string.

Change-Id: Iccd53e2eea18d37636c3c619d06cb473facef0cd
Reviewed-on: https://go-review.googlesource.com/8628
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-09 12:44:56 +00:00
Hyang-Ah (Hana) Kim
d886eeda27 bind/java: fix testpkg's gobind generate command.
Change-Id: I36494baac428ed9fdd777d2b03bf23a9cb2568b5
Reviewed-on: https://go-review.googlesource.com/8627
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-09 12:44:41 +00:00
Burcu Dogan
7858a6e1a7 sensor: minimize the number of epolls
Drain the event queue between ALooper_pollAll calls. ALooper_pollAll
makes an epoll to see if there is any I/O going on the underlying
resources and is relatively a costly operation. Try to consume the
queue first and block on pollAll again if necessary.

We should stop retrying if timeout occurs and return immediately.

Change-Id: I6e9f85df2dd275fb014f90f13de4f05d776d4b7d
Reviewed-on: https://go-review.googlesource.com/8590
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-08 03:40:08 +00:00
Nigel Tao
e5a0a60135 sensor: make the global Type values consts instead of vars.
Change-Id: I209b1d5c6e86ff08739add4aaab28e9a57565c93
Reviewed-on: https://go-review.googlesource.com/8601
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-04-07 23:58:06 +00:00
Burcu Dogan
16015b6039 sensor: don't block Read more than 30 secs
Don't block on Read forever, force timeout if nothing happens for
a while. 30 secs is high enough not to be the desired delay for
the movement sensors.

Change-Id: I257120809855382d7a945a132f5b7a2cff1ecfca
Reviewed-on: https://go-review.googlesource.com/8580
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-04-07 20:44:27 +00:00
Burcu Dogan
dad00d93e6 Revert "mobile/sensor: block until timeout occurs"
If the looper is waking up, the current timeout limit is exceeded.
There are no external APIs to query if a looper is trying to wake up
or blocking to wait for the event data. Therefore, I'm this
change and will replace the timeout with a significantly high number
that could only be exceeded if sensor fails with a fatal problem.
The goal is not to wait on ALooper_pollAll forever.

This reverts commit 1575a42f33e3354db87760bcc8c9d951e35347dd.

Change-Id: I861d81f2550c4435247a0b1d4ce141e94d1e3ec9
Reviewed-on: https://go-review.googlesource.com/8565
Reviewed-by: Burcu Dogan <jbd@google.com>
2015-04-07 20:20:34 +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