Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions android/lib/src/main/java/dev/keiji/jp2k/Jp2kDecoderAsync.kt
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class Jp2kDecoderAsync(
return
}
if (_state != State.Uninitialized) {
callback.onError(IllegalStateException("Jp2kDecoderAsync is not Uninitialized. Current state: $_state"))
callback.onError(IllegalStateException("Cannot initialize while in state: $_state"))
return
}
_state = State.Initializing
Expand Down Expand Up @@ -201,7 +201,7 @@ class Jp2kDecoderAsync(
synchronized(lock) {
// Allow if Initialized OR Decoding (queueing up)
if (_state != State.Initialized && _state != State.Decoding) {
callback.onError(IllegalStateException("Decoder is not ready (Current state: $_state)"))
callback.onError(IllegalStateException("Cannot decodeImage while in state: $_state"))
return
}
// Do NOT set state to Decoding here. Wait until execution starts.
Expand Down Expand Up @@ -342,7 +342,7 @@ class Jp2kDecoderAsync(
fun getMemoryUsage(callback: Callback<MemoryUsage>) {
synchronized(lock) {
if (_state != State.Initialized && _state != State.Decoding) {
callback.onError(IllegalStateException("Decoder is not ready (Current state: $_state)"))
callback.onError(IllegalStateException("Cannot getMemoryUsage while in state: $_state"))
return
}
}
Expand Down
18 changes: 18 additions & 0 deletions docs/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,24 @@ stateDiagram-v2
Terminated --> [*]
```

#### メソッドごとの挙動

各状態におけるメソッド呼び出し時の挙動は以下の通りです。

| State \ Method | init() | decodeImage() | getMemoryUsage() | release() |
| :--- | :--- | :--- | :--- | :--- |
| **Uninitialized** | **初期化開始** | Error | Error | 終了処理 (State=Terminated) |
| **Initializing** | Error | Error | Error | 終了処理 (State=Terminated) |
| **Initialized** | **成功 (何もしない)** | **デコード開始** | **取得開始** | 終了処理 (State=Terminated) |
| **Decoding** | Error | **デコード開始 (キューイング)** | **取得開始 (キューイング)** | 終了処理 (State=Terminated) |
| **Terminated** | Error | Error | Error | **成功 (何もしない)** |

* **Error**: `IllegalStateException` (またはそれに準ずるエラー) をコールバックに返却します。
* **初期化開始**: バックグラウンドで初期化処理を開始します。
* **デコード開始**: バックグラウンドでデコード処理を開始します。
* **取得開始**: バックグラウンドでメモリ使用量の取得を開始します。
* **キューイング**: 実行中の処理が完了した後、順次実行されます。

---

## 2. wrapper.c (C Wrapper for WASM)
Expand Down