diff --git a/module_usb_audio/endpoint0/audiorequests.xc b/module_usb_audio/endpoint0/audiorequests.xc index 9298380f..b98a4c6f 100644 --- a/module_usb_audio/endpoint0/audiorequests.xc +++ b/module_usb_audio/endpoint0/audiorequests.xc @@ -46,7 +46,7 @@ extern unsigned char mixSel[MAX_MIX_COUNT][MIX_INPUTS]; /* Global var for current frequency, set to default freq */ unsigned int g_curSamFreq = DEFAULT_FREQ; unsigned int g_curSamFreq48000Family = DEFAULT_FREQ % 48000 == 0; -unsigned int g_curSamFreqMultiplier = DEFAULT_FREQ / (DEFAULT_MCLK_FREQ / 512); +unsigned int g_curSamFreqMultiplier = (DEFAULT_FREQ * 512 * 4) / (DEFAULT_MCLK_FREQ); /* Store an int into a char array: Note this allows non-word aligned access unlike reinerpret cast */ static void storeInt(unsigned char buffer[], int index, int val) diff --git a/module_usb_audio/usb_buffer/usb_buffer.xc b/module_usb_audio/usb_buffer/usb_buffer.xc index 0c607308..4827f616 100644 --- a/module_usb_audio/usb_buffer/usb_buffer.xc +++ b/module_usb_audio/usb_buffer/usb_buffer.xc @@ -161,7 +161,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, #endif unsigned u_tmp; unsigned sampleFreq = 0; - unsigned lastClock; + unsigned lastClock = 0; unsigned clocks = 0; @@ -410,7 +410,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, /* Number of MCLKS this SOF, approx 125 * 24 (3000), sample by sample rate */ GET_SHARED_GLOBAL(cycles, g_curSamFreqMultiplier); cycles = ((int)((short)(u_tmp - lastClock))) * cycles; - cycles >>= 2; /* /4 */ + cycles = (int) cycles >> 2; /* /4 */ /* Any odd bits (lower than 16.23) have to be kept seperate */ remnant += cycles & mask;