forked from PAWPAW-Mirror/lib_xua
Added control channel for buffering for lower-power, non-memory polling buffering
This commit is contained in:
@@ -1,22 +1,18 @@
|
||||
#ifndef __decouple_h__
|
||||
#define __decouple_h__
|
||||
#ifndef __DECOUPLE_H__
|
||||
#define __DECOUPLE_H__
|
||||
|
||||
|
||||
/** Manage the data transfer between the USB audio buffer and the
|
||||
* Audio I/O driver.
|
||||
*
|
||||
* \param c_audio_out Channel connected to the audio() or mixer() threads
|
||||
* \param c_led Optional chanend connected to an led driver thread for
|
||||
* debugging purposes
|
||||
* \param c_midi Optional chanend connect to usb_midi() thread if present
|
||||
* \param c_clk_int Optional chanend connected to the clockGen() thread if present
|
||||
*/
|
||||
void decouple(chanend c_audio_out,
|
||||
// chanend ?c_midi,
|
||||
chanend ?c_clk_int
|
||||
//#ifdef IAP
|
||||
//, chanend ?c_iap
|
||||
//#endif
|
||||
#ifdef CHAN_BUFF_CTRL
|
||||
, chanend c_buff_ctrl
|
||||
#endif
|
||||
);
|
||||
|
||||
#endif // __decouple_h__
|
||||
#endif // __DECOUPLE_H__
|
||||
|
||||
@@ -512,8 +512,10 @@ unsigned char tmpBuffer[1026];
|
||||
|
||||
#pragma unsafe arrays
|
||||
void decouple(chanend c_mix_out,
|
||||
//chanend ?c_midi,
|
||||
chanend ?c_clk_int
|
||||
#ifdef CHAN_BUFF_CTRL
|
||||
, chanend c_buf_ctrl
|
||||
#endif
|
||||
)
|
||||
{
|
||||
unsigned sampFreq = DEFAULT_FREQ;
|
||||
@@ -640,6 +642,11 @@ void decouple(chanend c_mix_out,
|
||||
while(1)
|
||||
{
|
||||
int tmp;
|
||||
|
||||
#ifdef CHAN_BUFF_CTRL
|
||||
inuchar(c_buf_ctrl);
|
||||
#endif
|
||||
|
||||
if (!isnull(c_clk_int))
|
||||
{
|
||||
check_for_interrupt(c_clk_int);
|
||||
@@ -649,7 +656,6 @@ void decouple(chanend c_mix_out,
|
||||
asm("#decouple-default");
|
||||
|
||||
/* Check for freq change or other update */
|
||||
|
||||
GET_SHARED_GLOBAL(tmp, g_freqChange_flag);
|
||||
if (tmp == SET_SAMPLE_FREQ)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#ifndef __usb_buffer_h__
|
||||
#define __usb_buffer_h__
|
||||
#ifndef __USB_BUFFER_H__
|
||||
#define __USB_BUFFER_H__
|
||||
/** USB Audio Buffering Thread.
|
||||
*
|
||||
* This function buffers USB audio data between the XUD layer and the decouple
|
||||
@@ -37,7 +37,10 @@ void buffer(chanend c_aud_out,
|
||||
chanend c_aud_ctl,
|
||||
in port p_off_mclk
|
||||
#ifdef HID_CONTROLS
|
||||
,chanend c_hid
|
||||
, chanend c_hid
|
||||
#endif
|
||||
#ifdef CHAN_BUFF_CTRL
|
||||
, chanend c_buff_ctrl
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
|
||||
@@ -26,6 +26,12 @@ void GetADCCounts(unsigned samFreq, int &min, int &mid, int &max);
|
||||
|
||||
extern unsigned int g_curSamFreqMultiplier;
|
||||
|
||||
#ifdef CHAN_BUFF_CTRL
|
||||
#define SET_SHARED_GLOBAL2(x,y) SET_SHARED_GLOBAL(x,y); outuchar(c_buff_ctrl, 0);
|
||||
#else
|
||||
#define SET_SHARED_GLOBAL2(x,y) SET_SHARED_GLOBAL(x,y)
|
||||
#endif
|
||||
|
||||
|
||||
/* Global var for speed. Related to feedback. Used by input stream to determine IN packet size */
|
||||
unsigned g_speed;
|
||||
@@ -88,7 +94,10 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
|
||||
chanend c_aud_ctl,
|
||||
in port p_off_mclk
|
||||
#ifdef HID_CONTROLS
|
||||
,chanend c_hid
|
||||
, chanend c_hid
|
||||
#endif
|
||||
#ifdef CHAN_BUFF_CTRL
|
||||
, chanend c_buff_ctrl
|
||||
#endif
|
||||
)
|
||||
{
|
||||
@@ -166,17 +175,12 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
|
||||
|
||||
|
||||
xc_ptr p_inZeroBuff = array_to_xc_ptr(inZeroBuff);
|
||||
|
||||
set_thread_fast_mode_on();
|
||||
|
||||
|
||||
#ifdef IAP
|
||||
XUD_ResetEndpoint(ep_iap_from_host, null);
|
||||
iap_send_reset(c_iap);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#if defined(SPDIF_RX) || defined(ADAT_RX)
|
||||
asm("stw %0, dp[int_usb_ep]"::"r"(ep_int));
|
||||
#endif
|
||||
@@ -343,14 +347,14 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
|
||||
* thread locked, it must stay responsive to packets/SOFs. So, set a flag and check for
|
||||
* handshake elsewhere */
|
||||
/* Pass on sample freq change to decouple */
|
||||
SET_SHARED_GLOBAL(g_freqChange, SET_SAMPLE_FREQ);
|
||||
SET_SHARED_GLOBAL2(g_freqChange, SET_SAMPLE_FREQ);
|
||||
SET_SHARED_GLOBAL(g_freqChange_sampFreq, sampleFreq);
|
||||
SET_SHARED_GLOBAL(g_freqChange_flag, SET_SAMPLE_FREQ);
|
||||
}
|
||||
else
|
||||
{
|
||||
sampleFreq = inuint(c_aud_ctl);
|
||||
SET_SHARED_GLOBAL(g_freqChange, tmp); /* Set command */
|
||||
SET_SHARED_GLOBAL2(g_freqChange, tmp); /* Set command */
|
||||
SET_SHARED_GLOBAL(g_freqChange_sampFreq, sampleFreq); /* Set flag */
|
||||
SET_SHARED_GLOBAL(g_freqChange_flag, tmp);
|
||||
}
|
||||
@@ -447,7 +451,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
|
||||
case XUD_SetData_Select(c_aud_in, ep_aud_in, tmp):
|
||||
{
|
||||
/* Inform stream that buffer sent */
|
||||
SET_SHARED_GLOBAL(g_aud_to_host_flag, bufferIn+1);
|
||||
SET_SHARED_GLOBAL2(g_aud_to_host_flag, bufferIn+1);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -486,8 +490,8 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
|
||||
|
||||
write_via_xc_ptr(aud_from_host_buffer, tmp);
|
||||
|
||||
/* Sync with audio thread */
|
||||
SET_SHARED_GLOBAL(g_aud_from_host_flag, 1);
|
||||
/* Sync with decouple thread */
|
||||
SET_SHARED_GLOBAL2(g_aud_from_host_flag, 1);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
@@ -720,7 +724,4 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
set_thread_fast_mode_off();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user