Ejemplo n.º 1
0
/**
 * Oeffnet eine Datei
 * \param filename	Dateiname
 * \param *file		Zeiger auf Datei-Deskriptor
 * \param mode		Modus, in dem die Datei geoeffnet wird
 * \param *buffer	Puffer fuer mindestens BOTFS_BLOCK_SIZE Byte
 * \return			0, falls kein Fehler
 */
int8_t botfs_open(const char * filename, botfs_file_descr_t * file, uint8_t mode, void * buffer) {
	botfs_acquire_lock_low(&botfs_mutex);
	/* Datei suchen */
	botfs_file_t * ptr = search_file(filename, buffer);
	if (ptr == NULL) {
		botfs_release_lock_low(&botfs_mutex);
		PRINT_MSG("botfs_open(): file not found");
		return -1;
	}

	/* Datei-Deskriptor laden und updaten */
	*file = ptr->descr;
	file->mode = mode;
	file->pos = file->start + BOTFS_HEADER_SIZE;

	/* Datei-Header laden */
	if (botfs_read_low(file->start, buffer) != 0) {
		botfs_release_lock_low(&botfs_mutex);
		PRINT_MSG("botfs_open(): read_low()-error");
		return -2;
	}

	/* benutzte Bloecke lt. Header in den Datei-Deskriptor uebernehmen */
	botfs_file_header_t * ptr_head = buffer;
	file->used = ptr_head->used_blocks;
//	PRINT_MSG("botfs_open(): start=0x%x end=0x%x", file->used.start, file->used.end);

	int8_t tmp = 0;
	if (mode == BOTFS_MODE_W) {
		PRINT_MSG("botfs_open(): Datei wird geleert...");
		tmp = clear_file(file, buffer);
	}
	botfs_release_lock_low(&botfs_mutex);
	return tmp;
}
Ejemplo n.º 2
0
/**
 * Entfernt eine Datei
 * \param *filename	Dateiname
 * \param *buffer	Puffer fuer mindestens BOTFS_BLOCK_SIZE Byte
 * \return			0, falls kein Fehler
 */
int8_t botfs_unlink(const char * filename, void * buffer) {
	botfs_acquire_lock_low(&botfs_mutex);
	/* Datei suchen */
	botfs_file_t * ptr = search_file(filename, buffer);
	if (ptr == NULL) {
		botfs_release_lock_low(&botfs_mutex);
		PRINT_MSG("botfs_unlink(): Datei nicht vorhanden");
		return -1;
	}

	/* Root-Dir Eintrag loeschen */
	ptr->name[0] = 0;
	ptr->name[1] = 0;
	botfs_seek(&botfs_vol_data.rootdir, -1, SEEK_CUR); // Dateizeiger stand auf naechstem Dir-Block => -1
	if (botfs_write(&botfs_vol_data.rootdir, buffer) != 0) {
		botfs_release_lock_low(&botfs_mutex);
		PRINT_MSG("botfs_unlink(): Fehler beim Schreiben des Root-Blocks");
		return -2;
	}
	const uint16_t start = ptr->descr.start;
	const uint16_t end = ptr->descr.end;

	/* Freelist aktualisieren */
	int8_t res = add_to_freelist(start, end, buffer);

	botfs_release_lock_low(&botfs_mutex);

	PRINT_MSG("botfs_unlink(): Datei \"%s\" wurde geloescht", filename);
	return res;
}
Ejemplo n.º 3
0
/**
 * Initialisiert ein Volume
 * \param *image	Dateiname des Images
 * \param *buffer	Puffer fuer mindestens BOTFS_BLOCK_SIZE Byte
 * \param create	Soll das Volume erzeugt werden, falls es nicht existiert?
 * \return			0, falls kein Fehler
 */
