📄 threncinput.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 "thrEncInput.h"
#include "adpcm.h"
#include "adpcmParam.h"
#include "seeddm642.h"
#include "evmdm642_echocfg.h"
ThrEncInput thrEncInput;
/*create In Streams*/
Void thrEncInputInit()
{
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;
/* open the I/O streams */
thrEncInput.inStream = SIO_create("/dio_codec", SIO_INPUT, BUFSIZE, &attrs);
if (thrEncInput.inStream == NULL) {
SYS_abort("Create input stream FAILED.");
}
UTL_assert( thrEncInput.inStream != NULL );
//scomReceive = SCOM_create( "scomEncodeToInput", NULL );
scomReceive = SCOM_create( "scomOutputToInput", NULL );
UTL_assert( scomReceive != NULL );
}
/*prime Encode Input buffer*/
Void thrEncInputStartup()
{
Ptr buf0, buf1;
LOG_printf(&trace, "Allocate encode Input 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 input stream */
if (SIO_issue(thrEncInput.inStream, buf0, SIO_bufsize(thrEncInput.inStream), NULL) != SYS_OK) {
SYS_abort("Error issuing buffer to the input stream");
}
if (SIO_issue(thrEncInput.inStream, buf1, SIO_bufsize(thrEncInput.inStream), NULL) != SYS_OK) {
SYS_abort("Error issuing buffer to the input stream");
}
}
Void thrEncInputRun()
{
short *inbuf;
MyMsg *msg;
SCOM_Handle scomReceive, scomSend;
// open the SCOM queues (your own for receiving and another for sending)
scomReceive = SCOM_open( "scomOutputToInput" );
scomSend = SCOM_open( "scomInputToEncode" );
msg = MEM_alloc(1, sizeof( MyMsg ), 0 );
UTL_assert( scomReceive != NULL );
UTL_assert( scomSend != NULL );
while(1)
{
if ((SIO_reclaim(thrEncInput.inStream, (Ptr *)&inbuf, NULL)) < 0)
{
SYS_abort("Error reclaiming full buffer from the input stream");
}
msg->ptr=inbuf;
SCOM_putMsg( scomSend, msg->ptr );
SCOM_getMsg( scomReceive, SYS_FOREVER);
/* Issue an empty buffer to the input stream */
if (SIO_issue(thrEncInput.inStream, inbuf, SIO_bufsize(thrEncInput.inStream), NULL) != SYS_OK)
{
SYS_abort("Error issuing empty buffer to the input stream");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -