ci-platforms / darwin amd64 smoke (push) Skipped
GitHub / linux amd64 native GitHub-hosted native CI: success
ci-platforms / windows amd64 smoke (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: success
GitHub / darwin arm64 native GitHub-hosted native CI: success
GitHub / darwin amd64 native GitHub-hosted native CI: success
ci / checks (push) Failing after 1h21m34s
ci / native-authoring (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
github-native / gitea-pending (push) Skipped
github-native / darwin amd64 native (push) Skipped
github-native / linux amd64 native (push) Skipped
github-native / windows amd64 native (push) Skipped
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m4s
ci / release (push) Skipped
Add dockable Art tools, animation and previews, guarded asset workflows, and the Web Asset Studio built on the shared Art Core. Expand English and Russian documentation, interactive Try scenes, examples and editor icons. Add audio waveform navigation, source analysis, guarded previews and a browser Worker mixer. Preserve source changes and recovery with bounded checks, and strengthen native, browser and interoperability CI. Prepare version 0.12.5 and manually built native artifact candidates. Fix the production site image demo build dependency. Reuse immutable scene indices when capturing keyframes. Wait for real Persist save/load completion in component tests. Stabilize browser Game View captures outside pointer hover. Aseprite interchange and persistent Audio EDL recovery remain limited; the artifact workflow does not publish releases or change stable.
58 lines
2.1 KiB
Go
58 lines
2.1 KiB
Go
package audioedit
|
|
|
|
import (
|
|
"bytes"
|
|
"errors"
|
|
"fmt"
|
|
)
|
|
|
|
// PrepareMutation computes one independent candidate for an owner's existing
|
|
// journal. It creates no history, performs no I/O, and does not authorize a
|
|
// save or publication. The caller must serialize access and check that its
|
|
// own document, source and metadata are still current before adopting it.
|
|
//
|
|
// expectedRevision is checked against current, not against any external host.
|
|
// The caller and callback must not mutate current during the call. The callback
|
|
// may not mutate its argument concurrently or change source identity. It may
|
|
// retain its argument, but the returned candidate never shares its mutable
|
|
// slices or range pointers with that argument or current.
|
|
// No-op changes retain the original revision and return changed=false; errors
|
|
// return a zero document and leave current unchanged.
|
|
func PrepareMutation(current Document, expectedRevision uint64, fn func(*Document) error) (candidate Document, changed bool, err error) {
|
|
if fn == nil {
|
|
return Document{}, false, errors.New("audio mutation is nil")
|
|
}
|
|
if current.Revision != expectedRevision {
|
|
return Document{}, false, fmt.Errorf("audio document changed: have revision %d, expected %d", current.Revision, expectedRevision)
|
|
}
|
|
// Validate caller-owned lengths before copying potentially untrusted slices.
|
|
if err := current.Validate(); err != nil {
|
|
return Document{}, false, err
|
|
}
|
|
current = current.Clone()
|
|
before, err := current.stableBytes()
|
|
if err != nil {
|
|
return Document{}, false, err
|
|
}
|
|
next := current.Clone()
|
|
if err := fn(&next); err != nil {
|
|
return Document{}, false, err
|
|
}
|
|
if next.Source != current.Source {
|
|
return Document{}, false, errors.New("audio mutation cannot replace the source identity")
|
|
}
|
|
after, err := next.stableBytes()
|
|
if err != nil {
|
|
return Document{}, false, err
|
|
}
|
|
if bytes.Equal(before, after) {
|
|
return current, false, nil
|
|
}
|
|
if current.Revision == ^uint64(0) {
|
|
return Document{}, false, errors.New("audio revision exhausted")
|
|
}
|
|
// A callback cannot choose the generation used by its host's guards.
|
|
next.Revision = current.Revision + 1
|
|
return next.Clone(), true, nil
|
|
}
|