int8_t botfs_init(char * image, void * buffer, uint8_t create) {
	init_state = 0;
	/* Volume laden */
	PRINT_MSG("botfs_init_low(\"%s\")...", image);
	if (botfs_init_low(image, buffer, create) != 0) {
		PRINT_MSG("botfs_init(): botfs_init_low() schlug fehl");
		return -1;
	}

	/* Header einlesen */
	if (botfs_read_low(BOTFS_HEADER_POS, buffer) != 0) {
		PRINT_MSG("botfs_init(): botfs_read_low(BOTFS_HEADER_POS) schlug fehl");
		return -2;
	}

	/* Root-Dir- und Freelist-Adresse speichern */
	botfs_volume_t * volume = buffer;
	botfs_vol_data = volume->data.ctrldata;
	init_state = 1;

	if (botfs_check_volume_low(image, buffer) != 0) {
		PRINT_MSG("botfs_init(): Volume fehlerhaft");
		init_state = 0;
		return -3;
	}

	PRINT_MSG("botfs_init() erfolgreich");
	return 0;
}
Ejemplo n.º 4
0
/******************************************************************************
* 函 数 名: is_burn
* 功能描述: 检查efuse是否已经烧写了flash info
* 输入参数: @burn_flag: 烧写标志。1 - 已烧写;0 - 未烧写
*			@buffer: efuse中nandc info所在group的值
* 输出参数: 无
* 返 回 值: 0 - 成功; 非0 - 失败
* 函数说明: 检查
*******************************************************************************/
static s32 is_burn(u32 *burn_flag)
{
	s32 ret;
	u32 efuse_nand_info_addr = EFUSE_NANDC_GROUP_OFFSET;
    u32 buffer = 0;

	ret = bsp_efuse_read(&buffer, efuse_nand_info_addr, EFUSE_NANDC_GROUP_LENGTH);
	if(ret)
	{
		PRINT_MSG("Efuse read info error\n");
		goto erro;
	}

	PRINT_MSG("After read: 0x%x\n", buffer);

	ret = check_flag(buffer);
	if(EFUSE_NANDC_NOT_BURN == ret)
	{
		*burn_flag = EFUSE_NANDC_NOT_BURN;
	}
	else
	{
		*burn_flag = EFUSE_NANDC_HAD_BURN;
	}

	return OK;
erro:
	return ret;
}
Ejemplo n.º 5
0
int main (int argc, char **argv)
{
  uint_t err = 0;
  if (argc < 2) {
    err = 2;
    PRINT_ERR("not enough arguments\n");
    PRINT_MSG("read a wave file as a mono vector\n");
    PRINT_MSG("usage: %s <source_path> [samplerate] [win_size] [hop_size]\n", argv[0]);
    return err;
  }
  uint_t samplerate = 0;
  if ( argc >= 3 ) samplerate = atoi(argv[2]);
  uint_t win_size = 1024; // window size
  if ( argc >= 4 ) win_size = atoi(argv[3]);
  uint_t hop_size = win_size / 4;
  if ( argc >= 5 ) hop_size = atoi(argv[4]);
  uint_t n_frames = 0, read = 0;

  char_t *source_path = argv[1];
  aubio_source_t * source = new_aubio_source(source_path, samplerate, hop_size);
  if (!source) { err = 1; goto beach; }

  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(source);

  // create some vectors
  fvec_t * in = new_fvec (hop_size); // input audio buffer
  fvec_t * out = new_fvec (1); // output position

  // create tempo object
  aubio_tempo_t * o = new_aubio_tempo("default", win_size, hop_size, samplerate);

  do {
    // put some fresh data in input vector
    aubio_source_do(source, in, &read);
    // execute tempo
    aubio_tempo_do(o,in,out);
    // do something with the beats
    if (out->data[0] != 0) {
      PRINT_MSG("beat at %.3fms, %.3fs, frame %d, %.2fbpm with confidence %.2f\n",
          aubio_tempo_get_last_ms(o), aubio_tempo_get_last_s(o),
          aubio_tempo_get_last(o), aubio_tempo_get_bpm(o), aubio_tempo_get_confidence(o));
    }
    n_frames += read;
  } while ( read == hop_size );

  PRINT_MSG("read %.2fs, %d frames at %dHz (%d blocks) from %s\n",
      n_frames * 1. / samplerate,
      n_frames, samplerate,
      n_frames / hop_size, source_path);

  // clean up memory
  del_aubio_tempo(o);
  del_fvec(in);
  del_fvec(out);
  del_aubio_source(source);
beach:
  aubio_cleanup();

  return err;
}
Ejemplo n.º 6
0
static ret_t
remove_old_socket (const char *path)
{
	int         re;
	struct stat info;

	/* It might not exist
	 */
	re = cherokee_stat (path, &info);
	if (re != 0) {
		return ret_ok;
	}

	/* If exist, it must be a socket
	 */
	if (! S_ISSOCK(info.st_mode)) {
		PRINT_MSG ("ERROR: Something happens; '%s' isn't a socket.\n", path);
		return ret_error;
	}

	/* Remove it
	 */
	re = unlink (path);
	if (re != 0) {
		PRINT_MSG ("ERROR: Couldn't remove unix socket '%s'.\n", path);
		return ret_error;
	}

	return ret_ok;
}
// --------------------------------------------------------------------------
//  From class CMMFCodec.
//  The function sets codec configuration.
//  value used for aConfigType must be KUidMmfCodecAudioSettings
//  (defined in include\mmf\plugins\mmfCodecImplementationUIDs.hrh)
//
// --------------------------------------------------------------------------
//
void CAriAmrNbEncMmfCodec::ConfigureL( TUid /* aConfigType */,
                                                const TDesC8& aParam )
    {
    PRINT_ENTRY;
    if ( !iConfigured )
        {
        TInt encMode = 0;
        TInt dtx = 0;
        TInt offset = 0;

        Mem::Copy( &encMode,  aParam.Ptr() + offset,  sizeof( TInt ) );
        offset += sizeof(TInt);

        Mem::Copy( &dtx,  aParam.Ptr() + offset,  sizeof( TInt ) );
        offset += sizeof(TInt);

        iParam.iMode = ( TInt16 )encMode;
        iParam.iDtx = ( TInt16 )dtx;

        PRINT_MSG( LEVEL_HIGH, ( "Mode: %d", iParam.iMode ) );
        PRINT_MSG( LEVEL_HIGH, ( "DTX: %d", iParam.iDtx ) );

        User::LeaveIfError( iCodec->Reset( &iParam ) );

        iConfigured = ETrue;
        }
    PRINT_EXIT;
    }
