Commit Graph

776 Commits

Author SHA1 Message Date
Hajime Hoshi
7eeaef7ff8 audio/internal/readerdriver: Refactoring 2021-05-09 05:46:55 +09:00
Hajime Hoshi
22567d20b6 audio/internal/readerdriver: Implement {,Set}Volume for macOS 2021-05-09 05:36:03 +09:00
Hajime Hoshi
9df1092507 audio/internal/readerdriver: Bug fix: AudioQueue{Pause,Reset,Flush} cannot be called before AudioQueueStart 2021-05-09 05:28:42 +09:00
Hajime Hoshi
bc22ab53b2 audio/internal/readerdriver: Add comments 2021-05-09 05:01:51 +09:00
Hajime Hoshi
eb3301d30c audio/internal/readerdriver: Implement a reader-style driver for macOS
Updates #1549
2021-05-09 04:56:31 +09:00
Hajime Hoshi
fcdd4e16d4 audio/internal/readerdriver: Fill the buffer whenever starting to play 2021-05-09 03:51:45 +09:00
Hajime Hoshi
ae9e89b814 audio/internal/oboe: Bug fix: Not all players should not be suspended 2021-05-09 03:07:17 +09:00
Hajime Hoshi
7487222740 audio/internal/readerdriver: Remove Context's Close 2021-05-07 16:50:19 +09:00
Hajime Hoshi
410d0f52e5 audio/internal/readerdriver: Bug fix: createBuffer failed when the buffer size is 0
When the decoded audio size is exactly multiples of an internal
buffer size, the buffer's size becomes exactly zero when being
appended. In this case, createBuffer fails and the application
crashes.

This change fixes this issue by skipping to append a buffer in such
cases.

Closes #1635
2021-05-07 02:35:57 +09:00
Hajime Hoshi
aa9f669ec3 audio/internal/readerplayer: Move the buffer for resuming to the driver side
Closes #1633
2021-05-05 21:54:21 +09:00
Hajime Hoshi
4e0e5c6bbc audio/internal/oboe: Bug fix: Always use OpenSL
AAudio doesn't care about plugging in/out headsets. There is a
workaround [1], but this is not easy to apply. Instead, alwasy use
OpenSL.

[1] https://github.com/google/oboe/blob/master/docs/notes/disconnect.md

