Added audio stream start/stop callbacks for input/output
This commit is contained in:
@@ -6,6 +6,7 @@ lib_xua Change Log
|
||||
|
||||
* ADDED: Initial library documentation
|
||||
* ADDED: Application note AN00247: Using lib_xua with lib_spdif (transmit)
|
||||
* ADDED: Callbacks for input/output audio stream start/stop
|
||||
* CHANGE: I2S hardware resources no longer used globally and must be passed
|
||||
to XUA_AudioHub()
|
||||
* CHANGE: XUA_AudioHub() no longer pars S/PDIF transmitter task
|
||||
|
||||
@@ -409,23 +409,48 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
||||
}
|
||||
|
||||
#if (NUM_USB_CHAN_OUT > 0) && (NUM_USB_CHAN_IN > 0)
|
||||
if ((sp.wIndex == INTERFACE_NUMBER_AUDIO_OUTPUT) || (sp.wIndex == INTERFACE_NUMBER_AUDIO_INPUT))
|
||||
unsigned num_input_interfaces = g_interfaceAlt[INTERFACE_NUMBER_AUDIO_INPUT];
|
||||
unsigned num_output_interfaces = g_interfaceAlt[INTERFACE_NUMBER_AUDIO_OUTPUT];
|
||||
if (sp.wIndex == INTERFACE_NUMBER_AUDIO_INPUT)
|
||||
{
|
||||
/* Check for stream start stop on output and input audio interfaces */
|
||||
if(sp.wValue && !g_interfaceAlt[INTERFACE_NUMBER_AUDIO_OUTPUT] && !g_interfaceAlt[INTERFACE_NUMBER_AUDIO_INPUT])
|
||||
// in: 0 -> 1
|
||||
if (sp.wValue && !num_input_interfaces)
|
||||
{
|
||||
/* If start and input AND output not currently running */
|
||||
UserAudioStreamStart();
|
||||
UserAudioInputStreamStart();
|
||||
if (!num_output_interfaces)
|
||||
{
|
||||
UserAudioStreamStart();
|
||||
}
|
||||
}
|
||||
else if(((sp.wIndex == 1) && (!sp.wValue)) && g_interfaceAlt[INTERFACE_NUMBER_AUDIO_OUTPUT] && (!g_interfaceAlt[INTERFACE_NUMBER_AUDIO_INPUT]))
|
||||
// in: 1 -> 0
|
||||
else if (!sp.wValue && num_input_interfaces)
|
||||
{
|
||||
/* if output stop and output running and input not running */
|
||||
UserAudioStreamStop();
|
||||
UserAudioInputStreamStop();
|
||||
if (!num_output_interfaces)
|
||||
{
|
||||
UserAudioStreamStop();
|
||||
}
|
||||
}
|
||||
else if(((sp.wIndex == 2) && (!sp.wValue)) && g_interfaceAlt[INTERFACE_NUMBER_AUDIO_INPUT] && (!g_interfaceAlt[INTERFACE_NUMBER_AUDIO_OUTPUT]))
|
||||
}
|
||||
else if (sp.wIndex == INTERFACE_NUMBER_AUDIO_OUTPUT)
|
||||
{
|
||||
// out: 0 -> 1
|
||||
if (sp.wValue && !num_output_interfaces)
|
||||
{
|
||||
/* if input stop and input running and output not running */
|
||||
UserAudioStreamStop();
|
||||
UserAudioOutputStreamStart();
|
||||
if (!num_input_interfaces)
|
||||
{
|
||||
UserAudioStreamStart();
|
||||
}
|
||||
}
|
||||
// out: 1 -> 0
|
||||
else if (!sp.wValue && num_output_interfaces)
|
||||
{
|
||||
UserAudioOutputStreamStop();
|
||||
if (!num_input_interfaces)
|
||||
{
|
||||
UserAudioStreamStop();
|
||||
}
|
||||
}
|
||||
}
|
||||
#elif (NUM_USB_CHAN_OUT > 0)
|
||||
@@ -435,11 +460,13 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
||||
{
|
||||
/* if start and not currently running */
|
||||
UserAudioStreamStart();
|
||||
UserAudioOutputStreamStart();
|
||||
}
|
||||
else if (!sp.wValue && g_interfaceAlt[INTERFACE_NUMBER_AUDIO_OUTPUT])
|
||||
{
|
||||
/* if stop and currently running */
|
||||
UserAudioStreamStop();
|
||||
UserAudioOutputStreamStop();
|
||||
}
|
||||
}
|
||||
#elif (NUM_USB_CHAN_IN > 0)
|
||||
@@ -449,11 +476,13 @@ void XUA_Endpoint0(chanend c_ep0_out, chanend c_ep0_in, chanend c_audioControl,
|
||||
{
|
||||
/* if start and not currently running */
|
||||
UserAudioStreamStart();
|
||||
UserAudioInputStreamStart();
|
||||
}
|
||||
else if (!sp.wValue && g_interfaceAlt[INTERFACE_NUMBER_AUDIO_INPUT])
|
||||
{
|
||||
/* if stop and currently running */
|
||||
UserAudioStreamStop();
|
||||
UserAudioInputStreamStop();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
// Copyright (c) 2013-2018, XMOS Ltd, All rights reserved
|
||||
|
||||
/* Deafult implementations of AudioStreamStop() and AudioStreamStart(). Both can be over-ridden */
|
||||
/* Default implementations of AudioStreamStop() and AudioStreamStart()
|
||||
* callbacks.
|
||||
*/
|
||||
|
||||
void UserAudioStreamStop() __attribute__ ((weak));
|
||||
void UserAudioStreamStop()
|
||||
{
|
||||
@@ -12,3 +15,27 @@ void UserAudioStreamStart()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void UserAudioInputStreamStop() __attribute__ ((weak));
|
||||
void UserAudioInputStreamStop()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void UserAudioInputStreamStart() __attribute__ ((weak));
|
||||
void UserAudioInputStreamStart()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void UserAudioOutputStreamStop() __attribute__ ((weak));
|
||||
void UserAudioOutputStreamStop()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void UserAudioOutputStreamStart() __attribute__ ((weak));
|
||||
void UserAudioOutputStreamStart()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,5 +14,17 @@ void UserAudioStreamStart(void);
|
||||
/* Any actions required on stream stop e.g. DAC mute - run every steam stop */
|
||||
void UserAudioStreamStop(void);
|
||||
|
||||
/* Any actions required on input stream start */
|
||||
void UserAudioInputStreamStart(void);
|
||||
|
||||
/* Any actions required on input stream stop */
|
||||
void UserAudioInputStreamStop(void);
|
||||
|
||||
/* Any actions required on output stream start */
|
||||
void UserAudioOutputStreamStart(void);
|
||||
|
||||
/* Any actions required on output stream stop */
|
||||
void UserAudioOutputStreamStop(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user