Fixing [#28907] Frozen playback.

Also fixing two more crashes when audio files don't exist/cannot be read and apply a changed file path of a sound, reported by Jens Verwiebe in IRC.
This commit is contained in:
Joerg Mueller 2011-10-13 22:19:29 +00:00
parent d893ac690c
commit 9e17ecf010
5 changed files with 25 additions and 12 deletions

@ -69,7 +69,7 @@ bool AUD_NULLDevice::AUD_NULLHandle::seek(float position)
float AUD_NULLDevice::AUD_NULLHandle::getPosition()
{
return 0.0f;
return std::numeric_limits<float>::quiet_NaN();
}
AUD_Status AUD_NULLDevice::AUD_NULLHandle::getStatus()
@ -79,7 +79,7 @@ AUD_Status AUD_NULLDevice::AUD_NULLHandle::getStatus()
float AUD_NULLDevice::AUD_NULLHandle::getVolume()
{
return 0.0f;
return std::numeric_limits<float>::quiet_NaN();
}
bool AUD_NULLDevice::AUD_NULLHandle::setVolume(float volume)
@ -89,7 +89,7 @@ bool AUD_NULLDevice::AUD_NULLHandle::setVolume(float volume)
float AUD_NULLDevice::AUD_NULLHandle::getPitch()
{
return 0.0f;
return std::numeric_limits<float>::quiet_NaN();
}
bool AUD_NULLDevice::AUD_NULLHandle::setPitch(float pitch)
@ -153,7 +153,7 @@ void AUD_NULLDevice::unlock()
float AUD_NULLDevice::getVolume() const
{
return 0;
return std::numeric_limits<float>::quiet_NaN();
}
void AUD_NULLDevice::setVolume(float volume)

@ -295,7 +295,10 @@ void sound_cache(struct bSound* sound)
AUD_unload(sound->cache);
sound->cache = AUD_bufferSound(sound->handle);
sound->playback_handle = sound->cache;
if(sound->cache)
sound->playback_handle = sound->cache;
else
sound->playback_handle = sound->handle;
}
void sound_cache_notifying(struct Main* main, struct bSound* sound)
@ -332,6 +335,8 @@ void sound_load(struct Main *bmain, struct bSound* sound)
sound->playback_handle = NULL;
}
sound_free_waveform(sound);
// XXX unused currently
#if 0
switch(sound->type)
@ -625,7 +630,7 @@ float sound_sync_scene(struct Scene *scene)
else
return AUD_getPosition(scene->sound_scene_handle);
}
return 0.0f;
return .0f/.0f;
}
int sound_scene_playing(struct Scene *scene)
@ -782,7 +787,7 @@ static void sound_start_play_scene(struct Scene *UNUSED(scene)) {}
void sound_play_scene(struct Scene *UNUSED(scene)) {}
void sound_stop_scene(struct Scene *UNUSED(scene)) {}
void sound_seek_scene(struct Main *UNUSED(bmain), struct Scene *UNUSED(scene)) {}
float sound_sync_scene(struct Scene *UNUSED(scene)) { return 0.0f; }
float sound_sync_scene(struct Scene *UNUSED(scene)) { return .0f/.0f; }
int sound_scene_playing(struct Scene *UNUSED(scene)) { return -1; }
int sound_read_sound_buffer(struct bSound* UNUSED(sound), float* UNUSED(buffer), int UNUSED(length), float UNUSED(start), float UNUSED(end)) { return 0; }
void sound_read_waveform(struct bSound* sound) { (void)sound; }

@ -192,6 +192,9 @@ static void drawseqwave(Scene *scene, Sequence *seq, float x1, float y1, float x
waveform = seq->sound->waveform;
if(!waveform)
return;
startsample = floor((seq->startofs + seq->anim_startofs)/FPS * SOUND_WAVE_SAMPLES_PER_SECOND);
endsample = ceil((seq->startofs + seq->anim_startofs + seq->enddisp - seq->startdisp)/FPS * SOUND_WAVE_SAMPLES_PER_SECOND);
samplestep = (endsample-startsample) * stepsize / (x2-x1);

@ -453,6 +453,8 @@ static void rna_Sequence_filepath_set(PointerRNA *ptr, const char *value)
PointerRNA id_ptr;
RNA_id_pointer_create((ID *)seq->sound, &id_ptr);
RNA_string_set(&id_ptr, "filepath", value);
sound_load(G.main, seq->sound);
sound_update_scene_sound(seq->scene_sound, seq->sound);
}
BLI_split_dirfile(value, dir, name);

@ -1790,11 +1790,14 @@ void wm_event_do_handlers(bContext *C)
}
if(playing == 0) {
int ncfra = sound_sync_scene(scene) * (float)FPS + 0.5f;
if(ncfra != scene->r.cfra) {
scene->r.cfra = ncfra;
ED_update_for_newframe(CTX_data_main(C), scene, win->screen, 1);
WM_event_add_notifier(C, NC_WINDOW, NULL);
float time = sound_sync_scene(scene);
if(finite(time)) {
int ncfra = sound_sync_scene(scene) * (float)FPS + 0.5f;
if(ncfra != scene->r.cfra) {
scene->r.cfra = ncfra;
ED_update_for_newframe(CTX_data_main(C), scene, win->screen, 1);
WM_event_add_notifier(C, NC_WINDOW, NULL);
}
}
}