Closes #1634
2021-05-05 18:09:44 +09:00
Hajime Hoshi
1fecaa0a90 audio/internal/readdriver: Bug fix: Wait for a while after finishing to write
Closes #1632
2021-05-05 17:05:23 +09:00
Hajime Hoshi
ded3cd1433 audio/internal/readerdriver: Refactoring: Remove player.state 2021-05-05 15:32:53 +09:00
Hajime Hoshi
f556590582 android/internal/readerdriver: Bug fix: Infinite recursive at closeImpl 2021-05-05 03:58:47 +09:00
Hajime Hoshi
c954dfa8fb audio/internal/readerderiver: Bug fix: Reduce noises on Android
Closes #1632
2021-05-05 02:14:59 +09:00
Hajime Hoshi
83c9015468 audio/internal/oboe: Bug fix: Guard the players by a mutex
Closes #1631
2021-05-05 00:51:53 +09:00
Hajime Hoshi
ad86c297fb audio/internal/readdriver: Implement a driver for Android with Oboe
Closes #1626
2021-05-04 23:51:36 +09:00
Hajime Hoshi
804881fa94 audio/internal/readerdriver: Enable to return error at Suspend/Resume 2021-05-04 23:18:16 +09:00
Hajime Hoshi
58843b68f9 internal/hooks: Enable to return error at suspend/resume audio 2021-05-04 23:09:01 +09:00
Hajime Hoshi
bcf8ef85b6 audio: Bug fix: Compile error on the tests
Updates #1630
2021-05-04 22:10:49 +09:00
Hajime Hoshi
29eade9b4a audio/internal/readdriver: Bug fix: Implement Suspend/Resume for browsers
Closes #1630
2021-05-04 18:49:39 +09:00
Hajime Hoshi
11e76d3fc8 audio/vorbis: Catch the Seek error 2021-05-03 23:11:14 +09:00
Hajime Hoshi
fc5970768d audio/internal/go2cpp: Bug fix: Potential deadlock at Play
Closes #1629
2021-05-03 17:54:25 +09:00
Hajime Hoshi
7adf6aac27 audio/internal/readerdriver: Simplify type names 2021-05-01 16:25:40 +09:00
Hajime Hoshi
1acf5bc260 audio/internal/readerdriver: Bug fix: Compile error 2021-04-29 18:37:10 +09:00
Hajime Hoshi
760072e3a9 audio/internal/readerdriver: Use a channel instead of a callback function 2021-04-29 18:21:06 +09:00
Hajime Hoshi
e62eba387d audio/vorbis: Accept io.Reader instead of io.ReadSeeker
Closes #1621
2021-04-24 16:41:23 +09:00
Hajime Hoshi
68d24f1c62 audio/mp3: Accept io.Reader instead of io.ReadSeeker
Updates #1621
2021-04-24 16:39:49 +09:00
Hajime Hoshi
62899e5902 audio/wav: Accept io.Reader instead of io.ReadSeeker
Updates #1621
2021-04-24 16:35:28 +09:00
Hajime Hoshi
08c3025560 audio/internal/readerdriver: Refactoring 2021-04-20 03:20:29 +09:00
Hajime Hoshi
24dc20e80e audio/internal/readerdriver: Bug fix: Need to align the buffer size 2021-04-20 02:39:33 +09:00
Hajime Hoshi
e650e71d8c audio/internal/readerdriver: Bug fix: ReadFull could get stuck
If the source io.Reader's implementation is not good (e.g., Read
returns 0 if the buffer size is not multiples of 4), io.ReadFull
gets stuck forever. Instead, use reguler Read with a decent amount
of bytes buffer.

