Updated audio subsystem from Ken Pettit

This commit is contained in:
Gregory Nutt
2013-10-27 07:44:53 -06:00
parent 70a191159b
commit 8048001c5e
6 changed files with 1064 additions and 234 deletions
+123 -33
View File
@@ -11,22 +11,139 @@ config AUDIO
if AUDIO
config AUDIO_NCHANNELS
int "Number of Audio Channels"
default 2
config AUDIO_MULTI_SESSION
bool "Support multiple sessions"
default n
---help---
Stereo channel support is standard, but some systems may support 5 or 7
channel capability.
Some audio devices, such as USB attached sound cards, may support more
than one streaming session at a time (each with one or more audio channels).
Selecting this feature adds support for tracking multiple concurrent
sessions with the lower-level audio devices.
config AUDIO_LARGE_BUFFERS
bool "Support Audio Buffers with greater than 65K samples"
default n
---help---
By default, the Audio Pipeline Buffer uses a 16-bit max sample count, limiting
By default, the Audio Pipeline Buffers use a 16-bit max sample count, limiting
the number of samples per buffer to 65K. Enable this option to specify a
32-bit max sample count for increased samples / buffer capability.
channel capability.
config AUDIO_NUM_BUFFERS
int "Number of buffers for audio processing"
default 2
---help---
Specifies the number of buffers to allocate for audio processing.
If Driver Specified buffer sizes is enabled (below), then the
low-level drivers will have the opportunity to override this
value.
config AUDIO_BUFFER_NUMBYTES
int "Size of each audio buffer for audio processing"
default 8192
---help---
Specifies the allocation size for each audio buffer
If Driver Specified buffer sizes is enabled (below), then the
low-level drivers will have the opportunity to override this
value.
config AUDIO_DRIVER_SPECIFIC_BUFFERS
bool "Support for Driver specified buffer sizes"
default n
---help---
By default, the Audio system uses the same size and number of buffers
regardless of the specific audio device in use. Specifying 'y' here
adds extra code which allows the lower-level audio device to specify
a partucular size and number of buffers.
menu "Supported Audio Formats"
config AUDIO_FORMAT_AC3
bool "AC3 Format"
default n
---help---
Build in support for AC3 (Dolby Digital) Audio format.
config AUDIO_FORMAT_DTS
bool "DTS Format"
default n
---help---
Add in support for DTS format.
config AUDIO_FORMAT_PCM
bool "PCM Audio"
default y
---help---
Build in support for PCM Audio format.
config AUDIO_FORMAT_MP3
bool "MPEG 3 Layer 1"
default y
---help---
Build in support for MP3 Audio format.
config AUDIO_FORMAT_MIDI
bool "Midi Format"
default n
---help---
Add in support for MIDI format.
config AUDIO_FORMAT_WMA
bool "WMA Format (see copyright notice)"
default n
---help---
Add in support for Microsoft Windows Media format.
config AUDIO_FORMAT_OGG_VORBIS
bool "Ogg Vorbis format"
default n
---help---
Build in support for the Open Source Ogg Vorbis format.
endmenu
menu "Exclude Specific Audio Features"
config AUDIO_EXCLUDE_VOLUME
bool "Exclude volume controls"
default n
---help---
Exclude building support for changing the playback volume.
config AUDIO_EXCLUDE_BALANCE
bool "Exclude balance controls"
default n
---help---
Exclude building support for changing the balance.
config AUDIO_EXCLUDE_TONE
bool "Exclude tone (bass and treble) controls"
default n
---help---
Exclude building support for changing the bass and treble.
config AUDIO_EXCLUDE_PAUSE_RESUME
bool "Exclude pause and resume controls"
default n
---help---
Exclude building support for pausing and resuming audio files
once they are submitted. If the sound system is being used to play
short system notification or error type sounds that typicaly only
last a second or two, then there is no need (or chance) to pause or
resume sound playback once it has started.
config AUDIO_EXCLUDE_STOP
bool "Exclude stop playback controls"
default n
---help---
Exclude building support for stopping audio files once they are
submitted. If the sound system is being used to play short ssytem
notification or error type sounds that typicaly only last a second
or two, then there is no need (or chance) to stop the sound
playback once it has started.
endmenu
config AUDIO_CUSTOM_DEV_PATH
bool "Use custom device path"
default n
@@ -57,33 +174,6 @@ config AUDIO_DEV_PATH
endif
endif
menu "Supported Audio Formats"
config AUDIO_FORMAT_PCM
bool "PCM Audio"
default y
---help---
Build in support for PCM Audio format.
config AUDIO_FORMAT_MP3
bool "MPEG 3 Layer 1"
default n
---help---
Build in support for MP3 Audio format.
config AUDIO_FORMAT_WMA
bool "WMA Format (see copyright notice)"
default n
---help---
Add in support for Microsoft Windows Media format.
config AUDIO_FORMAT_OGG_VORBIS
bool "Ogg Vorbis format"
default n
---help---
Build in support for the Open Source Ogg Vorbis format.
endmenu
# These are here as placeholders of what could be added
-12
View File
@@ -53,18 +53,6 @@ ifeq ($(CONFIG_AUDIO_FORMAT_PCM),y)
CSRCS += pcm.c
endif
ifeq ($(CONFIG_AUDIO_MIXER),y)
CSRCS += mixer.c
endif
ifeq ($(CONFIG_AUDIO_MIDI_SYNTH),y)
CSRCS += midisynth.c
endif
ifeq ($(CONFIG_AUDIO_FONT),y)
CSRCS += audio_font.c
endif
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
+125
View File
@@ -0,0 +1,125 @@
README
^^^^^^
This directory contains the audio subsytem support for NuttX. The contents of this
directory are only built if CONFIG_AUDIO is defined in the NuttX configuration file.
Contents
^^^^^^^^
- Files in this directory
- Related Header Files
- Related directories
Files in this directory
^^^^^^^^^^^^^^^^^^^^^^^
This directory holds the NuttX audio subsystem upper-half. The upper-half provides
a common interface for applications to interface with and also defines a bind
layer for specific lower-half audio device drivers.
audio.c - The upper-half driver that binds to a lower-half driver from the
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.
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
^^^^^^^^^^^^^^^^^^^^
include/nuttx/audio/audio.h -- Top level include file defining the audio interface
include/nuttx/audio/vs1053.h -- Specific driver initialization prototypes
Configuration Settings
^^^^^^^^^^^^^^^^^^^^^^
General Audio Settings
----------------------
CONFIG_AUDIO
Enables overall support for audio subsystem
CONFIG_AUDIO_MULTI_SESSION
Enables support for the audio subystem to track mutliple open sessions
with lower-level audio devices.
CONFIG_AUDIO_LARGE_BUFFERS
Specifies that buffer size variables should be 32-bit vs. the normal 16-bit
size. This allows buffers to be larger than 64K bytes on systems with
an abundance of RAM.
CONFIG_AUDIO_NUM_BUFFERS
Sets the number of audio buffers to use for audio operations. If the
configuration has set CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS, and an audio
device does not support the operation, then this becomes the default number
of buffers to use.
CONFIG_AUDIO_BUFFER_SIZE
Sets the size of the audio buffers to use for audio operations. If the
configuration has set CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS, and an audio
device does not support the operation, then this becomes the default size
of buffers to use.
CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
Enables support for lower-level audio drivers to specify the number and size
of buffers that should be allocated for best performance while interacting
with that driver.
CONFIG_AUDIO_CUSTOM_DEV_PATH
Specifies that all audio devices should be registered in the filesystem at
a location other than the standard /dev/audio directory.
CONFIG_AUDIO_DEV_ROOT
Specifies that all audio devices should be registered in the /dev directory.
Saves a tiny bit of code and RAM space since an additional directory isn't needed,
but at the expense of execution speed when searching for audio devices since all
entries in /dev must be opened and tested if they provide audio support.
Available only if CONFIG_AUDIO_CUSTOM_DEV_PATH is selected.
CONFIG_AUDIO_DEV_PATH
Specifies a custom directory where audio devices will be registered.
Available if CONFIG_AUDIO_CUSTOM_DEV_PATH is selected and CONFIG_AUDIO_DEV_ROOT
is not selected.
Audio Format Support Selections
-------------------------------
CONFIG_AUDIO_FORMAT_AC3
Specifies that AC3 support should be enabled if available by a lower-half driver.
CONFIG_AUDIO_FORMAT_DTS
Specifies that DTS support should be enabled if available by a lower-half driver.
CONFIG_AUDIO_FORMAT_PCM
Specifies that PCM support should be enabled if available by a lower-half driver.
CONFIG_AUDIO_FORMAT_MP3
Specifies that MP3 support should be enabled if available by a lower-half driver.
CONFIG_AUDIO_FORMAT_MIDI
Specifies that MIDI support should be enabled if available by a lower-half driver.
CONFIG_AUDIO_FORMAT_WMA
Specifies that WMA support should be enabled if available by a lower-half driver.
CONFIG_AUDIO_FORMAT_OGG_VORBIS
Specifies that Ogg Vorbis support should be enabled if available by a lower-half driver.
Audio feature exclusion Selections
----------------------------------
CONFIG_AUDIO_EXCLUDE_VOLUME
Disables support in all libraries and drivers for setting the playback volume. In
this case, the device volume will depend on the default level defined by the
lower-level driver, typically via a config setting.
CONFIG_AUDIO_EXCLUDE_BALANCE
Disables support in all libraries and drivers for setting the playback balance.
Also, the volume support must not be excluded for balance to work or make sense.
CONFIG_AUDIO_EXCLUDE_TONE
Disables support for setting bass and treble.
CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
Disables support in all libraries and drivers for pausing and resuming playback.
CONFIG_AUDIO_EXCLUDE_STOP
Disables support in all libraries and drivers for stopping an audio playback
once it has started. Typically selected if only short notification audio sounds
are needed (vs. media playing type applications).
Related Subdirectories
^^^^^^^^^^^^^^^^^^^^^^
drivers/audio -- Contains the lower-level device specific drivers.
apps/system/nxplayer -- User-mode audio subsystem interface library.
+448 -122
View File
File diff suppressed because it is too large Load Diff
+52 -7
View File
@@ -84,11 +84,11 @@
*
****************************************************************************/
static void apb_semtake(sem_t *sem)
static void apb_semtake(FAR struct ap_buffer_s *apb)
{
/* Take the semaphore (perhaps waiting) */
while (sem_wait(sem) != 0)
while (sem_wait(&apb->sem) != 0)
{
/* The only case that an error should occr here is if
* the wait was awakened by a signal.
@@ -102,7 +102,7 @@ static void apb_semtake(sem_t *sem)
* Name: apb_semgive
****************************************************************************/
#define apb_semgive(s) sem_post(s)
#define apb_semgive(b) sem_post(&b->sem)
/****************************************************************************
* Name: apb_alloc
@@ -113,11 +113,41 @@ static void apb_semtake(sem_t *sem)
*
****************************************************************************/
FAR struct ap_buffer_s *apb_alloc(int type, int sampleCount)
int apb_alloc(FAR struct audio_buf_desc_s * bufdesc)
{
/* TODO: Implement the alloc logic */
uint32_t bufsize;
int ret;
struct ap_buffer_s *pBuf;
return NULL;
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;
}
/****************************************************************************
@@ -143,8 +173,19 @@ void apb_prepare(FAR struct ap_buffer_s *apb, int8_t allocmode, uint8_t format,
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);
}
}
/****************************************************************************
@@ -158,7 +199,11 @@ void apb_free(FAR struct ap_buffer_s *apb)
void apb_reference(FAR struct ap_buffer_s *apb)
{
/* TODO: Implement the reference logic */
/* Do we need any thread protection here? Almost certaily... */
apb_semtake(apb);
apb->crefs++;
apb_semgive(apb);
}
#endif /* CONFIG_AUDIO */
File diff suppressed because it is too large Load Diff