jack2 codebase
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

612 lines
22KB

  1. /*
  2. Copyright (C) 2008 Romain Moret at Grame
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  14. */
  15. #if defined(HAVE_CONFIG_H)
  16. #include "config.h"
  17. #endif
  18. #include "JackNetManager.h"
  19. #define DEFAULT_MULTICAST_IP "225.3.19.154"
  20. #define DEFAULT_PORT 19000
  21. using namespace std;
  22. namespace Jack
  23. {
  24. //JackNetMaster******************************************************************************************************
  25. JackNetMaster::JackNetMaster ( JackNetSocket& socket, session_params_t& params, const char* multicast_ip )
  26. : JackNetMasterInterface ( params, socket, multicast_ip )
  27. {
  28. jack_log ( "JackNetMaster::JackNetMaster" );
  29. //settings
  30. fClientName = const_cast<char*> ( fParams.fName );
  31. fJackClient = NULL;
  32. fSyncState = 1;
  33. uint port_index;
  34. //jack audio ports
  35. fAudioCapturePorts = new jack_port_t* [fParams.fSendAudioChannels];
  36. for ( port_index = 0; port_index < fParams.fSendAudioChannels; port_index++ )
  37. fAudioCapturePorts[port_index] = NULL;
  38. fAudioPlaybackPorts = new jack_port_t* [fParams.fReturnAudioChannels];
  39. for ( port_index = 0; port_index < fParams.fReturnAudioChannels; port_index++ )
  40. fAudioPlaybackPorts[port_index] = NULL;
  41. //jack midi ports
  42. fMidiCapturePorts = new jack_port_t* [fParams.fSendMidiChannels];
  43. for ( port_index = 0; port_index < fParams.fSendMidiChannels; port_index++ )
  44. fMidiCapturePorts[port_index] = NULL;
  45. fMidiPlaybackPorts = new jack_port_t* [fParams.fReturnMidiChannels];
  46. for ( port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++ )
  47. fMidiPlaybackPorts[port_index] = NULL;
  48. //monitor
  49. #ifdef JACK_MONITOR
  50. fPeriodUsecs = ( int ) ( 1000000.f * ( ( float ) fParams.fPeriodSize / ( float ) fParams.fSampleRate ) );
  51. string plot_name;
  52. plot_name = string ( fParams.fName );
  53. plot_name += string ( "_master" );
  54. plot_name += string ( ( fParams.fSlaveSyncMode ) ? "_sync" : "_async" );
  55. switch ( fParams.fNetworkMode )
  56. {
  57. case 's' :
  58. plot_name += string ( "_slow" );
  59. break;
  60. case 'n' :
  61. plot_name += string ( "_normal" );
  62. break;
  63. case 'f' :
  64. plot_name += string ( "_fast" );
  65. break;
  66. }
  67. fNetTimeMon = new JackGnuPlotMonitor<float> ( 128, 4, plot_name );
  68. string net_time_mon_fields[] =
  69. {
  70. string ( "sync send" ),
  71. string ( "end of send" ),
  72. string ( "sync recv" ),
  73. string ( "end of cycle" )
  74. };
  75. string net_time_mon_options[] =
  76. {
  77. string ( "set xlabel \"audio cycles\"" ),
  78. string ( "set ylabel \"% of audio cycle\"" )
  79. };
  80. fNetTimeMon->SetPlotFile ( net_time_mon_options, 2, net_time_mon_fields, 4 );
  81. #endif
  82. }
  83. JackNetMaster::~JackNetMaster()
  84. {
  85. jack_log ( "JackNetMaster::~JackNetMaster, ID %u.", fParams.fID );
  86. if ( fJackClient )
  87. {
  88. jack_deactivate ( fJackClient );
  89. FreePorts();
  90. jack_client_close ( fJackClient );
  91. }
  92. delete[] fAudioCapturePorts;
  93. delete[] fAudioPlaybackPorts;
  94. delete[] fMidiCapturePorts;
  95. delete[] fMidiPlaybackPorts;
  96. #ifdef JACK_MONITOR
  97. fNetTimeMon->Save();
  98. delete fNetTimeMon;
  99. #endif
  100. }
  101. bool JackNetMaster::Init()
  102. {
  103. //network init
  104. if ( !JackNetMasterInterface::Init() )
  105. return false;
  106. //set global parameters
  107. SetParams();
  108. //jack client and process
  109. jack_status_t status;
  110. if ( ( fJackClient = jack_client_open ( fClientName, JackNullOption, &status, NULL ) ) == NULL )
  111. {
  112. jack_error ( "Can't open a new jack client." );
  113. return false;
  114. }
  115. jack_set_process_callback ( fJackClient, SetProcess, this );
  116. if ( AllocPorts() != 0 )
  117. {
  118. jack_error ( "Can't allocate jack ports." );
  119. goto fail;
  120. }
  121. //process can now run
  122. fRunning = true;
  123. //finally activate jack client
  124. if ( jack_activate ( fJackClient ) != 0 )
  125. {
  126. jack_error ( "Can't activate jack client." );
  127. goto fail;
  128. }
  129. jack_info ( "NetJack new master started." );
  130. return true;
  131. fail:
  132. FreePorts();
  133. jack_client_close ( fJackClient );
  134. fJackClient = NULL;
  135. return false;
  136. }
  137. int JackNetMaster::AllocPorts()
  138. {
  139. jack_log ( "JackNetMaster::AllocPorts" );
  140. uint i;
  141. char name[24];
  142. jack_nframes_t port_latency = jack_get_buffer_size ( fJackClient );
  143. unsigned long port_flags;
  144. //audio
  145. port_flags = JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal;
  146. for ( i = 0; i < fParams.fSendAudioChannels; i++ )
  147. {
  148. sprintf ( name, "to_slave_%d", i+1 );
  149. if ( ( fAudioCapturePorts[i] = jack_port_register ( fJackClient, name, JACK_DEFAULT_AUDIO_TYPE, port_flags, 0 ) ) == NULL )
  150. return -1;
  151. jack_port_set_latency ( fAudioCapturePorts[i], 0 );
  152. }
  153. port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal;
  154. for ( i = 0; i < fParams.fReturnAudioChannels; i++ )
  155. {
  156. sprintf ( name, "from_slave_%d", i+1 );
  157. if ( ( fAudioPlaybackPorts[i] = jack_port_register ( fJackClient, name, JACK_DEFAULT_AUDIO_TYPE, port_flags, 0 ) ) == NULL )
  158. return -1;
  159. jack_port_set_latency ( fAudioPlaybackPorts[i], ( fParams.fNetworkMode == 'f' ) ? 0 : port_latency + ( fParams.fSlaveSyncMode ) ? 0 : port_latency );
  160. }
  161. //midi
  162. port_flags = JackPortIsInput | JackPortIsPhysical | JackPortIsTerminal;
  163. for ( i = 0; i < fParams.fSendMidiChannels; i++ )
  164. {
  165. sprintf ( name, "midi_to_slave_%d", i+1 );
  166. if ( ( fMidiCapturePorts[i] = jack_port_register ( fJackClient, name, JACK_DEFAULT_MIDI_TYPE, port_flags, 0 ) ) == NULL )
  167. return -1;
  168. jack_port_set_latency ( fMidiCapturePorts[i], 0 );
  169. }
  170. port_flags = JackPortIsOutput | JackPortIsPhysical | JackPortIsTerminal;
  171. for ( i = 0; i < fParams.fReturnMidiChannels; i++ )
  172. {
  173. sprintf ( name, "midi_from_slave_%d", i+1 );
  174. if ( ( fMidiPlaybackPorts[i] = jack_port_register ( fJackClient, name, JACK_DEFAULT_MIDI_TYPE, port_flags, 0 ) ) == NULL )
  175. return -1;
  176. jack_port_set_latency ( fMidiPlaybackPorts[i], ( fParams.fNetworkMode == 'f' ) ? 0 : port_latency + ( fParams.fSlaveSyncMode ) ? 0 : port_latency );
  177. }
  178. return 0;
  179. }
  180. void JackNetMaster::FreePorts()
  181. {
  182. jack_log ( "JackNetMaster::FreePorts, ID %u", fParams.fID );
  183. uint port_index;
  184. for ( port_index = 0; port_index < fParams.fSendAudioChannels; port_index++ )
  185. if ( fAudioCapturePorts[port_index] )
  186. jack_port_unregister ( fJackClient, fAudioCapturePorts[port_index] );
  187. for ( port_index = 0; port_index < fParams.fReturnAudioChannels; port_index++ )
  188. if ( fAudioPlaybackPorts[port_index] )
  189. jack_port_unregister ( fJackClient, fAudioPlaybackPorts[port_index] );
  190. for ( port_index = 0; port_index < fParams.fSendMidiChannels; port_index++ )
  191. if ( fMidiCapturePorts[port_index] )
  192. jack_port_unregister ( fJackClient, fMidiCapturePorts[port_index] );
  193. for ( port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++ )
  194. if ( fMidiPlaybackPorts[port_index] )
  195. jack_port_unregister ( fJackClient, fMidiPlaybackPorts[port_index] );
  196. }
  197. int JackNetMaster::SetSyncPacket()
  198. {
  199. if ( fParams.fTransportSync )
  200. {
  201. //TODO : set the TransportData
  202. //copy to TxBuffer
  203. memcpy ( fTxData, &fTransportData, sizeof ( net_transport_data_t ) );
  204. }
  205. return 0;
  206. }
  207. int JackNetMaster::SetProcess ( jack_nframes_t nframes, void* arg )
  208. {
  209. JackNetMaster* master = static_cast<JackNetMaster*> ( arg );
  210. return master->Process();
  211. }
  212. int JackNetMaster::Process()
  213. {
  214. if ( !fRunning )
  215. return 0;
  216. uint port_index;
  217. int res = 0;
  218. #ifdef JACK_MONITOR
  219. jack_time_t begin_time = jack_get_time();
  220. fNetTimeMon->New();
  221. #endif
  222. //buffers
  223. for ( port_index = 0; port_index < fParams.fSendMidiChannels; port_index++ )
  224. fNetMidiCaptureBuffer->SetBuffer ( port_index, static_cast<JackMidiBuffer*> ( jack_port_get_buffer ( fMidiCapturePorts[port_index],
  225. fParams.fPeriodSize ) ) );
  226. for ( port_index = 0; port_index < fParams.fSendAudioChannels; port_index++ )
  227. fNetAudioCaptureBuffer->SetBuffer ( port_index, static_cast<sample_t*> ( jack_port_get_buffer ( fAudioCapturePorts[port_index],
  228. fParams.fPeriodSize ) ) );
  229. for ( port_index = 0; port_index < fParams.fReturnMidiChannels; port_index++ )
  230. fNetMidiPlaybackBuffer->SetBuffer ( port_index, static_cast<JackMidiBuffer*> ( jack_port_get_buffer ( fMidiPlaybackPorts[port_index],
  231. fParams.fPeriodSize ) ) );
  232. for ( port_index = 0; port_index < fParams.fReturnAudioChannels; port_index++ )
  233. fNetAudioPlaybackBuffer->SetBuffer ( port_index, static_cast<sample_t*> ( jack_port_get_buffer ( fAudioPlaybackPorts[port_index],
  234. fParams.fPeriodSize ) ) );
  235. //Set the first packet to send
  236. memset ( fTxData, 0, fPayloadSize );
  237. SetSyncPacket();
  238. //send sync
  239. if ( SyncSend() == SOCKET_ERROR )
  240. return SOCKET_ERROR;
  241. #ifdef JACK_MONITOR
  242. fNetTimeMon->Add ( ( ( ( float ) ( jack_get_time() - begin_time ) ) / ( float ) fPeriodUsecs ) * 100.f );
  243. #endif
  244. //send data
  245. if ( DataSend() == SOCKET_ERROR )
  246. return SOCKET_ERROR;
  247. #ifdef JACK_MONITOR
  248. fNetTimeMon->Add ( ( ( ( float ) ( jack_get_time() - begin_time ) ) / ( float ) fPeriodUsecs ) * 100.f );
  249. #endif
  250. //receive sync
  251. res = SyncRecv();
  252. if ( ( res == 0 ) || ( res == SOCKET_ERROR ) )
  253. return res;
  254. #ifdef JACK_MONITOR
  255. fNetTimeMon->Add ( ( ( ( float ) ( jack_get_time() - begin_time ) ) / ( float ) fPeriodUsecs ) * 100.f );
  256. #endif
  257. //receive data
  258. res = DataRecv();
  259. if ( ( res == 0 ) || ( res == SOCKET_ERROR ) )
  260. return res;
  261. #ifdef JACK_MONITOR
  262. fNetTimeMon->AddLast ( ( ( ( float ) ( jack_get_time() - begin_time ) ) / ( float ) fPeriodUsecs ) * 100.f );
  263. #endif
  264. return 0;
  265. }
  266. //JackNetMasterManager***********************************************************************************************
  267. JackNetMasterManager::JackNetMasterManager ( jack_client_t* client, const JSList* params ) : fSocket()
  268. {
  269. jack_log ( "JackNetMasterManager::JackNetMasterManager" );
  270. fManagerClient = client;
  271. fManagerName = jack_get_client_name ( fManagerClient );
  272. fMulticastIP = DEFAULT_MULTICAST_IP;
  273. fSocket.SetPort ( DEFAULT_PORT );
  274. fGlobalID = 0;
  275. fRunning = true;
  276. const JSList* node;
  277. const jack_driver_param_t* param;
  278. for ( node = params; node; node = jack_slist_next ( node ) )
  279. {
  280. param = ( const jack_driver_param_t* ) node->data;
  281. switch ( param->character )
  282. {
  283. case 'a' :
  284. fMulticastIP = strdup ( param->value.str );
  285. break;
  286. case 'p':
  287. fSocket.SetPort ( param->value.ui );
  288. }
  289. }
  290. //set sync callback
  291. jack_set_sync_callback ( fManagerClient, SetSyncCallback, this );
  292. //activate the client (for sync callback)
  293. if ( jack_activate ( fManagerClient ) != 0 )
  294. jack_error ( "Can't activate the network manager client, transport disabled." );
  295. //launch the manager thread
  296. if ( jack_client_create_thread ( fManagerClient, &fManagerThread, 0, 0, NetManagerThread, this ) )
  297. jack_error ( "Can't create the network manager control thread." );
  298. }
  299. JackNetMasterManager::~JackNetMasterManager()
  300. {
  301. jack_log ( "JackNetMasterManager::~JackNetMasterManager" );
  302. jack_info ( "Exiting net manager..." );
  303. fRunning = false;
  304. jack_client_stop_thread ( fManagerClient, fManagerThread );
  305. master_list_t::iterator it;
  306. for ( it = fMasterList.begin(); it != fMasterList.end(); it++ )
  307. delete ( *it );
  308. fSocket.Close();
  309. SocketAPIEnd();
  310. }
  311. int JackNetMasterManager::SetSyncCallback ( jack_transport_state_t state, jack_position_t* pos, void* arg )
  312. {
  313. JackNetMasterManager* master_manager = static_cast<JackNetMasterManager*> ( arg );
  314. return master_manager->SyncCallback ( state, pos );
  315. }
  316. int JackNetMasterManager::SyncCallback ( jack_transport_state_t state, jack_position_t* pos )
  317. {
  318. //check sync state for every master in the list
  319. int ret = 1;
  320. master_list_it_t it;
  321. for ( it = fMasterList.begin(); it != fMasterList.end(); it++ )
  322. if ( ( *it )->fSyncState == 0 )
  323. ret = 0;
  324. jack_log ( "JackNetMasterManager::SyncCallback returns '%s'", ( ret ) ? "true" : "false" );
  325. return ret;
  326. }
  327. void* JackNetMasterManager::NetManagerThread ( void* arg )
  328. {
  329. JackNetMasterManager* master_manager = static_cast<JackNetMasterManager*> ( arg );
  330. jack_info ( "Starting Jack Network Manager." );
  331. jack_info ( "Listening on '%s:%d'", master_manager->fMulticastIP, master_manager->fSocket.GetPort() );
  332. master_manager->Run();
  333. return NULL;
  334. }
  335. void JackNetMasterManager::Run()
  336. {
  337. jack_log ( "JackNetMasterManager::Run" );
  338. //utility variables
  339. int attempt = 0;
  340. //data
  341. session_params_t params;
  342. int rx_bytes = 0;
  343. JackNetMaster* net_master;
  344. //init socket API (win32)
  345. if ( SocketAPIInit() < 0 )
  346. {
  347. jack_error ( "Can't init Socket API, exiting..." );
  348. return;
  349. }
  350. //socket
  351. if ( fSocket.NewSocket() == SOCKET_ERROR )
  352. {
  353. jack_error ( "Can't create the network management input socket : %s", StrError ( NET_ERROR_CODE ) );
  354. return;
  355. }
  356. //bind the socket to the local port
  357. if ( fSocket.Bind () == SOCKET_ERROR )
  358. {
  359. jack_error ( "Can't bind the network manager socket : %s", StrError ( NET_ERROR_CODE ) );
  360. fSocket.Close();
  361. return;
  362. }
  363. //join multicast group
  364. if ( fSocket.JoinMCastGroup ( fMulticastIP ) == SOCKET_ERROR )
  365. jack_error ( "Can't join multicast group : %s", StrError ( NET_ERROR_CODE ) );
  366. //local loop
  367. if ( fSocket.SetLocalLoop() == SOCKET_ERROR )
  368. jack_error ( "Can't set local loop : %s", StrError ( NET_ERROR_CODE ) );
  369. //set a timeout on the multicast receive (the thread can now be cancelled)
  370. if ( fSocket.SetTimeOut ( 2000000 ) == SOCKET_ERROR )
  371. jack_error ( "Can't set timeout : %s", StrError ( NET_ERROR_CODE ) );
  372. jack_info ( "Waiting for a slave..." );
  373. //main loop, wait for data, deal with it and wait again
  374. do
  375. {
  376. rx_bytes = fSocket.CatchHost ( &params, sizeof ( session_params_t ), 0 );
  377. if ( ( rx_bytes == SOCKET_ERROR ) && ( fSocket.GetError() != NET_NO_DATA ) )
  378. {
  379. jack_error ( "Error in receive : %s", StrError ( NET_ERROR_CODE ) );
  380. if ( ++attempt == 10 )
  381. {
  382. jack_error ( "Can't receive on the socket, exiting net manager." );
  383. return;
  384. }
  385. }
  386. if ( rx_bytes == sizeof ( session_params_t ) )
  387. {
  388. switch ( GetPacketType ( &params ) )
  389. {
  390. case SLAVE_AVAILABLE:
  391. if ( ( net_master = MasterInit ( params ) ) )
  392. SessionParamsDisplay ( &net_master->fParams );
  393. else
  394. jack_error ( "Can't init new net master..." );
  395. jack_info ( "Waiting for a slave..." );
  396. break;
  397. case KILL_MASTER:
  398. if ( KillMaster ( &params ) )
  399. jack_info ( "Waiting for a slave..." );
  400. break;
  401. default:
  402. break;
  403. }
  404. }
  405. }
  406. while ( fRunning );
  407. }
  408. JackNetMaster* JackNetMasterManager::MasterInit ( session_params_t& params )
  409. {
  410. jack_log ( "JackNetMasterManager::MasterInit, Slave : %s", params.fName );
  411. //settings
  412. fSocket.GetName ( params.fMasterNetName );
  413. params.fID = ++fGlobalID;
  414. params.fSampleRate = jack_get_sample_rate ( fManagerClient );
  415. params.fPeriodSize = jack_get_buffer_size ( fManagerClient );
  416. params.fBitdepth = 0;
  417. SetSlaveName ( params );
  418. //create a new master and add it to the list
  419. JackNetMaster* master = new JackNetMaster ( fSocket, params, fMulticastIP );
  420. if ( master->Init() )
  421. {
  422. fMasterList.push_back ( master );
  423. return master;
  424. }
  425. delete master;
  426. return NULL;
  427. }
  428. void JackNetMasterManager::SetSlaveName ( session_params_t& params )
  429. {
  430. jack_log ( "JackNetMasterManager::SetSlaveName" );
  431. master_list_it_t it;
  432. for ( it = fMasterList.begin(); it != fMasterList.end(); it++ )
  433. if ( strcmp ( ( *it )->fParams.fName, params.fName ) == 0 )
  434. sprintf ( params.fName, "%s-%u", params.fName, params.fID );
  435. }
  436. master_list_it_t JackNetMasterManager::FindMaster ( uint32_t id )
  437. {
  438. jack_log ( "JackNetMasterManager::FindMaster, ID %u.", id );
  439. master_list_it_t it;
  440. for ( it = fMasterList.begin(); it != fMasterList.end(); it++ )
  441. if ( ( *it )->fParams.fID == id )
  442. return it;
  443. return it;
  444. }
  445. int JackNetMasterManager::KillMaster ( session_params_t* params )
  446. {
  447. jack_log ( "JackNetMasterManager::KillMaster, ID %u.", params->fID );
  448. master_list_it_t master = FindMaster ( params->fID );
  449. if ( master != fMasterList.end() )
  450. {
  451. fMasterList.erase ( master );
  452. delete *master;
  453. return 1;
  454. }
  455. return 0;
  456. }
  457. }//namespace
  458. static Jack::JackNetMasterManager* master_manager = NULL;
  459. #ifdef __cplusplus
  460. extern "C"
  461. {
  462. #endif
  463. EXPORT jack_driver_desc_t* jack_get_descriptor()
  464. {
  465. jack_driver_desc_t *desc;
  466. desc = ( jack_driver_desc_t* ) calloc ( 1, sizeof ( jack_driver_desc_t ) );
  467. strcpy ( desc->name, "netmanager" );
  468. desc->nparams = 2;
  469. desc->params = ( jack_driver_param_desc_t* ) calloc ( desc->nparams, sizeof ( jack_driver_param_desc_t ) );
  470. int i = 0;
  471. strcpy ( desc->params[i].name, "multicast_ip" );
  472. desc->params[i].character = 'a';
  473. desc->params[i].type = JackDriverParamString;
  474. strcpy ( desc->params[i].value.str, DEFAULT_MULTICAST_IP );
  475. strcpy ( desc->params[i].short_desc, "Multicast Address" );
  476. strcpy ( desc->params[i].long_desc, desc->params[i].short_desc );
  477. i++;
  478. strcpy ( desc->params[i].name, "udp_net_port" );
  479. desc->params[i].character = 'p';
  480. desc->params[i].type = JackDriverParamInt;
  481. desc->params[i].value.i = DEFAULT_PORT;
  482. strcpy ( desc->params[i].short_desc, "UDP port" );
  483. strcpy ( desc->params[i].long_desc, desc->params[i].short_desc );
  484. return desc;
  485. }
  486. EXPORT int jack_internal_initialize ( jack_client_t* jack_client, const JSList* params )
  487. {
  488. if ( master_manager )
  489. {
  490. jack_error ( "Master Manager already loaded" );
  491. return 1;
  492. }
  493. else
  494. {
  495. jack_log ( "Loading Master Manager" );
  496. master_manager = new Jack::JackNetMasterManager ( jack_client, params );
  497. return ( master_manager ) ? 0 : 1;
  498. }
  499. }
  500. EXPORT int jack_initialize ( jack_client_t* jack_client, const char* load_init )
  501. {
  502. JSList* params = NULL;
  503. jack_driver_desc_t* desc = jack_get_descriptor();
  504. Jack::JackArgParser parser ( load_init );
  505. if ( parser.GetArgc() > 0 )
  506. {
  507. if ( parser.ParseParams ( desc, &params ) < 0 )
  508. jack_error ( "Internal client JackArgParser::ParseParams error." );
  509. }
  510. return jack_internal_initialize ( jack_client, params );
  511. }
  512. EXPORT void jack_finish ( void* arg )
  513. {
  514. if ( master_manager )
  515. {
  516. jack_log ( "Unloading Master Manager" );
  517. delete master_manager;
  518. master_manager = NULL;
  519. }
  520. }
  521. #ifdef __cplusplus
  522. }
  523. #endif