// --------------------------------------------------------------------------
//  Second phase of the two-phased constructor.
//  Creates an instance of encoder
// --------------------------------------------------------------------------
//
void CAriAacLCEncMmfCodec::ConstructL()
    {
    PRINT_ENTRY;
    iCodec = CAriAacLCEncWrapper::NewL();

    iInternalInputBuffer = ( TUint8* ) User::AllocZL( KMinBytesInput );
    iInternalOutputBuffer = ( TUint8* ) User::AllocZL( KMinDstLen );

    PRINT_MSG( LEVEL_HIGH, ( "Default NumberOfChannels: %d",
                                                iParam.iNumberOfChannels ) );
    PRINT_MSG( LEVEL_HIGH, ( "Default OutputBitRate: %d",
                                                iParam.iOutputBitRate ) );
    PRINT_MSG( LEVEL_HIGH, ( "Default OutputFormat: %d",
                                                iParam.iOutputFormat ) );

    PRINT_MSG( LEVEL_HIGH, ( "Default SamplingFrequency: %d",
                                                iParam.iSamplingFrequency ) );

    //Reset encoder with default parameters
    User::LeaveIfError( iCodec->Reset( &iParam ) );

    iSrclenToProcess = sizeof( TInt16 ) * KNoOfSamples *
                                                    iParam.iNumberOfChannels;
    PRINT_EXIT;
    }
Ejemplo n.º 9
0
/**
 * Laedt das Volume
 * \param *image	Dateiname des Images
 * \param *buffer	Puffer fuer mindestens BOTFS_BLOCK_SIZE Byte
 * \param create	Soll das Volume erzeugt werden, falls es nicht existiert?
 * \return			0, falls kein Fehler
 */
int8_t botfs_init_low(char * image, void * buffer, uint8_t create) {
	(void) buffer; // kein warning
#ifdef DEBUG_BOTFS_LOGFILE
	botfs_acquire_lock_low(&log_mutex);
	botfs_log_fd = fopen(BOTFS_DEBUG_LOGFILE, "wb");
	botfs_release_lock_low(&log_mutex);
#endif // DEBUG_BOTFS_LOGFILE

	botfs_acquire_lock_low(&file_mutex);
	image_file = fopen(image, "r+b");
	botfs_release_lock_low(&file_mutex);
	if (image_file == NULL) {
		PRINT_MSG("botfs_init_low(): Image-Datei \"%s\" konnte nicht geoeffnet werden", image);
		if (create != 1) {
			return -1;
		}
		PRINT_MSG("botfs_init_low(): Lege neues Images \"%s\" an...", image);
		if (botfs_create_volume(image, BOTFS_DEFAULT_VOL_NAME, BOTFS_DEFAULT_VOL_SIZE) != 0) {
			PRINT_MSG("botfs_init_low(): botfs_create_volume(\"%s\") schlug fehl", image);
			return -2;
		}
		botfs_acquire_lock_low(&file_mutex);
		image_file = fopen(image, "r+b");
		botfs_release_lock_low(&file_mutex);
		if (image_file == NULL) {
			PRINT_MSG("botfs_init_low(): angelegte Image-Datei \"%s\" konnte nicht geoeffnet werden", image);
			return -3;
		}
	}

	PRINT_MSG("botfs_init_low() erfolgreich");
	return 0;
}
Ejemplo n.º 10
0
static ret_t
check_worker_version (const char *this_exec)
{
	FILE *f;
	char  tmp[256];
	char *line, *p;
	int   re;

	snprintf (tmp, sizeof(tmp), "%s -i", cherokee_worker);
	f = popen (tmp, "r");
	if (f == NULL) {
		PRINT_MSG ("(critical) Cannot execute '%s'\n", tmp);
		goto error;
	}

	while (! feof(f)) {
		/* Skip line until it found the version entry
		 */
		line = fgets (tmp, sizeof(tmp), f);
		if (line == NULL)
			continue;

		line = strstr (line, "Version: ");
		if (line == NULL)
			continue;

		/* Compare both version strings
		 */
		line += 9;
		re = strncmp (line, PACKAGE_VERSION, strlen(PACKAGE_VERSION));
		if (re == 0) {
			pclose(f);
			return ret_ok;
		}

		/* Remove the new line character and report the error
		 */
		p = line;
		while (*p++ != '\n');
		*p = '\0';

		PRINT_MSG_S ("ERROR: Broken installation detected\n");
		PRINT_MSG   ("  Cherokee        (%s) %s\n", this_exec, PACKAGE_VERSION);
		PRINT_MSG   ("  Cherokee-worker (%s) %s\n", cherokee_worker, line);
		PRINT_MSG_S ("\n");
		PRINT_MSG_S ("This issue is usually caused by a secondary Cherokee installation in your $PATH.\n");
		PRINT_MSG_S ("The following command might help to find where the installations were performed:\n\n");
		PRINT_MSG_S ("find `echo $PATH | sed 's/:/ /g'` -name 'cherokee*' -exec dirname \"{}\" \\; | uniq\n");
		PRINT_MSG_S ("\n");

		goto error;
	}

	PRINT_MSG ("(critical) Couldn't find the version string: '%s -i'\n", cherokee_worker);
error:
	if (f != NULL) {
		pclose(f);
	}
	return ret_error;
}
Ejemplo n.º 11
0
static int
sem_new (void)
{
	int         i;
	int         re;
	int         sem;
	union semun ctrl;

	/* Create */
	sem = semget (getpid(), SEM_LAUNCH_TOTAL, IPC_CREAT | SEM_R | SEM_A);
	if (sem < 0) {
		PRINT_MSG ("Could not create semaphore: %s\n", strerror(errno));
		return -1;
	}

	/* Initialize */
	for (i=0; i < SEM_LAUNCH_TOTAL; i++) {
		ctrl.val = 0;
		re = semctl (sem, i, SETVAL, ctrl);
		if (re < 0) {
			goto error;
		}
	}

	return sem;

error:
	PRINT_MSG ("Could not initialize semaphore: %s\n", strerror(errno));
	return -1;
}
Ejemplo n.º 12
0
int main (int argc, char **argv)
{
  sint_t err = 0;

  if (argc < 3) {
    err = 2;
    PRINT_ERR("not enough arguments\n");
    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate] [hop_size]\n", argv[0]);
    return err;
  }

  char_t *source_path = argv[1];
  char_t *sink_path = argv[2];

  uint_t samplerate = 0;
  uint_t hop_size = 256;
  if ( argc >= 4 ) samplerate = atoi(argv[3]);
  if ( argc >= 5 ) hop_size = atoi(argv[4]);
  if ( argc >= 6 ) {
    err = 2;
    PRINT_ERR("too many arguments\n");
    return err;
  }

  fvec_t *vec = new_fvec(hop_size);
  if (!vec) { err = 1; goto beach_fvec; }

  aubio_source_t *i = new_aubio_source(source_path, samplerate, hop_size);
  if (!i) { err = 1; goto beach_source; }

  if (samplerate == 0 ) samplerate = aubio_source_get_samplerate(i);

  aubio_sink_t *o = new_aubio_sink(sink_path, samplerate);
  if (!o) { err = 1; goto beach_sink; }

  uint_t n_frames = 0, read = 0;

  do {
    aubio_source_do(i, vec, &read);
    aubio_sink_do(o, vec, read);
    n_frames += read;
  } while ( read == hop_size );

  PRINT_MSG("read %d frames at %dHz (%d blocks) from %s written to %s\n",
      n_frames, samplerate, n_frames / hop_size,
      source_path, sink_path);

  del_aubio_sink(o);
