summaryrefslogtreecommitdiff
path: root/nuttx/audio
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-11-10 11:20:06 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-11-10 11:20:06 -0600
commitb6f65ea46230955a33e42c46dc30c5e428d3dd08 (patch)
tree1f1b0619552f38e49112ade56883fb25e8f65b7d /nuttx/audio
parent5a70f55a6fce67a324ad049e39d3ce532025365b (diff)
downloadnuttx-b6f65ea46230955a33e42c46dc30c5e428d3dd08.tar.gz
nuttx-b6f65ea46230955a33e42c46dc30c5e428d3dd08.tar.bz2
nuttx-b6f65ea46230955a33e42c46dc30c5e428d3dd08.zip
Moved audio/buffer.c to libc/audio/lib_buffer.c so that it can be shared betweent he OS and applications in a kernel build
Diffstat (limited to 'nuttx/audio')
-rw-r--r--nuttx/audio/Makefile2
-rw-r--r--nuttx/audio/README.txt11
-rw-r--r--nuttx/audio/buffer.c210
3 files changed, 9 insertions, 214 deletions
diff --git a/nuttx/audio/Makefile b/nuttx/audio/Makefile
index 7b34de1ae..b95e3900b 100644
--- a/nuttx/audio/Makefile
+++ b/nuttx/audio/Makefile
@@ -42,7 +42,7 @@ endif
DEPPATH = --dep-path .
ASRCS =
-CSRCS = audio.c buffer.c
+CSRCS = audio.c
VPATH = .
# Include support for various drivers. Each Make.defs file will add its
diff --git a/nuttx/audio/README.txt b/nuttx/audio/README.txt
index 80178865d..be86cacb0 100644
--- a/nuttx/audio/README.txt
+++ b/nuttx/audio/README.txt
@@ -21,13 +21,18 @@ layer for specific lower-half audio device drivers.
drivers/audio subdirectory. For each attached audio device, there
will be an instance of this upper-half driver bound to the
instance of the lower half driver context.
+ pcm.c - Routines to manage PCM / WAV type data. Currently just a placeholder.
+ README - This file!
+
+Portions of the the audio system interface have application interfaces. Those
+portions reside in the nuttx/libc/audio directory where the will be built for
+access by both OS driver logic and user application logic. Those relevant
+files in nuttx/libc/audio include:
+
buffer.c - Routines to manage creattion and destruction of audio pipeline buffers
(apb) used in the audio subsystem. Audio pipeline buffers are passed
between user applications and the audio drivers to deliver audio
content for playback (or possibly recording in the future).
- pcm.c - Routines to manage PCM / WAV type data. Currently just a placeholder.
- README - This file!
-
Related Header Files
^^^^^^^^^^^^^^^^^^^^
diff --git a/nuttx/audio/buffer.c b/nuttx/audio/buffer.c
deleted file mode 100644
index b0b5c6c36..000000000
--- a/nuttx/audio/buffer.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/****************************************************************************
- * audio/buffer.c
- *
- * Copyright (C) 2013 Ken Pettit. All rights reserved.
- * Author: Ken Pettit <pettitkd@gmail.com>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- * 3. Neither the name NuttX nor the names of its contributors may be
- * used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
- * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
- * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <sys/types.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <semaphore.h>
-#include <errno.h>
-#include <debug.h>
-
-#include <nuttx/kmalloc.h>
-#include <nuttx/audio/audio.h>
-#include <nuttx/usb/audio.h>
-
-#if defined(CONFIG_AUDIO)
-
-/****************************************************************************
- * Preprocessor Definitions
- ****************************************************************************/
-
-/* Configuration ************************************************************/
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/****************************************************************************
- * Private Variables
- ****************************************************************************/
-
-/****************************************************************************
- * Public Variables
- ****************************************************************************/
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: apb_semtake
- *
- * Take an Audio Pipeline Buffer.
- *
- ****************************************************************************/
-
-static void apb_semtake(FAR struct ap_buffer_s *apb)
-{
- /* Take the semaphore (perhaps waiting) */
-
- while (sem_wait(&apb->sem) != 0)
- {
- /* The only case that an error should occr here is if
- * the wait was awakened by a signal.
- */
-
- ASSERT(errno == EINTR);
- }
-}
-
-/****************************************************************************
- * Name: apb_semgive
- ****************************************************************************/
-
-#define apb_semgive(b) sem_post(&b->sem)
-
-/****************************************************************************
- * Name: apb_alloc
- *
- * Allocate an Audio Pipeline Buffer for use in the Audio sub-system. This
- * will perform the actual allocate based on buffer data format, number of
- * channels, etc. and prepare the buffer for consumption.
- *
- ****************************************************************************/
-
-int apb_alloc(FAR struct audio_buf_desc_s * bufdesc)
-{
- uint32_t bufsize;
- int ret;
- struct ap_buffer_s *pBuf;
-
- DEBUGASSERT(bufdesc->u.ppBuffer != NULL);
-
- /* Perform a user mode allocation */
-
- bufsize = sizeof(struct ap_buffer_s) + bufdesc->numbytes;
- pBuf = kumalloc(bufsize);
- *bufdesc->u.ppBuffer = pBuf;
-
- /* Test if the allocation was successful or not */
-
- if (*bufdesc->u.ppBuffer == NULL)
- ret = -ENOMEM;
- else
- {
- /* Populate the buffer contents */
-
- memset(pBuf, bufsize, 0);
- pBuf->i.channels = 1;
- pBuf->crefs = 1;
- pBuf->nmaxbytes = bufdesc->numbytes;
- pBuf->nbytes = 0;
-#ifdef CONFIG_AUDIO_MULTI_SESSION
- pBuf->session = bufdesc->session;
-#endif
- sem_init(&pBuf->sem, 0, 1);
- ret = sizeof(struct audio_buf_desc_s);
- }
-
- return ret;
-}
-
-/****************************************************************************
- * Name: apb_prepare
- *
- * Prepare an AP Buffer for use in the Audio Pipeline.
- *
- ****************************************************************************/
-
-void apb_prepare(FAR struct ap_buffer_s *apb, int8_t allocmode, uint8_t format,
- uint8_t subformat, apb_samp_t maxsamples)
-{
- /* Perform a reference count decrement and possibly release the memory */
-
-}
-
-/****************************************************************************
- * Name: apb_free
- *
- * Free's a previously allocated or referenced Audio Pipeline Buffer
- *
- ****************************************************************************/
-
-void apb_free(FAR struct ap_buffer_s *apb)
-{
- int refcount;
-
- /* Perform a reference count decrement and possibly release the memory */
-
- apb_semtake(apb);
- refcount = apb->crefs--;
- apb_semgive(apb);
-
- if (refcount == 1)
- {
- auddbg("Freeing %p\n", apb);
- kufree(apb);
- }
-}
-
-/****************************************************************************
- * Name: apb_reference
- *
- * Claim a reference to an Audio Pipeline Buffer. Each call to apb_reference
- * will increment the reference count and must have a matching apb_free
- * call. When the refcount decrements to zero, the buffer will be freed.
- *
- ****************************************************************************/
-
-void apb_reference(FAR struct ap_buffer_s *apb)
-{
- /* Do we need any thread protection here? Almost certaily... */
-
- apb_semtake(apb);
- apb->crefs++;
- apb_semgive(apb);
-}
-
-#endif /* CONFIG_AUDIO */
-