Esempio n. 1
0
bool InitProgram(void){
//	GC_INIT();
  bool ret;

#if !defined(FOR_MACOSX)
  RADIUM_ensure_bin_packages_gc_is_used();
#endif
  
  printf("Initializing...\n");

	printf("...Error handler\n");
	Error_init();

	printf("...Memory handler\n");
	init_memory();

	root=tralloc(sizeof(struct Root));

	if(root==NULL){
		fprintf(stderr,"Not enough memory\n");
		return false;
	}

	root->keyoct=36;
        root->quantitize_options = Quantitize_get_default_options();
        root->grid_numerator=1;
        root->grid_denominator=1;
        root->min_standardvel=MAX_VELOCITY*40/100;
	root->standardvel=MAX_VELOCITY*80/100;
        ATOMIC_SET(root->editonoff, true);
        ATOMIC_SET(root->play_cursor_onoff, false);
        ATOMIC_SET(root->editor_follows_play_cursor_onoff, true);

	root->song=talloc(sizeof(struct Song));

	pc=tralloc(sizeof(PlayerClass));

	if(root->song==NULL || pc==NULL){
		fprintf(stderr,"Not enough memory\n");
		return false;
	}

        pc->pfreq = 48000; // Default value. Should be overridden in MIXER_start().

/*
	if( ( ! InitPEQmempool(1000) )  || ( ! Input_Init(4000) ) ){	// 1000 and 4000 are hardcoded values. Not good.
		return false;
	}
*/

        printf("...Midi\n");
        MIDI_input_init();

        SCHEDULER_init();

        PATCH_init();

	printf("...Sound\n");
        if(MIXER_start()==false){
          fprintf(stderr,"Could not open Sound\n");
          return false;
        }

	printf("...Player 1/2\n");

	if( ( ! InitPEQmempool() )   ){	// 1000 and 4000 are hardcoded values. Not good.
		return false;
	}


	printf("...Clock handler\n");

	if( ! InitClock() ) return false;

	printf("...Player 2/2\n");

	PEQ_GetType_Init();

	printf("...Instrument\n");

	if( OpenInstruments()==false ){
          return false;
        }

	printf("...Kebang\n");

	ret=NewSong();

#if !USE_OPENGL
	printf("...Blitting\n");

	if(ret==true){
	  Blt_blt(root->song->tracker_windows);
	}
#endif

	printf("Initialization finished.\n");

	return ret;
}
Esempio n. 2
0
static
tralloc_bool test_fragment_is_remained ( tralloc_context * ctx )
{
    size_t data_1_user_length = sizeof ( _tralloc_pool_fragment ) + sizeof ( uint8_t ) * 4;
    size_t data_2_user_length = sizeof ( uint8_t ) * 3;
    size_t data_1_length      = tralloc_predict_chunk_length ( TRALLOC_EXTENSION_POOL_CHILD ) + data_1_user_length;
    size_t data_2_length      = tralloc_predict_chunk_length ( TRALLOC_EXTENSION_POOL_CHILD ) + data_2_user_length;
    size_t pool_data_length   = data_1_length + data_2_length;

    tralloc_context * pool_data;
    uint8_t * data_1, * data_2;
    if (
        tralloc_with_extensions ( ctx, &pool_data, TRALLOC_EXTENSION_POOL, pool_data_length ) != 0 ||
        tralloc ( pool_data, ( tralloc_context ** ) &data_1, data_1_user_length ) != 0 ||
        tralloc ( pool_data, ( tralloc_context ** ) &data_2, data_2_user_length ) != 0 ||
        tralloc_free ( data_1 ) != 0
    ) {
        return TRALLOC_FALSE;
    }

    _tralloc_chunk * pool_chunk = _tralloc_get_chunk_from_context ( pool_data );
    if ( ! ( pool_chunk->extensions & TRALLOC_EXTENSION_POOL ) ) {
        return TRALLOC_FALSE;
    }
    _tralloc_pool * pool = _tralloc_get_pool_from_chunk ( pool_chunk );

    _tralloc_chunk * data_2_chunk = _tralloc_get_chunk_from_context ( data_2 );
    if ( ! ( data_2_chunk->extensions & TRALLOC_EXTENSION_POOL_CHILD ) ) {
        return TRALLOC_FALSE;
    }
    _tralloc_pool_child * data_2_child = _tralloc_get_pool_child_from_chunk ( data_2_chunk );

    _tralloc_pool_fragment * fragment = ( _tralloc_pool_fragment * ) ( ( uintptr_t ) data_2_child + data_2_child->length );

    // [ data_2 ] [ data_1_fragment ]
    if (
        pool->first_child  != data_2_child     ||
        pool->max_fragment != fragment         ||
        pool->memory       != pool_data        ||
        pool->length       != pool_data_length ||
        pool->autofree     != TRALLOC_FALSE    ||

        data_2_child->pool   != pool          ||
        data_2_child->prev   != NULL          ||
        data_2_child->next   != NULL          ||
        data_2_child->length != data_2_length ||

        fragment->prev       != NULL         ||
        fragment->next       != NULL         ||
        fragment->prev_child != data_2_child ||
        fragment->next_child != NULL         ||
        fragment->length     != data_1_length
    ) {
        return TRALLOC_FALSE;
    }

    if ( tralloc_realloc ( ( tralloc_context ** ) &data_2, data_2_user_length + data_1_length - sizeof ( _tralloc_pool_fragment ) ) != 0 ) {
        return TRALLOC_FALSE;
    }

    fragment = ( _tralloc_pool_fragment * ) ( ( uintptr_t ) data_2_child + data_2_child->length );

    // [ data_2 ] [ fragment ]
    if (
        pool->first_child  != data_2_child     ||
        pool->max_fragment != fragment         ||
        pool->memory       != pool_data        ||
        pool->length       != pool_data_length ||
        pool->autofree     != TRALLOC_FALSE    ||

        data_2_child->pool   != pool ||
        data_2_child->prev   != NULL ||
        data_2_child->next   != NULL ||
        data_2_child->length != data_2_length + data_1_length - sizeof ( _tralloc_pool_fragment ) ||

        fragment->prev       != NULL         ||
        fragment->next       != NULL         ||
        fragment->prev_child != data_2_child ||
        fragment->next_child != NULL         ||
        fragment->length     != sizeof ( _tralloc_pool_fragment )
    ) {
        return TRALLOC_FALSE;
    }

    if ( tralloc_free ( pool_data ) != 0 ) {
        return TRALLOC_FALSE;
    }
    return TRALLOC_TRUE;
}
Esempio n. 3
0
TPtr TRAlloc(TPtr ptr, TUInt64 size)
{
	return tralloc(ptr,size);
}