コード例 #1
0
HRESULT CWASAPIRenderFilter::IsFormatSupported(const WAVEFORMATEXTENSIBLE* pwfx, WAVEFORMATEXTENSIBLE** pwfxAccepted)
{
  WAVEFORMATEXTENSIBLE* pwfxCM = NULL;
  WAVEFORMATEX* tmpPwfx = NULL;
  
  HRESULT hr = m_pAudioClient->IsFormatSupported(m_pSettings->m_WASAPIShareMode, (WAVEFORMATEX*)pwfx, (WAVEFORMATEX**)&pwfxCM);
  if (hr != S_OK)
  {
    CopyWaveFormatEx((WAVEFORMATEXTENSIBLE**)&tmpPwfx, pwfx);
    tmpPwfx->cbSize = 0;
    tmpPwfx->wFormatTag = WAVE_FORMAT_PCM;

    hr = m_pAudioClient->IsFormatSupported(m_pSettings->m_WASAPIShareMode, (WAVEFORMATEX*)tmpPwfx, (WAVEFORMATEX**)&pwfxCM);
    if (hr != S_OK)
    {
      Log("CWASAPIRenderFilter::NegotiateFormat WASAPI client refused the format: (0x%08x)", hr);
      LogWaveFormat(pwfxCM, "Closest match would be" );
      SAFE_DELETE_WAVEFORMATEX(tmpPwfx);
      CoTaskMemFree(pwfxCM);
      return VFW_E_TYPE_NOT_ACCEPTED;
    }

    ToWaveFormatExtensible(pwfxAccepted, tmpPwfx);
    (*pwfxAccepted)->Format.cbSize = 0;
    (*pwfxAccepted)->Format.wFormatTag = WAVE_FORMAT_PCM;

    SAFE_DELETE_WAVEFORMATEX(tmpPwfx);
  }
  else
    CopyWaveFormatEx(pwfxAccepted, pwfx);

  return hr;
}
コード例 #2
0
HRESULT CWASAPIRenderFilter::IsFormatSupported(const WAVEFORMATEXTENSIBLE* pwfx, WAVEFORMATEXTENSIBLE** pwfxAccepted)
{
  WAVEFORMATEXTENSIBLE* pwfxCM = NULL;
  WAVEFORMATEX* tmpPwfx = NULL;
  AUDCLNT_SHAREMODE shareMode = m_pSettings->GetWASAPIMode();
  
  HRESULT hr = m_pAudioClient->IsFormatSupported(shareMode, (WAVEFORMATEX*)pwfx, (WAVEFORMATEX**)&pwfxCM);
  if (hr != S_OK)
  {
    if (hr == AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED)
    {
      Log("CWASAPIRenderFilter::NegotiateFormat WASAPI client will only accept shared mode sessions, check audio device's configuration.");
      return hr;
    }

    if (CBaseAudioSink::CanBitstream(pwfx)) // Misrepresenting the media type for bit streamable formats will make negotiation succeed, but playback will not
      return hr;

    CopyWaveFormatEx((WAVEFORMATEXTENSIBLE**)&tmpPwfx, pwfx);
    tmpPwfx->cbSize = 0;
    tmpPwfx->wFormatTag = WAVE_FORMAT_PCM;

    hr = m_pAudioClient->IsFormatSupported(shareMode, (WAVEFORMATEX*)tmpPwfx, (WAVEFORMATEX**)&pwfxCM);
    if (hr != S_OK)
    {
      Log("CWASAPIRenderFilter::NegotiateFormat WASAPI client refused the format: (0x%08x)", hr);
      LogWaveFormat(pwfxCM, "Closest match would be" );
      SAFE_DELETE_WAVEFORMATEX(tmpPwfx);
      CoTaskMemFree(pwfxCM);

      return VFW_E_TYPE_NOT_ACCEPTED;
    }

    ToWaveFormatExtensible(pwfxAccepted, tmpPwfx);
    (*pwfxAccepted)->Format.cbSize = 0;
    (*pwfxAccepted)->Format.wFormatTag = WAVE_FORMAT_PCM;

    SAFE_DELETE_WAVEFORMATEX(tmpPwfx);
  }
  else
    CopyWaveFormatEx(pwfxAccepted, pwfx);

  return hr;
}