a couple of fixes to the error handling code
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@5631 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
37c555c2ca
commit
8d52474bc7
@ -10,12 +10,13 @@ MediaExtractor::MediaExtractor(BDataIO * source, int32 flags)
|
||||
CALLED();
|
||||
fSource = source;
|
||||
fStreamInfo = 0;
|
||||
fStreamCount = 0;
|
||||
fReader = 0;
|
||||
|
||||
fErr = _CreateReader(&fReader, &fStreamCount, &fMff, source);
|
||||
if (fErr)
|
||||
if (fErr) {
|
||||
fStreamCount = 0;
|
||||
fReader = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
fStreamInfo = new stream_info[fStreamCount];
|
||||
|
||||
@ -162,19 +163,22 @@ status_t
|
||||
MediaExtractor::CreateDecoder(int32 stream, Decoder **decoder, media_codec_info *mci)
|
||||
{
|
||||
CALLED();
|
||||
if (fStreamInfo[stream].status != B_OK) {
|
||||
status_t res;
|
||||
|
||||
res = fStreamInfo[stream].status;
|
||||
if (res != B_OK) {
|
||||
printf("MediaExtractor::CreateDecoder can't create decoder for stream %ld\n", stream);
|
||||
return B_ERROR;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (B_OK != _CreateDecoder(decoder, mci, &fStreamInfo[stream].encodedFormat)) {
|
||||
res = _CreateDecoder(decoder, mci, &fStreamInfo[stream].encodedFormat);
|
||||
if (res != B_OK) {
|
||||
printf("MediaExtractor::CreateDecoder failed for stream %ld\n", stream);
|
||||
return B_ERROR;
|
||||
return res;
|
||||
}
|
||||
|
||||
(*decoder)->Setup(this, stream);
|
||||
|
||||
status_t res;
|
||||
res = (*decoder)->Setup(&fStreamInfo[stream].encodedFormat, fStreamInfo[stream].infoBuffer , fStreamInfo[stream].infoBufferSize);
|
||||
if (res != B_OK) {
|
||||
printf("MediaExtractor::CreateDecoder Setup failed for stream %ld\n", stream);
|
||||
|
@ -281,6 +281,7 @@ BMediaFile::InitReader(BDataIO *source, int32 flags)
|
||||
CALLED();
|
||||
|
||||
fSource = source;
|
||||
|
||||
fExtractor = new MediaExtractor(source, flags);
|
||||
fErr = fExtractor->InitCheck();
|
||||
if (fErr)
|
||||
|
@ -130,12 +130,13 @@ BMediaTrack::ReadFrames(void *out_buffer,
|
||||
if (!mh)
|
||||
mh = &temp_header;
|
||||
|
||||
*out_frameCount = 0;
|
||||
result = fDecoder->Decode(out_buffer, out_frameCount, mh, info);
|
||||
|
||||
fCurFrame += *out_frameCount;
|
||||
fCurTime = mh->start_time;
|
||||
|
||||
if (result == B_OK) {
|
||||
fCurFrame += *out_frameCount;
|
||||
fCurTime = mh->start_time;
|
||||
} else {
|
||||
*out_frameCount = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -452,13 +453,16 @@ BMediaTrack::BMediaTrack(BPrivate::media::MediaExtractor *extractor,
|
||||
CALLED();
|
||||
fExtractor = extractor;
|
||||
fStream = stream;
|
||||
fErr = B_OK;
|
||||
|
||||
if (B_OK != fExtractor->CreateDecoder(fStream, &fDecoder, &fMCI))
|
||||
if (fExtractor->CreateDecoder(fStream, &fDecoder, &fMCI) != B_OK) {
|
||||
// we do not set fErr here, because ReadChunk should still work
|
||||
fDecoder = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
fCurFrame = 0;
|
||||
fCurTime = 0;
|
||||
fErr = B_OK;
|
||||
|
||||
// not used:
|
||||
fEncoder = 0;
|
||||
|
@ -37,7 +37,9 @@ _CreateReader(Reader **reader, int32 *streamCount, media_file_format *mff, BData
|
||||
|
||||
if (B_OK != (*reader)->Sniff(streamCount)) {
|
||||
printf("_CreateReader: Sniff failed\n");
|
||||
return B_ERROR;
|
||||
_DestroyReader(*reader);
|
||||
return B_MEDIA_NO_HANDLER;
|
||||
// return B_ERROR;
|
||||
}
|
||||
|
||||
(*reader)->GetFileFormatInfo(mff);
|
||||
|
Loading…
Reference in New Issue
Block a user