Closes #1599
2021-04-20 01:29:15 +09:00
Hajime Hoshi
146678596b audio/internal/readerdriver: Bug fix: Invoke onReady for go2cpp
Updates #1599
2021-04-19 23:59:31 +09:00
Hajime Hoshi
ea9d64f5b8 audio: Bug fix: Need to call setReady from the reader player side
Updates #1599
2021-04-19 23:56:08 +09:00
Hajime Hoshi
0de024229d audio: Guarantee that (*Player).Current's returning value is increased monotonically
Closes #1501
2021-03-31 23:41:28 +09:00
Hajime Hoshi
83dc3966e7 audio/internal/go2cpp: Bug fix: Set the volume whenever the player state is 2021-03-31 21:08:32 +09:00
Hajime Hoshi
f0d7e16eb2 audio/internal/readerdriver: Refactoring 2021-03-28 23:27:47 +09:00
Hajime Hoshi
bf4c1e3d74 audio: Bug fix: Compile error for tests 2021-03-28 22:57:50 +09:00
Hajime Hoshi
f4efdd6355 audio/internal/go2cpp: Protect the functions by the lock correctly 2021-03-28 22:40:36 +09:00
Hajime Hoshi
f4b770eff6 audio/internal/readerdriver: Add Player.Err 2021-03-28 22:21:07 +09:00
Hajime Hoshi
b46cb324ed audio: Add audio/internal/readerdriver package 2021-03-28 18:34:16 +09:00
Hajime Hoshi
7212cd7999 audio: Bug fix: Race condition on accessing the set of players
Closes #1548
2021-03-24 23:41:18 +09:00
Hajime Hoshi
7696d51839 audio: Bug fix: Duplicated pausing at reader players
This caused unexpected 'Unread' calls.
2021-03-24 00:19:49 +09:00
Hajime Hoshi
1083233d5f audio/internal/go2cpp: Replace isWritable with unplayedBufferSize instead
This is the more accurate way not to overflow the underlying buffer.
2021-03-23 23:46:57 +09:00
Hajime Hoshi
6f185063d6 audio: Ensure Close is called at a readerPlayer is GCed 2021-03-22 04:11:08 +09:00
Hajime Hoshi
07c10880f4 audio: Bug fix: Test failures on browsers 2021-03-22 03:50:05 +09:00
Hajime Hoshi
a17fea39a1 audio: Bug fix: Compile error on Go 1.13 2021-03-22 02:16:46 +09:00
Hajime Hoshi
49a8a491cd audio: Implement the reader player for browsers
Updates #1458
2021-03-22 01:53:52 +09:00
Hajime Hoshi
9e73b0d287 audio: Rename UnwrittenBufferSize -> UnplayedBufferSize 2021-03-01 01:27:42 +09:00
Hajime Hoshi
6d442c0a17 audio: Add comments 2021-02-28 23:47:57 +09:00
Hajime Hoshi
4bc0bb607b audio: Lazy initialization at reader players 2021-02-28 23:41:30 +09:00
Hajime Hoshi
dbdfce5fed audio: Add readerDriverPlayer.UnwrittenBufferSize to get the exact position 2021-02-28 01:42:48 +09:00
Hajime Hoshi
b8cdcdb847 audio: Bug fix: NewInfiniteLoop(WithIntro) should work with incomplete values
Closes #1503
2021-02-22 02:15:45 +09:00
Hajime Hoshi
29099cf660 audio: Bug fix: Continue to play the audio after seeking on go2cpp 2021-02-21 23:54:43 +09:00
Hajime Hoshi
027463ff88 audio: Bug fix: timeStream was not used for a reader player 2021-02-21 18:48:58 +09:00
Hajime Hoshi
68411e9591 audio/internal/go2cpp: Avoid unnecessary allocations 2021-01-25 03:09:13 +09:00
Hajime Hoshi
c8ba51d26e audio/internal/convert: Avoid unnecessary allocations 2021-01-25 03:04:53 +09:00
Hajime Hoshi
514904392c audio: Bug fix: Deadlock at acquiring the semaphore
Closes #1469
2021-01-23 23:07:19 +09:00
Hajime Hoshi
fbc7b3c884 audio/vorbis: Bug fix: Resampling didn't work correctly 2021-01-19 00:41:47 +09:00
Hajime Hoshi
2432530b51 Revert "audio/internal/go2cpp: Fix C++ side and remove the preparation"
This reverts commit 65f974588c.

Reason: Didn't improve the performance on some devices
2021-01-17 04:48:11 +09:00
Hajime Hoshi
65f974588c audio/internal/go2cpp: Fix C++ side and remove the preparation 2021-01-17 03:47:45 +09:00
Hajime Hoshi
ed7d7e8976 audio/internal/go2cpp: Prepare the first buffer data to make the audio smoother 2021-01-16 03:28:47 +09:00
Hajime Hoshi
c742ae60bd audio: Bug fix: Implement renaderPlayer.IsPlayer correctly 2021-01-16 01:02:07 +09:00
Hajime Hoshi
ad218eae2d audio/internal/convert: Reduce allocations of float32 slices 2021-01-15 00:37:21 +09:00
Hajime Hoshi
612676cb19 audio/internal/go2cpp: Remove the buffer size argument 2021-01-13 22:30:52 +09:00
Hajime Hoshi
aeaa443bf2 audio/internal/go2cpp: Bug fix: Writing data must be concurrent-safe 2021-01-13 10:26:30 +09:00
Hajime Hoshi
78789a511c Revert "audio: Seek the source first at readerPlayer"
This reverts commit 68f12f066e.

