Very good question, and I think the answer is yes, which means that the "if" could just as well be deleted because chunksamples is always > 0.
In that case, it looks good to me.
I'd like to modify my previous answer. If you want correctly terminated audio streams it needs to be
Code:
/* add up the samples */
if (channelsamples > chunksamples)
file->info.audio_numsamples = stream->samples += chunksamples;
else if (channelsamples > 0)
file->info.audio_numsamples = stream->samples += channelsamples;
The previous code will count extra silence at the end of the audio stream, the amount depending on the wether you left in the original if or modified it / took it out.