本文整理汇总了C++中microsoft::wrl::ComPtr::Lock方法的典型用法代码示例。如果您正苦于以下问题:C++ ComPtr::Lock方法的具体用法?C++ ComPtr::Lock怎么用?C++ ComPtr::Lock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类microsoft::wrl::ComPtr
的用法示例。
在下文中一共展示了ComPtr::Lock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetNextBuffer
bool MediaStreamer::GetNextBuffer(uint8* buffer, uint32 maxBufferSize, uint32* bufferLength)
{
Microsoft::WRL::ComPtr<IMFSample> sample;
Microsoft::WRL::ComPtr<IMFMediaBuffer> mediaBuffer;
BYTE *audioData = nullptr;
DWORD sampleBufferLength = 0;
DWORD flags = 0;
*bufferLength = 0;
if (m_reader == nullptr)
{
return false;
}
DX::ThrowIfFailed(
m_reader->ReadSample(MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, nullptr, &flags, nullptr, &sample)
);
if (sample == nullptr)
{
if (flags & MF_SOURCE_READERF_ENDOFSTREAM)
{
return true;
}
else
{
return false;
}
}
DX::ThrowIfFailed(
sample->ConvertToContiguousBuffer(&mediaBuffer)
);
DX::ThrowIfFailed(
mediaBuffer->Lock(&audioData, nullptr, &sampleBufferLength)
);
// Only copy the sample if the remaining buffer is large enough.
if (sampleBufferLength <= maxBufferSize)
{
CopyMemory(buffer, audioData, sampleBufferLength);
*bufferLength = sampleBufferLength;
}
if (flags & MF_SOURCE_READERF_ENDOFSTREAM)
{
return true;
}
else
{
return false;
}
}
示例2: GetNextBuffer
bool MediaStreamer::GetNextBuffer(uint8* buffer, uint32 maxBufferSize, uint32* bufferLength)
{
Microsoft::WRL::ComPtr<IMFSample> sample;
Microsoft::WRL::ComPtr<IMFMediaBuffer> mediaBuffer;
BYTE *audioData = nullptr;
DWORD sampleBufferLength = 0;
DWORD flags = 0;
*bufferLength = 0;
if (m_reader == nullptr)
{
return false;
}
ThrowIfFailed(
m_reader->ReadSample(MF_SOURCE_READER_FIRST_AUDIO_STREAM, 0, nullptr, &flags, nullptr, &sample)
);
if (sample == nullptr)
{
if (flags & MF_SOURCE_READERF_ENDOFSTREAM)
{
return true;
}
else
{
return false;
}
}
ThrowIfFailed(
sample->ConvertToContiguousBuffer(&mediaBuffer)
);
ThrowIfFailed(
mediaBuffer->Lock(&audioData, nullptr, &sampleBufferLength)
);
// If buffer isn't large enough, dump sample
if (sampleBufferLength <= maxBufferSize)
{
CopyMemory(buffer, audioData, sampleBufferLength);
*bufferLength = sampleBufferLength;
}
else
{
#if defined(COCOS2D_DEBUG)
OutputDebugString(L"Sample buffer dumped");
#endif
}
if (flags & MF_SOURCE_READERF_ENDOFSTREAM)
{
return true;
}
else
{
return false;
}
}