Arnaud G. GIBERT
5cce284879
- Replace internal log system with LibLog V1.0.x, - Code cleanup, - Add GPL Licenses files.
237 lines
5.9 KiB
C
237 lines
5.9 KiB
C
/*----------------------------------------------------------------------------*/
|
|
/* drummer.c */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* This file is part of Drummer. */
|
|
/* */
|
|
/* Drummer is free software: you can redistribute it and/or modify it */
|
|
/* under the terms of the GNU General Public License as published by */
|
|
/* the Free Software Foundation, either version 3 of the License, or */
|
|
/* (at your option) any later version. */
|
|
/* */
|
|
/* Drummer is distributed in the hope that it will be useful, */
|
|
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
|
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
|
/* GNU General Public License for more details. */
|
|
/* */
|
|
/* You should have received a copy of the GNU General Public License */
|
|
/* along with Drummer. If not, see <https://www.gnu.org/licenses/>. */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* Includes */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
#define _DRUMMER_C_
|
|
|
|
|
|
|
|
#include <drummer.h>
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_Init */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
DRT_Status DR_Init()
|
|
{
|
|
DRT_Status status;
|
|
|
|
|
|
if( ( status = DR_DataStruct_Init( DRD_SAMPLE_RATE_DEFAULT, DRD_THREAD_NUMBER_DEFAULT)) != DRS_OK)
|
|
{
|
|
LG_LOG_ERROR_1( "Can't init data structures (%d)!", status);
|
|
return( status);
|
|
}
|
|
|
|
return( status);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* DR_DeInit */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
DRT_Status DR_DeInit()
|
|
{
|
|
DRT_Status status;
|
|
|
|
|
|
if( ( status = DR_DataStruct_DeInit()) != DRS_OK)
|
|
{
|
|
LG_LOG_ERROR_1( "Can't deinit data structures (%d)!", status);
|
|
return( status);
|
|
}
|
|
|
|
return( status);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
/* main */
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
int main( int argc, char **argv)
|
|
{
|
|
LGT_Status lg_status;
|
|
DRT_Status status;
|
|
DRT_Kit *kit_ptr;
|
|
DRT_Id i;
|
|
|
|
|
|
if( ( lg_status = LG_Library_Open( LGD_LOG_WRITER_DEFAULT, true)) != LGS_OK)
|
|
{
|
|
fprintf( stderr, "Can't open LibLog library: (%d)\n", lg_status);
|
|
exit( -1);
|
|
}
|
|
|
|
LG_LOG_INFO_0( "Drummer starting...");
|
|
|
|
if( ( status = DR_Init()) != DRS_OK)
|
|
{
|
|
exit( -1);
|
|
}
|
|
|
|
if( ( status = DR_Kits_Load()) != DRS_OK)
|
|
{
|
|
exit( -1);
|
|
}
|
|
/*
|
|
if( ( status = DR_Kit_Id_Find( &kit_ptr, base.Kit_DS_Ptr, 0)) != DRS_OK)
|
|
// if( ( status = DR_Kit_Logical_Id_Find( &kit_ptr, base.Kit_DS_Ptr, 31)) != DRS_OK)
|
|
// if( ( status = DR_Kit_Name_Find( &kit_ptr, base.Kit_DS_Ptr, "HardElectro1")) != DRS_OK)
|
|
{
|
|
exit( -1);
|
|
}
|
|
else
|
|
{
|
|
if( ( status = DR_Kit_Sample_Load( kit_ptr)) != DRS_OK)
|
|
{
|
|
exit( -1);
|
|
}
|
|
/*
|
|
fprintf( stderr, "Before!\n");
|
|
|
|
if( ( status = DR_Kit_Sample_UnLoad( kit_ptr)) != DRS_OK)
|
|
{
|
|
exit( -1);
|
|
}
|
|
*/
|
|
/*
|
|
fprintf( stderr, "After!\n");
|
|
|
|
if( ( status = DR_Kit_Sample_Load( kit_ptr)) != DRS_OK)
|
|
{
|
|
exit( -1);
|
|
}
|
|
*/
|
|
|
|
// }
|
|
|
|
DR_Kits_Sample_Load();
|
|
|
|
/*
|
|
for( i = 0; i < 1; i++)
|
|
{
|
|
if( ( status = DR_Kit_Logical_Id_Find( &kit_ptr, base.Kit_DS_Ptr, i)) == DRS_OK)
|
|
{
|
|
printf( "Loading Logical Id: (%d)\n", i);
|
|
DR_Kit_Sample_Load( kit_ptr);
|
|
}
|
|
}
|
|
*/
|
|
/*
|
|
if( DR_Task_Wait( &base) != DRS_OK)
|
|
{
|
|
printf( "DR_Task_Wait failed (%d)!\n");
|
|
exit(-1);
|
|
}
|
|
*/
|
|
|
|
LG_LOG_INFO_0( "hello world!");
|
|
|
|
|
|
|
|
// DR_Kits_Graph_Dump( &base);
|
|
|
|
/*
|
|
if( ( status = DR_Kits_Dump( &base)) != DRS_OK)
|
|
{
|
|
exit( -1);
|
|
}
|
|
*/
|
|
/*
|
|
DR_Task_Run( &base, (DRT_Instrument *)1);
|
|
DR_Task_Run( &base, (DRT_Instrument *)2);
|
|
DR_Task_Run( &base, (DRT_Instrument *)3);
|
|
*/
|
|
// sleep( 10);
|
|
|
|
/*
|
|
if( ( status = DR_Tasks_Dump( &base)) != DRS_OK)
|
|
{
|
|
exit( -1);
|
|
}
|
|
|
|
if( ( status = DR_Task_Wait( &base)) != DRS_OK)
|
|
{
|
|
exit( -1);
|
|
}
|
|
*/
|
|
DRT_Kit_Name *kit_name_tab;
|
|
long kit_number;
|
|
long kit_id;
|
|
|
|
if( ( status = DR_Kits_Name_Get( &kit_name_tab, &kit_number)) != DRS_OK)
|
|
{
|
|
exit( -1);
|
|
}
|
|
else
|
|
{
|
|
for( kit_id = 0; kit_id < kit_number; kit_id++)
|
|
{
|
|
LG_LOG_INFO_4( "Kit #: (%d) Id: (%d) Logical_Id: (%d) Name: [%s]",
|
|
kit_id, kit_name_tab[ kit_id].Id, kit_name_tab[ kit_id].Logical_Id, kit_name_tab[ kit_id].Name);
|
|
}
|
|
}
|
|
|
|
|
|
if( ( status = DR_Tasks_Dump()) != DRS_OK)
|
|
{
|
|
exit( -1);
|
|
}
|
|
|
|
if( ( status = DR_Kits_Stats_Dump()) != DRS_OK)
|
|
{
|
|
exit( -1);
|
|
}
|
|
|
|
if( ( status = DR_DeInit()) != DRS_OK)
|
|
{
|
|
exit( -1);
|
|
}
|
|
|
|
LG_LOG_INFO_0( "Drummer Ending!");
|
|
|
|
if( ( lg_status = LG_Library_Close( true)) != LGS_OK)
|
|
{
|
|
fprintf( stderr, "Can't close LibLog library: (%d)\n", lg_status);
|
|
exit( -1);
|
|
}
|
|
|
|
exit( 0);
|
|
}
|