⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thrdecoutput.c

📁 基于TI xdais算法标准的音频ADPCM算法
💻 C
字号:
#include <std.h>
#include <stdio.h>
#include <cassert>
#include <log.h>
#include <sys.h>
#include <mem.h>
#include <sio.h>
#include <csl.h>
#include <csl_cache.h>
#include <mbx.h>
#include <scom.h>
#include <utl.h>

#include "adpcm.h"
#include "seeddm642.h"
#include "adpcmParam.h"
#include "thrDecOutput.h"
#include "evmdm642_echocfg.h"

ThrDecOutput thrDecOutput;

Void thrDecOutputInit( )
{
    SIO_Attrs attrs;
   	SCOM_Handle scomReceive;
    /* align the buffer to allow it to be used with L2 cache */
    attrs = SIO_ATTRS;
    attrs.align = BUFALIGN;
    attrs.model = SIO_ISSUERECLAIM;

   	thrDecOutput.outStream = SIO_create("/dio_codec", SIO_OUTPUT, BUFSIZE, &attrs);
    if (thrDecOutput.outStream == NULL) {
        SYS_abort("Create output stream FAILED.");
    }
	    
	UTL_assert( thrDecOutput.outStream  != NULL );
    
    scomReceive = SCOM_create( "scomDecodeToOutput", NULL );
    
    UTL_assert( scomReceive != NULL );
}


Void thrDecOutputStartup( )
{
	Ptr buf0, buf1;

    LOG_printf(&trace, "Allocate Output buffers started");

    /* Allocate buffers for the SIO buffer exchanges */
    buf0 = (Ptr)MEM_calloc(0, BUFSIZE, BUFALIGN);
    buf1 = (Ptr)MEM_calloc(0, BUFSIZE, BUFALIGN);
    if (buf0 == NULL || buf1 == NULL ){
        SYS_abort("MEM_calloc failed.");
    } 

    /* Issue the first & second empty buffers to the output stream */
    if (SIO_issue(thrDecOutput.outStream, buf0, SIO_bufsize(thrDecOutput.outStream), NULL) != SYS_OK) {
        SYS_abort("Error issuing buffer to the output stream");
    }
    if (SIO_issue(thrDecOutput.outStream, buf1, SIO_bufsize(thrDecOutput.outStream), NULL) != SYS_OK) {
        SYS_abort("Error issuing buffer to the output stream");
    }
}


Void thrDecOutputRun()
{
	 short  *outbuf;
	 MyMsg *msg;
	
	SCOM_Handle scomReceiveFromDecode, scomSendToDecode, scomSendToInput;    

    // open the SCOM queues (your own for receiving and another for sending)
    scomReceiveFromDecode	 = SCOM_open( "scomDecodeToOutput" );
    scomSendToDecode = SCOM_open( "scomOutputToDecode" );
    scomSendToInput  = SCOM_open( "scomOutputToInput" );
    msg = MEM_alloc(1, sizeof( MyMsg ), 0 );
    
    UTL_assert( scomReceive != NULL );
    UTL_assert( scomSend    != NULL );

	while(1)
	{

	   	if (SIO_reclaim(thrDecOutput.outStream, (Ptr *)&outbuf, NULL) < 0) 
	   	{
	     	SYS_abort("Error reclaiming empty buffer from the output stream");
	    }
	    
	    msg->ptr=outbuf;
	    
	    SCOM_putMsg( scomSendToDecode, msg->ptr );
	    
	    SCOM_getMsg( scomReceiveFromDecode,  SYS_FOREVER);
	    
	   	/* Issue full buffer to the output stream */
	  	if (SIO_issue(thrDecOutput.outStream, outbuf, SIO_bufsize(thrDecOutput.outStream), NULL) != SYS_OK) 
	  	{
	   		SYS_abort("Error issuing full buffer to the output stream");
	   	}
	   	
	   	SCOM_putMsg( scomSendToInput,NULL);
	
	}	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -