void plAgeInfoStruct::Read( hsStream * s, hsResMgr* )
{
    s->LogSubStreamStart("push me");
    s->LogReadLE( &fFlags ,"AgeInfoStruct Flags");
    if ( IsFlagSet( kHasAgeFilename ) ) {
        s->LogSubStreamPushDesc("AgeFilename");
        plMsgStdStringHelper::Peek(fAgeFilename,s);
    }
    if ( IsFlagSet( kHasAgeInstanceName ) ) {
        s->LogSubStreamPushDesc("AgeInstanceName");
        plMsgStdStringHelper::Peek(fAgeInstanceName,s);
    }
    if ( IsFlagSet( kHasAgeInstanceGuid ) ) {
        s->LogSubStreamPushDesc("AgeInstanceGuid");
        fAgeInstanceGuid.Read( s );
    }
    if ( IsFlagSet( kHasAgeUserDefinedName ) ){
        s->LogSubStreamPushDesc("UserDefinedName");
        plMsgStdStringHelper::Peek(fAgeUserDefinedName,s);
    }
    if ( IsFlagSet( kHasAgeSequenceNumber ) ) {
        s->LogReadLE( &fAgeSequenceNumber ,"AgeSequenceNumber");
    }
    if ( IsFlagSet( kHasAgeDescription ) ) {
        s->LogSubStreamPushDesc("AgeDescription");
        plMsgStdStringHelper::Peek(fAgeDescription,s);
    }
    if ( IsFlagSet( kHasAgeLanguage ) ) {
        s->LogReadLE( &fAgeLanguage ,"AgeLanguage");
    }
    UpdateFlags();
    s->LogSubStreamEnd();
}
void HistogramTransformation::Make24BitLUT( uint16* lut ) const
{
   if ( lut == 0 )
      return;

   UpdateFlags();

   int numberOfThreads = m_parallel ? Min( int( m_maxProcessors ), Thread::NumberOfThreads( uint24_max+1, 256 ) ) : 1;
   int itemsPerThread = (uint24_max + 1)/numberOfThreads;
   bool useAffinity = m_parallel && Thread::IsRootThread();

   PArray<LUT2416Thread> threads;
   for ( int i = 0, j = 1; i < numberOfThreads; ++i, ++j )
      threads.Add( new LUT2416Thread( lut, *this,
                                      i*itemsPerThread, (j < numberOfThreads) ? j*itemsPerThread : uint24_max+1 ) );
   if ( numberOfThreads > 1 )
   {
      for ( int i = 0; i < numberOfThreads; ++i )
         threads[i].Start( ThreadPriority::DefaultMax, useAffinity ? i : -1 );
      for ( int i = 0; i < numberOfThreads; ++i )
         threads[i].Wait();
   }
   else
      threads[0].Run();
}
Example #3
0
//--------------------------------------------------------------------------
void WindowsWindow::Term()
{
	if (m_hHandle)
	{
		m_kNode.detach();
		m_spParent = nullptr;
		for (auto child : m_kChildList)
		{
			WindowsWindow* pkChild = VeDynamicCast(WindowsWindow, child);
			VE_ASSERT(pkChild);
			pkChild->Term();
		}
		VE_ASSERT(m_kChildList.empty());
		if (!VE_MASK_HAS_ALL(m_u32Flags, VE_WINDOW_FOREIGN))
		{
			if (!DestroyWindow(m_hHandle))
			{
				THROW("Couldn't destory window");
			}
		}
		m_hHandle = nullptr;
		UpdateFlags();
	}
	VE_ASSERT(!m_kNode.is_attach());
}
Example #4
0
//--------------------------------------------------------------------------
void WindowsWindow::Hide() noexcept
{
	if (IsValid() && IsVisible())
	{
		VE_ASSERT_NE(ShowWindow(m_hHandle, SW_HIDE), 0);
		UpdateFlags();
	}
}
Example #5
0
//--------------------------------------------------------------------------
void WindowsWindow::Show() noexcept
{
	if (IsValid() && IsHidden())
	{
		VE_ASSERT_EQ(ShowWindow(m_hHandle, SW_SHOW), 0);
		UpdateFlags();
	}
}
Example #6
0
GXBOOL GXImageImpl::Initialize(GTexture*pTexture)
{
  m_pNativeTex = pTexture;
  m_pNativeTex->AddRef();
  m_eFormat = pTexture->GetFormat();
  //pTexture->GetRatio((GXINT*)&m_nWidth, (GXINT*)&m_nHeight);
  UpdateDimension();
  ASSERT(m_nWidth > 0 && m_nHeight > 0);

  UpdateFlags();

  return TRUE;
}
Example #7
0
IRenderPass* EffectTechnique::RemovePass( StringRef name )
{
	IRenderPass* result=GetPassByName(name);
	if (result!=nullptr)
	{
		mRenderPasses.Remove(result);
		mRenderPassDict.RemoveKey(name);
		result->SetTechnique(nullptr);
		bool isValid=result->Release();
		UpdateFlags();
        return isValid?result:nullptr;
	}
	return result;
}
void HistogramTransformation::Make20BitLUT( uint16* lut ) const
{
   if ( lut == 0 )
      return;

   UpdateFlags();

   for ( uint32 i = 0; i <= uint20_max; ++i )
   {
      double f = double( i )/uint20_max;
      Transform( f );
      for ( transformation_list::const_iterator j = m_transformChain.Begin(); j != m_transformChain.End(); ++j )
         j->Transform( f );
      *lut++ = uint16( RoundInt( f*uint16_max ) );
   }
}
Example #9
0
void EffectTechnique::AddPass( IRenderPass* pass )
{
	IRenderPass* result=GetPassByName(pass->Name());
	if (result!=nullptr)
	{
		MEDUSA_ASSERT_FAILED("Duplicate add pass");
	}

	if (!pass->Name().IsEmpty())
	{
		mRenderPassDict.Add(pass->Name(),pass);
	}
	mRenderPasses.Add(pass);
	pass->Retain();
	pass->SetTechnique(this);

	UpdateFlags();
}
void plAgeInfoStruct::Write( hsStream * s, hsResMgr* )
{
    UpdateFlags();
    s->WriteLE( fFlags );
    if ( IsFlagSet( kHasAgeFilename ) )
        plMsgStdStringHelper::Poke(fAgeFilename,s);
    if ( IsFlagSet( kHasAgeInstanceName ) )
        plMsgStdStringHelper::Poke(fAgeInstanceName,s);
    if ( IsFlagSet( kHasAgeInstanceGuid ) )
        fAgeInstanceGuid.Write( s );
    if ( IsFlagSet( kHasAgeUserDefinedName ) )
        plMsgStdStringHelper::Poke(fAgeUserDefinedName,s);
    if ( IsFlagSet( kHasAgeSequenceNumber ) )
        s->WriteLE( fAgeSequenceNumber );
    if ( IsFlagSet( kHasAgeDescription ) )
        plMsgStdStringHelper::Poke(fAgeDescription,s);
    if ( IsFlagSet( kHasAgeLanguage ) )
        s->WriteLE( fAgeLanguage );
}
Example #11
0
GXBOOL GXImageImpl::Initialize(GXBOOL bRenderable, LPGXIMAGEINFOX pSrcFile/*貌似没用上*/, GXLPVOID lpBits)
{
  if(m_pNativeTex == NULL)
  {
    GXDWORD dwUsage = bRenderable ? GXRU_TEX_RENDERTARGET|GXRU_FREQUENTLYREAD : NULL;
    m_pGraphics->CreateTexture(&m_pNativeTex, NULL, m_nWidth, m_nHeight, 1, m_eFormat, dwUsage);

    // 如果参数是屏幕比率值, 就翻译为实际尺寸
    //if(m_nWidth < 0 || m_nHeight < 0)
    //  m_pNativeTex->GetDimension((GXUINT*)&m_nWidth, (GXUINT*)&m_nHeight);
    UpdateDimension();


    GXUINT nHelpWidth = 0, nHelpHeight = 0;
    if(bRenderable != FALSE || lpBits != NULL)
    {
      m_pNativeTex->GetDimension(&nHelpWidth, &nHelpHeight);
      m_pGraphics->CreateTexture(&m_pHelperTex, NULL, nHelpWidth, nHelpHeight, 1, m_eFormat, GXRU_SYSTEMMEM);
      ASSERT(m_pHelperTex != NULL);
    }

    if(lpBits != NULL)
    {
      GTexture::LOCKEDRECT lr;
      if(m_eFormat == GXFMT_A8R8G8B8)
      {
        if(m_pHelperTex->LockRect(&lr, NULL, 0)) {
          memcpy(lr.pBits, lpBits, nHelpWidth * nHelpHeight * 4);  // TODO: 应该加上一个尺寸转换
          m_pHelperTex->UnlockRect();
        }
        SetHelperState(HS_Fetch, NULL);
      }
      else
        ASSERT(m_eFormat);
    }
  }
  UpdateFlags();
  return TRUE;
}
void HistogramTransformation::Apply( Histogram& dstH, const Histogram& srcH ) const
{
   UpdateFlags();

   dstH.Allocate();
   dstH.m_histogram = 0;
   dstH.m_peakLevel = 0;

   if ( srcH.IsEmpty() )
      return;

   for ( int i = 0; i < srcH.m_resolution; ++i )
   {
      double f = double( i )/(srcH.m_resolution - 1);
      Transform( f );
      for ( transformation_list::const_iterator j = m_transformChain.Begin(); j != m_transformChain.End(); ++j )
         j->Transform( f );
      dstH.m_histogram[RoundInt( f*(dstH.m_resolution - 1) )] += srcH.m_histogram[i];
   }

   dstH.UpdatePeakLevel();
}
bool plAgeInfoStruct::IsEqualTo( const plAgeInfoStruct * other ) const
{
    UpdateFlags();
    other->UpdateFlags();

    // if we both have guids, just compare them.
    if ( HasAgeInstanceGuid() && other->HasAgeInstanceGuid() )
        return fAgeInstanceGuid.IsEqualTo( other->GetAgeInstanceGuid() );
    // otherwise compare everything.
    bool match = true;
    if (match && HasAgeFilename() && other->HasAgeFilename())
        match = match && ( stricmp( GetAgeFilename(), other->GetAgeFilename() )==0 );
    if (match && HasAgeInstanceName() && other->HasAgeInstanceName())
        match = match && ( stricmp( GetAgeInstanceName(), other->GetAgeInstanceName() )==0 );
    if (match && HasAgeUserDefinedName() && other->HasAgeUserDefinedName())
        match = match && ( stricmp( GetAgeUserDefinedName(), other->GetAgeUserDefinedName() )==0 );
    if (match && HasAgeSequenceNumber() && other->HasAgeSequenceNumber())
        match = match && fAgeSequenceNumber==other->GetAgeSequenceNumber();
    if (match && HasAgeLanguage() && other->HasAgeLanguage())
        match = match && fAgeLanguage==other->GetAgeLanguage();
    // don't compare description fields
    return match;
}
Example #14
0
//--------------------------------------------------------------------------
void WindowsWindow::Init(WindowsVideo& kVideo, const char* pcTitle,
	int32_t x, int32_t y, int32_t w, int32_t h, uint32_t u32Flags)
{
	Term();
	LPWSTR lpwstrTitle = WindowsVideo::UTF8ToWSTR(pcTitle);
	DWORD dwStyle = FlagsToWindowStyle(u32Flags);

	int32_t flag_x = x >> 28;
	int32_t flag_y = y >> 28;
	x = flag_x ? 0 : x;
	y = flag_y ? 0 : y;
	RECT windowRect = { x, y, w, h };
	AdjustWindowRect(&windowRect, dwStyle, FALSE);

	VE_ASSERT(w > 0 && w < UINT16_MAX && h > 0 && h < UINT16_MAX);
	m_u16Width = (uint16_t)w;
	m_u16Height = (uint16_t)h;

	w = windowRect.right - windowRect.left;
	h = windowRect.bottom - windowRect.top;

	switch (flag_x)
	{
	case 1:
		x = CW_USEDEFAULT;
		break;
	case 2:
		x = (GetSystemMetrics(SM_CXSCREEN) - w) >> 1;
		break;
	default:
		x = windowRect.left;
		break;
	}
	switch (flag_y)
	{
	case 1:
		y = CW_USEDEFAULT;
		break;
	case 2:
		y = (GetSystemMetrics(SM_CYSCREEN) - h) >> 1;
		break;
	default:
		y = windowRect.top;
		break;
	}

	x = x == CW_USEDEFAULT ? x : vtd::max(x, 0);
	y = y == CW_USEDEFAULT ? y : vtd::max(y, 0);

	m_hHandle = CreateWindowW(kVideo.m_wstrClassName, lpwstrTitle, dwStyle,
		x, y, w, h, nullptr, nullptr, kVideo.m_hInstance, this);

	VeFree(lpwstrTitle);

	if (!m_hHandle)
	{
		m_u16Width = 0;
		m_u16Height = 0;
		THROW("Couldn't create window");
	}

	if (VE_MASK_HAS_ALL(u32Flags, VE_WINDOW_SHOWN))
	{
		int32_t i32Show = SW_SHOW;
		if (VE_MASK_HAS_ALL(dwStyle, WS_THICKFRAME))
		{
			switch (u32Flags & 0xF)
			{
			case VE_WINDOW_MINIMIZED:
				i32Show = SW_SHOWMINIMIZED;
				break;
			case VE_WINDOW_MAXIMIZED:
				i32Show = SW_SHOWMAXIMIZED;
				break;
			case VE_WINDOW_DEPSTARTUP:
				i32Show = kVideo.m_i32CmdShow;
				break;
			default:
				break;
			}
		}
		ShowWindow(m_hHandle, i32Show);
	}

	m_u32Flags = u32Flags & (VE_WINDOW_ALLOW_HIGHDPI | VE_WINDOW_FOREIGN);
	UpdateFlags();

	kVideo.m_kWindowList.attach_back(m_kNode);
}
Example #15
0
void R2Texture::
Update (void)
{
  // Update flags
  UpdateFlags(RN_NO_FLAGS);
}
Example #16
0
// this involves positioning of the hud elements so i'm assuming magicka and stamina
// will need separate positions below the health bar.
void ObjectWidget::UpdateComponent(GFxMovieView * view, float * depth)
{
	TESForm * form = LookupFormByID(formId);
	if(form) {
		TESObjectREFR * reference = DYNAMIC_CAST(form, TESForm, TESObjectREFR);
		if(reference) {
			NiPoint3 markerPos;
			reference->GetMarkerPosition(&markerPos);
			markerPos.z += 25;

			float x_out = 0.0;
			float y_out = 0.0;
			float z_out = 0.0;

			GRectF rect = view->GetVisibleFrameRect();

			WorldPtToScreenPt3_Internal(g_worldToCamMatrix, g_viewPort, &markerPos, &x_out, &y_out, &z_out, 1e-5);

			// Move component, update component stats
			y_out = 1.0 - y_out; // Flip y for Flash coordinate system
			y_out = rect.top + (rect.bottom - rect.top) * y_out;
			x_out = rect.left + (rect.right - rect.left) * x_out;

			*depth = z_out;

			bool isVisible = false;
			bool isFriendly = false;
			QueryState(reference, &isVisible, &isFriendly);

			if ((g_hudExtension->hudFlags & HUDExtension::kFlags_HideName) == HUDExtension::kFlags_HideName || (flags & ObjectWidget::kFlag_HideName) == ObjectWidget::kFlag_HideName) {
				params[kProperty_Name].SetString("");
				UpdateText();
			} else {
				const char * text = CALL_MEMBER_FN(reference, GetReferenceName)();
				if (params[kProperty_Name].GetString() != text) {
					params[kProperty_Name].SetString(text);
					UpdateText();
				}
			}

			if ((flags & ObjectWidget::kFlag_UseHostility) == ObjectWidget::kFlag_UseHostility) {
				bool nowFriendly = IsFriendly();
				if (nowFriendly && !isFriendly) { // Turned hostile
					flags &= ~ObjectWidget::kFlag_Friendly;
					UpdateFlags();
					UpdateColors();
				}
				else if (!nowFriendly && isFriendly) { // Turned friendly
					flags |= ObjectWidget::kFlag_Friendly;
					UpdateFlags();
					UpdateColors();
				}
			}

			double scale = min(((100 - z_out * 100) * 10), 50);//(1.0 - z_out) * 100;//min(((100 - z_out * 100) * 10), 50);
			if(object.IsDisplayObject()) {
				GFxValue::DisplayInfo dInfo;
				dInfo.SetPosition(x_out, y_out);
				dInfo.SetScale(scale, scale);
				dInfo.SetVisible(isVisible);
				object.SetDisplayInfo(&dInfo);

				if((flags & kFlag_UpdatePercent) == kFlag_UpdatePercent)
					UpdateValues();
			}
		}
	}
}
int ste_adm_hw_handler_u8500(sqlite3* db_p, hw_handler_dev_next_fp_t dev_next_fp, hw_handler_dev_to_dev_next_fp_t dev_next_d2d_fp, fadeSpeed_t fadeSpeed)
{
    SRV_DBG_ASSERT_IS_NOT_WORKER_THREAD;
    SRV_DBG_ASSERT_IS_SERIALIZED_REQUEST;

    const char* name = NULL;
    char* dev_names = NULL;
    int ret = 0;
    int ret_func = STE_ADM_RES_ALSA_ERROR;
    char *command = NULL;
    char* data = NULL;
    int is_input, nDev_combo, idx_data;
    bool activeFMRx = false;
    bool activeFMTx = false;
    bool activeOutputDev = false;
    bool activeInputDev = false;
    bool activeInputDev_MIC = false;
    const char* dev_top = NULL;
    bool controls_open = false;

    ALOG_INFO("%s: Enter.", __func__);

    // Make sure that the settings that is written from ADM is not overwritten
    // by any sink or source
    audio_hal_alsa_set_ignore_defaults(true);

    // Create SQL-statement
    ClearFlags();
    command = malloc(1024 * sizeof(char));
    memset(command, 0, 1024);

    nDev_combo = 0;
    strcat(command, "SELECT * FROM HW_Settings_Combo WHERE (Codec = '");
    strcat(command, codec_name_ab8500_p);
    strcat(command, "')");
    while (dev_next_fp(&name) == 0) {
        if (strcmp(name, STE_ADM_DEVICE_STRING_FMRX) == 0) {
            activeFMRx = true;
        } else if (strcmp(name, STE_ADM_DEVICE_STRING_FMTX) == 0) {
            activeFMTx = true;
        } else if (is_asoc_device(name)) {
            if (adm_db_io_info(name, &is_input) != STE_ADM_RES_OK) {
                ALOG_INFO("%s: Warning: Device direction not found for device %s!", __func__, name);
            } else {
                if (is_input == 1) {
                    activeInputDev = true;
                    if (strcmp(name, STE_ADM_DEVICE_STRING_MIC) == 0) {
                        activeInputDev_MIC = true;
                    }
                } else {
                    activeOutputDev = true;
                }
            }
            UpdateFlags(name);
            nDev_combo++;
            strcat(command, " AND ('");
            strcat(command, name);
            strcat(command, "' IN (Dev1, Dev2, Dev3, Dev4, Dev5, Dev6)) ");
        }
    }

    // Become worker thread before opening ALSA controls (to avoid having the
    // "normal-thread" lock at the same time as the ALSA lock)
    srv_become_worker_thread();

    if (audio_hal_alsa_open_controls(card_name_p) < 0) {
        ALOG_ERR("%s: ERROR: Unable to open ALSA-card '%s'!\n", __func__, card_name_p);
        goto cleanup_worker;
    }
    controls_open = true;

    if (nDev_combo == 0) {
        strcat(command, " AND (Dev1 ='')");
    }
    strcat(command, " ORDER BY rowid LIMIT 1");

    /* Combo-data */
    idx_data = GetComboDataIndex(db_p, command);
    if (idx_data == -1) {
        ALOG_INFO("%s: WARNING: Data-index not found (idx_data = %d)!", __func__, idx_data);
        ret_func = STE_ADM_RES_OK;
        goto cleanup_worker;
    }

    data = GetData(db_p, idx_data);
    if (data == NULL) {
        ALOG_ERR("%s: ERROR: Failed to get data with index = %d!", __func__, idx_data);
        goto cleanup_worker;
    }

    ALOG_INFO("%s: Write HW-settings from file to ALSA-interface.", __func__);
    ret = audio_hal_alsa_set_controls_cfg((const char*)data);
    if (ret < 0) {
        ALOG_ERR("%s: ERROR: Failed to write HW-settings! ste_adm_hw_handler_alsa_set_controls returned %d.", __func__, ret);
        goto cleanup_worker;
    }

    if (data != NULL) {
        free(data);
        data = NULL;
    }

    /* Device-data */
    while (dev_next_fp(&name) == 0) {
        if (strlen(name) == 0)
            continue;

        ret = adm_db_toplevel_mapping_get(name, &dev_top);
        if (ret < 0) {
            ALOG_INFO("%s: ERROR: Unable to find top-level device for '%s'!\n", __func__, name);
            ret_func = ret;
            goto cleanup_worker;
        }
        ALOG_INFO("%s: '%s' maps to '%s'\n", __func__, name, dev_top);

        idx_data = GetDeviceDataIndex(db_p, dev_top);
        if (idx_data == -1) {
            ALOG_INFO("%s: No top-level device-specific data exists for '%s'!", __func__, dev_top);
            continue;
        }

        if (data != NULL) {
            free(data);
            data = NULL;
        }
        data = GetData(db_p, idx_data);
        if (data == NULL) {
            ALOG_ERR("%s: ERROR: Failed to get data with index = %d!", __func__, idx_data);
            goto cleanup_worker;
        }

        // Set Digital Gain Fade Speed Switch
        audio_hal_alsa_set_control("Digital Gain Fade Speed Switch", 0, fadeSpeed);

        ALOG_INFO("%s: Write HW-settings for device '%s'.", __func__, dev_top);
        ret = audio_hal_alsa_set_controls_cfg((const char*)data);
        if (ret < 0) {
            ALOG_ERR("%s: ERROR: Failed to write HW-settings! ste_adm_hw_handler_alsa_set_controls returned %d.", __func__, ret);
            goto cleanup_worker;
        }
    };

    /* Appending device to device connections */
    AppendD2D(db_p, dev_next_d2d_fp);
    ExecuteFlags();

    /* FM-devices */
    if (activeFMRx || activeFMTx) {
        ALOG_INFO("%s: FM-device active!", __func__);

        if (activeFMRx) {
            configure_fm_t config;

            if (FM_TYPE_DIGITAL == fmrx_type) {
                ALOG_INFO("%s: FMRx digital active! Setting DA-from-slot and AD-to-slot mapping...", __func__);

                config.type = AUDIO_HAL_DIGITAL;

                audio_hal_alsa_set_control("Digital Interface AD 5 Loopback Switch", 0, 1);
                audio_hal_alsa_set_control("Digital Interface AD 6 Loopback Switch", 0, 1);
                audio_hal_alsa_set_control("Digital Interface AD To Slot 6 Map", 0, 4); // REG_ADSLOTSELX_AD_OUT5_TO_SLOT_EVEN
                audio_hal_alsa_set_control("Digital Interface AD To Slot 7 Map", 0, 5); // REG_ADSLOTSELX_AD_OUT6_TO_SLOT_ODD
                audio_hal_alsa_set_control("Digital Interface DA 7 From Slot Map", 0, 24); // Slot 24 -> DA_IN7
                audio_hal_alsa_set_control("Digital Interface DA 8 From Slot Map", 0, 25); // Slot 25 -> DA_IN8
            } else {
                ALOG_INFO("%s: FMRx analog active! Setting DA-from-slot and AD-to-slot mapping...", __func__);

                config.type = AUDIO_HAL_ANALOG;

                audio_hal_alsa_set_control("Digital Interface AD 5 Loopback Switch", 0, 0);
                audio_hal_alsa_set_control("Digital Interface AD 6 Loopback Switch", 0, 0);
                audio_hal_alsa_set_control("Digital Interface AD To Slot 6 Map", 0, 0);
                audio_hal_alsa_set_control("Digital Interface AD To Slot 7 Map", 0, 1);
                audio_hal_alsa_set_control("AD 1 Select Capture Route", 0, 0);
                audio_hal_alsa_set_control("AD 2 Select Capture Route", 0, 0);
                audio_hal_alsa_set_control("Mic 2 or LINR Select Capture Route", 0, 1);
                audio_hal_alsa_set_control("LineIn Left", 0, 1);
                audio_hal_alsa_set_control("LineIn Right", 0, 1);
            }
            audio_hal_configure_channel(AUDIO_HAL_CHANNEL_FMRX, &config);

        } else if (activeFMTx) {
            ALOG_INFO("%s: FMTx active! Setting DA-from-slot and AD-to-slot mapping...", __func__);
            audio_hal_alsa_set_control("Digital Interface AD 5 Loopback Switch", 0, 1);
            audio_hal_alsa_set_control("Digital Interface AD 6 Loopback Switch", 0, 1);
            audio_hal_alsa_set_control("Digital Interface AD To Slot 16 Map", 0, 4); // REG_ADSLOTSELX_AD_OUT5_TO_SLOT_EVEN
            audio_hal_alsa_set_control("Digital Interface AD To Slot 17 Map", 0, 5); // REG_ADSLOTSELX_AD_OUT6_TO_SLOT_ODD
            audio_hal_alsa_set_control("Digital Interface DA 7 From Slot Map", 0, 14); // Slot 14 -> DA_IN7
            audio_hal_alsa_set_control("Digital Interface DA 8 From Slot Map", 0, 15); // Slot 15 -> DA_IN8
        }
    }

    /* Input-devices */
    if (activeInputDev) {
        int ADSel_slot0 = 2; // REG_ADSLOTSELX_AD_OUT3_TO_SLOT_EVEN
        int ADSel_slot1 = 1; // REG_ADSLOTSELX_AD_OUT2_TO_SLOT_ODD
        ALOG_INFO("%s: Input-device active!", __func__);
        if (activeInputDev_MIC) {
            int nChannels = GetMICChannelCount(db_p, STE_ADM_DEVICE_STRING_MIC);
            if (mic_type == MICROPHONE_TYPE_DIGITAL) {
                ALOG_INFO("%s: Device MIC actice (mic_type = MICROPHONE_TYPE_DIGITAL, nChannels = %d).", __func__, nChannels);
                ADSel_slot0 = 0;
                ADSel_slot1 = 1;
                audio_hal_alsa_set_control("AD 1 Select Capture Route", 0, 1); // DMic 1
                if (nChannels > 1)
                    audio_hal_alsa_set_control("AD 2 Select Capture Route", 0, 1); // DMic 2
            } else {
                ALOG_INFO("%s: Device MIC active (mic_type = MICROPHONE_TYPE_ANALOG, nChannels = %d).", __func__, nChannels);
                audio_hal_alsa_set_control("AD 3 Select Capture Route", 0, 0); // Mic 1
                if (nChannels > 1) {
                    audio_hal_alsa_set_control("AD 2 Select Capture Route", 0, 0); // LineIn (Mic 2)
                    audio_hal_alsa_set_control("Mic 2 or LINR Select Capture Route", 0, 0); // Mic 2
                } else {
                    // Force dual mono
                    ADSel_slot0 = 2; // REG_ADSLOTSELX_AD_OUT3_TO_SLOT_EVEN
                    ADSel_slot1 = 2; // REG_ADSLOTSELX_AD_OUT3_TO_SLOT_ODD
                }
            }
            audio_hal_alsa_set_control("DMic 1", 0, mic_type == MICROPHONE_TYPE_DIGITAL);
            audio_hal_alsa_set_control("DMic 2", 0, (mic_type == MICROPHONE_TYPE_DIGITAL) && (nChannels > 1));
            audio_hal_alsa_set_control("Mic 1", 0, mic_type != MICROPHONE_TYPE_DIGITAL);
            audio_hal_alsa_set_control("Mic 2", 0, (mic_type != MICROPHONE_TYPE_DIGITAL) && (nChannels > 1));
        }
        audio_hal_alsa_set_control("Digital Interface AD To Slot 0 Map", 0, ADSel_slot0);
        audio_hal_alsa_set_control("Digital Interface AD To Slot 1 Map", 0, ADSel_slot1);
    }

    /* Output-devices */
    if (activeOutputDev) {
        ALOG_INFO("%s: Output-device active! Setting DA from Slot mapping...", __func__);
        audio_hal_alsa_set_control("Digital Interface DA 1 From Slot Map", 0, 8); // Slot 8 -> DA_IN1
        audio_hal_alsa_set_control("Digital Interface DA 2 From Slot Map", 0, 9); // Slot 9 -> DA_IN2
        audio_hal_alsa_set_control("Digital Interface DA 3 From Slot Map", 0, 10); // Slot 10 -> DA_IN3
        audio_hal_alsa_set_control("Digital Interface DA 4 From Slot Map", 0, 11); // Slot 11 -> DA_IN4
        audio_hal_alsa_set_control("Digital Interface DA 5 From Slot Map", 0, 12); // Slot 12 -> DA_IN5
        audio_hal_alsa_set_control("Digital Interface DA 6 From Slot Map", 0, 13); // Slot 13 -> DA_IN6
    }

    ret_func = STE_ADM_RES_OK;

cleanup_worker:
    if (controls_open) {
        audio_hal_alsa_close_controls();
    }
    srv_become_normal_thread();

    if (command != NULL) free(command);
    if (dev_names != NULL) free(dev_names);
    if (data != NULL) free(data);

    ALOG_INFO("%s: Exit (%s).", __func__, (ret_func == STE_ADM_RES_OK) ? "OK" : "ERROR");

    return ret_func;
}
Example #18
0
//______________________________________________________________________________
void QAtrainsim(Int_t run = 0,
             const char *xmlfile   = "wn.xml",
             Int_t  stage          = 0, /*0 = QA train, 1...n - merging stage*/
             const char *cdb     = "raw://")
{
  run_number = run;

  ProcessEnvironment();

  //
  // set OCDB source
  TString ocdbConfig = "default,snapshot";
  if (gSystem->Getenv("CONFIG_OCDB"))
    ocdbConfig = gSystem->Getenv("CONFIG_OCDB");
  if (stage != 0) {
    //
    gSystem->Setenv("CONFIG_RUN", gSystem->Getenv("ALIEN_JDL_LPMRUNNUMBER"));
    // set OCDB 
    gROOT->LoadMacro("$ALIDPG_ROOT/MC/OCDBConfig.C");
    OCDBDefault(1);
  }
  else if (ocdbConfig.Contains("alien") || ocdbConfig.Contains("cvmfs")) {
    // set OCDB 
    gROOT->LoadMacro("$ALIDPG_ROOT/MC/OCDBConfig.C");
    OCDBDefault(1);
  }
  else {
    // set OCDB snapshot mode
    AliCDBManager *cdbm = AliCDBManager::Instance();
    cdbm->SetSnapshotMode("OCDBrec.root");
  }
  printf("------ Run QAtrainsim.C for collision type %s ------\n",CollisionSystem[iCollisionType]);


  UpdateFlags();
  
  TString cdbString(cdb);
  if (cdbString.Contains("raw://") && !ocdbConfig.Contains("cvmfs")) {
    TGrid::Connect("alien://");
    if (!gGrid || !gGrid->IsConnected()) {
      ::Error("QAtrain", "No grid connection");
      return;
    }
  }
  // gSystem->SetIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT -I$ALICE_PHYSICS -I$ALICE_PHYSICS/include -I$ALICE_PHYSICS/PWGPP/TRD/macros");
  // Set temporary merging directory to current one
  gSystem->Setenv("TMPDIR", gSystem->pwd());
  // Set temporary compilation directory to current one
  gSystem->SetBuildDir(gSystem->pwd(), kTRUE);
  // Load libraries
  // LoadLibraries();
  printf("Include path: %s\n", gSystem->GetIncludePath());
  // Create manager
  AliAnalysisManager *mgr  = new AliAnalysisManager("PilotAnalysis_sim", "Production train");
  mgr->SetRunFromPath(run_number);
  // Input handler
  AliESDInputHandlerRP *esdHandler = new AliESDInputHandlerRP();
  esdHandler->SetReadFriends(kTRUE);
  esdHandler->SetActiveBranches("ESDfriend");
  mgr->SetInputEventHandler(esdHandler);
  mgr->SetDebugLevel(debug_level);
  
  // Monte Carlo handler
  AliMCEventHandler* mcHandler = new AliMCEventHandler();
  mgr->SetMCtruthEventHandler(mcHandler);
  mcHandler->SetPreReadMode(1);
  mcHandler->SetReadTR(kTRUE);

  // subsidiary handler for mc-to-mc embedding
  TString bgDir = gSystem->Getenv("CONFIG_BGEVDIR");
  if (!bgDir.IsNull()) { // add extra handler for underlaying event
    if (bgDir.BeginsWith("alien://") && !gGrid && !TGrid::Connect("alien://")) {
      printf("Failed to create a grid connection\n");
      abort();
    }
    if (!bgDir.EndsWith("/")) bgDir += "/";
    AliMCEventHandler* mcHandlerBg = new AliMCEventHandler();
    mcHandlerBg->SetInputPath(bgDir.Data());
    mcHandlerBg->SetPreReadMode(1);
    mcHandlerBg->SetReadTR(kTRUE);
    mcHandler->AddSubsidiaryHandler(mcHandlerBg);
  }
  
  // AnalysisTasks
  //  mgr->Lock();
  mgr->SetFileInfoLog("fileinfo.log"); 
  AddAnalysisTasks(cdb);
  //  mgr->UnLock();
  //  mcHandler = (AliMCEventHandler*)mgr->GetMCtruthEventHandler();
  //  mcHandler->SetReadTR(kTRUE);
  //  mcHandler->SetPreReadMode(1);
  if (stage>0) {
    QAmerge(xmlfile, stage);
    return;
  }   
  // Input chain
  TChain *chain = new TChain("esdTree");
  chain->Add("AliESDs.root");
  TStopwatch timer;
  timer.Start();
  if (mgr->InitAnalysis()) {                                                                                                              
    mgr->PrintStatus(); 
    mgr->SetSkipTerminate(kTRUE);
  //   mgr->SetNSysInfo(1);
    mgr->StartAnalysis("local", chain);
  }
  timer.Print();
}
Example #19
0
//______________________________________________________________________________
void AODtrain(Int_t merge=0)
{
  // Main analysis train macro.
  ProcessEnvironment();

  UpdateFlags();

  PrintSettings();

  if (merge || doCDBconnect) {
    TGrid::Connect("alien://");
    if (!gGrid || !gGrid->IsConnected()) {
      ::Error("AODtrain", "No grid connection");
      return;
    }
  }
  // Set temporary merging directory to current one
  gSystem->Setenv("TMPDIR", gSystem->pwd());
  // Set temporary compilation directory to current one
  gSystem->SetBuildDir(gSystem->pwd(), kTRUE);
   printf("==================================================================\n");
   printf("===========    RUNNING FILTERING TRAIN   ==========\n");
   printf("===========    Collision System is %s    ==========\n",CollisionSystem[iCollision]);
   printf("==================================================================\n");
   printf("=  Configuring analysis train for:                               =\n");
   if (usePhysicsSelection)   printf("=  Physics selection                                                =\n");
   if (useTender)    printf("=  TENDER                                                        =\n");
   if (iESDfilter)   printf("=  ESD filter                                                    =\n");
   if (iMUONcopyAOD) printf("=  MUON copy AOD                                                 =\n");
   if (iJETAN)       printf("=  Jet analysis                                                  =\n");
   if (iJETANdelta)  printf("=     Jet delta AODs                                             =\n");
   if (iPWGHFvertexing) printf("=  PWGHF vertexing                                                =\n");
   if (iPWGDQJPSIfilter) printf("=  PWGDQ j/psi filter                                             =\n");
   if (iPWGHFd2h) printf("=  PWGHF D0->2 hadrons QA                                     =\n");

   // Make the analysis manager and connect event handlers
   AliAnalysisManager *mgr  = new AliAnalysisManager("Analysis Train", "Production train");
    mgr->SetCacheSize(0);
   if (useSysInfo) {
      //mgr->SetNSysInfo(100);
      AliSysInfo::SetVerbose(kTRUE);
   }   
   // Create input handler (input container created automatically)
   // ESD input handler
   AliESDInputHandler *esdHandler = new AliESDInputHandler();
   mgr->SetInputEventHandler(esdHandler);       
   // Monte Carlo handler
   if (useMC) {
      AliMCEventHandler* mcHandler = new AliMCEventHandler();
      mgr->SetMCtruthEventHandler(mcHandler);
      mcHandler->SetReadTR(useTR); 
   }   
   // AOD output container, created automatically when setting an AOD handler
   if (iAODhandler) {
      // AOD output handler
      AliAODHandler* aodHandler   = new AliAODHandler();
      aodHandler->SetOutputFileName("AliAOD.root");
      mgr->SetOutputEventHandler(aodHandler);
   }
   // Debugging if needed
   if (useDBG) mgr->SetDebugLevel(3);

   AddAnalysisTasks(cdbPath);
   if (merge) {
      AODmerge();
      mgr->InitAnalysis();
      mgr->SetGridHandler(new AliAnalysisAlien);
      mgr->StartAnalysis("gridterminate",0);
      return;
   }   
   // Run the analysis                                                                                                                     
   //
   TChain *chain = CreateChain();
   if (!chain) return;
                                                                                                                                                   
   TStopwatch timer;
   timer.Start();
   mgr->SetSkipTerminate(kTRUE);
   if (mgr->InitAnalysis()) {
      mgr->PrintStatus();
      mgr->StartAnalysis("local", chain);
   }
   timer.Print();
}