Add UserBufferManagementInit()

Used to reset any state required in UserBufferManagement(). Weak default
implementation provided, which does nothing.

Also tidied up weak default implementation of UserBufferManagement(),
and added a header file to define both function protypes.
This commit is contained in:
Sam Chesney
2017-01-31 18:42:19 +00:00
parent 342bf64c21
commit ba37e87dab
5 changed files with 35 additions and 12 deletions

View File

@@ -3,6 +3,7 @@ sc_usb_audio Change Log
7.0.2
-----
- ADDED: UserBufferManagementInit() to reset any state required in UserBufferManagement()
- ADDED: I2S output up-sampling (I2S_UPSAMPLE_FACTOR_OUT)
- CHANGE: Rename I2S input down-sampling (I2S_DOWNSAMPLE_FACTOR to I2S_DOWNSAMPLE_FACTOR_IN)

View File

@@ -16,6 +16,7 @@
#include "devicedefines.h"
#include "userbuffermanagement.h"
#include "xua_audio.h"
#include "audioports.h"
#include "audiohw.h"
@@ -243,10 +244,6 @@ static inline void TransferAdatTxSamples(chanend c_adat_out, const unsigned samp
}
#endif
/* sampsFromUsbToAudio: The sample frame the device has received from the host and is going to play to the output audio interfaces */
/* sampsFromAudioToUsb: The sample frame that was received from the audio interfaces and that the device is going to send to the host */
void UserBufferManagement(unsigned sampsFromUsbToAudio[], unsigned sampsFromAudioToUsb[], client audManage_if i_audMan);
#ifndef NO_USB
#pragma unsafe arrays
static inline unsigned DoSampleTransfer(chanend c_out, const int readBuffNo, const unsigned underflowWord, client audManage_if i_audMan)
@@ -526,8 +523,13 @@ int i2sOutUpsamplingCounter = 0;
memset(&i2sOutUs3.delayLine, 0, sizeof i2sOutUs3.delayLine);
#endif // (I2S_UPSAMPLE_FACTOR_OUT > 1)
UserBufferManagementInit(i_audMan);
unsigned command = DoSampleTransfer(c_out, readBuffNo, underflowWord, i_audMan);
// Reinitialise user state before entering the main loop
UserBufferManagementInit(i_audMan);
#ifdef ADAT_TX
unsafe{
//TransferAdatTxSamples(c_adat_out, samplesOut, adatSmuxMode, 0);

View File

@@ -1,14 +1,17 @@
#include "userbuffermanagement.h"
#include "xccompat.h"
#include "devicedefines.h"
/* Default implentation for UserBufferManagement() */
void UserBufferManagement(unsigned sampsFromUsbToAudio[], unsigned sampsFromAudioToUsb[]
, unsigned i_audMan
) __attribute__ ((weak));
void UserBufferManagement(unsigned sampsFromUsbToAudio[], unsigned sampsFromAudioToUsb[]
, unsigned i_audMan
)
/* Default implementation for UserBufferManagementInit() */
void __attribute__ ((weak)) UserBufferManagementInit(CLIENT_INTERFACE(audManage_if, i_audMan))
{
/* Do nothing */
}
/* Default implementation for UserBufferManagement() */
void __attribute__ ((weak)) UserBufferManagement(unsigned sampsFromUsbToAudio[],
unsigned sampsFromAudioToUsb[],
CLIENT_INTERFACE(audManage_if, i_audMan))
{
/* Do nothing */
}

View File

@@ -0,0 +1,13 @@
#ifndef _USERBUFFERMANAGEMENT_H_
#define _USERBUFFERMANAGEMENT_H_
#include "xua_audio.h"
#include <xccompat.h>
void UserBufferManagementInit(CLIENT_INTERFACE(audManage_if, i_audMan));
void UserBufferManagement(unsigned sampsFromUsbToAudio[],
unsigned sampsFromAudioToUsb[],
CLIENT_INTERFACE(audManage_if, i_audMan));
#endif // _USERBUFFERMANAGEMENT_H_

View File

@@ -1,6 +1,8 @@
#ifndef __audio_h__
#define __audio_h__
#if __XC__
#include "dfu_interface.h"
typedef interface audManage_if
@@ -46,4 +48,6 @@ void audio(chanend c_in,
void SpdifTxWrapper(chanend c_spdif_tx);
#endif // __XC__
#endif // __audio_h__