static int Process(ape* p,format_stream* Stream) { int Result = ERR_NONE; int retVal; if (Stream->Pending) { Result = Format_Send(&p->Format,Stream); if (Result == ERR_BUFFER_FULL || Result == ERR_SYNCED) return Result; } if (p->Format.Reader[0].BufferAvailable < (MINBUFFER/2) && !p->Format.Reader[0].NoMoreInput) return ERR_NEED_MORE_DATA; retVal = p->Decoder->GetData((char*)p->Buffer, p->BufferLen, &p->BufferFilled); if (retVal != ERROR_SUCCESS) return ERR_INVALID_DATA; if (p->BufferFilled == 0) return Format_CheckEof(&p->Format,Stream); Stream->Packet.RefTime = (tick_t)((p->Samples * TICKSPERSEC) / p->SampleRate); Stream->Packet.Data[0] = p->Buffer; Stream->Packet.Length = p->BufferFilled * p->SampleSize; Stream->Pending = 1; p->Samples += p->BufferFilled; Result = Format_Send(&p->Format,Stream); if (Result == ERR_BUFFER_FULL || Result == ERR_NEED_MORE_DATA) Result = ERR_NONE; return Result; }
static int Process(asap* p,format_stream* Stream) { int Result = ERR_NONE; if (Stream->Pending) { Result = Format_Send(&p->Format,Stream); if (Result == ERR_BUFFER_FULL || Result == ERR_SYNCED) return Result; } if (p->Samples >= p->Total) return Format_CheckEof(&p->Format,Stream); ASAP_Generate(p->Buffer, BUFFER_SIZE); Stream->Packet.RefTime = Scale(p->Samples,TICKSPERSEC,SAMPLE_RATE); Stream->Packet.Data[0] = p->Buffer; Stream->Packet.Length = BUFFER_SIZE; Stream->Pending = 1; p->Samples += p->SamplePerBuffer; Result = Format_Send(&p->Format,Stream); if (Result == ERR_BUFFER_FULL || Result == ERR_NEED_MORE_DATA) Result = ERR_NONE; return Result; }
static int Process(tta* p,format_stream* Stream) { int Result = ERR_NONE; int No,Burst; if (Stream->Pending) { Result = Format_Send(&p->Format,Stream); if (Result == ERR_BUFFER_FULL || Result == ERR_SYNCED) return Result; } Burst = Stream->PacketBurst; for (No=0;No<Burst;++No) { if (p->Format.Reader[0].BufferAvailable < (MINBUFFER/2) && !p->Format.Reader[0].NoMoreInput) return ERR_NEED_MORE_DATA; p->BufferFilled = get_samples(p->Buffer); if (p->BufferFilled == -1) return ERR_INVALID_DATA; if (p->BufferFilled == 0) return Format_CheckEof(&p->Format,Stream); Stream->Packet.RefTime = (tick_t)((p->Samples * TICKSPERSEC) / p->SampleRate); Stream->Packet.Data[0] = p->Buffer; Stream->Packet.Length = p->BufferFilled * p->SampleSize; Stream->Pending = 1; p->Samples += p->BufferFilled; Result = Format_Send(&p->Format,Stream); if (Result == ERR_BUFFER_FULL || Result == ERR_SYNCED) break; } if (Result == ERR_BUFFER_FULL || Result == ERR_NEED_MORE_DATA) Result = ERR_NONE; return Result; }
static int ProcessStream(rawimage* p,format_stream* Stream) { int Result,Length; if (Stream->Pending) { Result = Format_Send(&p->Format,Stream); if (Result == ERR_BUFFER_FULL || Result == ERR_SYNCED) return Result; } Length = p->Format.FileSize; if (Length < 0) Length = 1024*1024; if (Stream->BufferBlockLength < Length) Format_AllocBufferBlock(&p->Format,Stream,Length); do { format_ref *i; format_ref *Ref = Stream->Reader->ReadAsRef(Stream->Reader,-MAX_INT); for (i=Ref;i;i=i->Next) { int n = i->Length; if (n > Stream->BufferBlockLength - p->Total) n = Stream->BufferBlockLength - p->Total; if (n>0) { WriteBlock(&Stream->BufferBlock,p->Total,i->Buffer->Block.Ptr + i->Begin,n); p->Total += n; } } Format_ReleaseRef(&p->Format,Ref); } while (Stream->Reader->BufferAvailable>0); if (!Stream->Reader->Eof(Stream->Reader) && p->Total<Stream->BufferBlockLength) return ERR_NEED_MORE_DATA; if (!p->Total) return Format_CheckEof(&p->Format,Stream); Stream->Packet.RefTime = 0; Stream->Packet.Data[0] = Stream->BufferBlock.Ptr; Stream->Packet.Length = p->Total; Stream->Pending = 1; if (Stream->LastTime < TIME_UNKNOWN) Stream->LastTime = TIME_UNKNOWN; Result = Format_Send(&p->Format,Stream); if (Result == ERR_BUFFER_FULL || Result == ERR_NEED_MORE_DATA) Result = ERR_NONE; return Result; }