示例#1
0
bool Base::Open(const SoundDevice::Settings &settings)
//----------------------------------------------------
{
	if(IsOpen())
	{
		Close();
	}
	m_Settings = settings;
	if(m_Settings.Latency == 0.0) m_Settings.Latency = m_Caps.DefaultSettings.Latency;
	if(m_Settings.UpdateInterval == 0.0) m_Settings.UpdateInterval = m_Caps.DefaultSettings.UpdateInterval;
	m_Settings.Latency = Clamp(m_Settings.Latency, m_Caps.LatencyMin, m_Caps.LatencyMax);
	m_Settings.UpdateInterval = Clamp(m_Settings.UpdateInterval, m_Caps.UpdateIntervalMin, m_Caps.UpdateIntervalMax);
	if(m_Caps.CanChannelMapping)
	{
		if(m_Settings.ChannelMapping.GetNumHostChannels() == 0)
		{
			// default mapping
			m_Settings.ChannelMapping = SoundDevice::ChannelMapping(m_Settings.Channels);
		}
		if(m_Settings.ChannelMapping.GetNumHostChannels() != m_Settings.Channels)
		{
			return false;
		}
	} else
	{
		m_Settings.ChannelMapping = SoundDevice::ChannelMapping(m_Settings.Channels);
	}
	m_Flags = SoundDevice::Flags();
	m_DeviceUnavailableOnOpen = false;
	m_BufferAttributes.Latency = m_Settings.Latency;
	m_BufferAttributes.UpdateInterval = m_Settings.UpdateInterval;
	m_BufferAttributes.NumBuffers = 0;
	m_RequestFlags.store(0);
	return InternalOpen();
}
示例#2
0
HRESULT MediaInfo::Open(LPCWSTR uri)
{
	ComPtr<IMFSourceResolver> resolver;
	HRESULT hr = MFCreateSourceResolver(&resolver);
	if (FAILED(hr))
		return hr;

	MF_OBJECT_TYPE objType = MF_OBJECT_INVALID;
	ComPtr<IUnknown> punk;
	hr = resolver->CreateObjectFromURL(uri, MF_RESOLUTION_MEDIASOURCE, NULL, &objType, &punk);
	if (FAILED(hr))
		return hr;
	if (objType != MF_OBJECT_MEDIASOURCE)
		return E_FAIL;

	return InternalOpen(punk.Get());
}
示例#3
0
HRESULT MediaInfo::Open(IMFByteStream* stream)
{
	ComPtr<IMFSourceResolver> resolver;
	HRESULT hr = MFCreateSourceResolver(&resolver);
	if (FAILED(hr))
		return hr;

	MF_OBJECT_TYPE objType = MF_OBJECT_INVALID;
	ComPtr<IUnknown> punk;
	hr = resolver->CreateObjectFromByteStream(stream, NULL,
		MF_RESOLUTION_MEDIASOURCE|MF_RESOLUTION_CONTENT_DOES_NOT_HAVE_TO_MATCH_EXTENSION_OR_MIME_TYPE,
		NULL, &objType, &punk);
	if (FAILED(hr))
		return hr;
	if (objType != MF_OBJECT_MEDIASOURCE)
		return E_FAIL;

	return InternalOpen(punk.Get());
}