⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 o_karaoke.c

📁 Zoran V966 DVD 解码 Soc芯片的源程序
💻 C
📖 第 1 页 / 共 3 页
字号:
/* **************************************************************************************
*  Copyright (c) 2005 ZORAN Corporation, All Rights Reserved
*  THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
*
*  File: $Workfile: o_karaoke.c$
*
* Description:
* ========
* Project definition of the MSO_KARAOKE
*
****************************************************************************************/
#include "Config.h"				// Global Configuration - do not remove!
#include "Include\SysDefs.h"	// Global definition - do not remove!

#ifdef _DEBUG
#undef IFTRACE
#define IFTRACE if (gTraceUI)
#include "Debug\DbgMain.h"
#endif //_DEBUG

#ifdef INTERNAL_KARAOKE

/***************************************************************************************
* Include files
****************************************************************************************/
#include <stdio.h>
#include <string.h>
#include "include\sysdefs.h"
#include "Playcore\Coremain\coregdef.h"
#include "Playcore\Ps\Ps.h"

//Include API Files
#include "CoreAPI\CoreAPI.h"

// Included UI LOW LEVEL files

// Included UI MENU SYSTEM files
#include "GUI\Menu_system\ms_object.h"
#include "GUI\Menu_system\osd_rendering.h"
#include "GUI\Menu_system\ms_screen.h"
#include "GUI\Menu_system\ms_menu.h"
#include "GUI\Menu_system\ms_component.h"
#include "GUI\Menu_system\ms_container.h"
#include "GUI\Menu_system\ms_display.h"

#include "GUI\Object_class\Text\mso_text.h"
#include "GUI\Object_class\Hscroll\mso_hscroll_text.h"
#include "GUI\Object_class\Page\mso_page.h"
#include "GUI\Object_class\Button\mso_button.h"
#include "GUI\Object_class\Vlist\mso_vlist.h"
#include "GUI\Object_class\Choice\mso_choice.h"
#include "GUI\Object_class\Hslider\mso_hslider.h"

// Included CUSTOMER files
#include "Components\Message\o_message_handler.h"
#include "Resource\Bitmap\bitmap.h"
#include "Menu\menu_operation_def.h"
#include "Menu_config\menu_config_common.h"

// Included string related files
#include "Library\String_generate.h"
#include "Library\Number.h"
#include "Strings\Strings.h"
#include "Library\Container_misc.h"


#ifndef DEBUG_UI_TRACE
#undef dbg_printf(sMsg)
#define dbg_printf(sMsg)
#undef	dbgm_printf(sMsg, mode)
#define dbgm_printf(sMsg, mode)
#endif

// Include the module header file
#include "Components\Karaoke\o_karaoke.h"
// Include custom header file: customer specific definitions, over-writing common ones.
#include "Components\Karaoke\o_karaoke_config.h"
// Include configuration header file: named constants, macros and typedefs.
#include "Components\Custom\Karaoke\o_karaoke_custom.h"


/***************************************************************************************
* 	Utility functions
****************************************************************************************/
static BOOL _AddItemsToKaraokeKit(MSO_VLIST __NEAR* pList);
STATIC int _CalculateKeyShift(int iHardwareValue);
STATIC int _CalculateEcho(int iHardwareValue);

/***************************************************************************************
* 	Operation functions
****************************************************************************************/
static MS_OP _KaraokeOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
static MS_OP _KaraokeKitOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
static MS_OP _KaraokekitVlistOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
static MS_OP _KaraokeOnOffChoiceOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);

#ifdef D_KARAOKE_LRMODE
static MS_OP _LRModeChoiceOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
#endif//D_KARAOKE_LRMODE

static MS_OP _KeyShiftHSliderOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
static MS_OP _EchoHSliderOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
static MS_OP _VoiceCancelChoiceOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);

#ifdef D_KARAOKE_MELODY
static MS_OP _MelodyChoiceOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
#endif//D_KARAOKE_MELODY

#ifdef D_KARAOKE_MIC_EFFECT
static MS_OP _MicEffectChoiceOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
#endif//D_KARAOKE_MIC_EFFECT

#ifdef D_VOCAL_SUPPORT_ENABLED
static MS_OP _VocalEffectChoiceOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
#endif // D_VOCAL_SUPPORT_ENABLED

/***************************************************************************************
* 	Display functions
****************************************************************************************/
static BOOL _KaraokeFillOSDSeg(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea);

/***************************************************************************************
* 	Choice item action functions
****************************************************************************************/
STATIC void _KaraokeOnOffChoiceAction(MSO_OBJECT __NEAR* pThis, enMutatorType eType, UINT16 wValue);
#ifdef D_KARAOKE_LRMODE
STATIC void _LRModeChoiceAction(MSO_OBJECT __NEAR* pThis, enMutatorType eType, UINT16 wValue);
#endif//D_KARAOKE_LRMODE
STATIC UINT16 _KeyShiftSliderAction(HSLIDER_ACTION eType, UINT16 wValue);
STATIC UINT16 _EchoSliderAction(HSLIDER_ACTION eType, UINT16 wValue);
STATIC void _VoiceCancelChoiceAction(MSO_OBJECT __NEAR* pThis, enMutatorType eType, UINT16 wValue);
#ifdef D_KARAOKE_MELODY
STATIC void _MelodyChoiceAction(MSO_OBJECT __NEAR* pThis, enMutatorType eType, UINT16 wValue);
#endif//D_KARAOKE_MELODY

#ifdef D_KARAOKE_MIC_EFFECT
STATIC void _MicEffectChoiceAction(MSO_OBJECT __NEAR* pThis, enMutatorType eType, UINT16 wValue);
#endif//D_KARAOKE_MIC_EFFECT

#ifdef  D_VOCAL_SUPPORT_ENABLED
STATIC void  _VocalEffectChoiceAction(MSO_OBJECT __NEAR* pThis, enMutatorType eType, UINT16 wValue);
#endif//D_VOCAL_SUPPORT_ENABLED

/***************************************************************************************
* 	Include customization file.
****************************************************************************************/

// Include custom code file: customer specific code, over-writing common one.
#include "Components\Custom\Karaoke\o_karaoke_custom.c"
// Include configuration file: constants.
#include "Components\Karaoke\o_karaoke_config.c"


/***************************************************************************************
* 	Utility functions
****************************************************************************************/
static BOOL _AddItemsToKaraokeKit(MSO_VLIST __NEAR* pList)
{
	if(NULL != pList)
	{
		UINT8 cIndex;
		UINT8 cNumItems;
		UINT8 cTotalItemsInToolkit = 0;
		MSO_OBJECT __NEAR* pObject;

		// Get the total number of tools in the toolkit
		while(NULL != aKaraokeKit[cTotalItemsInToolkit])
			cTotalItemsInToolkit++;

		pList->moParam.mwTotalItems = cTotalItemsInToolkit;
		
		cNumItems = MIN(pList->moParam.mcNumVisibleItems, (pList->moParam.mwTotalItems - pList->moParam.mwFirstDisplayItem));
		
		for(cIndex = 0; cIndex < cNumItems; cIndex++)
		{			
			pObject = OVLIST_CreateAndAppendItem(pList, aKaraokeKit[pList->moParam.mwFirstDisplayItem + cIndex]);
			
			MS_SendOperation(pObject, MS_OP_OPEN, 0);
			MS_SendOperation(pObject, MS_OP_INIT, 0);		
		}			
		return TRUE;
	}	
	return FALSE;
}

/***************************************************************************************
*	Function	: 	_CalculateKeyShift
*
*	In		: 	iHardwareValue	=	Hardware value of the keyshift.
*
*	Out		: 	None.
*
*	Return	:	Hardware value of the keyshift translated to slider value.
*
*	Desc 	:	Translates the actual value to a slider value.
****************************************************************************************/
CONST KARAOKE_KEYSHIFT_SETTING aKeyShiftStages[] = 
{	
	KARAOKE_KEY_SHIFT_L7, KARAOKE_KEY_SHIFT_L6, KARAOKE_KEY_SHIFT_L5, KARAOKE_KEY_SHIFT_L4,
	KARAOKE_KEY_SHIFT_L3, KARAOKE_KEY_SHIFT_L2, KARAOKE_KEY_SHIFT_L1,
	KARAOKE_KEY_SHIFT_OFF,
	KARAOKE_KEY_SHIFT_R1, KARAOKE_KEY_SHIFT_R2, KARAOKE_KEY_SHIFT_R3, KARAOKE_KEY_SHIFT_R4,
	KARAOKE_KEY_SHIFT_R5, KARAOKE_KEY_SHIFT_R6, KARAOKE_KEY_SHIFT_R7
 };

STATIC int _CalculateKeyShift(int iHardwareValue)
{
	int iKeyShift = 0;

	while (aKeyShiftStages[iKeyShift ] != iHardwareValue)
	{ 
		iKeyShift ++;
	}
	return iKeyShift;
}


/***************************************************************************************
*	Function	: 	_CalculateEcho
*
*	In		: 	iHardwareValue	=	Hardware value of Echo.
*
*	Out		: 	None.
*
*	Return	:	Hardware value of the Echo translated to slider value.
*
*	Desc 	:	Translates the actual value to a slider value.
****************************************************************************************/
STATIC int _CalculateEcho(int iHardwareValue)
{
	return (iHardwareValue * ECHO_SLIDER_MAX_VALUE  / HW_MAX_ECHO_DELAY);
}

/***************************************************************************************
* 	Operation functions
****************************************************************************************/