beach_sink:
  del_aubio_source(i);
beach_source:
  del_fvec(vec);
beach_fvec:
  return err;
}
Ejemplo n.º 13
0
/******************************************************************************
* 函 数 名: burn_efuse_nandc
* 功能描述: 将flash spec info烧写进efuse
* 输入参数: 无
* 输出参数: 无
* 返 回 值: 0 - 成功; 非0 - 失败
* 函数说明:
*******************************************************************************/
s32 burn_efuse_nandc(void)
{
	s32 ret = ERROR;
	u32 burn_flag = 0;  /* 1 - already burn; 0 - not burn */
	struct nand_spec *spec;

	/* check whether nand info already burn */
    /* coverity[no_effect_test] */
	ret = is_burn(&burn_flag);
	if(ret)
	{
		PRINT_MSG("Check efuse info error\n");
		goto erro;
	}
	if(burn_flag)
	{
		PRINT_MSG("Efuse nandc info already burn\n");
		return OK;
	}

	/* get flash info  */
	spec = (struct nand_spec *)alloc(sizeof(struct nand_spec));
	if(!spec)
	{
		PRINT_MSG("Malloc memory failed\n");
		goto erro;
	}

	ret = bsp_get_nand_info(spec);
	if(OK != ret)
	{
		PRINT_MSG("Get flash info failed\n");
		goto erro;
	}

	PRINT_MSG("After get spec\n");
	PRINT_MSG("spec->pagesize			: 0x%x\n", spec->pagesize);
	PRINT_MSG("spec->pagenumperblock	: 0x%x\n", spec->pagenumperblock);
	PRINT_MSG("spec->addrnum			: 0x%x\n", spec->addrnum);
	PRINT_MSG("spec->ecctype			: 0x%x\n", spec->ecctype);


	/* burn flash info into efuse */
	ret = do_burn(spec);
	if(OK != ret)
	{
		PRINT_MSG("Burn flash info failed\n");
		goto erro;
	}

	return OK;

erro:
	return ret;
}
Ejemplo n.º 14
0
int main (int argc, char **argv)
{
  uint_t err = 0;
  if (argc < 2) {
    err = 2;
    PRINT_ERR("not enough arguments\n");
    PRINT_MSG("read a wave file as a mono vector\n");
    PRINT_MSG("usage: %s <source_path> [samplerate] [hop_size]\n", argv[0]);
    PRINT_MSG("examples:\n");
    PRINT_MSG(" - read file.wav at original samplerate\n");
    PRINT_MSG("       %s file.wav\n", argv[0]);
    PRINT_MSG(" - read file.wav at 32000Hz\n");
    PRINT_MSG("       %s file.aif 32000\n", argv[0]);
    PRINT_MSG(" - read file.wav at original samplerate with 4096 blocks\n");
    PRINT_MSG("       %s file.wav 0 4096 \n", argv[0]);
    return err;
  }

#if __APPLE__
  uint_t samplerate = 0;
  uint_t hop_size = 256;
  uint_t n_frames = 0, read = 0;
  if ( argc == 3 ) samplerate = atoi(argv[2]);
  if ( argc == 4 ) hop_size = atoi(argv[3]);

  char_t *source_path = argv[1];


  aubio_source_apple_audio_t * s =
    new_aubio_source_apple_audio(source_path, samplerate, hop_size);
  if (!s) { err = 1; goto beach; }
  fvec_t *vec = new_fvec(hop_size);

  if (samplerate == 0 ) samplerate = aubio_source_apple_audio_get_samplerate(s);

  do {
    aubio_source_apple_audio_do(s, vec, &read);
    fvec_print (vec);
    n_frames += read;
  } while ( read == hop_size );

  PRINT_MSG("read %d frames at %dHz (%d blocks) from %s\n", n_frames, samplerate,
    n_frames / hop_size, source_path);

  del_fvec (vec);
  del_aubio_source_apple_audio (s);
beach:
#else
  err = 3;
  PRINT_ERR("aubio was not compiled with aubio_source_apple_audio\n");
#endif /* __APPLE__ */
  return 0;
}
Ejemplo n.º 15
0
static int
sem_chmod (int sem, char *worker_uid)
{
	int              i;
	int              re;
	struct semid_ds  buf;
	union  semun     semopts;
	struct passwd   *passwd;
	int              uid     = 0;

	/* Read the UID
	 */
	uid = (int)strtol (worker_uid, (char **)NULL, 10);
	if (uid == 0) {
		passwd = getpwnam (worker_uid);
		if (passwd != NULL) {
			uid = passwd->pw_uid;
		}
	}

	if (uid == 0) {
		PRINT_MSG ("(warning) Couldn't get UID for user '%s'\n", worker_uid);
		return -1;
	}

	/* Initialize the memory
	 */
	memset (&buf,     0, sizeof(struct semid_ds));
	memset (&semopts, 0, sizeof(union  semun));

	semopts.buf = &buf;

	/* Set the permissions
	 */
	for (i=0; i<SEM_LAUNCH_TOTAL; i++) {
		re = semctl (sem, i, IPC_STAT, semopts);
		if (re != -0) {
			PRINT_MSG ("(warning) Couldn't IPC_STAT: errno=%d\n", errno);
			return -1;
		}

		buf.sem_perm.uid = uid;
		re = semctl (spawn_shared_sems, i, IPC_SET, semopts);
		if (re != 0) {
			PRINT_MSG ("(warning) Couldn't IPC_SET: uid=%d errno=%d\n", uid, errno);
			return -1;
		}
	}

	return 0;
}
// --------------------------------------------------------------------------
//  Second phase of the two-phased constructor.
//  Creates an instance of encoder
// --------------------------------------------------------------------------
//
void CAriAmrNbEncMmfCodec::ConstructL()
    {
    PRINT_ENTRY;
    iCodec = CAriAmrNbEncWrapper::NewL();

    iInternalInputBuffer = ( TUint8* ) User::AllocZL( KMinBytesInput );
    iInternalOutputBuffer = ( TUint8* ) User::AllocZL( KMinDstLen );

    PRINT_MSG( LEVEL_HIGH, ( "Default mode: %d", iParam.iMode ) );
    PRINT_MSG( LEVEL_HIGH, ( "Default DTX: %d", iParam.iDtx ) );
    //Reset encoder with default parameters
    User::LeaveIfError( iCodec->Reset( &iParam ) );
    PRINT_EXIT;
    }
