Ejemplo n.º 1
0
//-------------------------------------------------------------------------
// Description:
//
//  GetCurrentEffectsSetting
//      Gets the current aggregate effects-enable setting
//
// Parameters:
//
//  properties - Property store holding configurable effects settings
//
//  pkeyEnable - VT_UI4 property holding an enable/disable setting
//
//  processingMode - Audio processing mode
//
// Return values:
//  LONG - true if the effect is enabled
//
// Remarks:
//  The routine considers the value of the specified property, the well known
//  master PKEY_AudioEndpoint_Disable_SysFx property, and the specified
//  processing mode.If the processing mode is RAW then the effect is off. If
//  PKEY_AudioEndpoint_Disable_SysFx is non-zero then the effect is off.
//
LONG GetCurrentEffectsSetting(IPropertyStore* properties, PROPERTYKEY pkeyEnable, GUID processingMode)
{
    HRESULT hr;
    BOOL enabled;
    PROPVARIANT var;

    PropVariantInit(&var);

    // Get the state of whether channel swap MFX is enabled or not. 

    // Check the master disable property defined by Windows
    hr = properties->GetValue(PKEY_AudioEndpoint_Disable_SysFx, &var);
    enabled = (SUCCEEDED(hr)) && !((var.vt == VT_UI4) && (var.ulVal != 0));

    PropVariantClear(&var);

    // Check the APO's enable property, defined by this APO.
    hr = properties->GetValue(pkeyEnable, &var);
    enabled = enabled && ((SUCCEEDED(hr)) && ((var.vt == VT_UI4) && (var.ulVal != 0)));

    PropVariantClear(&var);

    enabled = enabled && !IsEqualGUID(processingMode, AUDIO_SIGNALPROCESSINGMODE_RAW);

    return (LONG)enabled;
}
Ejemplo n.º 2
0
HRESULT FakeDevice::GetObjectIDsFromPersistentUniqueIDs(
            ACCESS_SCOPE                          Scope,
    _In_    IPortableDevicePropVariantCollection* pPersistentIDs,
    _In_    IPortableDevicePropVariantCollection* pObjectIDs)
{
    HRESULT hr      = S_OK;
    DWORD   dwCount = 0;

    if ((pPersistentIDs == NULL) ||
        (pObjectIDs     == NULL))
    {
        hr = E_POINTER;
        CHECK_HR(hr, ("Cannot have NULL parameter"));
        return hr;
    }

    // Iterate through the persistent ID list and add the equivalent object ID for each element.
    hr = pPersistentIDs->GetCount(&dwCount);
    CHECK_HR(hr, "Failed to get count from persistent ID collection");

    if (hr == S_OK)
    {
        PROPVARIANT pvPersistentID = {0};

        for(DWORD dwIndex = 0; dwIndex < dwCount; dwIndex++)
        {
            PropVariantInit(&pvPersistentID);

            hr = pPersistentIDs->GetAt(dwIndex, &pvPersistentID);
            CHECK_HR(hr, "Failed to get persistent ID at index %d", dwIndex);

            if (hr == S_OK)
            {
                hr = m_DeviceContent.GetObjectIDByPersistentID(Scope, pvPersistentID.pwszVal, pObjectIDs);
                CHECK_HR(hr, "Failed to get object ID from persistent unique ID '%ws'", pvPersistentID.pwszVal);
            }

            if (hr == HRESULT_FROM_WIN32(ERROR_NOT_FOUND))
            {
                PROPVARIANT pvEmptyObjectID = {0};
                pvEmptyObjectID.vt = VT_LPWSTR;
                pvEmptyObjectID.pwszVal = L"";

                // Insert empty string when object cannot be found
                hr = pObjectIDs->Add(&pvEmptyObjectID);
                CHECK_HR(hr, "Failed to set empty string for persistent unique ID '%ws' when object cannot be found", pvPersistentID.pwszVal);
            }

            PropVariantClear(&pvPersistentID);

            if(FAILED(hr))
            {
                break;
            }
        }
    }

    return hr;
}
Ejemplo n.º 3
0
static HRESULT LoadUnknownMetadata(IStream *input, const GUID *preferred_vendor,
    DWORD persist_options, MetadataItem **items, DWORD *item_count)
{
    HRESULT hr;
    MetadataItem *result;
    STATSTG stat;
    BYTE *data;
    ULONG bytesread;

    TRACE("\n");

    hr = IStream_Stat(input, &stat, STATFLAG_NONAME);
    if (FAILED(hr))
        return hr;

    data = HeapAlloc(GetProcessHeap(), 0, stat.cbSize.QuadPart);
    if (!data) return E_OUTOFMEMORY;

    hr = IStream_Read(input, data, stat.cbSize.QuadPart, &bytesread);
    if (bytesread != stat.cbSize.QuadPart) hr = E_FAIL;
    if (hr != S_OK)
    {
        HeapFree(GetProcessHeap(), 0, data);
        return hr;
    }

    result = HeapAlloc(GetProcessHeap(), 0, sizeof(MetadataItem));
    if (!result)
    {
        HeapFree(GetProcessHeap(), 0, data);
        return E_OUTOFMEMORY;
    }

    PropVariantInit(&result[0].schema);
    PropVariantInit(&result[0].id);
    PropVariantInit(&result[0].value);

    result[0].value.vt = VT_BLOB;
    result[0].value.u.blob.cbSize = bytesread;
    result[0].value.u.blob.pBlobData = data;

    *items = result;
    *item_count = 1;

    return S_OK;
}
//
//  Retrieves the device friendly name for a particular device in a device collection.
//
LPWSTR GetDeviceName(IMMDeviceCollection *DeviceCollection, UINT DeviceIndex)
{
    IMMDevice *device;
    LPWSTR deviceId;
    HRESULT hr;

    hr = DeviceCollection->Item(DeviceIndex, &device);
    if (FAILED(hr))
    {
        printf("Unable to get device %d: %x\n", DeviceIndex, hr);
        return NULL;
    }
    hr = device->GetId(&deviceId);
    if (FAILED(hr))
    {
        printf("Unable to get device %d id: %x\n", DeviceIndex, hr);
        return NULL;
    }

    IPropertyStore *propertyStore;
    hr = device->OpenPropertyStore(STGM_READ, &propertyStore);
    SafeRelease(&device);
    if (FAILED(hr))
    {
        printf("Unable to open device %d property store: %x\n", DeviceIndex, hr);
        return NULL;
    }

    PROPVARIANT friendlyName;
    PropVariantInit(&friendlyName);
    hr = propertyStore->GetValue(PKEY_Device_FriendlyName, &friendlyName);
    SafeRelease(&propertyStore);

    if (FAILED(hr))
    {
        printf("Unable to retrieve friendly name for device %d : %x\n", DeviceIndex, hr);
        return NULL;
    }

    wchar_t deviceName[128];
    hr = StringCbPrintf(deviceName, sizeof(deviceName), L"%s (%s)", friendlyName.vt != VT_LPWSTR ? L"Unknown" : friendlyName.pwszVal, deviceId);
    if (FAILED(hr))
    {
        printf("Unable to format friendly name for device %d : %x\n", DeviceIndex, hr);
        return NULL;
    }

    PropVariantClear(&friendlyName);
    CoTaskMemFree(deviceId);

    wchar_t *returnValue = _wcsdup(deviceName);
    if (returnValue == NULL)
    {
        printf("Unable to allocate buffer for return\n");
        return NULL;
    }
    return returnValue;
}
Ejemplo n.º 5
0
// ----------------------------------------------------------------------------
//
AudioVolumeController* AudioVolumeController::createVolumeController( )
{
    HRESULT hr;
    IMMDeviceEnumerator *pEnumerator = NULL;
    IMMDevice *pDefaultDevice = NULL;
    IAudioEndpointVolume *endpointVolume = NULL;
    LPWSTR pstrDefaultId = NULL;
    IPropertyStore *pProperties = NULL;

    try {
        hr = CoCreateInstance(
               CLSID_MMDeviceEnumerator, NULL,
               CLSCTX_ALL, IID_IMMDeviceEnumerator,
               (void**)&pEnumerator);
        AUDIO_VOLUME_ASSERT( hr, "Cannot create COM device enumerator instance" );

        // Get the default audio endpoint (if we don't get one its not an error)
        hr = pEnumerator->GetDefaultAudioEndpoint( eRender, eConsole, &pDefaultDevice );
        AUDIO_VOLUME_ASSERT( hr, "Cannot get default audio render device" );

        hr = pDefaultDevice->OpenPropertyStore( STGM_READ, &pProperties );
        AUDIO_VOLUME_ASSERT( hr, "Cannot open IMMDevice property store" );

        PROPVARIANT varName;
        // Initialize container for property value.
        PropVariantInit(&varName);

        // Get the endpoint's friendly-name property.
        hr = pProperties->GetValue( PKEY_Device_DeviceDesc , &varName);
        AUDIO_VOLUME_ASSERT( hr, "Cannot open IMMDevice name property" );

        CString render_name = CW2A( varName.pwszVal );

        DMXStudio::log_status( "Default audio render device '%s'", render_name );

        PropVariantClear(&varName);

        hr = pDefaultDevice->Activate( IID_IAudioEndpointVolume, CLSCTX_INPROC_SERVER, NULL, (LPVOID *)&endpointVolume );
        AUDIO_VOLUME_ASSERT( hr, "Cannot activate default render device" );

        SAFE_RELEASE( pDefaultDevice );
        SAFE_RELEASE( pProperties );
        SAFE_RELEASE( pEnumerator );

        CoTaskMemFree( pstrDefaultId );

        return new AudioVolumeController( endpointVolume, render_name );
    }
    catch ( ... ) {
        CoTaskMemFree( pstrDefaultId );

        SAFE_RELEASE( pDefaultDevice );
        SAFE_RELEASE( pProperties );
        SAFE_RELEASE( pEnumerator );

        throw;
    }
}
Ejemplo n.º 6
0
HRESULT CSwapAPOLFX::Initialize(UINT32 cbDataSize, BYTE* pbyData)
{
    HRESULT                         hr = S_OK;
    PROPVARIANT                     var;

    IF_TRUE_ACTION_JUMP( ((NULL == pbyData) && (0 != cbDataSize)), hr = E_INVALIDARG, Exit);
    IF_TRUE_ACTION_JUMP( ((NULL != pbyData) && (0 == cbDataSize)), hr = E_POINTER, Exit);
    IF_TRUE_ACTION_JUMP( (cbDataSize != sizeof(APOInitSystemEffects) ), hr = E_INVALIDARG, Exit);

    APOInitSystemEffects* papoSysFxInit = (APOInitSystemEffects*)pbyData;

    //
    //  Store locally for later reference
    //
    m_spAPOSystemEffectsProperties = papoSysFxInit->pAPOSystemEffectsProperties;

    //
    //  Get the current value
    //
    PropVariantInit(&var);

    if (m_spAPOSystemEffectsProperties != NULL)
    {
        // Get the state of whether channel swap LFX is enabled or not
        hr = m_spAPOSystemEffectsProperties->GetValue(PKEY_Endpoint_Enable_Channel_Swap_LFX, &var);

        if (SUCCEEDED(hr) && (var.vt == VT_UI4))
        {
            if (var.ulVal == 0L)
            {
                m_fEnableSwapLFX = FALSE;
            }
            else
            {
                m_fEnableSwapLFX = TRUE;
            }
        }
        else
        {
            PropVariantClear(&var);
        }
    }

    //
    //  Register for notification of registry updates
    //
    hr = m_spEnumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
    IF_FAILED_JUMP(hr, Exit);

    hr = m_spEnumerator->RegisterEndpointNotificationCallback(this);
    IF_FAILED_JUMP(hr, Exit);

     m_bIsInitialized = true;


Exit:
    return hr;
}
///////////////////////////////////////////////////////////////////////////
//
// Function:
//      EnumDevice
//
// Description:
//      Enumerate audio device and return the device information.
//
//  Parameters:
//      eDataFlow: eRender for render device, eCapture for capture device
//      uNumElements: Size of audio device info structure array.
//      pDevicInfo: device info structure array. Caller is responsible to allocate and free
//                  memory. The array size is specified by uNumElements.
//
// Return:
//      S_OK if successful
//
///////////////////////////////////////////////////////////////////////////////
HRESULT EnumDevice(EDataFlow eDataFlow, UINT uNumElements, AUDIO_DEVICE_INFO *pDevicInfo)
{
    HRESULT hResult = S_OK;
    WCHAR* pszDeviceId = NULL;
    PROPVARIANT value;
    UINT index, dwCount;
    bool IsMicArrayDevice;

    CComPtr<IMMDeviceEnumerator> spEnumerator;
    CComPtr<IMMDeviceCollection> spEndpoints;    

    hResult = spEnumerator.CoCreateInstance(__uuidof(MMDeviceEnumerator));
    IF_FAILED_JUMP(hResult, Exit);

    hResult = spEnumerator->EnumAudioEndpoints(eDataFlow, DEVICE_STATE_ACTIVE, &spEndpoints);
    IF_FAILED_JUMP(hResult, Exit);

    hResult = spEndpoints->GetCount(&dwCount);
    IF_FAILED_JUMP(hResult, Exit);

    if (dwCount != uNumElements)
        return E_INVALIDARG;

    ZeroMemory(pDevicInfo, sizeof(AUDIO_DEVICE_INFO)*uNumElements);
    
    for (index = 0; index < dwCount; index++)
    {
        CComPtr<IMMDevice> spDevice;
        CComPtr<IPropertyStore> spProperties;

        PropVariantInit(&value);

        hResult = spEndpoints->Item(index, &spDevice);
        IF_FAILED_JUMP(hResult, Exit);
         
        hResult = spDevice->GetId(&pszDeviceId);
        IF_FAILED_JUMP(hResult, Exit);

        hResult = spDevice->OpenPropertyStore(STGM_READ, &spProperties);
        IF_FAILED_JUMP(hResult, Exit);

        hResult = spProperties->GetValue(PKEY_Device_FriendlyName, &value);
        IF_FAILED_JUMP(hResult, Exit);

        EndpointIsMicArray(spDevice, IsMicArrayDevice);

        StringCchCopy(pDevicInfo[index].szDeviceID, MAX_STR_LEN-1, pszDeviceId);
        StringCchCopy(pDevicInfo[index].szDeviceName, MAX_STR_LEN-1, value.pwszVal);
        pDevicInfo[index].bIsMicArrayDevice = IsMicArrayDevice;
        
        PropVariantClear(&value);
        CoTaskMemFree(pszDeviceId);
        pszDeviceId = NULL;
    }

Exit:
    return hResult;
}
Ejemplo n.º 8
0
std::string CAESinkDirectSound::GetDefaultDevice()
{
  IMMDeviceEnumerator* pEnumerator = NULL;
  IMMDevice*           pDevice = NULL;
  IPropertyStore*      pProperty = NULL;
  HRESULT              hr;
  PROPVARIANT          varName;
  std::string          strDevName = "default";

  hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL, IID_IMMDeviceEnumerator, (void**)&pEnumerator);
  if (FAILED(hr))
  {
    CLog::Log(LOGERROR, __FUNCTION__": Could not allocate WASAPI device enumerator. CoCreateInstance error code: %s", WASAPIErrToStr(hr));
    goto failed;
  }

  hr = pEnumerator->GetDefaultAudioEndpoint(eRender, eMultimedia, &pDevice);
  if (FAILED(hr))
  {
    CLog::Log(LOGERROR, __FUNCTION__": Retrieval of audio endpoint enumeration failed.");
    goto failed;
  }

  hr = pDevice->OpenPropertyStore(STGM_READ, &pProperty);
  if (FAILED(hr))
  {
    CLog::Log(LOGERROR, __FUNCTION__": Retrieval of DirectSound endpoint properties failed.");
    goto failed;
  }

  PropVariantInit(&varName);
  hr = pProperty->GetValue(PKEY_AudioEndpoint_FormFactor, &varName);
  if (FAILED(hr))
  {
    CLog::Log(LOGERROR, __FUNCTION__": Retrieval of DirectSound endpoint form factor failed.");
    goto failed;
  }
  AEDeviceType aeDeviceType = winEndpoints[(EndpointFormFactor)varName.uiVal].aeDeviceType;
  PropVariantClear(&varName);

  hr = pProperty->GetValue(PKEY_AudioEndpoint_GUID, &varName);
  if (FAILED(hr))
  {
    CLog::Log(LOGERROR, __FUNCTION__": Retrieval of DirectSound endpoint GUID failed.");    
    goto failed;
  }

  strDevName = localWideToUtf(varName.pwszVal);
  PropVariantClear(&varName);

failed:

  SAFE_RELEASE(pProperty);
  SAFE_RELEASE(pDevice);
  SAFE_RELEASE(pEnumerator);

  return strDevName;
}
Ejemplo n.º 9
0
STDMETHODIMP tTVPPlayerCallback::Invoke( IMFAsyncResult *pAsyncResult ) {
	HRESULT hr;
	MediaEventType met = MESessionClosed;
	CComPtr<IMFMediaEvent> pMediaEvent;
	if( SUCCEEDED(hr = owner_->GetMediaSession()->EndGetEvent( pAsyncResult, &pMediaEvent )) ) {
		if( SUCCEEDED(hr = pMediaEvent->GetType(&met)) ) {
			PROPVARIANT pvValue;
			PropVariantInit(&pvValue);
			switch( met ) {
			case MESessionClosed:
				owner_->OnMediaItemCleared();
				break;
			case MESessionPaused:
				owner_->OnPause();
				break;
			case MESessionEnded:
				owner_->OnPlayBackEnded();
				break;
			case MESessionNotifyPresentationTime:
				break;
			case MESessionRateChanged:
				if( SUCCEEDED(pMediaEvent->GetValue( &pvValue )) ) {
					double value;
					if( FAILED(PropVariantToDouble(pvValue,&value)) ) {
						value = 1.0;
					}
					owner_->OnRateSet(value);
				} else {
					owner_->OnRateSet(1.0);
				}
				break;
			case MESessionScrubSampleComplete:
				break;
			case MESessionStarted:
				owner_->OnPlay();
				break;
			case MESessionStopped:
				owner_->OnStop();
				break;
			case MESessionStreamSinkFormatChanged:
				break;
			case MESessionTopologiesCleared:
				break;
			case MESessionTopologySet:
				break;
			case MESessionTopologyStatus: {
				UINT32 status = MF_TOPOSTATUS_INVALID;
				pMediaEvent->GetUINT32( MF_EVENT_TOPOLOGY_STATUS, &status );
				owner_->OnTopologyStatus(status);
				break;
				}
			}
			PropVariantClear(&pvValue);
		}
		owner_->GetMediaSession()->BeginGetEvent( this, NULL );
	}
	return S_OK;
}
void CWordBinaryMetadataDiscoveryWorker::DiscoverSummaryInformation(REFFMTID iidPropsertySet) 
{
	bool bNotFound;
	OpenPropertySet(iidPropsertySet, bNotFound);
	if(bNotFound)
	{
		ClosePropertySet();
		return;
	}

	if(NULL == m_pPropertyStg)
		throw Workshare::Exception(_T("NULL pointer encountered (m_pPropertyStg)"));

	IEnumSTATPROPSTG *pEnumProp;
	
	HRESULT hRes = m_pPropertyStg->Enum(&pEnumProp);
	if(FAILED(hRes))
	{
		ClosePropertySet();
		HandlePropertyError(_T(__FUNCTION__), _T("Enumerate user-defined properties failed"), hRes);
		return;
	}

	STATPROPSTG PropertyInformation;
	ZeroMemory(&PropertyInformation, sizeof(STATPROPSTG));
	PROPSPEC propSpec;
	PROPVARIANT propVar;

	SetCodePageProperty();

	while(S_OK == pEnumProp->Next(1, &PropertyInformation, NULL))
	{
		PropVariantInit(&propVar);
		// Build a PROPSPEC for this property.
		ZeroMemory(&propSpec, sizeof(PROPSPEC));
		propSpec.ulKind = PRSPEC_PROPID;
		propSpec.propid = PropertyInformation.propid;

		// Read this property.
		hRes = m_pPropertyStg->ReadMultiple(1, &propSpec, &propVar);
		if(SUCCEEDED(hRes))
		{
			if (FMTID_SummaryInformation == iidPropsertySet)
				AddBuiltInPropertyForSummary(propVar, PropertyInformation.propid);
			else if (FMTID_DocSummaryInformation == iidPropsertySet)
				AddBuiltInPropertyForDocSummary(propVar, PropertyInformation.propid);
		}
		else
		{
			CStdString sErr;
			sErr.Format(_T("Failed to read property id: %d, error code: %d"), propSpec.propid, hRes);
			LOG_WS_ERROR(sErr);
		}
	}
	pEnumProp->Release();
	ClosePropertySet();
}
/**
 *  This method is called when we receive a WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FORMATS
 *  command.  This message is sent when the client needs to know the possible formats supported
 *  by the specified content type (e.g. for image objects, the driver may choose to support JPEG and BMP files).
 *
 *  The parameters sent to us are:
 *  - WPD_PROPERTY_CAPABILITIES_CONTENT_TYPE - a GUID value containing the content type
 *    whose formats the caller is interested in.  If the value is WPD_CONTENT_TYPE_ALL, then the driver
 *    must return a list of all formats supported by the device.
 *
 *  The driver should:
 *  - Return an IPortableDevicePropVariantCollection (of type VT_CLSID) in
 *      WPD_PROPERTY_CAPABILITIES_FORMATS, indicating the formats supported by the
 *      specified content type.
 *      If there are no formats supported by the specified content type, the driver should return an
 *      empty collection.
 */
HRESULT WpdCapabilities::OnGetSupportedFormats(
    _In_ IPortableDeviceValues*  pParams,
    _In_ IPortableDeviceValues*  pResults)
{
    HRESULT hr              = S_OK;
    GUID    guidContentType = GUID_NULL;
    CComPtr<IPortableDevicePropVariantCollection> pFormats;

    // First get ALL parameters for this command.  If we cannot get ALL parameters
    // then E_INVALIDARG should be returned and no further processing should occur.

    // Get the content type whose supported formats have been requested
    if (hr == S_OK)
    {
        hr = pParams->GetGuidValue(WPD_PROPERTY_CAPABILITIES_CONTENT_TYPE, &guidContentType);
        CHECK_HR(hr, "Missing value for WPD_PROPERTY_CAPABILITIES_CONTENT_TYPE");
    }

    // CoCreate a collection to store the supported formats.
    if (hr == S_OK)
    {
        hr = CoCreateInstance(CLSID_PortableDevicePropVariantCollection,
                              NULL,
                              CLSCTX_INPROC_SERVER,
                              IID_IPortableDevicePropVariantCollection,
                              (VOID**) &pFormats);
        CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDevicePropVariantCollection");
    }

    // Add the supported formats for the specified content type to the collection.
    if (hr == S_OK)
    {
        PROPVARIANT pv = {0};
        PropVariantInit(&pv);
        // Don't call PropVariantClear, since we did not allocate the memory for these GUIDs

        if ((guidContentType   == WPD_CONTENT_TYPE_DOCUMENT) ||
            ((guidContentType  == WPD_CONTENT_TYPE_ALL)))
        {
            // Add WPD_OBJECT_FORMAT_TEXT to the supported formats collection
            pv.vt    = VT_CLSID;
            pv.puuid = (CLSID*)&WPD_OBJECT_FORMAT_TEXT;
            hr = pFormats->Add(&pv);
            CHECK_HR(hr, "Failed to add WPD_OBJECT_FORMAT_TEXT");
        }
    }

    // Set the WPD_PROPERTY_CAPABILITIES_FORMATS value in the results.
    if (hr == S_OK)
    {
        hr = pResults->SetIUnknownValue(WPD_PROPERTY_CAPABILITIES_FORMATS, pFormats);
        CHECK_HR(hr, "Failed to set WPD_PROPERTY_CAPABILITIES_FORMATS");
    }

    return hr;
}
Ejemplo n.º 12
0
//! Retrieves the value associated with pkey, if it exists.
QVariant ShellNodeInfo::propertyValue(const PROPERTYKEY &pkey)
{
    QVariant ret;
    PROPVARIANT var;
    PropVariantInit(&var);
    if (d->item->GetProperty(pkey, &var) == S_OK)
        ret = util::fromPROPVARIANT(var);
    PropVariantClear(&var);
    return ret;
}
Ejemplo n.º 13
0
void MFDecoderSourceReader::reset()
{
    if (!m_sourceReader)
        return;
    PROPVARIANT vPos;
    PropVariantInit(&vPos);
    vPos.vt = VT_I8;
    vPos.uhVal.QuadPart = 0;
    m_sourceReader->SetCurrentPosition(GUID_NULL, vPos);
}
Ejemplo n.º 14
0
//nog werk nodig! met de union!!
PROPVARIANT ConvertJavaToPropVariant(JNIEnv* env, jobject jobjPropVariant)
{
	//variabelen
	jclass cls;
	jmethodID mid;
	PROPVARIANT pv;
	jstring jsValue;
	LPWSTR wszBuffer;
	LPWSTR wszValue;
	jobject jobjObjectValue;


	//methode implementatie
	PropVariantInit(&pv);
	cls = env->FindClass("jmtp/PropVariant");
	//printf("convert 1\n");
	mid = env->GetMethodID(cls, "getVt", "()I");
	pv.vt = static_cast<VARTYPE>(env->CallIntMethod(jobjPropVariant, mid));
	//printf("convert 2\n");
	int strLength;
	switch(pv.vt)
	{
		case VT_LPWSTR:
			//printf("convert 3\n");
			mid = env->GetMethodID(cls, "getValue", "()Ljava/lang/Object;");
			jsValue = (jstring)env->CallObjectMethod(jobjPropVariant, mid);
			strLength = env->GetStringLength(jsValue);
			//printf("convert3.4:%d\n", strLength);
			wszBuffer = ConvertJavaStringToWCHAR(env, jsValue); //(WCHAR*)env->GetStringChars(jsValue, NULL);
			wszValue = new WCHAR[strLength+1];
			if (wszValue == NULL) {
				//printf("conver tproblem null\n");
			}
			for (int i = 0; i < strLength; i++) {
				wszValue[i] = wszBuffer[i];
			}
			wszValue[strLength] = 0;
			//wcscpy_s(wszValue, strLength, wszBuffer);
			//wprintf(L"convert3.5:%s\n", wszBuffer);
			//wprintf(L"convert3.6:%s\n", wszValue);
			delete wszBuffer;
			pv.pwszVal = wszValue;
			//wprintf(L"convert4:%s\n", pv.pwszVal);
			break;
		case VT_BOOL:
			mid = env->GetMethodID(cls, "getValue", "()Ljava/lang/Object;");
			jobjObjectValue = env->CallObjectMethod(jobjPropVariant, mid);
			mid = env->GetMethodID(env->FindClass("java/lang/Boolean"), "booleanValue", "()Z");
			pv.boolVal = env->CallBooleanMethod(jobjObjectValue, mid);
			break;
	}
	//andere types worden momenteel niet ondersteunt
	
	return pv;
}
Ejemplo n.º 15
0
void CMFCamCapture::runSession()
{
    PROPVARIANT var;
    PropVariantInit(&var);
    
    HRESULT hr = S_OK;
    CHECK_HR(hr = m_spSession->Start(&GUID_NULL, &var));

done:
    PropVariantClear(&var);
}
Ejemplo n.º 16
0
 //   SINGLE_CHANNEL_AEC = 0
 //   OPTIBEAM_ARRAY_ONLY = 2
 //   OPTIBEAM_ARRAY_AND_AEC = 4
 //   SINGLE_CHANNEL_NSAGC = 5
 void KinectAudioSource::SetSystemMode( LONG mode )
 {
     // Set AEC-MicArray DMO system mode.
     // This must be set for the DMO to work properly
     PROPVARIANT pvSysMode;
     PropVariantInit(&pvSysMode);
     pvSysMode.vt = VT_I4;
     pvSysMode.lVal = mode;
     CHECKHR(propertyStore_->SetValue(MFPKEY_WMAAECMA_SYSTEM_MODE, pvSysMode));
     PropVariantClear(&pvSysMode);
 }
