forked from PAWPAW-Mirror/lib_xua
DSD/PCM mode now rememebered and only changed when required. Re-oreded when Stream Start/Stop is called for better use with Mute signals. Writes to shared mute sample
This commit is contained in:
@@ -110,6 +110,13 @@ extern unsigned g_iap_reset;
|
|||||||
'\0' \
|
'\0' \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef NATIVE_DSD
|
||||||
|
/* We remember if we are in DSD mode to avoid Configuring the DAC too often - thus avoiding pops and clicks */
|
||||||
|
unsigned g_dsdMode = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
unsigned g_muteSample = 0;
|
||||||
|
|
||||||
/* String descriptors */
|
/* String descriptors */
|
||||||
static unsigned char strDesc_langIDs[] = DESC_STR_LANGIDS;
|
static unsigned char strDesc_langIDs[] = DESC_STR_LANGIDS;
|
||||||
|
|
||||||
@@ -262,51 +269,13 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
|||||||
/* Over-riding USB_StandardRequests implementation */
|
/* Over-riding USB_StandardRequests implementation */
|
||||||
if(sp.bRequest == USB_SET_INTERFACE)
|
if(sp.bRequest == USB_SET_INTERFACE)
|
||||||
{
|
{
|
||||||
#if defined(OUTPUT) && defined(INPUT)
|
|
||||||
/* Check for stream start stop on output and input audio interfaces */
|
|
||||||
if(sp.wValue && !g_interfaceAlt[1] && !g_interfaceAlt[2])
|
|
||||||
{
|
|
||||||
/* If start and input AND output not currently running */
|
|
||||||
UserAudioStreamStart();
|
|
||||||
}
|
|
||||||
else if(((sp.wIndex == 1) && (!sp.wValue)) && g_interfaceAlt[1] && (!g_interfaceAlt[2]))
|
|
||||||
{
|
|
||||||
/* if output stop and output running and input not running */
|
|
||||||
UserAudioStreamStop();
|
|
||||||
}
|
|
||||||
else if(((sp.wIndex == 2) && (!sp.wValue)) && g_interfaceAlt[2] && (!g_interfaceAlt[1]))
|
|
||||||
{
|
|
||||||
/* if input stop and input running and output not running */
|
|
||||||
UserAudioStreamStop();
|
|
||||||
}
|
|
||||||
#elif defined(OUTPUT) || defined(INPUT)
|
|
||||||
if(sp.wValue && (!g_interfaceAlt[1]))
|
|
||||||
{
|
|
||||||
/* if start and not currently running */
|
|
||||||
UserAudioStreamStart();
|
|
||||||
}
|
|
||||||
else if (!sp.wValue && g_interfaceAlt[1])
|
|
||||||
{
|
|
||||||
/* if stop and currently running */
|
|
||||||
UserAudioStreamStop();
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
/* Record interface change */
|
|
||||||
if(sp.wIndex < NUM_INTERFACES)
|
|
||||||
g_interfaceAlt[sp.wIndex] = sp.wValue;
|
|
||||||
|
|
||||||
/* Check for audio stream from host start/stop */
|
/* Check for audio stream from host start/stop */
|
||||||
if(sp.wIndex == 1) // Ouput interface
|
if(sp.wIndex == 1) // Ouput interface
|
||||||
{
|
{
|
||||||
switch(sp.wValue)
|
switch(sp.wValue)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
#ifdef NATIVE_DSD
|
/* Stream stop */
|
||||||
outuint(c_audioControl, SET_DSD_MODE);
|
|
||||||
outuint(c_audioControl, DSD_MODE_OFF);
|
|
||||||
// Handshake
|
|
||||||
chkct(c_audioControl, XS1_CT_END);
|
|
||||||
#endif /* NATIVE_DSD */
|
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
/* Stream active + 0 chans */
|
/* Stream active + 0 chans */
|
||||||
@@ -323,25 +292,29 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
|||||||
outuint(c_audioControl, NUM_USB_CHAN_OUT_A1);
|
outuint(c_audioControl, NUM_USB_CHAN_OUT_A1);
|
||||||
}
|
}
|
||||||
#ifdef NATIVE_DSD
|
#ifdef NATIVE_DSD
|
||||||
outuint(c_audioControl, SET_DSD_MODE);
|
if(g_dsdMode)
|
||||||
outuint(c_audioControl, DSD_MODE_OFF);
|
{
|
||||||
|
outuint(c_audioControl, SET_DSD_MODE);
|
||||||
|
outuint(c_audioControl, DSD_MODE_OFF);
|
||||||
|
SET_SHARED_GLOBAL(g_muteSample, 0);
|
||||||
|
|
||||||
// Handshake
|
// Handshake
|
||||||
chkct(c_audioControl, XS1_CT_END);
|
chkct(c_audioControl, XS1_CT_END);
|
||||||
|
g_dsdMode = 0;
|
||||||
|
}
|
||||||
#endif /* NATIVE_DSD */
|
#endif /* NATIVE_DSD */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
#ifdef NATIVE_DSD
|
#ifdef NATIVE_DSD
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
outuint(c_audioControl, SET_DSD_MODE);
|
if(!g_dsdMode)
|
||||||
outuint(c_audioControl, DSD_MODE_NATIVE);
|
{
|
||||||
|
outuint(c_audioControl, SET_DSD_MODE);
|
||||||
// Handshake
|
outuint(c_audioControl, DSD_MODE_NATIVE);
|
||||||
chkct(c_audioControl, XS1_CT_END);
|
SET_SHARED_GLOBAL(g_muteSample, 0x96969696);
|
||||||
|
chkct(c_audioControl, XS1_CT_END);
|
||||||
|
g_dsdMode = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif /* NATIVE_DSD */
|
#endif /* NATIVE_DSD */
|
||||||
}
|
}
|
||||||
@@ -393,8 +366,44 @@ void Endpoint0( chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if 1
|
||||||
|
#if defined(OUTPUT) && defined(INPUT)
|
||||||
|
/* Check for stream start stop on output and input audio interfaces */
|
||||||
|
if(sp.wValue && !g_interfaceAlt[1] && !g_interfaceAlt[2])
|
||||||
|
{
|
||||||
|
/* If start and input AND output not currently running */
|
||||||
|
UserAudioStreamStart();
|
||||||
|
}
|
||||||
|
else if(((sp.wIndex == 1) && (!sp.wValue)) && g_interfaceAlt[1] && (!g_interfaceAlt[2]))
|
||||||
|
{
|
||||||
|
/* if output stop and output running and input not running */
|
||||||
|
UserAudioStreamStop();
|
||||||
|
}
|
||||||
|
else if(((sp.wIndex == 2) && (!sp.wValue)) && g_interfaceAlt[2] && (!g_interfaceAlt[1]))
|
||||||
|
{
|
||||||
|
/* if input stop and input running and output not running */
|
||||||
|
UserAudioStreamStop();
|
||||||
|
}
|
||||||
|
#elif defined(OUTPUT) || defined(INPUT)
|
||||||
|
if(sp.wValue && (!g_interfaceAlt[1]))
|
||||||
|
{
|
||||||
|
/* if start and not currently running */
|
||||||
|
UserAudioStreamStart();
|
||||||
|
}
|
||||||
|
else if (!sp.wValue && g_interfaceAlt[1])
|
||||||
|
{
|
||||||
|
/* if stop and currently running */
|
||||||
|
UserAudioStreamStop();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
/* Record interface change */
|
||||||
|
if(sp.wIndex < NUM_INTERFACES)
|
||||||
|
g_interfaceAlt[sp.wIndex] = sp.wValue;
|
||||||
|
|
||||||
/* No data stage for this request, just do data stage */
|
/* No data stage for this request, just do data stage */
|
||||||
retVal = XUD_DoSetRequestStatus(ep0_in);
|
retVal = XUD_DoSetRequestStatus(ep0_in);
|
||||||
|
|
||||||
} /* if(sp.bRequest == SET_INTERFACE) */
|
} /* if(sp.bRequest == SET_INTERFACE) */
|
||||||
|
|
||||||
break; /* BMREQ_H2D_STANDARD_INT */
|
break; /* BMREQ_H2D_STANDARD_INT */
|
||||||
|
|||||||
Reference in New Issue
Block a user