| 2165 | // returns an AddRef'd object |
| 2166 | |
| 2167 | HRESULT |
| 2168 | CCmdQueue::GetDueCommand(__out CDeferredCommand **ppCmd, long msTimeout) |
| 2169 | { |
| 2170 | // loop until we timeout or find a due command |
| 2171 | for (;;) |
| 2172 | { |
| 2173 | |
| 2174 | { |
| 2175 | CAutoLock lock(&m_Lock); |
| 2176 | |
| 2177 | // find the earliest command |
| 2178 | CDeferredCommand *pCmd = NULL; |
| 2179 | |
| 2180 | // check the presentation time and the |
| 2181 | // stream time list to find the earliest |
| 2182 | |
| 2183 | POSITION pos = m_listPresentation.GetHeadPosition(); |
| 2184 | |
| 2185 | if (NULL != pos) |
| 2186 | { |
| 2187 | pCmd = m_listPresentation.GetValid(pos); |
| 2188 | } |
| 2189 | |
| 2190 | if (m_bRunning) |
| 2191 | { |
| 2192 | pos = m_listStream.GetHeadPosition(); |
| 2193 | if (NULL != pos) |
| 2194 | { |
| 2195 | CDeferredCommand *pStrm = m_listStream.GetValid(pos); |
| 2196 | |
| 2197 | CRefTime t = pStrm->GetTime() + m_StreamTimeOffset; |
| 2198 | if (!pCmd || (t < pCmd->GetTime())) |
| 2199 | { |
| 2200 | pCmd = pStrm; |
| 2201 | } |
| 2202 | } |
| 2203 | } |
| 2204 | |
| 2205 | // if we have found one, is it due? |
| 2206 | if (pCmd) |
| 2207 | { |
| 2208 | if (CheckTime(pCmd->GetTime(), pCmd->IsStreamTime())) |
| 2209 | { |
| 2210 | |
| 2211 | // yes it's due - addref it |
| 2212 | pCmd->AddRef(); |
| 2213 | *ppCmd = pCmd; |
| 2214 | return S_OK; |
| 2215 | } |
| 2216 | } |
| 2217 | } |
| 2218 | |
| 2219 | // block until the advise is signalled |
| 2220 | if (WaitForSingleObject(m_evDue, msTimeout) != WAIT_OBJECT_0) |
| 2221 | { |
| 2222 | return E_ABORT; |
| 2223 | } |
| 2224 | } |
nothing calls this directly
no test coverage detected