| 4833 | // pointer and size will be correct. |
| 4834 | |
| 4835 | HRESULT CBaseAllocator::GetBuffer(__deref_out IMediaSample **ppBuffer, __in_opt REFERENCE_TIME *pStartTime, |
| 4836 | __in_opt REFERENCE_TIME *pEndTime, DWORD dwFlags) |
| 4837 | { |
| 4838 | UNREFERENCED_PARAMETER(pStartTime); |
| 4839 | UNREFERENCED_PARAMETER(pEndTime); |
| 4840 | UNREFERENCED_PARAMETER(dwFlags); |
| 4841 | CMediaSample *pSample; |
| 4842 | |
| 4843 | *ppBuffer = NULL; |
| 4844 | for (;;) |
| 4845 | { |
| 4846 | { // scope for lock |
| 4847 | CAutoLock cObjectLock(this); |
| 4848 | |
| 4849 | /* Check we are committed */ |
| 4850 | if (!m_bCommitted) |
| 4851 | { |
| 4852 | return VFW_E_NOT_COMMITTED; |
| 4853 | } |
| 4854 | pSample = (CMediaSample *)m_lFree.RemoveHead(); |
| 4855 | if (pSample == NULL) |
| 4856 | { |
| 4857 | SetWaiting(); |
| 4858 | } |
| 4859 | } |
| 4860 | |
| 4861 | /* If we didn't get a sample then wait for the list to signal */ |
| 4862 | |
| 4863 | if (pSample) |
| 4864 | { |
| 4865 | break; |
| 4866 | } |
| 4867 | if (dwFlags & AM_GBF_NOWAIT) |
| 4868 | { |
| 4869 | return VFW_E_TIMEOUT; |
| 4870 | } |
| 4871 | ASSERT(m_hSem != NULL); |
| 4872 | WaitForSingleObject(m_hSem, INFINITE); |
| 4873 | } |
| 4874 | |
| 4875 | /* Addref the buffer up to one. On release |
| 4876 | back to zero instead of being deleted, it will requeue itself by |
| 4877 | calling the ReleaseBuffer member function. NOTE the owner of a |
| 4878 | media sample must always be derived from CBaseAllocator */ |
| 4879 | |
| 4880 | ASSERT(pSample->m_cRef == 0); |
| 4881 | pSample->m_cRef = 1; |
| 4882 | *ppBuffer = pSample; |
| 4883 | |
| 4884 | #ifdef DXMPERF |
| 4885 | PERFLOG_GETBUFFER((IMemAllocator *)this, pSample); |
| 4886 | #endif // DXMPERF |
| 4887 | |
| 4888 | return NOERROR; |
| 4889 | } |
| 4890 | |
| 4891 | /* Final release of a CMediaSample will call this */ |
| 4892 |
no test coverage detected