Merge pull request #3848 from jamike/USBAUDIO_JITTER

USBAudio: writesync with 1 sample jitter capability.
pull/4079/head^2
Sam Grove 2017-03-30 00:01:07 +01:00 committed by GitHub
commit 067fe9b0e5
2 changed files with 18 additions and 7 deletions

View File

@ -113,9 +113,13 @@ bool USBAudio::write(uint8_t * buf) {
return true;
}
void USBAudio::writeSync(uint8_t *buf)
void USBAudio::writeSync(uint8_t *buf, AudioSampleCorrectType jitter_nb)
{
USBDevice::writeNB(EPISO_IN, buf, PACKET_SIZE_ISO_OUT, PACKET_SIZE_ISO_OUT);
if ((jitter_nb != RemoveOneSample) && (jitter_nb != AddOneSample)) {
jitter_nb = NoCorrection;
}
/* each sample is 2 bytes */
USBDevice::writeNB(EPISO_IN, buf, PACKET_SIZE_ISO_OUT + jitter_nb *(this->channel_nb_out*2), PACKET_SIZE_ISO_OUT+this->channel_nb_out*2);
}
uint32_t USBAudio::readSync(uint8_t *buf)
@ -195,7 +199,7 @@ bool USBAudio::USBCallback_setConfiguration(uint8_t configuration) {
// Configure isochronous endpoint
realiseEndpoint(EPISO_OUT, PACKET_SIZE_ISO_IN, ISOCHRONOUS);
realiseEndpoint(EPISO_IN, PACKET_SIZE_ISO_OUT, ISOCHRONOUS);
realiseEndpoint(EPISO_IN, PACKET_SIZE_ISO_OUT+this->channel_nb_out*2, ISOCHRONOUS);
// activate readings on this endpoint
readStart(EPISO_OUT, PACKET_SIZE_ISO_IN);
@ -597,8 +601,8 @@ uint8_t * USBAudio::configurationDesc() {
ENDPOINT_DESCRIPTOR, // bDescriptorType
PHY_TO_DESC(EPISO_IN), // bEndpointAddress
E_ISOCHRONOUS, // bmAttributes
(uint8_t)(LSB(PACKET_SIZE_ISO_OUT)), // wMaxPacketSize
(uint8_t)(MSB(PACKET_SIZE_ISO_OUT)), // wMaxPacketSize
(uint8_t)(LSB(PACKET_SIZE_ISO_OUT+channel_nb_out*2)), // wMaxPacketSize
(uint8_t)(MSB(PACKET_SIZE_ISO_OUT+channel_nb_out*2)), // wMaxPacketSize
0x01, // bInterval
0x00, // bRefresh
0x00, // bSynchAddress

View File

@ -123,11 +123,18 @@ public:
*/
bool write(uint8_t * buf);
/** Audio Jitter value*/
enum AudioSampleCorrectType {
RemoveOneSample = -1,
NoCorrection = 0,
AddOneSample = 1
};
/**
* Write packet in endpoint fifo. assuming tx fifo is empty
* @param buf pointer on the audio packet which will be sent
*/
void writeSync(uint8_t *buf);
* @param jitter_nb : AudioSampleCorrecttype
**/
void writeSync(uint8_t *buf, AudioSampleCorrectType jitter_nb = NoCorrection );
/**
* Write and read an audio packet at the same time (on the same frame)