forked from PAWPAW-Mirror/lib_xua
Added use of SAMPLE_SUBSLOT_SIZE_ defines and general use of global slotSizevar. Added unpack/pack of 2 byte slot size. Added unreachable builtins to slotsize switch and default case.
This commit is contained in:
@@ -98,9 +98,11 @@ unsigned packState = 0;
|
|||||||
unsigned packData = 0;
|
unsigned packData = 0;
|
||||||
|
|
||||||
#if (AUDIO_CLASS==2)
|
#if (AUDIO_CLASS==2)
|
||||||
int slotSize = 4; /* 4 bytes per ssample for Audio Class 2.0 */
|
int g_slotSize = SAMPLE_SUBSLOT_SIZE_HS; /* 4 bytes per ssample for Audio Class 2.0 */
|
||||||
|
int g_maxPacketSize = MAX_DEVICE_AUD_PACKET_SIZE_CLASS_TWO;
|
||||||
#else
|
#else
|
||||||
int slotSize = 3; /* 3 bytes per sample for Audio Class 1.0 */
|
int g_slotSize = SAMPLE_SUBSLOT_SIZE_FS; /* 3 bytes per sample for Audio Class 1.0 */
|
||||||
|
int g_maxPacketSize = MAX_DEVICE_AUD_PACKET_SIZE_CLASS_ONE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#pragma select handler
|
#pragma select handler
|
||||||
@@ -123,11 +125,13 @@ void handle_audio_request(chanend c_mix_out)
|
|||||||
#if defined(AUDIO_CLASS_FALLBACK) || defined (FULL_SPEED_AUDIO_2)
|
#if defined(AUDIO_CLASS_FALLBACK) || defined (FULL_SPEED_AUDIO_2)
|
||||||
if (usb_speed == XUD_SPEED_HS)
|
if (usb_speed == XUD_SPEED_HS)
|
||||||
{
|
{
|
||||||
slotSize = 4; /* 4 bytes per sample */
|
g_slotSize = SAMPLE_SUBSLOT_SIZE_HS; /* Typically 4 bytes per sample for HS */
|
||||||
|
g_maxPacketSize = MAX_DEVICE_AUD_PACKET_SIZE_CLASS_TWO;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
slotSize = 3; /* 3 bytes per sample */
|
g_slotSize = SAMPLE_SUBSLOT_SIZE_FS; /* Typically 3 bytes per sample for FS */
|
||||||
|
g_maxPacketSize = MAX_DEVICE_AUD_PACKET_SIZE_CLASS_ONE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -156,77 +160,130 @@ void handle_audio_request(chanend c_mix_out)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Not in overflow, store samples from mixer into sample buffer */
|
|
||||||
if (usb_speed == XUD_SPEED_HS)
|
|
||||||
{
|
|
||||||
unsigned ptr = g_aud_to_host_dptr;
|
|
||||||
|
|
||||||
for(int i = 0; i < g_numUsbChanIn; i++)
|
/* Not in overflow, store samples from mixer into sample buffer */
|
||||||
|
switch(g_slotSize)
|
||||||
|
{
|
||||||
|
case 4:
|
||||||
{
|
{
|
||||||
/* Receive sample */
|
#if (SAMPLE_SUBSLOT_SIZE_HS != 4) && (SAMPLE_SUBSLOT_SIZE_FS != 4)
|
||||||
int sample = inuint(c_mix_out);
|
__builtin_unreachable();
|
||||||
#if !defined(IN_VOLUME_IN_MIXER)
|
|
||||||
/* Apply volume */
|
|
||||||
int mult;
|
|
||||||
int h;
|
|
||||||
unsigned l;
|
|
||||||
asm("ldw %0, %1[%2]":"=r"(mult):"r"(p_multIn),"r"(i));
|
|
||||||
{h, l} = macs(mult, sample, 0, 0);
|
|
||||||
sample = h << 3;
|
|
||||||
sample |= (l >> 29) & 0x7; // Note, this step is not required if we assume sample depth is 24 (rather than 32)
|
|
||||||
#elif defined(IN_VOLUME_IN_MIXER) && defined(IN_VOLUME_AFTER_MIX)
|
|
||||||
sample = sample << 3;
|
|
||||||
#endif
|
#endif
|
||||||
/* Write into fifo */
|
unsigned ptr = g_aud_to_host_dptr;
|
||||||
write_via_xc_ptr(ptr, sample);
|
|
||||||
ptr+=4;
|
for(int i = 0; i < g_numUsbChanIn; i++)
|
||||||
|
{
|
||||||
|
/* Receive sample */
|
||||||
|
int sample = inuint(c_mix_out);
|
||||||
|
#if !defined(IN_VOLUME_IN_MIXER)
|
||||||
|
/* Apply volume */
|
||||||
|
int mult;
|
||||||
|
int h;
|
||||||
|
unsigned l;
|
||||||
|
asm("ldw %0, %1[%2]":"=r"(mult):"r"(p_multIn),"r"(i));
|
||||||
|
{h, l} = macs(mult, sample, 0, 0);
|
||||||
|
sample = h << 3;
|
||||||
|
sample |= (l >> 29) & 0x7; // Note, this step is not required if we assume sample depth is 24 (rather than 32)
|
||||||
|
#elif defined(IN_VOLUME_IN_MIXER) && defined(IN_VOLUME_AFTER_MIX)
|
||||||
|
sample = sample << 3;
|
||||||
|
#endif
|
||||||
|
/* Write into fifo */
|
||||||
|
write_via_xc_ptr(ptr, sample);
|
||||||
|
ptr+=4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update global pointer */
|
||||||
|
g_aud_to_host_dptr = ptr;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update global pointer */
|
case 3:
|
||||||
g_aud_to_host_dptr = ptr;
|
#if (SAMPLE_SUBSLOT_SIZE_HS != 3) && (SAMPLE_SUBSLOT_SIZE_FS != 3)
|
||||||
}
|
__builtin_unreachable();
|
||||||
else
|
|
||||||
{
|
|
||||||
for(int i = 0; i < g_numUsbChanIn; i++)
|
|
||||||
{
|
|
||||||
/* Receive sample */
|
|
||||||
int sample = inuint(c_mix_out);
|
|
||||||
#ifndef IN_VOLUME_IN_MIXER
|
|
||||||
/* Apply volume */
|
|
||||||
int mult;
|
|
||||||
int h;
|
|
||||||
unsigned l;
|
|
||||||
asm("ldw %0, %1[%2]":"=r"(mult):"r"(p_multIn),"r"(i));
|
|
||||||
{h, l} = macs(mult, sample, 0, 0);
|
|
||||||
sample = h << 3;
|
|
||||||
#endif
|
#endif
|
||||||
/* Pack 3 byte samples */
|
for(int i = 0; i < g_numUsbChanIn; i++)
|
||||||
switch (packState&0x3)
|
|
||||||
{
|
{
|
||||||
case 0:
|
/* Receive sample */
|
||||||
packData = sample;
|
int sample = inuint(c_mix_out);
|
||||||
break;
|
#ifndef IN_VOLUME_IN_MIXER
|
||||||
case 1:
|
/* Apply volume */
|
||||||
packData = packData >> 8 | ((sample & 0xff00)<<16);
|
int mult;
|
||||||
write_via_xc_ptr(g_aud_to_host_dptr, packData);
|
int h;
|
||||||
g_aud_to_host_dptr+=4;
|
unsigned l;
|
||||||
write_via_xc_ptr(g_aud_to_host_dptr, sample>>16);
|
asm("ldw %0, %1[%2]":"=r"(mult):"r"(p_multIn),"r"(i));
|
||||||
packData = sample;
|
{h, l} = macs(mult, sample, 0, 0);
|
||||||
break;
|
sample = h << 3;
|
||||||
case 2:
|
#endif
|
||||||
packData = (packData>>16) | ((sample & 0xffff00) << 8);
|
/* Pack 3 byte samples */
|
||||||
write_via_xc_ptr(g_aud_to_host_dptr, packData);
|
switch (packState&0x3)
|
||||||
g_aud_to_host_dptr+=4;
|
{
|
||||||
packData = sample;
|
case 0:
|
||||||
break;
|
packData = sample;
|
||||||
case 3:
|
break;
|
||||||
packData = (packData >> 24) | (sample & 0xffffff00);
|
case 1:
|
||||||
write_via_xc_ptr(g_aud_to_host_dptr, packData);
|
packData = (packData >> 8) | ((sample & 0xff00)<<16);
|
||||||
g_aud_to_host_dptr+=4;
|
write_via_xc_ptr(g_aud_to_host_dptr, packData);
|
||||||
break;
|
g_aud_to_host_dptr+=4;
|
||||||
|
write_via_xc_ptr(g_aud_to_host_dptr, sample>>16);
|
||||||
|
packData = sample;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
packData = (packData>>16) | ((sample & 0xffff00) << 8);
|
||||||
|
write_via_xc_ptr(g_aud_to_host_dptr, packData);
|
||||||
|
g_aud_to_host_dptr+=4;
|
||||||
|
packData = sample;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
packData = (packData >> 24) | (sample & 0xffffff00);
|
||||||
|
write_via_xc_ptr(g_aud_to_host_dptr, packData);
|
||||||
|
g_aud_to_host_dptr+=4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
packState++;
|
||||||
}
|
}
|
||||||
packState++;
|
break;
|
||||||
}
|
|
||||||
|
case 2:
|
||||||
|
|
||||||
|
#if (SAMPLE_SUBSLOT_SIZE_HS != 2) && (SAMPLE_SUBSLOT_SIZE_FS != 2)
|
||||||
|
__builtin_unreachable();
|
||||||
|
#endif
|
||||||
|
for(int i = 0; i < g_numUsbChanIn; i++)
|
||||||
|
{
|
||||||
|
/* Receive sample */
|
||||||
|
int sample = inuint(c_mix_out);
|
||||||
|
#if !defined(IN_VOLUME_IN_MIXER)
|
||||||
|
/* Apply volume */
|
||||||
|
int mult;
|
||||||
|
int h;
|
||||||
|
unsigned l;
|
||||||
|
asm("ldw %0, %1[%2]":"=r"(mult):"r"(p_multIn),"r"(i));
|
||||||
|
{h, l} = macs(mult, sample, 0, 0);
|
||||||
|
sample = h << 3;
|
||||||
|
#if (SAMPLE_BIT_RESOLUTION_HS > 24) || (SAMPLE_BIT_RESOLUTION_FS > 24)
|
||||||
|
sample |= (l >> 29) & 0x7; // Note, this step is not required if we assume sample depth is 24 (rather than 32)
|
||||||
|
#endif
|
||||||
|
#elif defined(IN_VOLUME_IN_MIXER) && defined(IN_VOLUME_AFTER_MIX)
|
||||||
|
sample = sample << 3;
|
||||||
|
#endif
|
||||||
|
/* Write into fifo */
|
||||||
|
switch (packState&0x1)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
packData = sample;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
packData = (packData>>16) | (sample & 0xffff0000);
|
||||||
|
write_via_xc_ptr(g_aud_to_host_dptr, packData);
|
||||||
|
g_aud_to_host_dptr+=4;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
__builtin_unreachable();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Input any remaining channels - past this thread we always operate on max channel count */
|
/* Input any remaining channels - past this thread we always operate on max channel count */
|
||||||
@@ -273,79 +330,132 @@ void handle_audio_request(chanend c_mix_out)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (usb_speed == XUD_SPEED_HS)
|
switch(g_slotSize)
|
||||||
{
|
{
|
||||||
/* Buffering not underflow condition send out some samples...*/
|
case 4:
|
||||||
for(int i = 0; i < g_numUsbChanOut; i++)
|
#if (SAMPLE_SUBSLOT_SIZE_HS != 4) && (SAMPLE_SUBSLOT_SIZE_FS != 4)
|
||||||
{
|
__builtin_unreachable();
|
||||||
|
#endif
|
||||||
|
/* Buffering not underflow condition send out some samples...*/
|
||||||
|
for(int i = 0; i < g_numUsbChanOut; i++)
|
||||||
|
{
|
||||||
#pragma xta endpoint "mixer_request"
|
#pragma xta endpoint "mixer_request"
|
||||||
int sample;
|
int sample;
|
||||||
int mult;
|
int mult;
|
||||||
int h;
|
int h;
|
||||||
unsigned l;
|
unsigned l;
|
||||||
|
|
||||||
read_via_xc_ptr(sample, g_aud_from_host_rdptr);
|
read_via_xc_ptr(sample, g_aud_from_host_rdptr);
|
||||||
g_aud_from_host_rdptr+=4;
|
g_aud_from_host_rdptr+=4;
|
||||||
|
|
||||||
#ifndef OUT_VOLUME_IN_MIXER
|
#ifndef OUT_VOLUME_IN_MIXER
|
||||||
asm("ldw %0, %1[%2]":"=r"(mult):"r"(p_multOut),"r"(i));
|
asm("ldw %0, %1[%2]":"=r"(mult):"r"(p_multOut),"r"(i));
|
||||||
{h, l} = macs(mult, sample, 0, 0);
|
{h, l} = macs(mult, sample, 0, 0);
|
||||||
h <<= 3;
|
h <<= 3;
|
||||||
h |= (l >>29)& 0x7; // Note this step is not required if we assume sample depth is 24bit (rather than 32bit)
|
#if (SAMPLE_BIT_RESOLUTION_HS > 24) || (SAMPLE_BIT_RESOLUTION_FS > 24)
|
||||||
outuint(c_mix_out, h);
|
h |= (l >>29)& 0x7; // Note this step is not required if we assume sample depth is 24bit (rather than 32bit)
|
||||||
#else
|
|
||||||
outuint(c_mix_out, sample);
|
|
||||||
#endif
|
#endif
|
||||||
}
|
outuint(c_mix_out, h);
|
||||||
}
|
#else
|
||||||
else
|
outuint(c_mix_out, sample);
|
||||||
{
|
#endif
|
||||||
/* Buffering not underflow condition send out some samples...*/
|
}
|
||||||
for(int i = 0; i < g_numUsbChanOut; i++)
|
|
||||||
{
|
|
||||||
#pragma xta endpoint "mixer_request"
|
|
||||||
int sample;
|
|
||||||
int mult;
|
|
||||||
int h;
|
|
||||||
unsigned l;
|
|
||||||
|
|
||||||
/* Unpack 3 byte samples */
|
break;
|
||||||
switch (unpackState&0x3)
|
|
||||||
|
case 3:
|
||||||
|
#if (SAMPLE_SUBSLOT_SIZE_HS != 3) && (SAMPLE_SUBSLOT_SIZE_FS != 3)
|
||||||
|
__builtin_unreachable();
|
||||||
|
#endif
|
||||||
|
/* Buffering not underflow condition send out some samples...*/
|
||||||
|
for(int i = 0; i < g_numUsbChanOut; i++)
|
||||||
{
|
{
|
||||||
case 0:
|
#pragma xta endpoint "mixer_request"
|
||||||
read_via_xc_ptr(unpackData, g_aud_from_host_rdptr);
|
int sample;
|
||||||
g_aud_from_host_rdptr+=4;
|
int mult;
|
||||||
sample = unpackData << 8;
|
int h;
|
||||||
break;
|
unsigned l;
|
||||||
case 1:
|
|
||||||
sample = (unpackData >> 16);
|
/* Unpack 3 byte samples */
|
||||||
read_via_xc_ptr(unpackData, g_aud_from_host_rdptr);
|
switch (unpackState&0x3)
|
||||||
g_aud_from_host_rdptr+=4;
|
{
|
||||||
sample = sample | (unpackData << 16);
|
case 0:
|
||||||
break;
|
read_via_xc_ptr(unpackData, g_aud_from_host_rdptr);
|
||||||
case 2:
|
g_aud_from_host_rdptr+=4;
|
||||||
sample = (unpackData >> 8);
|
sample = unpackData << 8;
|
||||||
read_via_xc_ptr(unpackData, g_aud_from_host_rdptr);
|
break;
|
||||||
g_aud_from_host_rdptr+=4;
|
case 1:
|
||||||
sample = sample | (unpackData<< 24);
|
sample = (unpackData >> 16);
|
||||||
break;
|
read_via_xc_ptr(unpackData, g_aud_from_host_rdptr);
|
||||||
case 3:
|
g_aud_from_host_rdptr+=4;
|
||||||
sample = unpackData & 0xffffff00;
|
sample = sample | (unpackData << 16);
|
||||||
break;
|
break;
|
||||||
}
|
case 2:
|
||||||
unpackState++;
|
sample = (unpackData >> 8);
|
||||||
|
read_via_xc_ptr(unpackData, g_aud_from_host_rdptr);
|
||||||
|
g_aud_from_host_rdptr+=4;
|
||||||
|
sample = sample | (unpackData<< 24);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
sample = unpackData & 0xffffff00;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unpackState++;
|
||||||
|
|
||||||
#ifndef OUT_VOLUME_IN_MIXER
|
#ifndef OUT_VOLUME_IN_MIXER
|
||||||
asm("ldw %0, %1[%2]":"=r"(mult):"r"(p_multOut),"r"(i));
|
asm("ldw %0, %1[%2]":"=r"(mult):"r"(p_multOut),"r"(i));
|
||||||
{h, l} = macs(mult, sample, 0, 0);
|
{h, l} = macs(mult, sample, 0, 0);
|
||||||
h <<= 3;
|
h <<= 3;
|
||||||
outuint(c_mix_out, h);
|
outuint(c_mix_out, h);
|
||||||
#else
|
#else
|
||||||
outuint(c_mix_out, sample);
|
outuint(c_mix_out, sample);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
|
|
||||||
|
case 2:
|
||||||
|
#if (SAMPLE_SUBSLOT_SIZE_HS != 3) && (SAMPLE_SUBSLOT_SIZE_FS != 3)
|
||||||
|
__builtin_unreachable();
|
||||||
|
#endif
|
||||||
|
/* Buffering not underflow condition send out some samples...*/
|
||||||
|
for(int i = 0; i < g_numUsbChanOut; i++)
|
||||||
|
{
|
||||||
|
#pragma xta endpoint "mixer_request"
|
||||||
|
int sample;
|
||||||
|
int mult;
|
||||||
|
int h;
|
||||||
|
unsigned l;
|
||||||
|
|
||||||
|
switch (unpackState&0x1)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
read_via_xc_ptr(unpackData, g_aud_from_host_rdptr);
|
||||||
|
sample = unpackData << 16;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
g_aud_from_host_rdptr+=4;
|
||||||
|
sample = unpackData & 0xffff0000;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
unpackState++;
|
||||||
|
|
||||||
|
#ifndef OUT_VOLUME_IN_MIXER
|
||||||
|
asm("ldw %0, %1[%2]":"=r"(mult):"r"(p_multOut),"r"(i));
|
||||||
|
{h, l} = macs(mult, sample, 0, 0);
|
||||||
|
h <<= 3;
|
||||||
|
outuint(c_mix_out, h);
|
||||||
|
#else
|
||||||
|
outuint(c_mix_out, sample);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
__builtin_unreachable();
|
||||||
|
break;
|
||||||
|
|
||||||
|
} /* switch(g_slotsize) */
|
||||||
|
|
||||||
/* Output remaining channels. Past this point we always operate on MAX chan count */
|
/* Output remaining channels. Past this point we always operate on MAX chan count */
|
||||||
for(int i = 0; i < NUM_USB_CHAN_OUT - g_numUsbChanOut; i++)
|
for(int i = 0; i < NUM_USB_CHAN_OUT - g_numUsbChanOut; i++)
|
||||||
@@ -354,7 +464,7 @@ void handle_audio_request(chanend c_mix_out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 3/4 bytes per sample */
|
/* 3/4 bytes per sample */
|
||||||
aud_data_remaining_to_device -= (g_numUsbChanOut*slotSize);
|
aud_data_remaining_to_device -= (g_numUsbChanOut*g_slotSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!inOverflow)
|
if (!inOverflow)
|
||||||
@@ -365,16 +475,13 @@ void handle_audio_request(chanend c_mix_out)
|
|||||||
|
|
||||||
if (totalSampsToWrite)
|
if (totalSampsToWrite)
|
||||||
{
|
{
|
||||||
if (usb_speed == XUD_SPEED_HS)
|
unsigned datasize = totalSampsToWrite * g_slotSize * g_numUsbChanIn;
|
||||||
{
|
|
||||||
g_aud_to_host_wrptr += 4+totalSampsToWrite*4*g_numUsbChanIn;
|
/* Round up to nearest word - note, not needed for slotsize == 4! */
|
||||||
}
|
datasize = (datasize+3) & (~0x3);
|
||||||
else
|
|
||||||
{
|
g_aud_to_host_wrptr += 4+datasize;
|
||||||
unsigned int datasize = totalSampsToWrite*3*NUM_USB_CHAN_IN_A1;
|
|
||||||
datasize = (datasize+3) & (~0x3); // round up to nearest word
|
|
||||||
g_aud_to_host_wrptr += 4+datasize;
|
|
||||||
}
|
|
||||||
if (g_aud_to_host_wrptr >= aud_to_host_fifo_end)
|
if (g_aud_to_host_wrptr >= aud_to_host_fifo_end)
|
||||||
{
|
{
|
||||||
g_aud_to_host_wrptr = aud_to_host_fifo_start;
|
g_aud_to_host_wrptr = aud_to_host_fifo_start;
|
||||||
@@ -389,6 +496,7 @@ void handle_audio_request(chanend c_mix_out)
|
|||||||
totalSampsToWrite = speedRem >> 16;
|
totalSampsToWrite = speedRem >> 16;
|
||||||
speedRem &= 0xffff;
|
speedRem &= 0xffff;
|
||||||
|
|
||||||
|
#if 0
|
||||||
if (usb_speed == XUD_SPEED_HS)
|
if (usb_speed == XUD_SPEED_HS)
|
||||||
{
|
{
|
||||||
if (totalSampsToWrite < 0 || totalSampsToWrite*4*g_numUsbChanIn > (MAX_DEVICE_AUD_PACKET_SIZE_CLASS_TWO))
|
if (totalSampsToWrite < 0 || totalSampsToWrite*4*g_numUsbChanIn > (MAX_DEVICE_AUD_PACKET_SIZE_CLASS_TWO))
|
||||||
@@ -403,6 +511,12 @@ void handle_audio_request(chanend c_mix_out)
|
|||||||
totalSampsToWrite = 0;
|
totalSampsToWrite = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
if (totalSampsToWrite < 0 || totalSampsToWrite * g_slotSize * g_numUsbChanIn > g_maxPacketSize)
|
||||||
|
{
|
||||||
|
totalSampsToWrite = 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Calc slots left in fifo */
|
/* Calc slots left in fifo */
|
||||||
space_left = g_aud_to_host_rdptr - g_aud_to_host_wrptr;
|
space_left = g_aud_to_host_rdptr - g_aud_to_host_wrptr;
|
||||||
@@ -413,12 +527,12 @@ void handle_audio_request(chanend c_mix_out)
|
|||||||
space_left = aud_to_host_fifo_end - g_aud_to_host_wrptr;
|
space_left = aud_to_host_fifo_end - g_aud_to_host_wrptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((space_left <= 0) || (space_left > totalSampsToWrite*g_numUsbChanIn*4+4))
|
if ((space_left <= 0) || (space_left > totalSampsToWrite*g_numUsbChanIn * 4 + 4))
|
||||||
{
|
{
|
||||||
/* Packet okay, write to fifo */
|
/* Packet okay, write to fifo */
|
||||||
if (totalSampsToWrite)
|
if (totalSampsToWrite)
|
||||||
{
|
{
|
||||||
write_via_xc_ptr(g_aud_to_host_wrptr, totalSampsToWrite*slotSize*g_numUsbChanIn);
|
write_via_xc_ptr(g_aud_to_host_wrptr, totalSampsToWrite*g_slotSize*g_numUsbChanIn);
|
||||||
packState = 0;
|
packState = 0;
|
||||||
g_aud_to_host_dptr = g_aud_to_host_wrptr + 4;
|
g_aud_to_host_dptr = g_aud_to_host_wrptr + 4;
|
||||||
}
|
}
|
||||||
@@ -432,7 +546,7 @@ void handle_audio_request(chanend c_mix_out)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!outUnderflow && (aud_data_remaining_to_device<(slotSize*g_numUsbChanOut)))
|
if (!outUnderflow && (aud_data_remaining_to_device<(g_slotSize*g_numUsbChanOut)))
|
||||||
{
|
{
|
||||||
/* Handle any tail - incase a bad driver sent us a datalength not a multiple of chan count */
|
/* Handle any tail - incase a bad driver sent us a datalength not a multiple of chan count */
|
||||||
if (aud_data_remaining_to_device)
|
if (aud_data_remaining_to_device)
|
||||||
@@ -831,7 +945,7 @@ void decouple(chanend c_mix_out,
|
|||||||
read_via_xc_ptr(datalength, released_buffer);
|
read_via_xc_ptr(datalength, released_buffer);
|
||||||
|
|
||||||
/* Ignore bad small packets */
|
/* Ignore bad small packets */
|
||||||
if ((datalength >= (g_numUsbChanOut * slotSize)) && (released_buffer == aud_from_host_wrptr))
|
if ((datalength >= (g_numUsbChanOut * g_slotSize)) && (released_buffer == aud_from_host_wrptr))
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Move the write pointer of the fifo on - round up to nearest word */
|
/* Move the write pointer of the fifo on - round up to nearest word */
|
||||||
|
|||||||
Reference in New Issue
Block a user