Ejemplo n.º 17
0
int zarlinkCaculateDevObj(RTKDevType dev_type)
{
	int fxs_dev;
	int fxo_dev;
	int fxsfxo_dev;
	int fxsfxs_dev=0;
	int total_dev;

	if (DEV_FXS==dev_type) //display once
		PRINT_MSG("Total %d lines. %d fxs and %d fxo from Global configuration\n",
			ZARLINK_SLIC_CH_NUM, ZARLINK_FXS_LINE_NUM, ZARLINK_FXO_LINE_NUM);

	/* Use minimum number of device	to caculate possible combination */
	fxsfxo_dev = MIN(ZARLINK_FXS_LINE_NUM, ZARLINK_FXO_LINE_NUM);/* FXS+FXO dev */
#if defined (CONFIG_RTK_VOIP_SLIC_ZARLINK_880_SERIES)
	fxsfxs_dev = (ZARLINK_FXS_LINE_NUM - fxsfxo_dev) >> 1;	 	 /* FXS+FXS dev */ 
#endif
	fxs_dev = ZARLINK_FXS_LINE_NUM - fxsfxo_dev - 2*fxsfxs_dev;  /* FXS device  */
	fxo_dev	= ZARLINK_FXO_LINE_NUM - fxsfxo_dev; 				 /* FXO device  */

	total_dev = fxs_dev+fxsfxs_dev+fxo_dev+fxsfxo_dev;

	if (DEV_FXS==dev_type) //display once
		PRINT_MSG("Total %d devices\tFXS:%d, FXS+FXS:%d, FXS+FXO:%d, FXO:%d\n",
			total_dev, fxs_dev, fxsfxs_dev, fxsfxo_dev, fxo_dev );

	if (ZARLINK_SLIC_DEV_NUM < total_dev) {
		PRINT_R("error : %s() Not enough space for chObj\n",__FUNCTION__);
		return FAILED;
	}

	switch (dev_type) {
		case DEV_FXS:
			return fxs_dev;			
			break;
		case DEV_FXO:
			return fxo_dev;			
			break;
		case DEV_FXSFXS:
			return fxsfxs_dev;			
			break;
		case DEV_FXSFXO:
			return fxsfxo_dev;			
			break;
		default:
			return 0;
			break;
	}
	return 0;
}
Ejemplo n.º 18
0
static bool mesh_validate_customdata(
        CustomData *data, CustomDataMask mask,
        const bool do_verbose, const bool do_fixes,
        bool *r_change)
{
	bool is_valid = true;
	bool has_fixes = false;
	int i = 0;

	PRINT_MSG("%s: Checking %d CD layers...\n", __func__, data->totlayer);

	while (i < data->totlayer) {
		CustomDataLayer *layer = &data->layers[i];
		bool ok = true;

		if (CustomData_layertype_is_singleton(layer->type)) {
			const int layer_tot = CustomData_number_of_layers(data, layer->type);
			if (layer_tot > 1) {
				PRINT_ERR("\tCustomDataLayer type %d is a singleton, found %d in Mesh structure\n",
				          layer->type, layer_tot);
				ok = false;
			}
		}

		if (mask != 0) {
			CustomDataMask layer_typemask = CD_TYPE_AS_MASK(layer->type);
			if ((layer_typemask & mask) == 0) {
				PRINT_ERR("\tCustomDataLayer type %d which isn't in the mask\n",
				          layer->type);
				ok = false;
			}
		}

		if (ok == false) {
			if (do_fixes) {
				CustomData_free_layer(data, layer->type, 0, i);
				has_fixes = true;
			}
		}

		if (ok)
			i++;
	}

	PRINT_MSG("%s: Finished (is_valid=%d)\n\n", __func__, (int)!has_fixes);

	*r_change = has_fixes;

	return is_valid;
}
Ejemplo n.º 19
0
/*
 * free_blocks_status () only shows the status
 * of the free blocks
 */
