collect agent address on receive to send back audio

This commit is contained in:
Stephen Birarda 2013-02-13 13:42:23 -08:00
parent 3d874357d7
commit 09dee91279
3 changed files with 13 additions and 14 deletions

View file

@ -38,10 +38,10 @@ const short JITTER_BUFFER_SAMPLES = JITTER_BUFFER_LENGTH_MSECS * (SAMPLE_RATE /
const short NUM_AUDIO_SOURCES = 2;
const short ECHO_SERVER_TEST = 1;
char WORKCLUB_AUDIO_SERVER[] = "192.168.1.19";
char WORKCLUB_AUDIO_SERVER[] = "0.0.0.0";
char EC2_WEST_AUDIO_SERVER[] = "54.241.92.53";
const int AUDIO_UDP_LISTEN_PORT = 55444;
const int AUDIO_UDP_LISTEN_PORT = 55446;
int starve_counter = 0;
@ -88,7 +88,7 @@ int audioCallback (const void *inputBuffer,
// int16_t *inputRight = ((int16_t **) inputBuffer)[1];
if (inputLeft != NULL) {
data->audioSocket->send((char *) EC2_WEST_AUDIO_SERVER, 55443, (void *)inputLeft, BUFFER_LENGTH_BYTES);
data->audioSocket->send((char *) WORKCLUB_AUDIO_SERVER, 55443, (void *)inputLeft, BUFFER_LENGTH_BYTES);
//
// Measure the loudness of the signal from the microphone and store in audio object
//

View file

@ -158,7 +158,7 @@ int speed;
//
SerialInterface serialPort;
char serial_portname[] = "/dev/tty.usbmodem411";
char serial_portname[] = "/dev/tty.usbmodemfd131";
int serial_on = 0;
int latency_display = 1;

View file

@ -36,8 +36,7 @@ const long MIN_SAMPLE_VALUE = std::numeric_limits<int16_t>::min();
const int MAX_SOURCE_BUFFERS = 20;
sockaddr_in address, destAddress;
socklen_t destLength = sizeof(destAddress);
sockaddr_in agentAddress;
struct AgentList {
char *address;
@ -196,7 +195,7 @@ void *sendBufferThread(void *args)
}
audioSocket->send(agents[a].address, agents[a].port, clientMix, BUFFER_LENGTH_BYTES);
audioSocket->send(agents[a].address, agents[a].port, (void *) clientMix, BUFFER_LENGTH_BYTES);
if (sentBytes < BUFFER_LENGTH_BYTES) {
std::cout << "Error sending mix packet! " << sentBytes << strerror(errno) << "\n";
@ -222,19 +221,19 @@ void *sendBufferThread(void *args)
struct processArgStruct {
int16_t *packetData;
sockaddr_in destAddress;
sockaddr_in agentAddress;
};
void *processClientPacket(void *args)
{
struct processArgStruct *processArgs = (struct processArgStruct *) args;
sockaddr_in destAddress = processArgs->destAddress;
sockaddr_in agentAddress = processArgs->agentAddress;
if (addAgent(destAddress, processArgs->packetData)) {
if (addAgent(agentAddress, processArgs->packetData)) {
std::cout << "Added agent: " <<
inet_ntoa(destAddress.sin_addr) << " on " <<
ntohs(destAddress.sin_port) << "\n";
inet_ntoa(agentAddress.sin_addr) << " on " <<
ntohs(agentAddress.sin_port) << "\n";
}
pthread_exit(0);
@ -263,10 +262,10 @@ int main(int argc, const char * argv[])
pthread_create(&bufferSendThread, NULL, sendBufferThread, (void *)&sendBufferArgs);
while (true) {
if(audioSocket.receive(packetData, &receivedBytes)) {
if(audioSocket.receive(&agentAddress, packetData, &receivedBytes)) {
struct processArgStruct args;
args.packetData = packetData;
args.destAddress = destAddress;
args.agentAddress = agentAddress;
pthread_t clientProcessThread;
pthread_create(&clientProcessThread, NULL, processClientPacket, (void *)&args);