advanced.c
上传用户:wstnjxml
上传日期:2014-04-03
资源大小:7248k
文件大小:11k
源码类别:

Windows CE

开发平台:

C/C++

  1. /*****************************************************************************
  2.  *
  3.  * This program is free software ; you can redistribute it and/or modify
  4.  * it under the terms of the GNU General Public License as published by
  5.  * the Free Software Foundation; either version 2 of the License, or
  6.  * (at your option) any later version.
  7.  *
  8.  * This program is distributed in the hope that it will be useful,
  9.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11.  * GNU General Public License for more details.
  12.  *
  13.  * You should have received a copy of the GNU General Public License
  14.  * along with this program; if not, write to the Free Software
  15.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  16.  *
  17.  * $Id: advanced.c 615 2006-01-26 16:57:51Z picard $
  18.  *
  19.  * The Core Pocket Media Player
  20.  * Copyright (c) 2004-2005 Gabor Kovacs
  21.  *
  22.  ****************************************************************************/
  23. #include "common.h"
  24. typedef struct advanced
  25. {
  26. node Node;
  27. bool_t OldShell;
  28. bool_t SlowVideo;
  29. bool_t ColorLookup;
  30. bool_t NoBackLight;
  31. bool_t HomeScreen;
  32. bool_t NoWMMX;
  33. bool_t IDCTSwap;
  34. bool_t VR41XX;
  35. bool_t KeyFollowDir;
  36. bool_t MemoryOverride;
  37. bool_t BenchFromPos;
  38. bool_t AviFrameRate;
  39. bool_t Priority;
  40. bool_t SystemVolume;
  41. bool_t WidcommAudio;
  42. bool_t WidcommDLL;
  43. tick_t DropTolerance;
  44. tick_t SkipTolerance;
  45. tick_t AVOffset;
  46. bool_t NoBatteryWarning;
  47. bool_t NoEventChecking;
  48. bool_t CardPlugins;
  49. bool_t WaveoutPriority;
  50. bool_t NoDeblocking;
  51. bool_t BlinkLED;
  52. } advanced;
  53. static const datatable Params[] = 
  54. {
  55. { ADVANCED_NOBACKLIGHT, TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  56. { ADVANCED_HOMESCREEN, TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  57. #if defined(TARGET_WINCE)
  58. { ADVANCED_OLDSHELL, TYPE_BOOL, DF_SETUP|DF_RESTART|DF_CHECKLIST },
  59. #endif
  60. #if defined(ARM) 
  61. { ADVANCED_NOWMMX, TYPE_BOOL, DF_SETUP|DF_CHECKLIST|DF_RESTART },
  62. #endif
  63. #if !defined(SH3) && !defined(MIPS)
  64. { ADVANCED_SLOW_VIDEO, TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  65. #endif
  66. #if defined(ARM) || defined(_M_IX86)
  67. { ADVANCED_IDCTSWAP, TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  68. #endif
  69. #if !defined(SH3) 
  70. { ADVANCED_COLOR_LOOKUP,TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  71. #endif
  72. { ADVANCED_KEYFOLLOWDIR,TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  73. #if defined(TARGET_PALMOS)
  74. { ADVANCED_MEMORYOVERRIDE, TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  75. #endif
  76. { ADVANCED_PRIORITY, TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  77. #if !defined(SH3) && !defined(TARGET_PALMOS)
  78. { ADVANCED_SYSTEMVOLUME, TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  79. #endif
  80. #if defined(MIPS)
  81. { ADVANCED_VR41XX,TYPE_BOOL, DF_SETUP|DF_CHECKLIST|DF_RESTART },
  82. #endif
  83. { ADVANCED_BENCHFROMPOS,TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  84. { ADVANCED_AVIFRAMERATE,TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  85. #if defined(TARGET_WINCE)
  86. { ADVANCED_WIDCOMMAUDIO,TYPE_BOOL, DF_SETUP|DF_CHECKLIST|DF_RESTART },
  87. #endif
  88. #if defined(TARGET_WINCE) || defined(TARGET_WIN32)
  89. // { ADVANCED_WAVEOUTPRIORITY, TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  90. #endif
  91. #if defined(TARGET_PALMOS)
  92. { ADVANCED_NOBATTERYWARNING,TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  93. { ADVANCED_NOEVENTCHECKING,TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  94. { ADVANCED_CARDPLUGINS,TYPE_BOOL, DF_SETUP|DF_CHECKLIST|DF_NOSAVE|DF_RESTART },
  95. { ADVANCED_BLINKLED,TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  96. #endif
  97. { ADVANCED_NODEBLOCKING,TYPE_BOOL, DF_SETUP|DF_CHECKLIST },
  98. { ADVANCED_AVOFFSET, TYPE_TICK, DF_SETUP|DF_MINMAX|DF_MSEC|DF_GAP|DF_NEG|DF_RESYNC, -2*TICKSPERSEC, 2*TICKSPERSEC },
  99. { ADVANCED_DROPTOL, TYPE_TICK, DF_SETUP|DF_MINMAX|DF_MSEC, 0, TICKSPERSEC },
  100. { ADVANCED_SKIPTOL, TYPE_TICK, DF_SETUP|DF_MINMAX|DF_MSEC, 0, 5*TICKSPERSEC },
  101. { ADVANCED_WIDCOMMDLL, TYPE_BOOL, DF_SETUP|DF_HIDDEN },
  102. DATATABLE_END(ADVANCED_ID)
  103. };
  104. static int Enum(advanced* p, int* No, datadef* Param)
  105. {
  106. int Result = NodeEnumTable(No,Param,Params);
  107. if (Result == ERR_NONE)
  108. {
  109. #if defined(TARGET_WINCE)
  110. if (Param->No == ADVANCED_WIDCOMMAUDIO && !p->WidcommDLL)
  111. Param->Flags |= DF_HIDDEN;
  112. if (Param->No == ADVANCED_OLDSHELL && (
  113. (QueryPlatform(PLATFORM_CAPS) & CAPS_OLDSHELL) || 
  114. QueryPlatform(PLATFORM_TYPENO) == TYPE_SMARTPHONE || 
  115. (QueryPlatform(PLATFORM_TYPENO) == TYPE_POCKETPC && QueryPlatform(PLATFORM_VER) >= 421)))
  116. Param->Flags |= DF_HIDDEN;
  117. #endif
  118. #if defined(TARGET_PALMOS)
  119. if (Param->No == ADVANCED_MEMORYOVERRIDE && !MemGetInfo(NULL))
  120. Param->Flags |= DF_HIDDEN;
  121. #endif
  122. if (Param->No == ADVANCED_NOWMMX && !(QueryPlatform(PLATFORM_CAPS) & CAPS_ARM_WMMX))
  123. Param->Flags |= DF_HIDDEN;
  124. if (Param->No == ADVANCED_HOMESCREEN && QueryPlatform(PLATFORM_TYPENO) != TYPE_SMARTPHONE)
  125. Param->Flags |= DF_HIDDEN;
  126. if (Param->No == ADVANCED_VR41XX && !(QueryPlatform(PLATFORM_CAPS) != CAPS_MIPS_VR41XX))
  127. Param->Flags |= DF_HIDDEN;
  128. }
  129. return Result;
  130. }
  131. static int Get(advanced* p, int No, void* Data, int Size)
  132. {
  133. int Result = ERR_INVALID_PARAM;
  134. switch (No)
  135. {
  136. case ADVANCED_OLDSHELL: GETVALUE(p->OldShell,bool_t); break;
  137. case ADVANCED_HOMESCREEN: GETVALUE(p->HomeScreen,bool_t); break;
  138. case ADVANCED_NOBACKLIGHT: GETVALUE(p->NoBackLight,bool_t); break;
  139. case ADVANCED_VR41XX: GETVALUE(p->VR41XX,bool_t); break;
  140. case ADVANCED_IDCTSWAP: GETVALUE(p->IDCTSwap,bool_t); break;
  141. case ADVANCED_NOWMMX: GETVALUE(p->NoWMMX,bool_t); break;
  142. case ADVANCED_NODEBLOCKING: GETVALUE(p->NoDeblocking,bool_t); break;
  143. case ADVANCED_BLINKLED: GETVALUE(p->BlinkLED,bool_t); break;
  144. case ADVANCED_PRIORITY: GETVALUE(p->Priority,bool_t); break;
  145. case ADVANCED_SYSTEMVOLUME: GETVALUE(p->SystemVolume,bool_t); break;
  146. case ADVANCED_SLOW_VIDEO: GETVALUE(p->SlowVideo,bool_t); break;
  147. case ADVANCED_COLOR_LOOKUP: GETVALUE(p->ColorLookup,bool_t); break;
  148. case ADVANCED_DROPTOL: GETVALUE(p->DropTolerance,tick_t); break;
  149. case ADVANCED_SKIPTOL: GETVALUE(p->SkipTolerance,tick_t); break;
  150. case ADVANCED_AVOFFSET: GETVALUE(p->AVOffset,tick_t); break;
  151. case ADVANCED_BENCHFROMPOS: GETVALUE(p->BenchFromPos,bool_t); break;
  152. case ADVANCED_AVIFRAMERATE: GETVALUE(p->AviFrameRate,bool_t); break;
  153. case ADVANCED_WIDCOMMAUDIO: GETVALUE(p->WidcommAudio,bool_t); break;
  154. case ADVANCED_WIDCOMMDLL: GETVALUE(p->WidcommDLL,bool_t); break;
  155. case ADVANCED_KEYFOLLOWDIR: GETVALUE(p->KeyFollowDir,bool_t); break;
  156. case ADVANCED_WAVEOUTPRIORITY: GETVALUE(p->WaveoutPriority,bool_t); break;
  157. case ADVANCED_MEMORYOVERRIDE: GETVALUE(p->MemoryOverride,bool_t); break;
  158. case ADVANCED_NOBATTERYWARNING: GETVALUE(p->NoBatteryWarning,bool_t); break;
  159. case ADVANCED_NOEVENTCHECKING: GETVALUE(p->NoEventChecking,bool_t); break;
  160. case ADVANCED_CARDPLUGINS: GETVALUE(p->CardPlugins,bool_t); break;
  161. }
  162. return Result;
  163. }
  164. static int Set(advanced* p, int No, const void* Data, int Size)
  165. {
  166. int Result = ERR_INVALID_PARAM;
  167. switch (No)
  168. {
  169. case ADVANCED_OLDSHELL: SETVALUE(p->OldShell,bool_t,ERR_NONE); break;
  170. case ADVANCED_HOMESCREEN: SETVALUE(p->HomeScreen,bool_t,ERR_NONE); break;
  171. case ADVANCED_NOBACKLIGHT: SETVALUE(p->NoBackLight,bool_t,ERR_NONE); break;
  172. case ADVANCED_VR41XX: SETVALUE(p->VR41XX,bool_t,ERR_NONE); break;
  173. case ADVANCED_IDCTSWAP: SETVALUECMP(p->IDCTSwap,bool_t,NodeSettingsChanged(),EqBool); break;
  174. case ADVANCED_NOWMMX: SETVALUE(p->NoWMMX,bool_t,ERR_NONE); break;
  175. case ADVANCED_BLINKLED: SETVALUE(p->BlinkLED,bool_t,ERR_NONE); break;
  176. case ADVANCED_NODEBLOCKING: SETVALUECMP(p->NoDeblocking,bool_t,NodeSettingsChanged(),EqBool); break;
  177. case ADVANCED_PRIORITY: SETVALUECMP(p->Priority,bool_t,NodeSettingsChanged(),EqBool); break;
  178. case ADVANCED_SYSTEMVOLUME: SETVALUECMP(p->SystemVolume,bool_t,NodeSettingsChanged(),EqBool); break;
  179. case ADVANCED_SLOW_VIDEO: SETVALUECMP(p->SlowVideo,bool_t,NodeSettingsChanged(),EqBool); break;
  180. case ADVANCED_COLOR_LOOKUP: SETVALUECMP(p->ColorLookup,bool_t,NodeSettingsChanged(),EqBool); break;
  181. case ADVANCED_DROPTOL: SETVALUECMP(p->DropTolerance,tick_t,NodeSettingsChanged(),EqInt); break;
  182. case ADVANCED_SKIPTOL: SETVALUECMP(p->SkipTolerance,tick_t,NodeSettingsChanged(),EqInt); break;
  183. case ADVANCED_AVOFFSET: SETVALUECMP(p->AVOffset,tick_t,NodeSettingsChanged(),EqInt); break;
  184. case ADVANCED_BENCHFROMPOS: SETVALUE(p->BenchFromPos,bool_t,ERR_NONE); break;
  185. case ADVANCED_AVIFRAMERATE: SETVALUECMP(p->AviFrameRate,bool_t,NodeSettingsChanged(),EqBool); break;
  186. case ADVANCED_WIDCOMMAUDIO: SETVALUE(p->WidcommAudio,bool_t,ERR_NONE); break;
  187. case ADVANCED_KEYFOLLOWDIR: SETVALUE(p->KeyFollowDir,bool_t,ERR_NONE); break;
  188. case ADVANCED_WAVEOUTPRIORITY: SETVALUECMP(p->WaveoutPriority,bool_t,NodeSettingsChanged(),EqBool); break;
  189. case ADVANCED_MEMORYOVERRIDE: SETVALUECOND(p->MemoryOverride,bool_t,ERR_NONE,MemGetInfo(NULL)); break;
  190. case ADVANCED_NOBATTERYWARNING: SETVALUE(p->NoBatteryWarning,bool_t,ERR_NONE); break;
  191. case ADVANCED_NOEVENTCHECKING: SETVALUECMP(p->NoEventChecking,bool_t,NodeSettingsChanged(),EqBool); break;
  192. case ADVANCED_CARDPLUGINS: SETVALUE(p->CardPlugins,bool_t,ERR_NONE); break;
  193. case ADVANCED_WIDCOMMDLL: 
  194. assert(Size==sizeof(bool_t));
  195. if (p->WidcommDLL && !*(bool_t*)Data)
  196. p->WidcommAudio = 1;
  197. break;
  198. }
  199. return Result;
  200. }
  201. bool_t QueryAdvanced(int Param)
  202. {
  203. node* Advanced = Context()->Advanced;
  204. bool_t Value=0;
  205. if (Advanced)
  206. Advanced->Get(Advanced,Param,&Value,sizeof(Value));
  207. return Value;
  208. }
  209. static int Create(advanced* p)
  210. {
  211. int Caps = QueryPlatform(PLATFORM_CAPS);
  212. video Desktop;
  213. QueryDesktop(&Desktop);
  214. p->Node.Enum = (nodeenum)Enum,
  215. p->Node.Get = (nodeget)Get,
  216. p->Node.Set = (nodeset)Set,
  217. p->SlowVideo = 0;
  218. #if defined(TARGET_WINCE)
  219. p->SystemVolume = QueryPlatform(PLATFORM_VER) < 421;
  220. #else
  221. p->SystemVolume = 0;
  222. #endif
  223. p->BenchFromPos = 0;
  224. p->VR41XX = 1;
  225. p->MemoryOverride = 0;
  226. p->KeyFollowDir = HaveDPad();
  227. p->ColorLookup = !(Caps & CAPS_MIPS_VR41XX) && !(Caps & CAPS_ARM_XSCALE);
  228. p->OldShell = (Caps & CAPS_OLDSHELL) != 0;
  229. p->DropTolerance = (TICKSPERSEC*55)/1000;
  230. p->SkipTolerance = (TICKSPERSEC*700)/1000;
  231. p->AVOffset = 0;
  232. p->BlinkLED = 1;
  233. #if defined(TARGET_PALMOS)
  234. // causes major problems on Sony TJ35, like screen not turning off with audio, or hold/power button not working...
  235. //p->NoEventChecking = (QueryPlatform(PLATFORM_CAPS) & CAPS_SONY)!=0;
  236. #endif
  237. #if defined(TARGET_WINCE)
  238. {
  239. tchar_t FileName[MAXPATH];
  240. GetSystemPath(FileName,TSIZEOF(FileName),T("BtCeAvIf.dll"));
  241. p->WidcommAudio = p->WidcommDLL = FileExits(FileName);
  242. }
  243. #endif
  244. return ERR_NONE;
  245. }
  246. static const nodedef Advanced =
  247. {
  248. sizeof(advanced)|CF_GLOBAL|CF_SETTINGS,
  249. ADVANCED_ID,
  250. NODE_CLASS,
  251. PRI_MAXIMUM+50,
  252. (nodecreate)Create,
  253. NULL,
  254. };
  255. void Advanced_Init()
  256. {
  257. NodeRegisterClass(&Advanced);
  258. Context()->Advanced = NodeEnumObject(NULL,ADVANCED_ID);
  259. }
  260. void Advanced_Done()
  261. {
  262. Context()->Advanced = NULL;
  263. NodeUnRegisterClass(ADVANCED_ID);
  264. }