natiny_clip_reload
C
int natiny_clip_reload(NatinyClip clip, NatinyResource ogg);
Replaces the samples inside an existing clip. The handle does not change.
Parameters
| Name |
Type |
Description |
clip |
NatinyClip |
Live clip handle from natiny_clip_load |
ogg |
NatinyResource |
Resource handle containing Ogg Vorbis data |
Returns
| Type |
Description |
int |
1 on success, 0 on failure |
Example
C
NatinyClip clip = natiny_clip_load(resource);
NatinyAudioSource source = natiny_audio_create_source(clip);
NatinyResource replacement = natiny_resource_load("sounds/rain.ogg");
/* Every source on this clip picks up the new sound. */
if (!natiny_clip_reload(clip, replacement)) {
/* The clip still contains its previous samples. */
}
natiny_resource_destroy(replacement);
Notes
- Active sources restart from the beginning of the new sound. Paused and
stopped sources remain paused and stopped.
- Returns
0 if clip is not live or ogg cannot be decoded as Ogg Vorbis.
A failure leaves the old samples unchanged.
- The resource bytes are consumed during the call and may be destroyed after
a successful reload.
- The old samples are released only once the mixer is known to have stopped
reading them, so a reload is safe while sound is playing.