Reason: Some data can be read after seeking before resetting
2021-01-13 02:01:00 +09:00
Hajime Hoshi
68f12f066e audio: Seek the source first at readerPlayer 2021-01-12 22:52:26 +09:00
Hajime Hoshi
2f8172f819 audio/internal/go2cpp: Recreate the underlying audio player when resetting 2021-01-12 20:42:45 +09:00
Hajime Hoshi
a66097df19 audio/internal/go2cpp: Remove unnecessary set 2021-01-12 11:38:30 +09:00
Hajime Hoshi
2dc37d30de audio/internal/go2cpp: Add a comment 2021-01-12 01:07:36 +09:00
Hajime Hoshi
a7dd00596a audio/internal/go2cpp: Add signaling at Pause 2021-01-12 00:43:16 +09:00
Hajime Hoshi
c009070840 audio/internal/go2cpp: Add readerDriverPlayer.Reset 2021-01-11 23:54:43 +09:00
Hajime Hoshi
3abb7a3604 audio/internal/go2cpp: Increase the temporary buffer size 2021-01-11 21:56:47 +09:00
Hajime Hoshi
8e6c3a570e audio/internal/go2cpp: Bug fix: Pass the correct size 2021-01-11 18:07:25 +09:00
Hajime Hoshi
9cc5bd80f9 audio/internal/go2cpp: Better waiting condition 2021-01-11 15:37:40 +09:00
Hajime Hoshi
dc8217dfeb audio/internal/go2cpp: Bug fix: Wrong state 2021-01-11 15:25:53 +09:00
Hajime Hoshi
52942751f0 audio: Move go2cpp -> internal/go2cpp 2021-01-09 18:21:32 +09:00
Hajime Hoshi
3579e1d0b7 audio: Implement timeStream 2021-01-09 17:16:37 +09:00
Hajime Hoshi
a2a7f5e701 audio: Add an implementation for go2cpp 2021-01-09 17:16:34 +09:00
Hajime Hoshi
bd3e930eef audio: Add readerPlayerFactory / readerDriver 2021-01-09 00:45:13 +09:00
Hajime Hoshi
bd1c3ff030 audio: Rename writerContext -> writerPlayerFactory 2021-01-07 11:24:40 +09:00
Hajime Hoshi
a6b3f32f3a audio: Refactoring 2021-01-07 02:14:42 +09:00
Hajime Hoshi
e04e709a10 audio: Refactor test files 2021-01-07 01:53:41 +09:00
Hajime Hoshi
bda285b376 audio: Refactoring 2021-01-07 01:33:57 +09:00
Hajime Hoshi
e77beac235 audio: Define playerImpl interface 2021-01-07 00:59:13 +09:00
Hajime Hoshi
7cf32efcd5 audio: Rename playerImpl -> writerContextPlayerImpl 2021-01-07 00:46:50 +09:00
Hajime Hoshi
c42a40a541 audio: Rename context -> writerContext
This is a preparation of a new type of context with io.Readers.
2021-01-07 00:26:28 +09:00
Hajime Hoshi
9849cb5c2b audio/wav: Add DecodeWithSampleRate
Closes #1460
2021-01-06 23:09:52 +09:00
Hajime Hoshi
b78dde0e37 audio/mp3: Add DecodeWithSampleRate
Updates #1460
2021-01-06 23:03:50 +09:00
Hajime Hoshi
f6a440765b audio/vorbis: Fix comments 2021-01-06 23:02:56 +09:00
Hajime Hoshi
96ca0a7ff9 audio/vorbis: Add DecodeWithSampleRate
Updates #1460
2021-01-06 22:57:25 +09:00
Hajime Hoshi
30278b80aa audio: Use the larget buffer size for go2cpp 2021-01-05 16:07:36 +09:00
Hajime Hoshi
0bf6eee605 audio: Reduce making a slice at a player's read 2021-01-04 21:51:26 +09:00
Hajime Hoshi
3fb304e5a8 audio/internal/convert: Refactoring 2021-01-04 21:42:00 +09:00
Hajime Hoshi
f292594184 audio: Use a new implentation for go2cpp in Oto 2020-12-30 19:21:15 +09:00
Hajime Hoshi
9a705c64f3 audio: Bug fix: Compile error 2020-12-21 18:39:06 +09:00
Hajime Hoshi
2a2866bf65 audio: Use a null context on go2cpp 2020-12-21 18:35:42 +09:00
Hajime Hoshi
8e46769284 audio: Remove returning values from Play/Pause 2020-10-10 23:45:18 +09:00
Hajime Hoshi
0673b384d8 audio: Update the comment
Updates #859
2020-10-07 23:43:38 +09:00
Hajime Hoshi
f1f7b350de audio, audio/mp3, audio/vorbis, audio/wav: Remove Close functions
Fixes #859
2020-10-07 23:39:58 +09:00
Hajime Hoshi
426cb5948a audio/vorbis: Remove the GopherJS part
Updates #1129
2020-10-07 01:33:19 +09:00
Hajime Hoshi
a22fdee171 audio/mp3: Remove the GopherJS part
Updates #1129
2020-10-07 01:33:19 +09:00
Hajime Hoshi
944a19c6f7 audio: Remove the error returning value from NewContext
Updates #1380
2020-10-05 02:25:13 +09:00
Hajime Hoshi
29b4087ebf audio: Remove the error returning value from NewPlayerFromBytes
Updates #1380
2020-10-05 02:18:27 +09:00
Hajime Hoshi
f4d050161a audio: Remove (*Context).Update
Updates #1127
2020-10-04 15:41:34 +09:00
Hajime Hoshi
825972b3e1 audio/mp3, audio/vorbis, audio/wav: Remove deprecated functions
Updates #1127
2020-10-04 15:35:17 +09:00
Hajime Hoshi
bf515bb594 Update version to v2.0.0-alpha 2020-10-04 04:30:40 +09:00
Hajime Hoshi
9906e4b882 go generate 2020-09-20 23:28:17 +09:00
Hajime Hoshi
01a84a7121 audio/mp3: Make panic messages more consistent 2020-08-23 19:50:43 +09:00
Hajime Hoshi
d0181ce130 audio/wav: Remove an unused function 2020-08-23 19:49:31 +09:00
Hajime Hoshi
50fc914d72 Revert "audio/wav: Allow passing non-io.Seeker to Decode"
This reverts commit 19cd69da55.

Reason: Marked #1202 'won't fix'
2020-08-23 19:46:28 +09:00
Hajime Hoshi
19cd69da55 audio/wav: Allow passing non-io.Seeker to Decode
Updates #1202
2020-08-23 19:15:20 +09:00
Hajime Hoshi
a1ac574a60 docs: Use 'Deprecated:' annotation
Fixes #1160
2020-05-19 01:50:55 +09:00
Hajime Hoshi
4fa52dcc56 Remove MonoGame support
Fixes #1148
2020-05-08 19:32:28 +09:00
Hajime Hoshi
2e49ed5402 audio: Add a mock implementation for MonoGame
Updates #1078
2020-04-21 23:59:41 +09:00
Hajime Hoshi
7ac6b0bfa3 Update dependencies 2020-03-31 03:32:38 +09:00
hiroebe
ad00414a2a audio: Remove duplicate check for io.Seeker (#1051) 2020-01-10 19:37:31 +09:00
Hajime Hoshi
5182060899 Revert "audio: Bug fix: Fill empty data even when audio is suspended"
This reverts commit 529dddda53.

Updates #975

Reason: This causes PARTIAL_WAKE_LOCK on Android (AudioDirectOut) (#931)
2019-11-09 15:24:56 +09:00
Hajime Hoshi
529dddda53 audio: Bug fix: Fill empty data even when audio is suspended
When writing is stopped on Oto's players, unexpected delaying
happens.

The ideal solution is to have APIs to suspend and resume Oto's
player, but this is not easy. For a temporary solution, write
zero values on the players when audio is suspended.

Fixes #975
2019-11-07 01:13:00 +09:00
Hajime Hoshi
3c29fbdce2 jsutil: Refactoring: SliceToTypedArray -> CopySliceToJS
This unifieslocations of the temporary buffer.
2019-10-30 00:35:48 +09:00
Hajime Hoshi
fe805d7fd1 audio/vorbis/internal/stb: Bug fix: Forbid to use it from Wasm 2019-10-28 00:07:38 +09:00
Hajime Hoshi
f50875ff4b Change the build tag strategy: GopehrJS or not GopherJS 2019-10-27 23:33:22 +09:00
Hajime Hoshi
124389561c audio: Bug fix: The dummy player should have long enough buffer
In the current implementation, the audio context will be ready
when a player's Write is finished. If the buffer is too short,
Write finishes immediately without accessing the low audio layer
and the audio context would be ready without playing anything.

This change changes the dummy buffer to have a long enough buffer
so that Write will be wait for acutual audio playing.

Fixes #970
2019-10-23 02:41:12 +09:00
Hajime Hoshi
b78f678700 audio: Bug fix: (*Context).IsReady never returned true unless there is a player
The audio context is never ready unless there is a player. This is
problematic when a user tries to play audio after the context is
ready. Play a dummy player to avoid the blocking.

Fixes #969
2019-10-22 23:45:13 +09:00
Hajime Hoshi
689d230cb7 vorbis: Embed files for tests
Updates #881
2019-09-15 19:50:56 +09:00
Hajime Hoshi
dbb8a5e873 audio: Block all the players when suspended
This avoid to write 0 bytes when the app is in background. This
should reduce CPU usage.

Updates #931
2019-09-07 02:03:59 +09:00
Hajime Hoshi
c52e043006 Add jsutil package for new API of Go 1.13
Audio part still cannot be compiled due to Oto.

Fixes #878
2019-06-15 00:49:57 +09:00
Hajime Hoshi
13ce1c28b4 uidriver/mobile: Use timer.NewTimer instead of time.After
timer.NewTimer is much better than time.After in terms of memory
usage. See also https://golang.org/pkg/time/#After
2019-06-01 01:30:08 +09:00
Acid147
21abd85a63 Small cleanup (#877)
* Remove unused variables and constants
* Remove redundant return statement
* Change flock.NewFlock to flock.New
2019-05-26 18:06:43 +09:00
Hajime Hoshi
3ce8babd9b audio: Remove unnecessary sleepings 2019-05-02 23:57:33 +09:00
Hajime Hoshi
bd85d0e08d audio: Add TestPauseBeforeInit
This confirms that Pause before initialization should not launch
another loop.
2019-05-02 21:39:08 +09:00
Hajime Hoshi
7e2a679b17 audio: Context should be reset for each test
As the context remembers the last error, the context should be
re-created for each test.
2019-05-02 21:35:20 +09:00
Hajime Hoshi
396f257629 audio: Fix comments 2019-05-02 04:10:33 +09:00
Hajime Hoshi
876340da17 audio: Bug fix: context.ready should be set true after writing 2019-05-02 03:27:43 +09:00
Hajime Hoshi
2e35d9dc70 audio: Refactoring 2019-05-02 03:21:56 +09:00
Hajime Hoshi
5dd12afd38 audio: Stop the loop when pausing
This change reduces the necessity to fill zero bytes.
2019-05-02 03:16:45 +09:00
Hajime Hoshi
5121b072f1 audio: Change init from a variable to a channel 2019-05-02 02:37:32 +09:00
Hajime Hoshi
bea5b0f685 audio: Add comments 2019-05-02 02:11:35 +09:00
Hajime Hoshi
2aa79e0aa4 audio/vorbis/internal/stb: Bug fix: Make the package buildable only under 'js' environment
Building `syscall/js` itself can be done only under 'js'
environment.

See also https://travis-ci.org/hajimehoshi/ebiten/builds/526786060
2019-05-01 17:50:59 +09:00
Hajime Hoshi
10fb5e33be Replace GopherWasm with syscall/js
Fixes #857
2019-05-01 17:28:00 +09:00
Hajime Hoshi
c112c31e7e audio: Reimplement audio by using multiple oto.Player 2019-04-30 18:20:52 +09:00
Hajime Hoshi
339e76afec audio: Bug fix: Dead lock at seeking
When sending something to channels, a lock should not be used,
or the receiver side might be using the same lock.

Bug: #855
2019-04-30 12:51:22 +09:00
Hajime Hoshi
e19479d243 audio: Add comments about explanation how deadlock happens
This might be related to #855
2019-04-30 01:41:34 +09:00
Hajime Hoshi
5ecc595ce4 audio: Bug fix: Reset playing state at the end of the readLoop 2019-04-29 22:31:10 +09:00
Hajime Hoshi
d2979e288d audio: Bug fix: runningReadLoop must be set to true before starting the goroutine
This can cause deadlock by multiple goroutines if runningReadLoop
is set to true in the goroutine.

Related to #855?
2019-04-29 21:46:26 +09:00
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
Hajime Hoshi
005d18ceff audio/internal/convert: Use int64 (now it is fast enough on browsers?) 2018-01-05 20:03:17 +09:00
Hajime Hoshi
c020101afc audio/internal/convert: Use cosine table 2018-01-05 19:40:12 +09:00
Hajime Hoshi
2884fb7070 audio/internal/convert: Fix algorithm 2018-01-05 18:21:14 +09:00
Hajime Hoshi
df62b16270 audio: Use bigger buffer size for mobile phones 2017-12-31 01:28:08 +09:00
Hajime Hoshi
de1a22d9f3 audio/internal/convert: Bug fix: remove unneeded import 2017-12-31 00:15:36 +09:00
Hajime Hoshi
03942292f5 audio/internal/convert: Change the window smaller for performance
On iOS, resapling performance was not good.
2017-12-31 00:14:52 +09:00
Hajime Hoshi
97ec367e23 audio: Use := 2017-12-30 21:18:34 +09:00
Hajime Hoshi
65c0bf55fc audio: Fix buffer size for the latest Oto 2017-12-28 20:37:36 +09:00
Hajime Hoshi
a98b03f738 audio/mp3: Flexible timeout 2017-12-27 19:18:02 +09:00
Hajime Hoshi
e2a026138a audio/internal/convert: Use float64 for positions 2017-12-27 18:55:17 +09:00
Hajime Hoshi
6d6504085c audio/internal/convert: Rename members 2017-12-27 18:05:55 +09:00
Hajime Hoshi
50a6158513 audio/mp3: Adjust timeout 2017-12-26 14:55:01 +09:00
Hajime Hoshi
3855bcc5a4 audio/mp3: Change the timeout for decoding (for Firefox) 2017-12-26 00:59:36 +09:00
Hajime Hoshi
ad54538d07 audio/mp3: Use byte instead of uint8 2017-12-26 00:11:17 +09:00
Hajime Hoshi
bb44eebe78 audio/mp3: Replace magic numbers with consts in io package 2017-12-26 00:10:30 +09:00
Hajime Hoshi
908ccb9404 audio/mp3: Try again decoding when timed out (#464) 2017-12-26 00:08:33 +09:00
Hajime Hoshi
623caad3ec audio: Bug fix: appropriate buffer size on browsers 2017-12-25 01:54:55 +09:00
Hajime Hoshi
60eef4618d audio: Revert size (due to noise on browsers) 2017-12-25 00:16:47 +09:00
Hajime Hoshi
4a06198160 audio: Smaller buffers (experimental) 2017-12-24 22:16:45 +09:00
Hajime Hoshi
5679103d71 audio: Use io.CopyN 2017-12-24 21:21:15 +09:00
Hajime Hoshi
a74cf21f21 audio/mp3: Revert calling Gosched(): Looks like this doesn't make sense 2017-12-24 04:53:51 +09:00
Hajime Hoshi
2155b2f04a audio/mp3: Channels should be used only once 2017-12-24 04:40:20 +09:00
Hajime Hoshi
e14257d76d audio: A little better buffer size for Android Chrome 2017-12-24 04:01:41 +09:00
Hajime Hoshi
ae6bdf23f2 audio: Recalculate audio buffer size 2017-12-24 03:54:42 +09:00
Hajime Hoshi
7b1f501bd7 audio/mp3: Force context switch when decoding 2017-12-24 03:14:10 +09:00
Hajime Hoshi
18c6890d96 audio: More often reading (decoding) audio source to reduce noise 2017-12-24 00:58:14 +09:00
Hajime Hoshi
7ce87a6c82 audio: Simplify read/write logic 2017-12-24 00:51:17 +09:00
Hajime Hoshi
00d8d61795 audio: Adjust buffer size 2017-12-23 23:15:44 +09:00
Hajime Hoshi
f3997cf5ae audio: Fix comments 2017-12-23 21:14:08 +09:00
Hajime Hoshi
a540d6b2bb audio: Adjust buffer size 2017-12-23 19:59:52 +09:00
Hajime Hoshi
19ca74e86b audio: Remove player's mutex 2017-12-23 19:01:28 +09:00
Hajime Hoshi
637ed0d965 audio: Refactoring 2017-12-23 18:39:14 +09:00
Hajime Hoshi
04739a7249 audio: Bug fix: Seek might cause dead lock after Close 2017-12-23 18:31:20 +09:00
Hajime Hoshi
db77658935 audio: Reduce locks by using channels 2017-12-23 17:55:48 +09:00
Hajime Hoshi
ba3de063ac audio: Refactoring 2017-12-23 17:05:14 +09:00
Hajime Hoshi
3dcb486a5c audio: Refactoring 2017-12-23 05:02:15 +09:00
Hajime Hoshi
7cc6154de6 audio: Reduce noise (#443) 2017-12-23 04:25:48 +09:00
Hajime Hoshi
3addbfce8a audio: Simplify error handling 2017-12-23 04:12:12 +09:00
Hajime Hoshi
a21571fb57 audio: Refactoring 2017-12-23 04:01:18 +09:00
Hajime Hoshi
a5f8c1b1f8 audio: Async reading sources (#443) 2017-12-23 03:24:54 +09:00
Hajime Hoshi
31350dc497 mp3: Avoid calling Length() if possible (#463) 2017-12-22 05:17:01 +09:00
Hajime Hoshi
7b76b7822f audio: Fix comments 2017-12-17 01:24:45 +09:00
Hajime Hoshi
7cd89bc44b audio: Adjust buffer size for Android Chrome 2017-12-17 01:20:10 +09:00
Hajime Hoshi
7f9afd4e14 audio: Unify buffer size 1/15[s] experimentally
This would mitigate glitches on Windows (#451)
2017-12-17 00:41:35 +09:00
Hajime Hoshi
6956e15b08 audio: Fix comments 2017-12-02 16:26:20 +09:00
Hajime Hoshi
3db965d547 audio: Fix doc 2017-12-01 01:38:47 +09:00
Hajime Hoshi
0379e3c591 audio: Deprecate Update 2017-12-01 00:26:28 +09:00
Hajime Hoshi
dba7124e38 audio: Use safer buffer size as experiment (#451) 2017-11-23 23:31:26 +09:00
Hajime Hoshi
b46ed224a7 mp3: Add comment about error handling 2017-10-18 02:11:09 +09:00
Hajime Hoshi
2624ed6824 audio: Refactoring 2017-10-14 19:45:32 +09:00
Hajime Hoshi
bc2469a275 audio: Fix wrong comments 2017-10-01 18:07:18 +09:00
Hajime Hoshi
626b772b25 doc: Improve comments 2017-10-01 17:24:30 +09:00
Hajime Hoshi
b4e3e9375c audio: Use samller window for resampling on browsers 2017-09-29 02:05:14 +09:00
Hajime Hoshi
2c6f6e605e audio/mp3: Bug fix: Decode error on Safari (#438) 2017-09-28 03:10:51 +09:00