Fix error handling crashes.
This commit is contained in:
@@ -142,22 +142,9 @@ void RageSound::Unload()
|
|||||||
databuf.clear();
|
databuf.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is called upon fatal failure. Replace the sound with silence. */
|
|
||||||
void RageSound::Fail(CString reason)
|
void RageSound::Fail(CString reason)
|
||||||
{
|
{
|
||||||
delete Sample;
|
LOG->Warn("Decoding %s failed: %s", GetLoadedFilePath().c_str(), reason.c_str() );
|
||||||
Sample = NULL;
|
|
||||||
|
|
||||||
LOG->Warn("sound error %s", reason.c_str());
|
|
||||||
/* XXX: we can't do this anymore, and it was a hack anyway */
|
|
||||||
/* XXX
|
|
||||||
* full_buf.append(0, 1024); should be OK, but VC6 is broken ... */
|
|
||||||
basic_string<char> empty(1024, 0);
|
|
||||||
// full_buf.insert(full_buf.end(), empty.begin(), empty.end());
|
|
||||||
position = 0;
|
|
||||||
|
|
||||||
LOG->Warn("Decoding %s failed: %s",
|
|
||||||
GetLoadedFilePath().c_str(), reason.c_str() );
|
|
||||||
|
|
||||||
error = reason;
|
error = reason;
|
||||||
}
|
}
|
||||||
@@ -343,18 +330,16 @@ int RageSound::FillBuf(int bytes)
|
|||||||
if(cnt == 0)
|
if(cnt == 0)
|
||||||
return got_something; /* EOF */
|
return got_something; /* EOF */
|
||||||
|
|
||||||
RateChange(inbuf, cnt, speed_input_samples, speed_output_samples, channels);
|
|
||||||
|
|
||||||
if(cnt == -1)
|
if(cnt == -1)
|
||||||
{
|
{
|
||||||
/* XXX untested */
|
|
||||||
Fail(Sample->GetError());
|
Fail(Sample->GetError());
|
||||||
|
|
||||||
/* Pretend we got data; we actually just switched to a non-streaming
|
/* Pretend we got EOF. */
|
||||||
* buffer. */
|
return 0;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RateChange(inbuf, cnt, speed_input_samples, speed_output_samples, channels);
|
||||||
|
|
||||||
/* Add the data to the buffer. */
|
/* Add the data to the buffer. */
|
||||||
databuf.write((const char *) inbuf, cnt);
|
databuf.write((const char *) inbuf, cnt);
|
||||||
bytes -= cnt;
|
bytes -= cnt;
|
||||||
|
|||||||
Reference in New Issue
Block a user