Skip to content

fix(runtime): make AudioFrame copies own their sample data - #3450

Open
wangxiuwen wants to merge 1 commit into
modelscope:mainfrom
wangxiuwen:fix/audio-frame-copy-ownership
Open

fix(runtime): make AudioFrame copies own their sample data#3450
wangxiuwen wants to merge 1 commit into
modelscope:mainfrom
wangxiuwen:fix/audio-frame-copy-ownership

Conversation

@wangxiuwen

Copy link
Copy Markdown

What does this PR do?

Complete AudioFrame's copy ownership semantics:

  • Deep-copy the owned sample buffer in the copy constructor.
  • Copy global_start and global_end metadata.
  • Add a deep-copy assignment operator with self-assignment and allocation-failure guards.

Why is this needed?

AudioFrame owns data and releases it in its destructor. The existing copy constructor copied only part of the metadata and silently dropped the sample buffer. The implicit copy-assignment operator was more dangerous: it shallow-copied the owned pointer, allowing two frames to free the same allocation.

Implementing both copy operations keeps the existing copyable API while giving each frame independent ownership of its samples.

Validation

  • git diff --check
  • Verified the copy constructor and assignment operator copy all frame fields.
  • Verified self-assignment leaves the frame unchanged.
  • Verified assignment allocates the replacement before releasing the destination buffer.
  • Verified AudioFrame copy operations are not currently used by the in-tree runtime call sites, so this does not change hot-path behavior.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant