none
IMediaObject->ProcessOutput problem RRS feed

  • Question

  • Hi everyone!

    I have a problem with audio detection with Kinect.

    DMO->ProcessOutput returns the error code 0x800401F0.

    I give up and have no idea how to solve it.

    There is full code:

    Set audio stream

    /// <summary>
    /// Start processing stream
    /// </summary>
    /// <returns>Indicates success or failure</returns>
    bool UKinect::setAudioStream()
    {
        // Get the audio source
        hr = sensor->NuiGetAudioSource(&pNuiAudioSource);
        if (FAILED(hr))
        {
    		cerr <<"[UKinect] ERROR: Failed to get Audio Source." << endl;
            return false;
        }
    
        hr = pNuiAudioSource->QueryInterface(IID_IMediaObject, (void**)&pDMO);
        if (FAILED(hr))
        {
    		cerr <<"[UKinect] ERROR: Failed to access the DMO (in audio)." << endl;
            return false;
        }
    
        hr = pNuiAudioSource->QueryInterface(IID_IPropertyStore, (void**)&pPropertyStore);
        if (FAILED(hr))
        {
    		cerr <<"[UKinect] ERROR: Failed to access the Audio Property store." << endl;
            return false;
        }
    
        // Set AEC-MicArray DMO system mode. This must be set for the DMO to work properly.
        // Possible values are:
        //   SINGLE_CHANNEL_AEC = 0
        //   OPTIBEAM_ARRAY_ONLY = 2
        //   OPTIBEAM_ARRAY_AND_AEC = 4
        //   SINGLE_CHANNEL_NSAGC = 5
        PROPVARIANT pvSysMode;
        PropVariantInit(&pvSysMode);
        pvSysMode.vt = VT_I4;
        pvSysMode.lVal = (LONG)(4); // Use OPTIBEAM_ARRAY_ONLY setting. Set OPTIBEAM_ARRAY_AND_AEC instead if you expect to have sound playing from speakers.
        pPropertyStore->SetValue(MFPKEY_WMAAECMA_SYSTEM_MODE, pvSysMode);
        PropVariantClear(&pvSysMode);
    
        // Set DMO output format
        WAVEFORMATEX wfxOut = {AudioFormat, AudioChannels, AudioSamplesPerSecond, AudioAverageBytesPerSecond, AudioBlockAlign, AudioBitsPerSample, 0};
        DMO_MEDIA_TYPE mt = {0};
        hr = MoInitMediaType(&mt, sizeof(WAVEFORMATEX));
        if (FAILED(hr))
        {
    		cerr <<"[UKinect] ERROR: Init audio media type structure." << endl;
            return false;
        }
    
        mt.majortype = MEDIATYPE_Audio;
        mt.subtype = MEDIASUBTYPE_PCM;
        mt.lSampleSize = 0;
        mt.bFixedSizeSamples = TRUE;
        mt.bTemporalCompression = FALSE;
        mt.formattype = FORMAT_WaveFormatEx;	
        memcpy_s(mt.pbFormat, sizeof(WAVEFORMATEX), &wfxOut, sizeof(WAVEFORMATEX));
    
        hr = pDMO->SetOutputType(0, &mt, 0); 
    	if (FAILED(hr))
        {
    		cerr <<"[UKinect] ERROR: Set audio output type." << endl;
            return false;
        }
        MoFreeMediaType(&mt);
    
    	cout <<"[UKinect] INFO: Audio stream has been created."<< endl;
    
        return true;
    }

    and pooling function called every 20-50ms

    /// <summary>
    /// Get the audio readings from the stream
    /// </summary>
    bool UKinect::poolAudio()
    {
        if (pNuiAudioSource && pDMO)
        {
            // Set buffer
            DWORD dwStatus;
            DMO_OUTPUT_DATA_BUFFER outputBuffer = {0};
            outputBuffer.pBuffer = &captureBuffer;
    
            do
            { 
                captureBuffer.Init(0);
                outputBuffer.dwStatus = 0;
    
                // Process audio data
                hr = pDMO->ProcessOutput(0, 1, &outputBuffer, &dwStatus);
    			if (FAILED(hr))
    			{
    				cout << hex << hr << endl;
    				return false;
    			}
    				
    				
    				
    					
                if (S_OK == hr)
                {
                    // Get the reading
                    double beamAngle, sourceAngle, sourceConfidence;
                    if (SUCCEEDED(pNuiAudioSource->GetBeam(&beamAngle)) && SUCCEEDED(pNuiAudioSource->GetPosition(&sourceAngle, &sourceConfidence)))
                    {
                        // Set reading to UVars
    					audioBeamAngle = static_cast<float>((180.0 * beamAngle) / M_PI);
    					audioSourceAngle = static_cast<float>((180.0 * sourceAngle) / M_PI);
    					audioSourceConfidence = sourceConfidence;
                    } else {
    					cerr <<"[UKinect] ERROR: Getting audio beam, position and source." << endl;
    					return false;
    				}
    			} else {
    				cerr <<"[UKinect] ERROR: Process audio output." << endl;
    				return false;
    			}
            } while (outputBuffer.dwStatus & DMO_OUTPUT_DATA_BUFFERF_INCOMPLETE); //Check if there is still remaining data
        } else {
    		cerr <<"[UKinect] ERROR: Pool audio." << endl;
    		return false;
    	}
    	return true;
    }


    Wednesday, August 7, 2013 1:12 PM

Answers

All replies