A very simple example of a single instance integration without real-time audio on Linux.
A very simple example of a single instance integration without real-time audio on Linux. Ethernet tuning interface. Examples
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <pthread.h>
#include "TargetInfo.h"
static IOPinDescriptor g_InputPin[1];
static IOPinDescriptor g_OutputPin[1];
const void* g_module_descriptor_table[] =
{
LISTOFCLASSOBJECTS
};
#define MASTER_HEAP_SIZE (1024*1024)
#define FASTB_HEAP_SIZE (1024*1024)
#define SLOW_HEAP_SIZE (1024*1024)
UINT32 g_FastHeapA[MASTER_HEAP_SIZE];
UINT32 g_SlowHeap[MASTER_HEAP_SIZE];
UINT32 g_FastHeapB[MASTER_HEAP_SIZE];
UINT32 AWE_Packet_Buffer[264];
UINT32 AWE_Packet_Buffer_Reply[264];
void error(const char *msg)
{
perror(msg);
exit(1);
}
void *tuningPacketRxThread(void*)
{
int sockfd, newsockfd;
socklen_t clilen;
unsigned char buffer[264];
struct sockaddr_in serv_addr, cli_addr;
int n;
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
{
error("ERROR opening socket");
}
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = INADDR_ANY;
serv_addr.sin_port = htons(15098);
if (bind(sockfd, (struct sockaddr *) &serv_addr,
sizeof(serv_addr)) < 0)
{
error("ERROR on binding");
}
listen(sockfd,5);
clilen = sizeof(cli_addr);
newsockfd = accept(sockfd,
(struct sockaddr *) &cli_addr,
&clilen);
if (newsockfd < 0)
error("ERROR on accept");
int i=1;
printf( "entering loop ...\n");
while(1)
{
memset((void*) AWE_Packet_Buffer, 0, 264);
n = read(newsockfd,AWE_Packet_Buffer,264*sizeof(AWE_Packet_Buffer[0]));
if (n < 0) error("ERROR reading from socket");
unsigned int plen = AWE_Packet_Buffer[0]>>16;
n = write(newsockfd,AWE_Packet_Buffer,plen*sizeof(AWE_Packet_Buffer[0]));
if (n < 0) error("ERROR writing to socket");
}
close(newsockfd);
close(sockfd);
}
void InitializeAWEInstance()
{
int ret = 0;
UINT32 module_descriptor_table_size = sizeof(g_module_descriptor_table) / sizeof(g_module_descriptor_table[0]);
g_AWEInstance.
numModules = module_descriptor_table_size;
g_AWEInstance.
pName = TARGET_NAME;
ret =
awe_initPin(g_InputPin, INPUT_CHANNEL_COUNT, NULL);
if (ret != 0)
{
printf("awe_initPin inputPin failed\n");
}
ret =
awe_initPin(g_OutputPin, OUTPUT_CHANNEL_COUNT, NULL);
if (ret != 0)
{
printf("awe_initPin outputPin failed\n");
}
if (ret != 0)
{
printf("awe_init instance 1 failed\n");
}
}
int main( int argc, const char* argv[] )
{
pthread_t rxthread_id;
pthread_t processthread_id;
InitializeAWEInstance();
pthread_create(&rxthread_id, NULL, tuningPacketRxThread, NULL);
pthread_join(rxthread_id, NULL);
while(1)
{
}
}
The AWECore API Header File.
The AWECore Helper Functions File.
#define PACKET_OPCODE(x)
Get the OPCODE of the packet.
Definition: AWECoreUtils.h:50
#define PACKET_INSTANCEID(x)
This will get the instance ID of a packet.
Definition: AWECoreUtils.h:46
INT32 awe_initPin(IOPinDescriptor *pPin, UINT32 channels, const char *name)
Initialize an input or output pin.
INT32 awe_packetProcess(AWEInstance *pAWE)
Process an AWEInstance's newly received tuning packet.
INT32 awe_init(AWEInstance *pAWE)
Initialize the instance.
A list of all AWE Server Commands.
The AWE instance.
Definition: AWEInstance.h:45
IOPinDescriptor * pInputPin
A BSP author must define/allocate an input pin in their BSP and assign it to this member NOTE: AudioW...
Definition: AWEInstance.h:103
const char * pName
The name of the AWE Instance that will be displayed in Server.
Definition: AWEInstance.h:172
float profileSpeed
Profiling clock speed in Hz.
Definition: AWEInstance.h:164
UINT32 * pReplyBuffer
Reply buffer pointer.
Definition: AWEInstance.h:146
UINT32 * pFastHeapB
The second fast heap, B .
Definition: AWEInstance.h:57
UINT32 numThreads
Number of threads supported for multithreaded systems(1-4).
Definition: AWEInstance.h:176
IOPinDescriptor * pOutputPin
A BSP author must define/allocate an output pin in their BSP and assign it to this member NOTE: Audio...
Definition: AWEInstance.h:109
UINT32 * pPacketBuffer
The Packet buffer pointer.
Definition: AWEInstance.h:137
UINT32 slowHeapSize
The slow heap size.
Definition: AWEInstance.h:71
UINT32 fundamentalBlockSize
Base frame size of this instance.
Definition: AWEInstance.h:183
UINT32 * pSlowHeap
The slow heap.
Definition: AWEInstance.h:60
float sampleRate
Default sample rate of this instance.
Definition: AWEInstance.h:179
UINT32 packetBufferSize
Packet buffer size.
Definition: AWEInstance.h:153
UINT32 fastHeapBSize
The fast heap B size.
Definition: AWEInstance.h:68
AWEFlashFSInstance * pFlashFileSystem
DSPC Flash file system instance.
Definition: AWEInstance.h:188
float coreSpeed
A BSP author will set this to the speed of the CPU they are integrating into.
Definition: AWEInstance.h:161
UINT32 instanceId
The ID of this instance.
Definition: AWEInstance.h:50
UINT32 numModules
Number of modules in module table.
Definition: AWEInstance.h:119
const ModClassModule ** pModuleDescriptorTable
Pointer to module table.
Definition: AWEInstance.h:127
UINT32 fastHeapASize
The fast heap A size in 32-bit words.
Definition: AWEInstance.h:65
UINT32 * pFastHeapA
Fast heap A.
Definition: AWEInstance.h:54