Hajime Hoshi
89f6eba925
Revert "audio: Bug fix: Make ensureReadLoop exactly atomic"
...
This reverts commit 835497edd3
.
Reason: This causes a dead lock at examples/piano with many notes.
This might be related to #855
2019-04-29 14:57:55 +09:00
Hajime Hoshi
fe3e8e376a
audio: Move seeking from the loop to Seek function
...
Seek should work in both cases the loop runs and not. This change
is a preparation.
2019-04-29 02:27:15 +09:00
Hajime Hoshi
c4c6acacf9
audio: Remove (*mux).hasPlayer
2019-04-29 01:01:29 +09:00
Hajime Hoshi
96012b661f
audio: Bug fix: bufferToInt16 can return smaller result
...
Fixes #854
2019-04-29 00:32:57 +09:00
Hajime Hoshi
835497edd3
audio: Bug fix: Make ensureReadLoop exactly atomic
2019-04-29 00:05:54 +09:00
Hajime Hoshi
b1607de99d
audio: Refactoring
2019-04-28 23:58:06 +09:00
Hajime Hoshi
14b6e95217
audio: Use a boolean value to inidicate inited state intead of channels
...
This is a preparation to use oto.Players for Players. By using a
boolean value, suspending state can be detected from multiple
oto.Players.
2019-04-28 19:53:28 +09:00
Hajime Hoshi
fe55e55b7e
audio: Refactoring
2019-04-28 19:53:28 +09:00
Hajime Hoshi
1327e2239c
audio: Use a boolean value to indicate suspending state instead of channels
...
This is a preparation to use oto.Players for Players. By using a
boolean value, suspending state can be detected from multiple
oto.Players.
2019-04-28 19:53:28 +09:00
Hajime Hoshi
2b7705e7ad
audio: AppendHookOnBeforeUpdate should treat multiple calbacks
2019-04-28 19:53:22 +09:00
Hajime Hoshi
31758bf3ab
audio: Remove comment
2019-04-28 19:49:37 +09:00
Hajime Hoshi
2bea7d4e1a
audio: Error on duplicated source
...
Fixes #853
2019-04-28 19:39:46 +09:00
Hajime Hoshi
70a225fd7e
audio: Use dummy hooks from tests
2019-04-28 19:35:59 +09:00
Hajime Hoshi
81549a3523
audio: Bug fix: Remove redundant Unlock
2019-04-28 02:44:32 +09:00
Hajime Hoshi
9fc2ae158c
audio: Bug fix: Close always returned error
2019-04-28 02:22:11 +09:00
Hajime Hoshi
e4f0a0aa04
audio: Bug fix: Remove depenency on finalizer
...
This change fixes playerImpl leak by removing dependency on
finalizer usages. Now readLoop can (or should) be called multiple
times even after closing. Only when (*Player).Close is called
explicitly, the read loop cannot be started again.
Fixes #852
2019-04-28 02:03:55 +09:00
Hajime Hoshi
4f831de008
audio: Remove (*playerImpl).sync and use mutex instead
...
This is a preparation to work syncing wihtout the read-loop.
2019-04-28 01:37:52 +09:00
Hajime Hoshi
acc4ef4e11
audio: Add comments
2019-04-01 01:59:10 +09:00
Hajime Hoshi
df2604c221
audio: Comment about ownership
...
This behavior might be changed at version 2 though (#837 ).
2019-04-01 01:32:14 +09:00
Hajime Hoshi
cba109ebee
audio/mp3: Bug fix: Accept non-io.Closer at Resampling
2019-04-01 00:04:57 +09:00
Hajime Hoshi
49c0b64b60
audio/mp3: Bug fix: Close source when needed
2019-03-31 22:58:22 +09:00
Hajime Hoshi
aa042980ee
audio/mp3: Remove Close calls
...
Close is removed at 14af46a99b
2019-03-31 22:42:34 +09:00
Hajime Hoshi
ed855d6c6c
audio: Refactoring: remove the unused returning value
2019-03-02 04:42:19 +09:00
Hajime Hoshi
a3eddeb50f
Improve panic messages
2019-02-06 23:43:03 -10:00
Hajime Hoshi
a4123a479e
audio: Initialize the context first
...
This is necessary to create an audio's Player before the loop if
we want to create *oto.Player for each *audio.Player.
2019-01-30 00:45:36 +09:00
Hajime Hoshi
13b0d82b6d
audio: Use oto.NewContext
2019-01-30 00:36:47 +09:00
Hajime Hoshi
f16f6cf4b9
audio/internal/convert: Add Float32Reader and NewReaderFromFloat32Reader
2019-01-15 11:46:31 +09:00
Hajime Hoshi
13f6549cb6
audio/vorbis: Remove duplicated decoded data
...
There was duplicated decoded date in audio/vorbis package and Ogg
decoder package. This change removes this duplication and reduces
memory usage.
2019-01-15 03:52:27 +09:00
Hajime Hoshi
6d714a16cf
audio: Remove unneeded 'break'
2019-01-10 02:34:58 +09:00
Hajime Hoshi
a6b3f761f8
audio: Refactoring: Remove dependency on clock package
2019-01-10 00:59:38 +09:00
Hajime Hoshi
28c96d256a
audio: Bug fix: Test compilation error
2019-01-09 23:39:12 +09:00
Hajime Hoshi
14404334e7
audio: Rename players to mux
2019-01-09 22:10:52 +09:00
Hajime Hoshi
e9422a9f2c
audio: Improve test flakiness
2019-01-06 00:11:34 +09:00
Hajime Hoshi
7956e0ebbc
Revert "Revert "audio: No need goroutine for tests""
...
This reverts commit 62a9bb195c
.
2018-12-28 02:18:16 +09:00
Hajime Hoshi
62a9bb195c
Revert "audio: No need goroutine for tests"
...
This reverts commit 7740656054
.
2018-12-28 02:15:11 +09:00
Hajime Hoshi
7740656054
audio: No need goroutine for tests
2018-12-27 03:37:29 +09:00
Hajime Hoshi
ed7552962d
audio: Improve test flakiness
2018-12-27 03:34:27 +09:00
Hajime Hoshi
1760070130
audio: Add comments about GC ( #746 )
2018-12-18 23:07:19 +09:00
Hajime Hoshi
b9eba54115
audio: Use a dummy driver for testing
...
Fixes #750
This also fixes an out-of-index bug when all players are skipped.
2018-12-17 23:06:59 +09:00
Hajime Hoshi
b0cb216f5f
audio: Close audio after its playing finishes
...
Fixes #746
This is a temporal fix and we will need further re-designing of
audio package.
2018-12-17 04:02:32 +09:00
Hajime Hoshi
08a369b8fd
audio: Bug fix: GC audio players correctly
...
Fixes #746
2018-12-15 22:33:45 +09:00
Hajime Hoshi
feca647087
audio/vorbis: Unretain the Ogg decoder on Close ( #733 )
2018-11-09 03:48:28 +09:00
Hajime Hoshi
eda8d61413
audio/vorbis: Unretain the Ogg decoder after decoding is done ( #733 )
2018-11-09 03:46:00 +09:00
Hajime Hoshi
d14202ef7b
audio: Add Context.IsReady
...
Fixes #717
2018-10-16 00:02:19 +09:00
Hajime Hoshi
c0884b5ab2
audio/vorbis: Avoid unnecessary appending
2018-10-06 00:06:47 +09:00
Hajime Hoshi
1cf3022ce6
audio/vorbis: Update stbvorbis.js
...
Fixes #667
2018-10-05 22:12:39 +09:00
Hajime Hoshi
d5ca4c3953
audio/vorbis: Bug fix: compilation error
2018-09-02 23:55:59 +09:00
Hajime Hoshi
70044013e9
audio/vorbis: Rename []uint8 -> []byte
2018-09-02 23:54:50 +09:00
Hajime Hoshi
59bcbca379
audio: Add NewInfiniteLoopWithIntro ( #652 )
2018-07-28 21:25:42 +09:00
Hajime Hoshi
2969de5b1f
audio: Refactoring: Redefine bytesPerSample
2018-07-24 01:54:01 +09:00
Hajime Hoshi
a0bd31ef1f
audio: Rename stream -> src
2018-07-24 01:22:05 +09:00
Hajime Hoshi
6a1afe8fbe
audio: Add test for negative position
2018-07-23 04:01:43 +09:00
Hajime Hoshi
0d5924b448
audio: Add test for InifiniteLoop
2018-07-23 03:30:06 +09:00
Hajime Hoshi
34ac185327
audio: Rename file
2018-07-23 03:15:17 +09:00
Hajime Hoshi
082556ad5c
audio: Better error message
2018-07-23 02:28:07 +09:00
Hajime Hoshi
05ac690db5
audio/vorbis/internal/stb: Use stbvorbis.js
...
Fixes #641
2018-07-22 17:15:28 +09:00
Hajime Hoshi
d752408da3
Fix comments not to use the term 'this function'
2018-07-15 01:04:46 +09:00
Hajime Hoshi
c6842f2cd8
audio/vorbis/internal/stb: Use TypedArrayOf ( #642 )
2018-07-07 17:46:55 +09:00
Hajime Hoshi
c0ccc16767
audio/mp3: Use TypedArray ( #642 )
2018-07-07 17:19:47 +09:00
Hajime Hoshi
e61af537f4
audio/vorbis: Use jfreymuth/oggvorbis when the target is Wasm
2018-07-05 02:27:23 +09:00
Hajime Hoshi
de7065bbf7
audio/vorbis/internal/stb: Use float32 version of decoder for efficiency
2018-07-05 01:37:51 +09:00
Hajime Hoshi
9bf2eaff58
audio/vorbis/internal/stb: Rename files
2018-07-04 12:04:00 +09:00
Hajime Hoshi
992f6c767a
audio/vorbis: Use stb_vorbis.c on browsers
...
This change adds a Ogg/Vorbis decoder stb_vorbis.c usage that is
compiled by Emscripten as WebAssembly.
Fixes #623
2018-07-04 01:23:11 +09:00
Hajime Hoshi
6e51d31524
Use new GopherWasm API ( #634 )
...
I plan to merge this right after
https://github.com/gopherjs/gopherwasm/pull/3 is merged.
2018-06-30 00:02:15 +09:00
Hajime Hoshi
a9359e4ef8
Use GopherJS/GopherWasm
2018-06-24 16:10:24 +09:00
Hajime Hoshi
a8c27b4eb1
audio/mp3: Bug fix: float32ArrayToSlice didn't work for Wasm
2018-06-24 04:33:05 +09:00
Hajime Hoshi
baee2ba4c9
audio/mp3: Bug fix: ArrayBuffer in the backend can be different from Uint8Array range
2018-06-24 02:31:34 +09:00
Hajime Hoshi
4c70ad382d
audio/mp3: Bug fix: Avoid using a detached ArrayBuffer
2018-06-24 02:12:00 +09:00
Hajime Hoshi
5aefa837db
audio/mp3: Use gopherwasm
2018-06-24 01:42:16 +09:00
Hajime Hoshi
273093b237
audio: Skip the player in the state of starting, seeking or EOF
...
This is basically reland of
2fee7a6fe5
.
Before this change, if a player's buffer was not enough for
reading, 0 value were used and this caused noises. The reading
size should be aligned with all the players.
However, there are some cases that the player should be skippped.
For example, just after a player just starts playing or seeking,
the buffer is empty. In this case, other players should not wait
for the player since decoding might take some time. Another case
is that the player reached EOF.
This change aligns the read buffer sizes but use zero values only
when the player just starts or seeks, or reaches EOF.
2018-06-09 22:00:11 +09:00
Hajime Hoshi
facf184548
Revert "audio: Consider the state of the player's starting and seeking"
...
This reverts commit 2fee7a6fe5
.
Reason: This causes freezing on browsers
2018-06-09 19:28:20 +09:00
Hajime Hoshi
b62e07b9bd
audio: Remove println
2018-06-09 19:05:07 +09:00
Hajime Hoshi
2fee7a6fe5
audio: Consider the state of the player's starting and seeking
...
Before this change, if a player's buffer was not enough for
reading, 0 value were used and this caused noises. The reading
size should be aligned with all the players.
Just after a player just starts playing or seeking, the buffer is
empty but other players should not wait for the player read since
decoding might take some time.
To summerize, this change aligns the read buffer sizes but use
zero values only when the player just starts or seeks.
2018-06-09 19:01:57 +09:00
Hajime Hoshi
91958d24ef
audio: Use bigger buffers for mobiles
2018-06-09 18:14:18 +09:00
Hajime Hoshi
faaf391619
audio: Give up syncing audio timer and game timer ( #617 )
...
Syncing was already incomplete (e.g. decoding takes more than one
frame and delays can happen in this case). Giving up syncing audio
timer and game timer should not affect the game experience so much.
Instead, clock implementation will be much simpler.
2018-05-27 00:30:12 +09:00
Hajime Hoshi
5976e4bbbc
audio: More intellegent suspending/resuming ( #617 )
...
Before this change, the audio is suspended when the game stops for
1/12[s]. However, as game often stops for more than 1/12[s]
especially on mobiles, this implemntation caused some audio
glitches.
This change fixes this problem by re-implementing suspending/
resumeing audio by detecting the window is active/focused or not.
2018-05-26 23:31:04 +09:00
Hajime Hoshi
df048d9bf6
audio: Don't use nosync GopherJS
...
nosync package is good in terms of performance, but this assumes
that duplicated lock never happens. As audio package runs multiple
goroutines, theoretically duplicated lock can happen, and it looks
like this is an actual case (#603 ).
This change replaces nosync usages with regular sync usages.
Probably I'll deprecate nosync usages via internal/sync package
everywhere in Ebiten.
This might fix #603 .
2018-05-09 12:14:20 +09:00
Hajime Hoshi
83f168a010
audio/vorbis: Bug fix: fail to decode too short ogg
2018-04-07 22:13:12 +09:00
Hajime Hoshi
75ac8e6f2b
vorbis: Add tests ( #570 )
2018-03-31 01:51:39 +09:00
Hajime Hoshi
a31874ed48
vorbis: Bug fix: Length returned wrong result with monoral source ( #570 )
2018-03-30 11:59:03 +09:00
Hajime Hoshi
f1f0277deb
wav: Set finalizer for the stream
2018-03-27 12:10:57 +09:00
Hajime Hoshi
88cfd219e7
mp3: Set finalizer for the stream
2018-03-27 10:58:13 +09:00
Hajime Hoshi
f4e018a336
vorbis: Bug fix: Read was not responsible with Close ( #569 )
2018-03-27 10:51:21 +09:00
Hajime Hoshi
632a97974d
audio: Fix wrong English word
2018-03-22 00:36:48 +09:00
Hajime Hoshi
18113f259a
audio: NewPlayer now accepts io.ReadCloser
...
Fixes #414
2018-03-22 00:33:17 +09:00
Hajime Hoshi
1b0e71765f
internal/hooks: Rename Update -> BeforeUpdate
2018-03-15 02:50:10 +09:00
Hajime Hoshi
063153e41d
ebitenutil: Speed up to avoid copying by image.Rect
2018-03-11 21:39:22 +09:00
Hajime Hoshi
61950817fa
audio: Bug fix: importing audio without NewContext causes error
2018-03-04 22:18:14 +09:00
Hajime Hoshi
647d8f0094
audio: Use time.NewTimer and Stop instead of time.After
...
Fixes #532
2018-03-04 19:23:38 +09:00
Hajime Hoshi
392ee92aeb
Add internal/hooks to replace internal/audiobinding
2018-02-04 17:33:17 +09:00
Hajime Hoshi
2322c5600b
audio: Revert the buffer size
...
This basically reverts df62b16270
.
2018-01-29 11:57:52 +09:00
Hajime Hoshi
5c55df87d7
audio: Deprecate Size() and add Length() ( #466 )
2018-01-09 01:25:38 +09:00
Hajime Hoshi
ef282f7f4f
audio/internal/convert: Remove unused functions
2018-01-09 00:26:54 +09:00
Hajime Hoshi
e83810fc57
audio/internal/convert: Add resampling_test.go
...
Fixes #369
2018-01-08 23:44:44 +09:00
Hajime Hoshi
d5d5ebb0b3
clock: Make ProceedAudioTimer take a number of frames
2018-01-07 18:32:19 +09:00
Hajime Hoshi
d12a3d4073
clock: Refactoring
2018-01-07 17:10:56 +09:00
Hajime Hoshi
0b3495b81f
audio: Use mock sync on browsers
2018-01-07 15:26:18 +09:00
Hajime Hoshi
11a1e6ec39
audio/internal/convert: Adjust window size again (confirmed this worked well on iPhone 6)
2018-01-06 01:49:55 +09:00
Hajime Hoshi
5b2dbf6036
audio/internal/convert: Adjust resamplingBufferSize again
2018-01-06 01:46:54 +09:00
Hajime Hoshi
ab70f6fc58
audio/internal/convert: Much faster sine/cosine functions
2018-01-06 00:15:07 +09:00