Fixed two crash bugs related to audio.

Originally committed to SVN as r463.
This commit is contained in:
Rodrigo Braz Monteiro 2006-07-04 21:59:30 +00:00
parent 4a5106daf0
commit fec305fe78

View file

@ -133,6 +133,9 @@ void AudioDisplay::Reset() {
//////////////// ////////////////
// Update image // Update image
void AudioDisplay::UpdateImage(bool weak) { void AudioDisplay::UpdateImage(bool weak) {
// Loaded?
if (!loaded || !provider) return;
// Prepare bitmap // Prepare bitmap
int displayH = h+20; int displayH = h+20;
if (origImage) { if (origImage) {
@ -776,6 +779,7 @@ void AudioDisplay::SetSamplesPercent(int percent,bool update,float pivot) {
// Update samples // Update samples
void AudioDisplay::UpdateSamples() { void AudioDisplay::UpdateSamples() {
// Set samples // Set samples
if (!provider) return;
__int64 totalSamples = provider->GetNumSamples(); __int64 totalSamples = provider->GetNumSamples();
int total = totalSamples / w; int total = totalSamples / w;
int max = 5760000 / w; // 2 minutes at 48 kHz maximum int max = 5760000 / w; // 2 minutes at 48 kHz maximum
@ -817,6 +821,7 @@ void AudioDisplay::SetFile(wxString file, VideoProvider *vprovider) {
Reset(); Reset();
loaded = false; loaded = false;
temporary = false;
} }
// Load // Load
@ -868,6 +873,7 @@ void AudioDisplay::SetFromVideo() {
//////////////////// ////////////////////
// Update scrollbar // Update scrollbar
void AudioDisplay::UpdateScrollbar() { void AudioDisplay::UpdateScrollbar() {
if (!provider) return;
int page = w/12; int page = w/12;
int len = provider->GetNumSamples() / samples / 12; int len = provider->GetNumSamples() / samples / 12;
Position = PositionSample / samples; Position = PositionSample / samples;
@ -1054,6 +1060,9 @@ void AudioDisplay::SetDialogue(SubtitlesGrid *_grid,AssDialogue *diag,int n) {
////////////////// //////////////////
// Commit changes // Commit changes
void AudioDisplay::CommitChanges () { void AudioDisplay::CommitChanges () {
// Loaded?
if (!loaded) return;
if (!Options.AsBool(_T("Audio SSA Mode")) && !box->audioKaraoke->splitting) { if (!Options.AsBool(_T("Audio SSA Mode")) && !box->audioKaraoke->splitting) {
// Check if there's any need to commit // Check if there's any need to commit
if (!NeedCommit) return; if (!NeedCommit) return;