aboutsummaryrefslogtreecommitdiffstats
path: root/src/gaudin/gaudin.c
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2014-03-11 17:13:31 +1000
committerinmarket <andrewh@inmarket.com.au>2014-03-11 17:13:31 +1000
commitea5a1b849df6e5085a92957ad387f9e653674415 (patch)
tree72ede5ed78263a6fdba25039398b5c2a55bd1d3a /src/gaudin/gaudin.c
parent944c33cbff5f2cfb1c80f48193aa2161574864fd (diff)
downloaduGFX-ea5a1b849df6e5085a92957ad387f9e653674415.tar.gz
uGFX-ea5a1b849df6e5085a92957ad387f9e653674415.tar.bz2
uGFX-ea5a1b849df6e5085a92957ad387f9e653674415.zip
Combine GAUDIN and GAUDOUT into a single GAUDIO module.
Simplify GAUDIN (now GAUDIO RECORD) api. Update audio demo's to match. Port Win32 driver to new audio api.
Diffstat (limited to 'src/gaudin/gaudin.c')
-rw-r--r--src/gaudin/gaudin.c158
1 files changed, 0 insertions, 158 deletions
diff --git a/src/gaudin/gaudin.c b/src/gaudin/gaudin.c
deleted file mode 100644
index 2e3507ef..00000000
--- a/src/gaudin/gaudin.c
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * This file is subject to the terms of the GFX License. If a copy of
- * the license was not distributed with this file, you can obtain one at:
- *
- * http://ugfx.org/license.html
- */
-
-/**
- * @file src/gaudin/gaudin.c
- * @brief GAUDIN sub-system code.
- *
- * @addtogroup GAUDIN
- * @{
- */
-#include "gfx.h"
-
-#if GFX_USE_GAUDIN
-
-/* Include the driver defines */
-#include "src/gaudin/driver.h"
-
-static gaudin_params aud;
-static gfxSem *paudSem;
-static GEventAudioIn *paudEvent;
-static audin_sample_t *lastbuffer;
-static size_t lastcount;
-static uint16_t audFlags;
- #define AUDFLG_RUNNING 0x0001
- #define AUDFLG_USE_EVENTS 0x0002
-
-#if GFX_USE_GEVENT
- static GTimer AudGTimer;
-
- static void AudGTimerCallback(void *param) {
- (void) param;
- GSourceListener *psl;
- GEventADC *pe;
-
- psl = 0;
- while ((psl = geventGetSourceListener((GSourceHandle)(&aud), psl))) {
- if (!(pe = (GEventAudioIn *)geventGetEventBuffer(psl))) {
- // This listener is missing - save this.
- psl->srcflags |= GAUDIN_LOSTEVENT;
- continue;
- }
-
- pe->type = GEVENT_AUDIO_IN;
- pe->channel = aud.channel;
- pe->count = lastcount;
- pe->buffer = lastbuffer;
- pe->flags = psl->srcflags;
- psl->srcflags = 0;
- geventSendEvent(psl);
- }
- }
-#endif
-
-void GAUDIN_ISR_CompleteI(audin_sample_t *buffer, size_t n) {
- /* Save the details */
- lastcount = n;
- lastbuffer = buffer;
-
- /* Signal the user with the data */
- if (paudEvent) {
- #if GFX_USE_GEVENT
- paudEvent->type = GEVENT_AUDIO_IN;
- #endif
- paudEvent->channel = aud.channel;
- paudEvent->count = lastcount;
- paudEvent->buffer = lastbuffer;
- paudEvent->flags = 0;
- }
-
- /* Our two signalling mechanisms */
- if (paudSem)
- gfxSemSignalI(paudSem);
-
- #if GFX_USE_GEVENT
- if (audFlags & AUDFLG_USE_EVENTS)
- gtimerJabI(&AudGTimer);
- #endif
-}
-
-void GAUDIN_ISR_ErrorI(void) {
- /* Ignore any errors for now */
-}
-
-void _gaudinInit(void)
-{
- #if GFX_USE_GEVENT
- gtimerInit(&AudGTimer);
- #endif
-}
-
-void _gaudinDeinit(void)
-{
- // Commented stuff still ToDo
- #if GFX_USE_GEVENT
- gtimerDeinit(&AudGTimer);
- #endif
-}
-
-bool_t gaudinInit(uint16_t channel, uint32_t frequency, audin_sample_t *buffer, size_t bufcount, size_t samplesPerEvent) {
- /* Check the channel is valid */
- if (channel >= GAUDIN_NUM_CHANNELS || frequency > GAUDIN_MAX_SAMPLE_FREQUENCY)
- return FALSE;
-
- /* Stop any existing transfers */
- if ((audFlags & AUDFLG_RUNNING))
- gaudin_lld_stop();
- audFlags = 0;
-
- /* Initialise everything */
- aud.channel = channel;
- aud.frequency = frequency;
- aud.buffer = buffer;
- aud.bufcount = bufcount;
- aud.samplesPerEvent = samplesPerEvent;
- paudSem = 0;
- paudEvent = 0;
-
- /* Set up the low level driver */
- gaudin_lld_init(&aud);
- return TRUE;
-}
-
-#if GFX_USE_GEVENT
- GSourceHandle gaudinGetSource(void) {
- if (!gtimerIsActive(&AudGTimer))
- gtimerStart(&AudGTimer, AudGTimerCallback, 0, TRUE, TIME_INFINITE);
- audFlags |= AUDFLG_USE_EVENTS;
- return (GSourceHandle)&aud;
- }
-#endif
-
-void gaudinSetBSem(gfxSem *pbsem, GEventAudioIn *pEvent) {
- gfxSystemLock();
- paudSem = pbsem;
- paudEvent = pEvent;
- gfxSystemUnlock();
-}
-
-void gaudinStart(void) {
- if (!(audFlags & AUDFLG_RUNNING)) {
- audFlags |= AUDFLG_RUNNING;
- gaudin_lld_start();
- }
-}
-
-void gaudinStop(void) {
- if ((audFlags & AUDFLG_RUNNING)) {
- gaudin_lld_stop();
- audFlags &= ~AUDFLG_RUNNING;
- }
-}
-
-#endif /* GFX_USE_GAUDIN */
-/** @} */