Mixer communications updated for new underflow protocol

This commit is contained in:
Ross Owen
2013-12-09 15:47:59 +00:00
parent 042d8f1969
commit 51e9415a57

View File

@@ -1,7 +1,6 @@
#include <xs1.h>
#include <print.h>
#include "mixer.h"
#include "devicedefines.h"
#include "xc_ptr.h"
@@ -184,8 +183,10 @@ void giveSamplesToHost(chanend c, xc_ptr samples, xc_ptr ptr, xc_ptr multIn)
}
#pragma unsafe arrays
static void getSamplesFromHost(chanend c, xc_ptr samples, int base)
static void getSamplesFromHost(chanend c, xc_ptr samples, int base, unsigned underflow)
{
if(!underflow)
{
#pragma loop unroll
for (int i=0;i<NUM_USB_CHAN_OUT;i++)
{
@@ -216,12 +217,17 @@ static void getSamplesFromHost(chanend c, xc_ptr samples, int base)
#else
write_via_xc_ptr_indexed(samples,base+i,sample);
#endif
}
} }
}
#pragma unsafe arrays
void giveSamplesToDevice(chanend c, xc_ptr samples, xc_ptr ptr, xc_ptr multOut)
void giveSamplesToDevice(chanend c, xc_ptr samples, xc_ptr ptr, xc_ptr multOut, unsigned underflow)
{
outuint(c, underflow);
if(!underflow)
{
#pragma loop unroll
for (int i=0;i<NUM_USB_CHAN_OUT;i++)
{
@@ -245,6 +251,7 @@ void giveSamplesToDevice(chanend c, xc_ptr samples, xc_ptr ptr, xc_ptr multOut)
outuint(c, sample);
#endif
}
}
}
#pragma unsafe arrays
@@ -291,15 +298,15 @@ void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
while (1)
{
#pragma xta endpoint "mixer1_req"
/* Request from audio() */
inuint(c_mixer2);
/* Request data from decouple thread */
outuint(c_host, 0);
/* Between request to decouple and respose ~ 400nS latency for interrupt to fire */
select
select
{
case inuint_byref(c_mix_ctl, cmd):
{
@@ -406,7 +413,7 @@ void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
break;
}
default:
/* Select default */
/* Select default */
break;
}
@@ -424,12 +431,10 @@ void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
#pragma loop unroll
for (int i=0;i<MAX_MIX_COUNT;i++)
{
write_via_xc_ptr_indexed(samples,
(NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + i),
0);
write_via_xc_ptr_indexed(samples, (NUM_USB_CHAN_OUT + NUM_USB_CHAN_IN + i), 0);
}
/* Inform mixer 2 about freq change */
/* Inform mixer2 (or audio())about freq change */
outct(c_mixer2, XS1_CT_END);
outuint(c_mixer2, sampFreq);
@@ -439,7 +444,7 @@ void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
}
else
{
inuint(c_host);
unsigned underflow = inuint(c_host);
#if MAX_MIX_COUNT > 0
outuint(c_mixer2, 0);
giveSamplesToHost(c_host, samples, samples_to_host_map, multIn);
@@ -506,10 +511,10 @@ void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
}
#else /* IF MAX_MIX_COUNT > 0 */
/* No mixes, this thread runs on its own doing just volume */
giveSamplesToDevice(c_mixer2, samples, samples_to_device_map, multOut);
giveSamplesToDevice(c_mixer2, samples, samples_to_device_map, multOut, underflow);
getSamplesFromDevice(c_mixer2, samples, NUM_USB_CHAN_OUT);
giveSamplesToHost(c_host, samples, samples_to_host_map, multIn);
getSamplesFromHost(c_host, samples, 0);
getSamplesFromHost(c_host, samples, 0, underflow);
#endif
}
}
@@ -517,6 +522,7 @@ void mixer1(chanend c_host, chanend c_mix_ctl, chanend c_mixer2)
int mixer2_mix2_flag = (DEFAULT_FREQ > 96000);
#if (MAX_MIX_COUNT > 0)
#pragma unsafe arrays
void mixer2(chanend c_mixer1, chanend c_audio)
{
@@ -622,6 +628,7 @@ void mixer2(chanend c_mixer1, chanend c_audio)
}
}
}
#endif
void mixer(chanend c_mix_in, chanend c_mix_out, chanend c_mix_ctl)
{