Fixed MP4 handler passing the end of the stream

This commit is contained in:
Chris Moeller 2012-08-30 19:33:56 -07:00
parent 73bdcf4b52
commit 36ece2d151
3 changed files with 15 additions and 2 deletions

View File

@ -97,6 +97,7 @@
<DelayLoadDLLs>%(DelayLoadDLLs)</DelayLoadDLLs>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>

View File

@ -44,6 +44,10 @@ void decode_mp4_aac(mp4_aac_codec_data * data, sample * outbuf, int32_t samples_
samples_done += samples_remain;
while ( samples_done < samples_to_do ) {
if (data->sampleId >= data->numSamples) {
memset(outbuf, 0, (samples_to_do - samples_done) * stream_info->numChannels * sizeof(sample));
break;
}
if (!MP4ReadSample( data->h_mp4file, data->track_id, ++data->sampleId, (uint8_t**)(&buffer), (uint32_t*)(&buffer_size), 0, 0, 0, 0)) return;
ubuffer_size = buffer_size;
bytes_valid = buffer_size;

View File

@ -34,8 +34,16 @@ int mp4_file_read( void* handle, void* buffer, int64_t size, int64_t* nin, int64
mp4_streamfile * file = ( mp4_streamfile * ) handle;
int64_t max_size = file->size - file->offset - file->start;
if ( size > max_size ) size = max_size;
*nin = read_streamfile( (uint8_t *) buffer, file->offset, size, file->streamfile );
file->offset += *nin;
if ( size > 0 )
{
*nin = read_streamfile( (uint8_t *) buffer, file->offset, size, file->streamfile );
file->offset += *nin;
}
else
{
*nin = 0;
return 1;
}
return 0;
}