📄 o_sacd.c
字号:
/* **************************************************************************************
* Copyright (c) 2004 ZORAN Corporation, All Rights Reserved
* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF ZORAN CORPORATION
*
* File: $Workfile: o_sacd.c $
*
* Description:
* ============
* Project definition of the MSO_SACD
*
****************************************************************************************/
#include "Config.h" // Global Configuration - do not remove!
#if D_SUPPORT_SACD
#ifdef DEBUG_UI_TRACE
#undef IFTRACE
#define IFTRACE if (gTraceUI)
#include "Debug\DbgMain.h"
#endif //DEBUG_UI_TRACE
#include "Include\SysDefs.h"
/***************************************************************************************
* Include files
****************************************************************************************/
#include <stdio.h>
#include <string.h>
#include "Kernel\eventdef.h"
#include "include\math-macro.h"
#include "CoreAPI\CoreAPI.h"
#include "CoreAPI\DeviceManager.h"
#include "Library\Container_misc.h"
#include "Library\String_generate.h"
#include "Library\Number.h"
#include "GUI\Menu_system\ms_object.h"
#include "gui\menu_system\osd_rendering.h"
#include "gui\menu_system\ms_display.h"
#include "GUI\Menu_system\ms_screen.h"
#include "GUI\Menu_system\ms_component.h"
#include "GUI\Object_class\Button\mso_button.h"
#include "GUI\Object_class\Text\mso_text.h"
#include "GUI\Object_class\Hscroll\mso_hscroll_text.h"
#include "GUI\Object_class\Vlist\mso_vlist.h"
#include "GUI\Resource\Bitmap\bitmap.h"
#include "Menu\menu_operation_def.h"
#include "Menu_config\menu_config_common.h"
#include "Components\Sacd\o_sacd.h"
#include "Components\Sacd\o_sacd_config.h"
#include "Components\Custom\Sacd\o_sacd_custom.h"
#ifndef DEBUG_UI_TRACE
#undef dbg_printf(sMsg)
#define dbg_printf(sMsg)
#undef dbgm_printf(sMsg, mode)
#define dbgm_printf(sMsg, mode)
#endif //DEBUG_UI_TRACE
/***************************************************************************************
* Utility functions
****************************************************************************************/
STATIC BOOL _AddTools(MSO_VLIST __NEAR* pList);
STATIC BOOL _IsHDAreaSwitched(void);
STATIC void _ResetHDAreaChangedFlag(void);
/***************************************************************************************
* Operation functions
****************************************************************************************/
STATIC MS_OP _PlayStateOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
STATIC MS_OP _PlayFileOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
STATIC MS_OP _PlayTimeOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
STATIC MS_OP _BtnSwitchHDAreaOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
STATIC MS_OP _BtnSwitchCDLayerOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
STATIC MS_OP _ToolkitVlistOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
STATIC MS_OP _ToolKitOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
STATIC MS_OP _ListItemOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
STATIC MS_OP _BrowserVListOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
STATIC MS_OP _BrowserScrollListOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
STATIC MS_OP _HelpTextOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
STATIC MS_OP _SACDOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam);
/***************************************************************************************
* Display functions
****************************************************************************************/
STATIC BOOL _ListItemFillOSDSeg(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea);
STATIC BOOL _SACDFillOSDSeg(MSO_OBJECT __NEAR* pThis, MS_AREA __NEAR* pAbsArea);
/***************************************************************************************
* Utility functions
****************************************************************************************/
STATIC void _GetPlayState(FORMATED_UNICODE_STRING __NEAR* pFormUniStr, UINT32 wParam);
STATIC void _GetPlayFile(FORMATED_UNICODE_STRING __NEAR* pFormUniStr, UINT32 wParam);
STATIC void _GetPlayTime(FORMATED_UNICODE_STRING __NEAR* pFormUniStr, UINT32 wParam);
STATIC void _GetTrackName(FORMATED_UNICODE_STRING __NEAR* pFormUniStr, UINT32 wParam);
#include "Components\Custom\Sacd\o_sacd_custom.c"
#include "Components\Sacd\o_sacd_config.c"
/* Macros for the Playstate object */
#define _MakePlayStateParam(_PlayState_, _IsResumeStop_, _ScanSpeed_) (((UINT32)_PlayState_ << 24) | ((UINT32)_IsResumeStop_ << 16) | (_ScanSpeed_ & 0xFFFF))
#define _GetPlayStateFromParam(_Param_) ((UINT8)(_Param_ >> 24))
#define _GetResumeStopStatusFromParam(_Param_) ((BOOL)((_Param_ >> 16) & 0xFF))
#define _GetScanSpeedFromParam(_Param_) ((INT16)(_Param_ & 0xFFFF))
/* Macros for the Playfile object */
#define _MakePlayFileParam(_CurrentTrack_, _TotalTracks_) (((UINT32)_CurrentTrack_ << 16) | _TotalTracks_)
#define _GetCurrentFileFromParam(_Param_) ((UINT16)(_Param_ >> 16))
#define _GetTotalFilesFromParam(_Param_) ((UINT16)_Param_)
/***************************************************************************************
* Function : _AddTools
*
* In : pList = Pointer to List to which items would to be added.
*
* Out : None.
*
* Return : TRUE if successful.
*
* Desc : This is a helper function that adds tools to the toolkit (an object of type
* MSO_VLIST). The aTools array contains a lits of descriptors of the tools
* that are to be added to the toolkit.
****************************************************************************************/
STATIC BOOL _AddTools(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 != aTools[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, aTools[pList->moParam.mwFirstDisplayItem + cIndex]);
MS_SendOperation(pObject, MS_OP_OPEN, 0);
MS_SendOperation(pObject, MS_OP_INIT, 0);
}
return TRUE;
}
return FALSE;
}
/***************************************************************************************
* Function : _IsHDAreaSwitched
*
* In : None.
*
* Out : None.
*
* Return : TRUE if the HD area was switched.
*
* Desc : Returns TRUE if the HD area was changed. The Browser list uses this flag to
* detemine whether the active item should be displayed. This flag is for one time
* use only, and is reset after use.
****************************************************************************************/
STATIC BOOL _IsHDAreaSwitched(void)
{
MSO_SACD __NEAR* pSACDWindow = (MSO_SACD __NEAR*)MS_FindDescendant(gpScreen, &oSACDDescriptor);
if(NULL != pSACDWindow)
return pSACDWindow->moParam.mbHDAreaChanged;
return FALSE;
}
/***************************************************************************************
* Function : _ResetHDAreaChangedFlag
*
* In : None.
*
* Out : None.
*
* Return : None.
*
* Desc : Reset the HD area changed flag.
****************************************************************************************/
STATIC void _ResetHDAreaChangedFlag(void)
{
MSO_SACD __NEAR* pSACDWindow = (MSO_SACD __NEAR*)MS_FindDescendant(gpScreen, &oSACDDescriptor);
if(NULL != pSACDWindow)
pSACDWindow->moParam.mbHDAreaChanged = FALSE;
}
/***************************************************************************************
* Function : _GetPlayState
*
* In : 1. pFormUniStr = Pointer to structure that holds the formatted Unicode string.
* 2. wParam = Contains the current play state, and resume stop state in
* the HIWORD, and the scan speed in the LOWORD.
*
* Out : None.
*
* Desc :
****************************************************************************************/
#pragma argsused
STATIC void _GetPlayState(FORMATED_UNICODE_STRING __NEAR* pFormUniStr, UINT32 wParam)
{
UINT8 cIdx = 0;
UINT8 cPlayState = _GetPlayStateFromParam(wParam);
INT16 nScanSpeed = _GetScanSpeedFromParam(wParam);
UINT16 szStr[12];
if(PST_PLAY == cPlayState)
cIdx = STR_GenerateUnicodeChar(PRIVATE_SYMBOL_PLAY, szStr, cIdx, sizeof(szStr));
else if(PST_PAUSE == cPlayState)
cIdx = STR_GenerateUnicodeChar(PRIVATE_SYMBOL_PAUSE, szStr, cIdx, sizeof(szStr));
else if(PST_STOP == cPlayState)
{
if(_GetResumeStopStatusFromParam(wParam))
cIdx = STR_GenerateUnicodeChar(PRIVATE_SYMBOL_STOP_RESUME, szStr, cIdx, sizeof(szStr));
else
cIdx = STR_GenerateUnicodeChar(PRIVATE_SYMBOL_STOP, szStr, cIdx, sizeof(szStr));
}
else if(PST_SCAN == cPlayState)
{
if(0 < nScanSpeed)
cIdx = STR_GenerateUnicodeChar(PRIVATE_SYMBOL_FORWARD, szStr, cIdx, sizeof(szStr));
else if(0 > nScanSpeed)
cIdx = STR_GenerateUnicodeChar(PRIVATE_SYMBOL_BACKWARD, szStr, cIdx, sizeof(szStr));
}
szStr[cIdx] = 0;
OSDR_GetFormUniStr_Ram(pFormUniStr, (UINT32)szStr);
}
/***************************************************************************************
* Function : _GetPlayFile
*
* In : 1. pFormUniStr = Pointer to structure that holds the formatted Unicode string.
* 2. wParam = Contains the current playing track in the HIWORD, and the
* total number of tracks in the LOWORD.
*
* Out : None.
*
* Desc : This function builds the unicode formatted string which would display the current
* playing track, and the total number of tracks.
****************************************************************************************/
#pragma argsused
STATIC void _GetPlayFile(FORMATED_UNICODE_STRING __NEAR* pFormUniStr, UINT32 wParam)
{
STR_GenerateNumericAndTotalNumeric(_GetCurrentFileFromParam(wParam), _GetTotalFilesFromParam(wParam),
pFormUniStr->mszUniStr, 0, UNISTR_LENGTH_MAX + 1);
OSDR_FormatUniString(pFormUniStr);
}
/***************************************************************************************
* Function : _GetPlayTime
*
* In : 1. pFormUniStr = Pointer to structure that holds the formatted Unicode string.
* 2. wParam = Contains elapsed time of the currently playing track.
*
* Out : None.
*
* Desc : This function builds the unicode formatted string which would display the elapsed time
* of the currently playing track.
****************************************************************************************/
#pragma argsused
STATIC void _GetPlayTime(FORMATED_UNICODE_STRING __NEAR* pFormUniStr, UINT32 wParam)
{
STR_GeneratePlaybackTime((UINT16)wParam, pFormUniStr->mszUniStr, 0, UNISTR_LENGTH_MAX + 1);
OSDR_FormatUniString(pFormUniStr);
}
/***************************************************************************************
* Function : _GetTrackName
*
* In : 1. pFormUniStr = Pointer to structure that holds the formatted Unicode string.
* 2. wParam = Contains elapsed time of the currently playing track.
*
* Out : None.
*
* Desc : This function builds the unicode formatted string which would display the SACD track
* name.
****************************************************************************************/
#pragma argsused
STATIC void _GetTrackName(FORMATED_UNICODE_STRING __NEAR* pFormUniStr, UINT32 wParam)
{
CoreAPI_GetTrackOrTitleName((UINT16)wParam, pFormUniStr->mszUniStr, UNISTR_LENGTH_MAX + 1);
// Generate names for the tracks if the core returned an empty string.
if('\0' == pFormUniStr->mszUniStr[0])
{
OSDR_GetFormUniStr_OsdMessage(pFormUniStr, S_TRACK);
// Tag a space on the end, followed by the track number.
pFormUniStr->mszUniStr[pFormUniStr->mcStrLength++] = UNICODE_SPACE;
pFormUniStr->mszUniStr[pFormUniStr->mcStrLength++] = ((UINT8)(wParam + 1)/10 + 0x30);
pFormUniStr->mszUniStr[pFormUniStr->mcStrLength++] = ((UINT8)(wParam + 1)%10 + 0x30);
}
// Reformat the unicode string.
OSDR_FormatUniString(pFormUniStr);
}
/***************************************************************************************
* Operation functions
****************************************************************************************/
/***************************************************************************************
* Function : _PlayStateOperation
*
* In :
*
* Out :
*
* Desc : MSO_SACD user operation function.
****************************************************************************************/
#pragma argsused
STATIC MS_OP _PlayStateOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{
MsOp = OTEXT_Operation(pThis, MsOp, lParam);
// Post-processing.
switch(MsOp)
{
case MS_OP_INIT: // Fall Through !!!
{
MSO_SACD_PLAYSTATE __NEAR* pPlayState = (MSO_SACD_PLAYSTATE __NEAR*)pThis;
pPlayState->moParam.mcPlayState = PST_STOP;
pPlayState->moParam.mbIsResumeStop = FALSE;
pPlayState->moParam.mnScanSpeed = 0;
}
break;
case MS_OP_ON_DEFROST: // Fall Through !!!
case MS_OP_TICK:
{
UINT32 dwParam = 0;
MSO_SACD_PLAYSTATE __NEAR* pPlayState = (MSO_SACD_PLAYSTATE __NEAR*)pThis;
UINT8 cPlayState = (UINT8)CoreAPI_GetPlayState();
BOOL bIsResumeStop = CoreAPI_IsResumeStop();
INT16 nScanSpeed = CoreAPI_GetScanSpeed();
if((cPlayState != pPlayState->moParam.mcPlayState)
|| (bIsResumeStop != pPlayState->moParam.mbIsResumeStop)
|| (nScanSpeed != pPlayState->moParam.mnScanSpeed))
{
pPlayState->moParam.mcPlayState = cPlayState;
pPlayState->moParam.mbIsResumeStop = bIsResumeStop;
pPlayState->moParam.mnScanSpeed = nScanSpeed;
dwParam = _MakePlayStateParam(cPlayState, bIsResumeStop, nScanSpeed);
MS_SendOperation(pThis, MS_OP_BUILD_TEXT_STRING, dwParam);
MS_DisplayAddObject(pThis);
}
}
break;
default:
break;
}
return MsOp;
}
/***************************************************************************************
* Function : _PlayFileOperation
*
* In :
*
* Out :
*
* Desc : MSO_SACD user operation function.
****************************************************************************************/
STATIC MS_OP _PlayFileOperation(MSO_OBJECT __NEAR* pThis, MS_OP MsOp, UINT32 lParam)
{
MsOp = OTEXT_Operation(pThis, MsOp, lParam);
// Post-processing.
switch(MsOp)
{
case MS_OP_INIT: // Fall Through !!!
case MS_OP_PREPARE_FOR_FREEZE:
{
MSO_SACD_PLAYFILE __NEAR* pPlayFile = (MSO_SACD_PLAYFILE __NEAR*)pThis;
pPlayFile->moParam.mwCurrentTrack = INVALID_TRACK;
pPlayFile->moParam.mwTotalTracks = INVALID_TRACK;
}
break;
case MS_OP_ON_DEFROST: // Fall Through !!!
case MS_OP_TICK:
{
// Do not display in full stop state.
if((PST_STOP == CoreAPI_GetPlayState()) && (!CoreAPI_IsResumeStop()))
{
if(!MS_IsInvisible(pThis))
{
MS_SetInvisible(pThis);
MS_DisplayAddObject(pThis);
}
}
else
{
MSO_SACD_PLAYFILE __NEAR* pPlayFile = (MSO_SACD_PLAYFILE __NEAR*)pThis;
UINT16 wCurrentTrack = CoreAPI_GetCurrentChapterTrackNum();
UINT16 wTotalTracks = CoreAPI_GetTotalChapterTrackNum(0);
if((wCurrentTrack != pPlayFile->moParam.mwCurrentTrack) || (wTotalTracks != pPlayFile->moParam.mwTotalTracks) || MS_IsInvisible(pThis))
{
UINT32 dwParam;
pPlayFile->moParam.mwCurrentTrack = wCurrentTrack;
pPlayFile->moParam.mwTotalTracks = wTotalTracks;
dwParam = _MakePlayFileParam(pPlayFile->moParam.mwCurrentTrack, pPlayFile->moParam.mwTotalTracks);
MS_SendOperation(pThis, MS_OP_BUILD_TEXT_STRING, dwParam);
MS_ClearInvisible(pThis);
MS_DisplayAddObject(pThis);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -