make audio display not crash on no audio loaded (1 FPE fix, 1 NULL deref fix)

Originally committed to SVN as r1294.
This commit is contained in:
David Lamparter 2007-06-23 02:43:42 +00:00
parent 7c002835d8
commit 69bb371305
1 changed files with 4 additions and 1 deletions

View File

@ -904,7 +904,7 @@ __int64 AudioDisplay::GetSampleAtX(int x) {
/////////////////////////////////////////////////
// Gets the x coordinate corresponding to sample
int AudioDisplay::GetXAtSample(__int64 n) {
return (n/samples)-Position;
return samples ? (n/samples)-Position : 0;
}
@ -1838,6 +1838,9 @@ void AudioDisplay::OnSize(wxSizeEvent &event) {
///////////////
// Timer event
void AudioDisplay::OnUpdateTimer(wxTimerEvent &event) {
if (!origImage)
return;
// Get lock and check if it's OK
if (player->GetMutex()) {
wxMutexLocker locker(*player->GetMutex());