Ejemplo n.º 17
0
HRESULT FakeDevice::GetFunctionalObjects(
    _In_    REFGUID                               guidFunctionalCategory,
    _In_    IPortableDevicePropVariantCollection* pFunctionalObjects)
{
    HRESULT     hr = S_OK;
    PROPVARIANT pv = {0};

    if(pFunctionalObjects == NULL)
    {
        hr = E_POINTER;
        CHECK_HR(hr, "Cannot have NULL parameter");
        return hr;
    }

    PropVariantInit(&pv);
    // Don't call PropVariantClear, since we did not allocate the memory for these object identifiers

    // Add WPD_DEVICE_OBJECT_ID to the functional object identifiers collection
    if ((guidFunctionalCategory  == WPD_FUNCTIONAL_CATEGORY_DEVICE) ||
        (guidFunctionalCategory  == WPD_FUNCTIONAL_CATEGORY_ALL))
    {
        pv.vt       = VT_LPWSTR;
        pv.pwszVal  = WPD_DEVICE_OBJECT_ID;
        hr = pFunctionalObjects->Add(&pv);
        CHECK_HR(hr, "Failed to add device object ID");
    }

    // Add CONTACTS_SERVICE_OBJECT_ID to the functional object identifiers collection
    if (hr == S_OK)
    {
        if ((guidFunctionalCategory  == SERVICE_Contacts) ||
            (guidFunctionalCategory  == WPD_FUNCTIONAL_CATEGORY_ALL))
        {
            pv.vt       = VT_LPWSTR;
            pv.pwszVal  = CONTACTS_SERVICE_OBJECT_ID;
            hr = pFunctionalObjects->Add(&pv);
            CHECK_HR(hr, "Failed to add contacts service object ID");
        }
    }

    // Add STORAGE_OBJECT_ID to the functional object identifiers collection
    // if request is not scoped by the contacts service
    if ((guidFunctionalCategory  == WPD_FUNCTIONAL_CATEGORY_STORAGE) ||
        (guidFunctionalCategory  == WPD_FUNCTIONAL_CATEGORY_ALL))
    {
        pv.vt       = VT_LPWSTR;
        pv.pwszVal  = STORAGE_OBJECT_ID;
        hr = pFunctionalObjects->Add(&pv);
        CHECK_HR(hr, "Failed to add storage object ID");
    }

    return hr;
}
Ejemplo n.º 18
0
/** Starts playback */
void FImfVideoPlayer::StartPlayback( )
{
	check( MediaSession != NULL );

	PROPVARIANT VariantStart;
	PropVariantInit( &VariantStart );

	HRESULT HResult = MediaSession->Start( &GUID_NULL, &VariantStart );
	check( SUCCEEDED( HResult ) );

	PropVariantClear( &VariantStart );
}
Ejemplo n.º 19
0
HRESULT CopyAttribute(IMFAttributes *pSrc, IMFAttributes *pDest, const GUID& key)
{
    PROPVARIANT var;
    PropVariantInit( &var );
    HRESULT hr = pSrc->GetItem(key, &var);
    if (SUCCEEDED(hr))
    {
        hr = pDest->SetItem(key, var);
        PropVariantClear(&var);
    }
    return hr;
}
Ejemplo n.º 20
0
void OleProperties::SetCodePageProperty(IPropertyStoragePtr& spPropertyStorage)
{
	PROPSPEC propSpecification = {0};
	propSpecification.ulKind = PRSPEC_PROPID;
	propSpecification.propid = PID_CODEPAGE;

	PROPVARIANT propVariant;
	PropVariantInit(&propVariant);
	HRESULT hResult = spPropertyStorage->ReadMultiple(1, &propSpecification, &propVariant);
	if (S_OK == hResult)
		m_wCodePage = propVariant.iVal;
}
void MediaPlayerPrivateMediaFoundation::seekDouble(double time)
{
    const double tenMegahertz = 10000000;
    PROPVARIANT propVariant;
    PropVariantInit(&propVariant);
    propVariant.vt = VT_I8;
    propVariant.hVal.QuadPart = static_cast<__int64>(time * tenMegahertz);
    
    HRESULT hr = m_mediaSession->Start(&GUID_NULL, &propVariant);
    ASSERT(SUCCEEDED(hr));
    PropVariantClear(&propVariant);
}
Ejemplo n.º 22
0
PLUGIN_EXPORT LPCWSTR GetString(void* data)
{
	static WCHAR result[256];
	wsprintf(result, L"ERROR");
	if (!InitCom() || !pEnumerator)
	{
		UnInitCom();
		wsprintf(result, L"ERROR - Initializing COM");
		return result;
	}

	IMMDevice * pEndpoint = 0;
	if (pEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &pEndpoint) == S_OK)
	{
		IPropertyStore * pProps = 0;
		if (pEndpoint->OpenPropertyStore(STGM_READ, &pProps) == S_OK)
		{
			PROPVARIANT varName;
			PropVariantInit(&varName);
			if (pProps->GetValue(PKEY_Device_DeviceDesc, &varName) == S_OK)
			{
				wcsncpy(result, varName.pwszVal, 255);
				PropVariantClear(&varName);
				SAFE_RELEASE(pProps)
				SAFE_RELEASE(pEndpoint)
				UnInitCom();
				return result;
			}
			else
			{
				PropVariantClear(&varName);
				SAFE_RELEASE(pProps)
				SAFE_RELEASE(pEndpoint)
				wsprintf(result, L"ERROR - Getting Device Description");
			}
		}
		else
		{
			SAFE_RELEASE(pProps)
			SAFE_RELEASE(pEndpoint)
			wsprintf(result, L"ERROR - Getting Property");
		}
	}
	else
	{
		SAFE_RELEASE(pEndpoint)
		wsprintf(result, L"ERROR - Getting Default Device");
	}

	UnInitCom();
	return result;
}
void CWordBinaryMetadataDiscoveryWorker::SetCodePageProperty()
{
	PROPSPEC propSpec;
	PROPVARIANT propVar;

	PropVariantInit(&propVar);
	ZeroMemory(&propSpec, sizeof(PROPSPEC));
	propSpec.ulKind = PRSPEC_PROPID;
	propSpec.propid = PID_CODEPAGE;
	HRESULT hRes = m_pPropertyStg->ReadMultiple(1, &propSpec, &propVar);
	if (hRes == S_OK)
		m_wCodePage = propVar.iVal;
}
Ejemplo n.º 24
0
BOOL PyObject_AsPROPVARIANT(PyObject *ob, PROPVARIANT *pVar)
{
	if (ob==Py_None) {
		PropVariantInit(pVar);
	} else if (ob==Py_True) {
		pVar->boolVal = -1;
		pVar->vt = VT_BOOL;
	} else if (ob==Py_False) {
		pVar->boolVal = 0;
		pVar->vt = VT_BOOL;
	} else if (PyLong_Check(ob)) {
		pVar->hVal.QuadPart = PyLong_AsLongLong(ob);
		if (pVar->hVal.QuadPart == -1 && PyErr_Occurred()){
		// Could still fit in an unsigned long long
			PyErr_Clear();
			pVar->uhVal.QuadPart = PyLong_AsUnsignedLongLong(ob);
			if (pVar->uhVal.QuadPart == -1 && PyErr_Occurred())
				return FALSE;
			pVar->vt = VT_UI8;
		}
		else{
			pVar->vt=VT_I8;
			// Could still fit in a regular long
			if (pVar->hVal.QuadPart >= LONG_MIN && pVar->hVal.QuadPart <= LONG_MAX){
				pVar->lVal = (long)pVar->hVal.QuadPart;
				pVar->vt = VT_I4;
			}
			// ... or an unsigned long
			else if (pVar->hVal.QuadPart >=0 && pVar->hVal.QuadPart <= ULONG_MAX){
				pVar->ulVal = (unsigned long)pVar->hVal.QuadPart;
				pVar->vt = VT_UI4;
			}
		}
#if (PY_VERSION_HEX < 0x03000000)
	// Not needed in Py3k, as PyInt_Check is defined to PyLong_Check
	} else if (PyInt_Check(ob)) {
		pVar->lVal = PyInt_AsLong(ob);
		pVar->vt = VT_I4;
#endif
	} else if (PyFloat_Check(ob)) {
		pVar->dblVal = PyFloat_AsDouble(ob);
		pVar->vt = VT_R8;
	} else if (PyUnicode_Check(ob) || PyString_Check(ob)) {
		PyWinObject_AsBstr(ob, &pVar->bstrVal);
		pVar->vt = VT_BSTR;
	} else {
		PyErr_SetString(PyExc_TypeError, "Unsupported object for PROPVARIANT");
		return FALSE;
	}
	return TRUE;
}
Ejemplo n.º 25
0
static void test_BodyDeleteProp(void)
{
    static const char topic[] = "wine topic";
    HRESULT hr;
    IMimeMessage *msg;
    IMimeBody *body;
    PROPVARIANT prop;

    hr = MimeOleCreateMessage(NULL, &msg);
    ok(hr == S_OK, "ret %08x\n", hr);

    PropVariantInit(&prop);

    hr = IMimeMessage_BindToObject(msg, HBODY_ROOT, &IID_IMimeBody, (void**)&body);
    ok(hr == S_OK, "ret %08x\n", hr);

    hr = IMimeBody_DeleteProp(body, "Subject");
    ok(hr == MIME_E_NOT_FOUND, "ret %08x\n", hr);

    hr = IMimeBody_DeleteProp(body, PIDTOSTR(PID_HDR_SUBJECT));
    ok(hr == MIME_E_NOT_FOUND, "ret %08x\n", hr);

    prop.vt = VT_LPSTR;
    prop.u.pszVal = CoTaskMemAlloc(strlen(topic)+1);
    strcpy(prop.u.pszVal, topic);
    hr = IMimeBody_SetProp(body, "Subject", 0, &prop);
    ok(hr == S_OK, "ret %08x\n", hr);
    PropVariantClear(&prop);

    hr = IMimeBody_DeleteProp(body, "Subject");
    ok(hr == S_OK, "ret %08x\n", hr);

    hr = IMimeBody_GetProp(body, "Subject", 0, &prop);
    ok(hr == MIME_E_NOT_FOUND, "ret %08x\n", hr);

    prop.vt = VT_LPSTR;
    prop.u.pszVal = CoTaskMemAlloc(strlen(topic)+1);
    strcpy(prop.u.pszVal, topic);
    hr = IMimeBody_SetProp(body, PIDTOSTR(PID_HDR_SUBJECT), 0, &prop);
    ok(hr == S_OK, "ret %08x\n", hr);
    PropVariantClear(&prop);

    hr = IMimeBody_DeleteProp(body, PIDTOSTR(PID_HDR_SUBJECT));
    ok(hr == S_OK, "ret %08x\n", hr);

    hr = IMimeBody_GetProp(body, PIDTOSTR(PID_HDR_SUBJECT), 0, &prop);
    ok(hr == MIME_E_NOT_FOUND, "ret %08x\n", hr);

    IMimeBody_Release(body);
    IMimeMessage_Release(msg);
}
Ejemplo n.º 26
0
const QHash<QString, QString> WASAPISystem::getDevices(EDataFlow dataflow) {
	QHash<QString, QString> devices;

	HRESULT hr;

	IMMDeviceEnumerator *pEnumerator = NULL;
	IMMDeviceCollection *pCollection = NULL;

	hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), reinterpret_cast<void **>(&pEnumerator));

	if (! pEnumerator || FAILED(hr)) {
		qWarning("WASAPI: Failed to instatiate enumerator");
	} else {
		hr = pEnumerator->EnumAudioEndpoints(dataflow, DEVICE_STATE_ACTIVE, &pCollection);
		if (! pCollection || FAILED(hr)) {
			qWarning("WASAPI: Failed to enumerate");
		} else {
			devices.insert(QString(), tr("Default Device"));

			UINT ndev = 0;
			pCollection->GetCount(&ndev);
			for (unsigned int idx=0;idx<ndev;++idx) {
				IMMDevice *pDevice = NULL;
				IPropertyStore *pStore = NULL;

				pCollection->Item(idx, &pDevice);
				pDevice->OpenPropertyStore(STGM_READ, &pStore);

				LPWSTR strid = NULL;
				pDevice->GetId(&strid);

				PROPVARIANT varName;
				PropVariantInit(&varName);

				pStore->GetValue(PKEY_Device_FriendlyName, &varName);

				devices.insert(QString::fromWCharArray(strid), QString::fromWCharArray(varName.pwszVal));

				PropVariantClear(&varName);
				CoTaskMemFree(strid);

				pStore->Release();
				pDevice->Release();
			}
			pCollection->Release();
		}
		pEnumerator->Release();
	}

	return devices;
}
STDMETHODIMP CLocationReport::GetValue(REFPROPERTYKEY pKey, PROPVARIANT *pValue)
{
    HRESULT hr = S_OK;

    // properties for civic address reports
    if (pKey.pid == SENSOR_DATA_TYPE_ADDRESS1.pid)
    {
        hr = InitPropVariantFromString(m_address1, pValue);
    } 
    else if (pKey.pid == SENSOR_DATA_TYPE_ADDRESS2.pid)
    {    
        hr = InitPropVariantFromString(m_address2, pValue);
    }
    else if (pKey.pid == SENSOR_DATA_TYPE_CITY.pid)
    {
        hr = InitPropVariantFromString(m_city, pValue);
    }
    else if (pKey.pid == SENSOR_DATA_TYPE_STATE_PROVINCE.pid)
    {
        hr = InitPropVariantFromString(m_stateprovince, pValue);
    } 
    else if (pKey.pid == SENSOR_DATA_TYPE_POSTALCODE.pid)
    {
        hr = InitPropVariantFromString(m_postalcode, pValue);
    }
    else if (pKey.pid == SENSOR_DATA_TYPE_COUNTRY_REGION.pid)    
    {
        hr = InitPropVariantFromString(m_countryregion, pValue);
    }
    // properties for latitude/longitude reports
    else if (pKey.pid == SENSOR_DATA_TYPE_LATITUDE_DEGREES.pid)
    {
        hr = InitPropVariantFromDouble(m_latitude, pValue);
    } 
    else if (pKey.pid == SENSOR_DATA_TYPE_LONGITUDE_DEGREES.pid)
    {
        hr = InitPropVariantFromDouble(m_longitude, pValue);
    }
    else if (pKey.pid == SENSOR_DATA_TYPE_ERROR_RADIUS_METERS.pid)    
    {
        hr = InitPropVariantFromDouble(m_errorradius, pValue);
    }
    else 
    {
        hr = HRESULT_FROM_WIN32(ERROR_NO_DATA);
        PropVariantInit(pValue);
    }

    return hr;
}
Ejemplo n.º 28
0
// Private method
// dwKeyName means:
// 0 DeviceDesc (main name)
// 1 DeviceInterface_FriendlyName (interface name)
// 2 Device_FriendlyName (main name + interface name)
void _GetDeviceName(IMMDevice *pDevice, LPWSTR pszBuffer, int bufferLen, DWORD dwKeyName)
{
    static const WCHAR szDefault[] = L"<Device not available>";

    HRESULT hr = E_FAIL;
    IPropertyStore *pProps = NULL;
    PROPVARIANT varName;

    // Initialize container for property value.
    PropVariantInit(&varName);

    // assert(pszBuffer != NULL);
    // assert(bufferLen > 0);
	// assert(dwKeyName == 0 || dwKeyName == 1 || dwKeyName == 2);

    if (pDevice != NULL)
    {
        hr = pDevice->OpenPropertyStore(STGM_READ, &pProps);
        if (hr == S_OK)
        {
			switch (dwKeyName) {
				case 0:
                    hr = pProps->GetValue(PKEY_Device_DeviceDesc, &varName);
					break;
				case 1:
                    hr = pProps->GetValue(PKEY_DeviceInterface_FriendlyName, &varName);
					break;
				case 2:
                    hr = pProps->GetValue(PKEY_Device_FriendlyName, &varName);
					break;
			}
        }
    }

    if (hr == S_OK)
    {
        // Found the device name.
        wcsncpy_s(pszBuffer, bufferLen, varName.pwszVal, _TRUNCATE);
    }
    else
    {
        // Failed to find the device name.
        wcsncpy_s(pszBuffer, bufferLen, szDefault, _TRUNCATE);
    }

    PropVariantClear(&varName);
    SAFE_RELEASE(pProps);

    return;
}
Ejemplo n.º 29
0
/////////////////////////////////////////////////////////////////////////
//
// GetStoredApplicationOrder()
//
// Retrieves the gadget order from the property store.  The memory must
// be CoTaskMemFree'd by the caller.
//
// Parameters:
//      ppAppIds [out]
//          A pointer to an array of APPLICATION_IDs that upon return will
//          contain the application IDs in the order that they should be
//          presented on the device
//      pcAppIds [out]
//          A pointer to a DWORD that upon return will contain the count of
//          APPLICATION_ID contained in the array pointed to by ppAppIds.
//
// Return Values:
//      S_OK: Success
//
/////////////////////////////////////////////////////////////////////////
HRESULT CWssBasicDDI::GetStoredApplicationOrder(APPLICATION_ID** ppAppIds,
                                                DWORD* pcAppIds)
{
    if ((NULL == m_pUserSID) ||
        (0 == IsValidSid(m_pUserSID)) ||
        (NULL == m_pPropertyStore))
    {
        return E_UNEXPECTED;
    }

    HRESULT hr = S_OK;
    LPTSTR wszKey = NULL;

    // Initialize out parameters
    *ppAppIds = NULL;
    *pcAppIds = 0;

    //
    // Get the key to use for the property store
    //
    hr = GetApplicationOrderString(&wszKey);

    //
    // Put the data into a PROPVARIANT, and store it in the property store
    //
    if ((SUCCEEDED(hr)) && (NULL != wszKey))
    {
        PROPVARIANT pvBlob = {0};

        PropVariantInit(&pvBlob);

        hr = m_pPropertyStore->GetNamedValue(wszKey, &pvBlob);
        if (SUCCEEDED(hr) &&
            (VT_BLOB == pvBlob.vt) &&
            (0 == (pvBlob.blob.cbSize % sizeof(APPLICATION_ID))))
        {
            *pcAppIds = pvBlob.blob.cbSize / sizeof(APPLICATION_ID);
            *ppAppIds = (APPLICATION_ID*)pvBlob.blob.pBlobData;
        }

        // Don't clear the PROPVARIANT because we don't want to erase the memory that we pass out of this method
    }

    if (NULL != wszKey)
    {
        ::CoTaskMemFree(wszKey);
    }

    return hr;
}
/**
 *  This method is called when we receive a WPD_COMMAND_CAPABILITIES_GET_SUPPORTED_FUNCTIONAL_CATEGORIES
 *  command.
 *
 *  The parameters sent to us are:
 *  - none.
 *
 *  The driver should:
 *  - Return an IPortableDevicePropVariantCollection (of type VT_CLSID) in
 *      WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORIES, containing
 *      the supported functional categories for this device.
 */
HRESULT WpdCapabilities::OnGetFunctionalCategories(
    _In_ IPortableDeviceValues*  pParams,
    _In_ IPortableDeviceValues*  pResults)
{
    HRESULT hr = S_OK;
    CComPtr<IPortableDevicePropVariantCollection> pFunctionalCategories;

    UNREFERENCED_PARAMETER(pParams);

    // CoCreate a collection to store the supported functional categories.
    if (hr == S_OK)
    {
        hr = CoCreateInstance(CLSID_PortableDevicePropVariantCollection,
                              NULL,
                              CLSCTX_INPROC_SERVER,
                              IID_IPortableDevicePropVariantCollection,
                              (VOID**) &pFunctionalCategories);
        CHECK_HR(hr, "Failed to CoCreate CLSID_PortableDevicePropVariantCollection");
    }

    // Add the supported functional categories to the collection.
    if (hr == S_OK)
    {
        for (DWORD dwIndex = 0; dwIndex < ARRAYSIZE(g_SupportedFunctionalCategories); dwIndex++)
        {
            PROPVARIANT pv = {0};
            PropVariantInit(&pv);
            // Don't call PropVariantClear, since we did not allocate the memory for these GUIDs

            pv.vt    = VT_CLSID;
            pv.puuid = (GUID*) &g_SupportedFunctionalCategories[dwIndex];

            hr = pFunctionalCategories->Add(&pv);
            CHECK_HR(hr, "Failed to add supported functional category at index %d", dwIndex);
            if (FAILED(hr))
            {
                break;
            }
        }
    }

    // Set the WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORIES value in the results.
    if (hr == S_OK)
    {
        hr = pResults->SetIUnknownValue(WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORIES, pFunctionalCategories);
        CHECK_HR(hr, "Failed to set WPD_PROPERTY_CAPABILITIES_FUNCTIONAL_CATEGORIES");
    }

    return hr;
}