/***************************************************************************************
*	Function 	: 	_KaraokeOperation
*
*	In		:
*
*	Out		:
*
*	Desc 	:	MSO_KARAOKE user operation function.
****************************************************************************************/
#pragma argsused
static MS_OP _KaraokeOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{
	// Pre-processing
	switch(MsOp)
	{
	case MS_OP_INIT:
		{
#ifdef D_GUI_O_KARAOKE_TIMEOUT
			MSO_KARAOKE __NEAR* pKaraoke = (MSO_KARAOKE __NEAR*)pThis;
			pKaraoke->moParam.mwTimeOut = KARAOKE_TIMEOUT_SECONDS * 10;
#endif
			MS_ComponentInitFocus((MSO_COMPONENT __NEAR*)pThis);
		}
		break;

	case MS_OP_TICK:
		if (!CoreAPI_IsBitsteamAllowedKaraoke())
		{
			MS_SendOperation(pThis, MS_OP_CLOSE_PARENT, 0);
		}
#ifdef D_GUI_O_KARAOKE_TIMEOUT
		else
		{
			MSO_KARAOKE __NEAR* pKaraoke = (MSO_KARAOKE __NEAR*)pThis;
			if (pKaraoke->moParam.mwTimeOut)
			{
				pKaraoke->moParam.mwTimeOut--;
				if (0 == pKaraoke->moParam.mwTimeOut)
				{
					MS_SendOperation(pThis, MS_OP_CLOSE_PARENT, 0);
				}
			}
		}
#endif
		break;

#ifdef D_GUI_O_KARAOKE_TIMEOUT
	case MS_OP_UP:
	case MS_OP_DOWN:
	case MS_OP_RIGHT:
	case MS_OP_LEFT:
	case MS_OP_ENTER:
		{
			MSO_KARAOKE __NEAR* pKaraoke = (MSO_KARAOKE __NEAR*)pThis;
			pKaraoke->moParam.mwTimeOut = KARAOKE_TIMEOUT_SECONDS * 10;
		}
		break;
#endif

	case MS_OP_LR:
		{
			// There are two ways to modify the L/R mode:
			// 1. Pressing the L/R key on the remote control.
			// 2. Pressing the L/R Mode button on the Karaoke component. 
			// If the L/R key is pressed, the value displayed for the L/R mode on the karaoke component 
			// needs to be refreshed. An easy solution(Kerchak solution) is to close the karaoke component.
			MS_SendOperation(pThis, MS_OP_CLOSE_PARENT, 0);
		}
		break;
		
	case MS_OP_KARAOKE:
		{
			MS_SendOperation(pThis, MS_OP_CLOSE_PARENT, 0);
		}
		return MS_OP_NONE;

	case MS_OP_CLOSE_PARENT:
		{
			// When close the componet, save setting
			CoreAPI_UpdatePlayerSetting(PS_UPDATE_SAVE_SETTINGS, 0);
		}
		break;

	default:
		break;
	}	
	return MS_ComponentBasicOperation(pThis, MsOp, lParam);
}

/***************************************************************************************
*	Function 	: 	_KaraokeKitOperation
*
*	In		:
*
*	Out		:
*
*	Desc 	:	The karaoke kit operation function.
****************************************************************************************/
#pragma argsused
static MS_OP _KaraokeKitOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{
	//Pre-processing
	// TODO : if any	

	MsOp = VScrollListOperation(pThis, MsOp, lParam);

	// Post-processing
	switch(MsOp)
	{		
	case MS_OP_REFRESH:
		{			
			MSO_VLIST __NEAR* pList = (MSO_VLIST __NEAR*)MS_GetObjectListPtr(pThis);				
			MS_ASSERT(NULL != pList);

			if(pList->moParam.mwTotalItems > pList->moParam.mcNumVisibleItems)
			{
				// Remove all items.
				MS_SendOperation((MSO_OBJECT __NEAR*)pList, MS_OP_EMPTY, 0);

				_AddItemsToKaraokeKit(pList);
				MS_DisplayAddObject(pThis);	

				// Set focus to the appropriate list item.
				if(MS_IsFocused(pList))
				{
					MSO_OBJECT __NEAR* pObject = MS_GetObjectListPtr(pList);
						
					if(!MS_IS_FOCUS_ON_LASTITEM(pList))	
						MS_ScreenSetFocusObject(pObject);
					else
					{						
						// Make sure we do not set focus on the Value VScroll list.					
						while(NULL != pObject->mpNext)
							pObject = pObject->mpNext;						
						MS_ScreenSetFocusObject(pObject);
					}
				}
			}			
		}
		return MS_OP_NONE;
		
	default:
		break;
	}	
	return MsOp;
}

/***************************************************************************************
*	Function 	: 	_KaraokekitVlistOperation
*
*	In		:
*
*	Out		:
*
*	Desc 	:	The karaoke kit VLIST operation function.
****************************************************************************************/
#pragma argsused
static MS_OP _KaraokekitVlistOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{
	switch(MsOp)
	{
	case MS_OP_INIT:
		return MS_OP_NONE;
		
	case MS_OP_OPEN:
		_AddItemsToKaraokeKit((MSO_VLIST __NEAR*)pThis);
		break;
		
	default:
		break;
	}	
	return VListOperation(pThis, MsOp, lParam);
}

/***************************************************************************************
*	Function 	: 	_KaraokeOnOffChoiceOperation
*
*	In		:
*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -