Hi all,
I am writing a AVStream base PCI driver. I use avshws and avssamp as my sample.
There is an audio pin in my driver. The audio out format is ADPCM.
I use graphedit to test my driver. If the connection is as in following:
audio pin –> ADPCM decoder –> AVI Mux –> File writer (a.avi)
(ouotput adpcm) (output PCM)
Then the total audio duration time is correct. That is, if I save the non compressed audio format of AVI, it works fine.
My problem is that if I connect as in following:
audio pin –> AVI Mux –> File writer (a.avi)
(ouotput adpcm)
Then the total audio duration time is very short though the audio data sounds OK.
I have set duration of each frame as below:
pHeader->Duration = -liTimeout.QuadPart;
However, it seems no effect.
Does anyone know how to fix audio time duration of AVI file? Should I modify audio frame size or should I modify audio process routine?
Any suggestion would be greatly appreciated!
Thanks a lot!
Gordon
The following are my audio process routine:
NTSTATUS
CAudioCapturePin::
Process(
IN LARGE_INTEGER &liTimeout
)
{
pStreamPointer = KsPinGetLeadingEdgeStreamPointer( m_Pin,
KSSTREAM_POINTER_STATE_LOCKED );
…
PKSSTREAM_HEADER pHeader = pStreamPointer->StreamHeader;
PBYTE pData = static_cast< PBYTE >( pHeader->Data );
RtlCopyMemory( pData, pAudio, dwAudioLen);
pHeader->DataUsed = dwAudioLen;
// If a clock has been assigned, timestamp the packets with the
// time shown on the clock.
if( m_Clock != NULL )
{
PKS_FRAME_INFO FrameInfo = reinterpret_cast
<pks_frame_info>(pHeader + 1);
LONGLONG llClockTime = m_Clock->GetTime();
llClockTime = m_Clock->GetCorrelatedTime(&llClockTime);
pHeader -> PresentationTime.Numerator =
pHeader -> PresentationTime.Denominator = 1;
pHeader->PresentationTime.Time = llClockTime;
pHeader->Duration = -liTimeout.QuadPart;
pHeader -> OptionsFlags =
KSSTREAM_HEADER_OPTIONSF_TIMEVALID |
KSSTREAM_HEADER_OPTIONSF_DURATIONVALID;
if( pHeader->Size >= sizeof(KSSTREAM_HEADER) + sizeof(KS_FRAME_INFO))
{
FrameInfo->ExtendedHeaderSize = sizeof (KS_FRAME_INFO);
FrameInfo->PictureNumber = m_nAudioFrameNum;
FrameInfo->DropCount = 0;
}
}
else
{
// If there is no clock, don’t time stamp the packets.
pHeader->PresentationTime.Time = 0;
pHeader->Duration = 0;
pHeader->OptionsFlags = 0;
}
KsStreamPointerUnlock( pStreamPointer, TRUE );
}
return STATUS_SUCCESS;
}</pks_frame_info>