uint64_t samples, ibytes;
Float64 osamplerate;
+ int input_done;
+
hb_audio_remap_t *remap;
};
if (!pv->ibytes)
{
*npackets = 0;
- return 1;
+ if (pv->input_done)
+ {
+ // EOF on input
+ buffers->mBuffers[0].mDataByteSize = 0;
+ return noErr;
+ }
+ else
+ {
+ // Not enough data available
+ return 1;
+ }
}
if (pv->buf != NULL)
hb_work_private_t *pv = w->private_data;
UInt32 npackets = 1;
- /* check if we need more data */
- if ((pv->ibytes = hb_list_bytes(pv->list)) < pv->isamples * pv->isamplesiz)
+ /* check if we need more data or we have already got to EOF
+ if so, we need to call the audio converter again even
+ without data to get out the remaining packets.
+ */
+ if (pv->input_done != 1 &&
+ (pv->ibytes = hb_list_bytes(pv->list)) < pv->isamples * pv->isamplesiz)
{
return NULL;
}
// only drop the output buffer if it's actually empty
if (!npackets || odesc.mDataByteSize <= 0)
{
- hb_log("encCoreAudio: 0 packets returned");
return NULL;
}
hb_list_add(pv->list, tmp);
}
- hb_buffer_t *bufout = NULL, *buf = NULL;
- while (hb_list_bytes(pv->list) >= pv->isamples * pv->isamplesiz)
+ hb_buffer_t *bufout = NULL, *buf = NULL, *b = NULL;
+ while ((b = Encode(w)))
{
- hb_buffer_t *b = Encode(w);
- if (b != NULL)
+ if (bufout == NULL)
{
- if (bufout == NULL)
- {
- bufout = b;
- }
- else
- {
- buf->next = b;
- }
- buf = b;
+ bufout = b;
}
+ else
+ {
+ buf->next = b;
+ }
+ buf = b;
}
+
// add the eof marker to the end of our buf chain
if (buf != NULL)
{
{
// EOF on input. Finish encoding what we have buffered then send
// it & the eof downstream.
+ pv->input_done = 1;
*buf_out = Flush(w, in);
return HB_WORK_DONE;
}