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();
|
CALLED();
|
||||||
fSource = source;
|
fSource = source;
|
||||||
fStreamInfo = 0;
|
fStreamInfo = 0;
|
||||||
fStreamCount = 0;
|
|
||||||
fReader = 0;
|
|
||||||
|
|
||||||
fErr = _CreateReader(&fReader, &fStreamCount, &fMff, source);
|
fErr = _CreateReader(&fReader, &fStreamCount, &fMff, source);
|
||||||
if (fErr)
|
if (fErr) {
|
||||||
|
fStreamCount = 0;
|
||||||
|
fReader = 0;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fStreamInfo = new stream_info[fStreamCount];
|
fStreamInfo = new stream_info[fStreamCount];
|
||||||
|
|
||||||
@ -162,19 +163,22 @@ status_t
|
|||||||
MediaExtractor::CreateDecoder(int32 stream, Decoder **decoder, media_codec_info *mci)
|
MediaExtractor::CreateDecoder(int32 stream, Decoder **decoder, media_codec_info *mci)
|
||||||
{
|
{
|
||||||
CALLED();
|
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);
|
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);
|
printf("MediaExtractor::CreateDecoder failed for stream %ld\n", stream);
|
||||||
return B_ERROR;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*decoder)->Setup(this, stream);
|
(*decoder)->Setup(this, stream);
|
||||||
|
|
||||||
status_t res;
|
|
||||||
res = (*decoder)->Setup(&fStreamInfo[stream].encodedFormat, fStreamInfo[stream].infoBuffer , fStreamInfo[stream].infoBufferSize);
|
res = (*decoder)->Setup(&fStreamInfo[stream].encodedFormat, fStreamInfo[stream].infoBuffer , fStreamInfo[stream].infoBufferSize);
|
||||||
if (res != B_OK) {
|
if (res != B_OK) {
|
||||||
printf("MediaExtractor::CreateDecoder Setup failed for stream %ld\n", stream);
|
printf("MediaExtractor::CreateDecoder Setup failed for stream %ld\n", stream);
|
||||||
|
@ -281,6 +281,7 @@ BMediaFile::InitReader(BDataIO *source, int32 flags)
|
|||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
fSource = source;
|
fSource = source;
|
||||||
|
|
||||||
fExtractor = new MediaExtractor(source, flags);
|
fExtractor = new MediaExtractor(source, flags);
|
||||||
fErr = fExtractor->InitCheck();
|
fErr = fExtractor->InitCheck();
|
||||||
if (fErr)
|
if (fErr)
|
||||||
|
@ -130,12 +130,13 @@ BMediaTrack::ReadFrames(void *out_buffer,
|
|||||||
if (!mh)
|
if (!mh)
|
||||||
mh = &temp_header;
|
mh = &temp_header;
|
||||||
|
|
||||||
*out_frameCount = 0;
|
|
||||||
result = fDecoder->Decode(out_buffer, out_frameCount, mh, info);
|
result = fDecoder->Decode(out_buffer, out_frameCount, mh, info);
|
||||||
|
if (result == B_OK) {
|
||||||
fCurFrame += *out_frameCount;
|
fCurFrame += *out_frameCount;
|
||||||
fCurTime = mh->start_time;
|
fCurTime = mh->start_time;
|
||||||
|
} else {
|
||||||
|
*out_frameCount = 0;
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -452,13 +453,16 @@ BMediaTrack::BMediaTrack(BPrivate::media::MediaExtractor *extractor,
|
|||||||
CALLED();
|
CALLED();
|
||||||
fExtractor = extractor;
|
fExtractor = extractor;
|
||||||
fStream = stream;
|
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;
|
fDecoder = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
fCurFrame = 0;
|
fCurFrame = 0;
|
||||||
fCurTime = 0;
|
fCurTime = 0;
|
||||||
fErr = B_OK;
|
|
||||||
|
|
||||||
// not used:
|
// not used:
|
||||||
fEncoder = 0;
|
fEncoder = 0;
|
||||||
|
@ -37,7 +37,9 @@ _CreateReader(Reader **reader, int32 *streamCount, media_file_format *mff, BData
|
|||||||
|
|
||||||
if (B_OK != (*reader)->Sniff(streamCount)) {
|
if (B_OK != (*reader)->Sniff(streamCount)) {
|
||||||
printf("_CreateReader: Sniff failed\n");
|
printf("_CreateReader: Sniff failed\n");
|
||||||
return B_ERROR;
|
_DestroyReader(*reader);
|
||||||
|
return B_MEDIA_NO_HANDLER;
|
||||||
|
// return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*reader)->GetFileFormatInfo(mff);
|
(*reader)->GetFileFormatInfo(mff);
|
||||||
|
Loading…
Reference in New Issue
Block a user