void free_blocks_status (char *block_ptr){
  int i, j;
  block_header_t *b;

  TLSF_t *ptr_TLSF;
  
  ptr_TLSF = (TLSF_t *) block_ptr; 
  if (!ptr_TLSF || ptr_TLSF -> magic_number != MAGIC_NUMBER) {
    PRINT_MSG 
      ("free_blocks_status() error: TLSF structure is not initialized\n");
    PRINT_MSG 
      ("Hint: Execute init_memory_pool() before calling free_blocks_status()");

    return;
  }

  PRINT_DBG_C ("\nTLSF structure address 0x");
  PRINT_DBG_H (ptr_TLSF);
  PRINT_DBG_C ("\nFREE BLOCKS\n\n");
  for (i = ptr_TLSF -> max_fl_index  - 1 - MIN_LOG2_SIZE; i >= 0; i--) {
    if (ptr_TLSF -> fl_array [i].bitmapSL > 0)
      for (j = ptr_TLSF -> max_sl_index - 1; j >= 0; j--) {
        if (ptr_TLSF -> fl_array [i].sl_array[j]) {
          b = ptr_TLSF -> fl_array [i].sl_array [j];
          PRINT_DBG_C ("[");
          PRINT_DBG_D (i + MIN_LOG2_SIZE);
          PRINT_DBG_C ("] ");
          PRINT_DBG_D (TLSF_WORDS2BYTES(1 << (i + MIN_LOG2_SIZE)));
	  PRINT_DBG_C (" bytes -> Free blocks: 0x");
	  PRINT_DBG_H (ptr_TLSF -> fl_array [i].bitmapSL);
          PRINT_DBG_C ("\n");
	  
          while (b) {
	    PRINT_DBG_C (">>>> First_Level [");
	    PRINT_DBG_D (i + MIN_LOG2_SIZE);
	    PRINT_DBG_C ("] Second Level [");
	    PRINT_DBG_D (j);
	    PRINT_DBG_C ("] -> ");
	    PRINT_DBG_D (TLSF_WORDS2BYTES((1 << (i + MIN_LOG2_SIZE)) + 
			  ( ((1 << (i + MIN_LOG2_SIZE)) / 
			     ptr_TLSF -> max_sl_index) * j)));

            PRINT_DBG_C (" bytes\n");
            print_block (b);
            b = b -> ptr.free_ptr.next;
          }
        }
      }
  }
}
static gboolean
sort_queue (gpointer user_data)
{
  static gint     sorts = 0;
  static gpointer last_p = NULL;
  gpointer        p;
  gboolean        can_quit = FALSE;
  gint            sort_multiplier;
  gint            len;
  gint            i;

  sort_multiplier = GPOINTER_TO_INT (user_data);

  if (SORT_QUEUE_AFTER) {
    PRINT_MSG (("sorting async queue...")); 
    g_async_queue_sort (async_queue, sort_compare, NULL);

    sorts++;

    if (sorts >= sort_multiplier) {
      can_quit = TRUE;
    }
    
    g_async_queue_sort (async_queue, sort_compare, NULL);
    len = g_async_queue_length (async_queue);

    PRINT_MSG (("sorted queue (for %d/%d times, size:%d)...", sorts, MAX_SORTS, len)); 
  } else {
    can_quit = TRUE;
    len = g_async_queue_length (async_queue);
    DEBUG_MSG (("printing queue (size:%d)...", len)); 
  }

  for (i = 0, last_p = NULL; i < len; i++) {
    p = g_async_queue_pop (async_queue);
    DEBUG_MSG (("item %d ---> %d", i, GPOINTER_TO_INT (p))); 

    if (last_p) {
      g_assert (GPOINTER_TO_INT (last_p) <= GPOINTER_TO_INT (p));
    }

    last_p = p;
  }
  
  if (can_quit && QUIT_WHEN_DONE) {
    g_main_loop_quit (main_loop);
  }

  return !can_quit;
}
Ejemplo n.º 21
0
static ret_t
process_wait (pid_t wpid)
{
	pid_t re;
	int   exitcode = 0;

	while (true) {
		re = waitpid (wpid, &exitcode, 0);
		if (re > 0)
			break;
		else if (errno == EINTR)
			if (graceful_restart)
				break;
			else
				continue;
		else if (errno == ECHILD) {
			return ret_ok;
		} else {
			return ret_error;
		}
	}

	if (WIFEXITED(exitcode)) {
		int re = WEXITSTATUS(exitcode);

		if (wpid == pid && re == EXIT_OK_ONCE) {
			clean_up();
			exit (EXIT_OK);

		} else if (wpid == pid && re == EXIT_ERROR_FATAL) {
			clean_up();
			exit (EXIT_ERROR);
		}

		/* Child terminated normally */
		PRINT_MSG ("PID %d: exited re=%d\n", wpid, re);
		if (re != 0 && wpid == pid) {
			worker_retcode = re;
			return ret_error;
		}
	}
	else if (WIFSIGNALED(exitcode)) {
		/* Child process terminated by a signal */
		PRINT_MSG ("PID %d: received a signal=%d\n", wpid, WTERMSIG(exitcode));
	}

	worker_retcode = 0;
	return ret_ok;
}
Ejemplo n.º 22
0
/**
 * Prueft eine Dateiposition auf Gueltigkeit
 * \param *file		Zeiger auf Datei-Deskriptor
 * \param pos		Zu ueberpruefende Position (in Bloecken)
 */
