Exemplo n.º 1
0
/*{{{ TransformerTerminate*/
static int TransformerTerminate(struct MMEContext_s *Context)
{
	MME_ERROR MMEStatus;
	if (Context->TransformerInitialized)
	{
		Context->TransformerInitialized = false;
		MMEStatus = MME_TermTransformer(Context->MMEHandle);
		if (MMEStatus != MME_SUCCESS)
		{
			MONITOR_ERROR("%s: Failed to terminate mme transformer - Error 0x%08x.\n", Context->TransformerName, MMEStatus);
			return -EFAULT;
		}
	}
	return 0;
}
Exemplo n.º 2
0
/* MME_TermTransformer()
 * Terminate a transformer instance
 */
MME_ERROR acc_MME_TermTransformer(MME_TransformerHandle_t handle)
{
	MME_ERROR mme_status;
	int hdl_idx = handles_search(handle);
	if (log_enable == ACC_TRUE)
	{
		FILE *fcmd = cmd_log_lock();
		FWRITE(cmd_str[CMD_TERM], strlen(cmd_str[CMD_TERM]) + 1, 1, fcmd);
		FWRITE(&hdl_idx, sizeof(int), 1, fcmd);
		cmd_log_release(fcmd);
	}
	mme_status = MME_TermTransformer(handle);
	if (log_enable == ACC_TRUE)
	{
		if (mme_status == MME_SUCCESS) handles[hdl_idx] = 0;
	}
	return mme_status;
}
Exemplo n.º 3
0
int main(void)
{
    MME_TransformerInitParams_t initParams = { sizeof(MME_TransformerInitParams_t) };
    MixerParamsInit_t mixerInit;
    MME_TransformerHandle_t localHdl, remoteHdl;

    MME_ERROR err;

    /* initialize the underlying EMBX transport */
    embxRuntimeInit();

    /* initialize the MME API */
    err = MME_Init();
    if (MME_SUCCESS != err) {
        printf("ERROR: cannot initialize the MME API (%d)\n", err);
    }

    /* other misc. initialization */
    OS_SIGNAL_INIT(&callbackSignal);

    /* pre-construct the data structure to be passed at transformer
     * initialization time
     */
    initParams.Priority = MME_PRIORITY_NORMAL;
    initParams.Callback = mixerCallback;
    initParams.TransformerInitParamsSize = sizeof(MixerParamsInit_t);
    initParams.TransformerInitParams_p = &mixerInit;
    MME_INDEXED_PARAM(mixerInit, MixerParamsInit_volume, 0) = 1.0;
    MME_INDEXED_PARAM(mixerInit, MixerParamsInit_volume, 1) = 4.0/3.0;


    /* display the waveforms that will be mixed */
    printf("ORIGINAL WAVEFORMS\n"
           "------------------\n\n");
    printTwinSignal(sample1, sample2, sizeof(sample1));


    printf("\nSIMPLE MIXING USING A LOCALLY REGISTERED TRANSFORMER\n"
           "----------------------------------------------------\n\n");

    /* register a local transformer */
    err = Mixer_RegisterTransformer("local.8bit_mixer");
    if (MME_SUCCESS != err) {
        printf("ERROR: cannot register local.8bit_mixer (%d)\n", err);
    }

    /* initialize the local transformer */
    err = MME_InitTransformer("local.8bit_mixer", &initParams, &localHdl);
    if (MME_SUCCESS != err) {
        printf("ERROR: cannot instanciate local.8bit_mixer (%d)\n", err);
    }

    /* perform a simple mix using the local transformer */
    err = simpleMix(localHdl);
    if (MME_SUCCESS != err) {
        printf("ERROR: cannot perform mixer transformer on mme.8bit_mixer (%d)\n", err);
    }


    printf("\nSIMPLE MIXING USING A REMOTELY REGISTERED TRANSFORMER\n"
           "-----------------------------------------------------\n\n");

#if !(defined(__LINUX__) && !defined(__KERNEL__))
    /* register the transport for the remote transformer (at this point we will
     * block until the remote processor initializes itself)
     */
    err = MME_RegisterTransport("shm");
    if (MME_SUCCESS != err) {
        printf("ERROR: cannot register transport to external processors (%d)\n", err);
    }
#endif

    /* repeatly attempt to connect to the remote transformer until it is registered or
     * a serious error occurs.
     */
    do {
        err = MME_InitTransformer("mme.8bit_mixer", &initParams, &remoteHdl);
    } while (err == MME_UNKNOWN_TRANSFORMER);
    if (MME_SUCCESS != err) {
        printf("ERROR: cannot instanciate mme.8bit_mixer (%d)\n", err);
    }

    /* perform the same mix as above using a remotely registered transformer. the
     * results should be identical assuming both processors implement IEEE single
     * precision floating point maths.
     */
    err = simpleMix(remoteHdl);
    if (MME_SUCCESS != err) {
        printf("ERROR: cannot perform mixer transformer on mme.8bit_mixer (%d)\n", err);
    }

    /* clean up prior to shutting down */
    err = MME_TermTransformer(remoteHdl);
    if (MME_SUCCESS != err) {
        printf("ERROR: cannot terminate mme.8bit_mixer (%d)\n", err);
    }

    err = MME_TermTransformer(localHdl);
    if (MME_SUCCESS != err) {
        printf("ERROR: cannot terminate local.8bit_mixer (%d)\n", err);
    }

    err = MME_Term();
    if (MME_SUCCESS != err) {
        printf("ERROR: cannot terminate the MME API (%d)\n", err);
    }

#ifndef __LINUX__
    (void) EMBX_Deinit();
#endif

    return 0;
}
Exemplo n.º 4
0
int main(void)
{
	MME_TransformerInitParams_t initParams[2] = {{ sizeof(MME_TransformerInitParams_t) },
                                                     { sizeof(MME_TransformerInitParams_t) }};
	MixerParamsInit_t mixerInit[2];
	MME_TransformerHandle_t remoteHdl[2];

	MME_ERROR err;

	/* initialize the underlying EMBX transport */
	setupEMBXAndOS();

	/* initialize the MME API */
	err = MME_Init();
	if (MME_SUCCESS != err) {
		printf("ERROR: cannot initialize the MME API (%d)\n", err);
	}

	/* other misc. initialization */
	OS_SIGNAL_INIT(&callbackSignal);

	/* pre-construct the data structure to be passed at transformer 
	 * initialization time
	 */
	initParams[0].Priority = MME_PRIORITY_NORMAL;
	initParams[0].Callback = mixerCallback;
	initParams[0].TransformerInitParamsSize = sizeof(MixerParamsInit_t);
	initParams[0].TransformerInitParams_p = &mixerInit[0];
	MME_INDEXED_PARAM(mixerInit[0], MixerParamsInit_volume, 0) = 1.0;
	MME_INDEXED_PARAM(mixerInit[0], MixerParamsInit_volume, 1) = 4.0/3.0;

	initParams[1].Priority = MME_PRIORITY_NORMAL;
	initParams[1].Callback = mixerCallback;
	initParams[1].TransformerInitParamsSize = sizeof(MixerParamsInit_t);
	initParams[1].TransformerInitParams_p = &mixerInit[1];
	MME_INDEXED_PARAM(mixerInit[1], MixerParamsInit_volume, 0) = 0.4;
	MME_INDEXED_PARAM(mixerInit[1], MixerParamsInit_volume, 1) = 0.7;
	
#if !(defined(__LINUX__) && !defined(__KERNEL__))
	/* register the transport for the remote transformer (at this point we will
	 * block until the remote processor initializes itself)
	 */
	printf("Trying to register transport shm\n");

	err = MME_RegisterTransport("shm");
	if (MME_SUCCESS != err) {
		printf("ERROR: cannot register transport to external processors (%d)\n", err);
	}
#endif

	/* repeatly attempt to connect to the remote transformer until it is registered or
	 * a serious error occurs.
	 */
	do {
		task_delay(time_ticks_per_sec() * 2);
		printf("Trying to init mme.8bit_mix_1\n");
		err = MME_InitTransformer("mme.8bit_mixer_1", &initParams[0], &remoteHdl[0]);
	} while (err == MME_UNKNOWN_TRANSFORMER);

	if (MME_SUCCESS != err) {
		printf("ERROR: cannot instantiate mme.8bit_mixer_1 (%d)\n", err);
	}

	do {
		task_delay(time_ticks_per_sec() * 2);
		printf("Trying to init mme.8bit_mix_2\n");
		err = MME_InitTransformer("mme.8bit_mixer_2", &initParams[1], &remoteHdl[1]);
	} while (err == MME_UNKNOWN_TRANSFORMER);

	if (MME_SUCCESS != err) {
		printf("ERROR: cannot instantiate mme.8bit_mixer_2 (%d)\n", err);
	}

	/* display the waveforms that will be mixed */
	printf("ORIGINAL WAVEFORMS\n"
	       "------------------\n\n");
	printTwinSignal(sample1, sample2, sizeof(sample1));

	printf("\nSIMPLE MIXING USING TWO REMOTELY REGISTERED TRANSFORMERS\n"
	         "--------------------------------------------------------\n\n");

	/* perform the mix as above using remotely registered transformer. the 
	 * results should be identical assuming both processors implement IEEE single
	 * precision floating point maths.
	 */
	err = simpleMix(remoteHdl);
	if (MME_SUCCESS != err) {
		printf("ERROR: cannot perform mixer transformer on mme.8bit_mixer (%d)\n", err);
	}

	/* clean up prior to shutting down */
	err = MME_TermTransformer(remoteHdl[0]);
	if (MME_SUCCESS != err) {
		printf("ERROR: cannot terminate mme.8bit_mixer (%d)\n", err);
	}

	err = MME_TermTransformer(remoteHdl[1]);
	if (MME_SUCCESS != err) {
		printf("ERROR: cannot terminate mme.8bit_mixer (%d)\n", err);
	}

	err = MME_Term();
	if (MME_SUCCESS != err) {
		printf("ERROR: cannot terminate the MME API (%d)\n", err);
	}

	(void) EMBX_Deinit();

	return 0;
}