static int8_t check_pos(botfs_file_descr_t * file, uint16_t pos) {
	if (pos > file->start && pos <= file->end) {
		return 0;
	}
	PRINT_MSG("check_pos(): start=0x%x, end=0x%x, pos=0x%x", file->start, file->end, pos);
	return -1;
}
Ejemplo n.º 23
0
static void
test_slist_insert_sorted_with_data (void)
{
  GSList *slist = NULL;
  gint    i;

  PRINT_MSG (("testing g_slist_insert_sorted_with_data()"));

  for (i = 0; i < SIZE; i++) {
    slist = g_slist_insert_sorted_with_data (slist, 
					   GINT_TO_POINTER (array[i]), 
					   (GCompareDataFunc)sort, 
					   NULL);
  }

  for (i = 0; i < SIZE - 1; i++) {
    gpointer p1, p2;

    p1 = g_slist_nth_data (slist, i);
    p2 = g_slist_nth_data (slist, i+1);

    g_assert (GPOINTER_TO_INT (p1) <= GPOINTER_TO_INT (p2));
    DEBUG_MSG (("slist_insert_sorted_with_data #%3.3d ---> %d", i, GPOINTER_TO_INT (p1)));
  }
}
Ejemplo n.º 24
0
int
main (int argc, char *argv[])
{
  gint i;

  DEBUG_MSG (("debugging messages turned on"));

  DEBUG_MSG (("creating %d random numbers", SIZE));

  /* Create an array of random numbers. */
  for (i = 0; i < SIZE; i++) {
    array[i] = g_random_int_range (NUMBER_MIN, NUMBER_MAX);
    DEBUG_MSG (("number #%3.3d ---> %d", i, array[i]));
  }

  /* Start tests. */
  test_slist_sort ();
  test_slist_sort_with_data ();

  test_slist_insert_sorted ();
  test_slist_insert_sorted_with_data ();

  test_slist_reverse ();
  test_slist_nth ();

  PRINT_MSG (("testing finished"));

  return 0;
}
Ejemplo n.º 25
0
int pcm_set_LoopMode(unsigned char group, unsigned int mode, unsigned char main_chid, unsigned char mate_chid)
{
	int i, j = 0;
	if (mode==0)
	{
		PRINT_MSG("Set Loop Mode=0 for group%d\n", group);
		pcm_LoopMode[group].mode = mode;	//0: Not loop mode, 1: loop mode, 2: loop mode with VoIP
		return 1;
	}
	
	if ((mode != 0) && (pcm_LoopMode[group].mode != 0))
	{
		PRINT_R("Wrong Setting for PCM Loop Mode. Group%d has been set to mode%d\n", group, pcm_LoopMode[group].mode);
		return 0;
	}

	if (main_chid == mate_chid)
	{
		PRINT_R("Wrong Setting for PCM Loop Mode. main_chid= %d, mate_chid= %d\n", main_chid, mate_chid);
		return 0;
	}

	//if (pcm_LoopMode[group].mode != mode)
	{
		PRINT_MSG("Enter Loop Mode=%d, ch= %d, %d for group%d\n", mode, main_chid, mate_chid, group);
		pcm_LoopMode[group].mode = mode;
		pcm_LoopMode[group].main_ch = main_chid;
		pcm_LoopMode[group].mate_ch = mate_chid;
		
		for(i=0; i<2; i++)
		{
			if (i ==0)
				j = main_chid;
			else if (i ==1)
				j = mate_chid;
			
			rx_loop_r[j]=0;
			rx_loop_w[j]=0;
			tx_loop_r[j]=0;
			tx_loop_w[j]=0;
		}
	}
	
	return 1;

}
Ejemplo n.º 26
0
Timer::Timer(Type type, const char *name /* = NULL */, ReportType r)
  : m_type(type), m_report(r) {
  if (name) {
    m_name = name;
    PRINT_MSG("%s...", name);
  }
  m_start = measure();
}
Ejemplo n.º 27
0
int main (int argc, char **argv)
{
  sint_t err = 0;

  if (argc < 3) {
    err = 2;
    PRINT_ERR("not enough arguments\n");
    PRINT_MSG("usage: %s <input_path> <output_path> [samplerate]\n", argv[0]);
    return err;
  }

#ifdef __APPLE__
  uint_t samplerate = 44100;
  uint_t hop_size = 512;
  uint_t n_frames = 0, read = 0;

  char_t *source_path = argv[1];
  char_t *sink_path = argv[2];
  if ( argc == 4 ) samplerate = atoi(argv[3]);

  fvec_t *vec = new_fvec(hop_size);
  aubio_source_apple_audio_t *i = new_aubio_source_apple_audio(source_path, samplerate, hop_size);
  if (samplerate == 0 ) samplerate = aubio_source_apple_audio_get_samplerate(i);
  aubio_sink_apple_audio_t *o = new_aubio_sink_apple_audio(sink_path, samplerate);

  if (!i || !o) { err = 1; goto beach; }

  do {
    aubio_source_apple_audio_do(i, vec, &read);
    aubio_sink_apple_audio_do(o, vec, read);
    n_frames += read;
  } while ( read == hop_size );

  PRINT_MSG("%d frames read from %s\n written to %s at %dHz\n",
      n_frames, source_path, sink_path, samplerate);

beach:
  del_aubio_source_apple_audio(i);
  del_aubio_sink_apple_audio(o);
  del_fvec(vec);
#else
  err = 3;
  PRINT_ERR("aubio was not compiled with aubio_source_apple_audio\n");
#endif /* __APPLE__ */
  return err;
}
Ejemplo n.º 28
0
//-------------------------------------------------------------------------------------
void Messagelog::writeLog(Mercury::Channel* pChannel, KBEngine::MemoryStream& s)
{
	uint32 logtype;
	COMPONENT_TYPE componentType = UNKNOWN_COMPONENT_TYPE;
	COMPONENT_ID componentID = 0;
	COMPONENT_ORDER componentOrder = 0;
	int64 t;
	GAME_TIME kbetime = 0;
	std::string str;
	std::stringstream logstream;

	s >> logtype;
	s >> componentType;
	s >> componentID;
	s >> componentOrder;
	s >> t >> kbetime;
	s >> str;

	time_t tt = static_cast<time_t>(t);	
    tm* aTm = localtime(&tt);
    //       YYYY   year
    //       MM     month (2 digits 01-12)
    //       DD     day (2 digits 01-31)
    //       HH     hour (2 digits 00-23)
    //       MM     minutes (2 digits 00-59)
    //       SS     seconds (2 digits 00-59)

	if(aTm == NULL)
	{
		ERROR_MSG("Messagelog::writeLog: log is error!\n");
		return;
	}

	char timebuf[MAX_BUF];
    kbe_snprintf(timebuf, MAX_BUF, " [%-4d-%02d-%02d %02d:%02d:%02d %02d] ", aTm->tm_year+1900, aTm->tm_mon+1, 
		aTm->tm_mday, aTm->tm_hour, aTm->tm_min, aTm->tm_sec, kbetime);

	logstream << KBELOG_TYPE_NAME_EX(logtype);
	logstream << " ";
	logstream << COMPONENT_NAME_EX_1(componentType);
	logstream << " ";
	logstream << componentID;
	logstream << " ";
	logstream << (int)componentOrder;
	logstream << timebuf;
	logstream << "- ";
	logstream << str;
	DebugHelper::getSingleton().changeLogger(COMPONENT_NAME_EX(componentType));
	PRINT_MSG(logstream.str());
	DebugHelper::getSingleton().changeLogger("default");

	LOG_WATCHERS::iterator iter = logWatchers_.begin();
	for(; iter != logWatchers_.end(); iter++)
	{
		iter->second.onMessage(logtype, componentType, componentID, componentOrder, t, kbetime, str, logstream);
	}
}
Ejemplo n.º 29
0
/**
 * Liest BOTFS_BLOCK_SIZE Bytes aus einer Datei in einen Puffer
 * \param *file		Zeiger auf Datei-Deskriptor
 * \param *buffer	Puffer fuer mindestens BOTFS_BLOCK_SIZE Byte, in die Daten geschrieben werden
 * \return			0, falls kein Fehler
 */
int8_t botfs_read(botfs_file_descr_t * file, void * buffer) {
	if (init_state != 1) {
		return -99;
	}
	/* Positions-Check */
	if (check_pos(file, file->pos) != 0) {
		PRINT_MSG("botfs_read(): Position 0x%x ungueltig!", file->pos);
		return -1;
	}

	/* Daten lesen und Dateizeiger anpassen */
	if (botfs_read_low(file->pos++, buffer) != 0) {
		PRINT_MSG("botfs_read(): botfs_read_low() meldet Fehler");
		return -2;
	}

	return 0;
}
Ejemplo n.º 30
0
int
main (int argc, char **argv)
{
	ret_t            ret;
	struct sigaction act;

	ret = check_for_python();
	if (ret != ret_ok) {
		PRINT_MSG ("ERROR: Couldn't find python.\n");
		exit (EXIT_ERROR);
	}

	/* Signal handling */
	act.sa_handler = SIG_IGN;
	sigaction (SIGPIPE, &act, NULL);

	memset(&act, 0, sizeof(act));
	act.sa_sigaction = signals_handler;
	act.sa_flags     = SA_SIGINFO;
	sigaction (SIGCHLD, &act, NULL);
	sigaction (SIGINT,  &act, NULL);
	sigaction (SIGTERM, &act, NULL);

	/* Initialize the embedded server */
	cherokee_init();
	cherokee_spawner_set_active (false);
	process_parameters (argc, argv);

	ret = cherokee_server_new (&srv);
	if (ret != ret_ok)
		exit (EXIT_ERROR);

	ret = config_server (srv);
	if (ret != ret_ok)
		exit (EXIT_ERROR);

	ret = cherokee_server_initialize (srv);
	if (ret != ret_ok)
		exit (EXIT_ERROR);

	print_connection_info();

	ret = cherokee_server_unlock_threads (srv);
	if (ret != ret_ok)
		exit (EXIT_ERROR);

	do {
		ret = cherokee_server_step (srv);
	} while (ret == ret_eagain);

	cherokee_server_stop (srv);
	cherokee_server_free (srv);

	cherokee_mrproper();
	return EXIT_OK;
}