summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NxWidgets/nxwm/include/cmediaplayer.hxx10
-rw-r--r--apps/include/nxplayer.h152
-rw-r--r--apps/system/nxplayer/nxplayer.c110
-rw-r--r--nuttx/audio/Kconfig46
-rw-r--r--nuttx/audio/audio.c4
-rw-r--r--nuttx/include/nuttx/audio/audio.h23
6 files changed, 314 insertions, 31 deletions
diff --git a/NxWidgets/nxwm/include/cmediaplayer.hxx b/NxWidgets/nxwm/include/cmediaplayer.hxx
index 6e19ddaf3..9ba86c988 100644
--- a/NxWidgets/nxwm/include/cmediaplayer.hxx
+++ b/NxWidgets/nxwm/include/cmediaplayer.hxx
@@ -97,6 +97,16 @@ namespace NxWM
* FFORWARD2| X | X | X | PLAYING | PLAYING | REWIND1 |
* REWIND2 | X | X | X | PLAYING |FFORWARD1 | PLAYING |
* ---------+----------+----------+----------+----------+----------+----------+
+ *
+ * Configuration Dependencies. States in the above state transition table may
+ * not be supported if any of the following features are excluded from the
+ * configuration:
+ *
+ * CONFIG_AUDIO_EXCLUDE_STOP
+ * CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
+ * CONFIG_AUDIO_EXCLUDE_VOLUME
+ * CONFIG_AUDIO_EXCLUDE_FFORWARD
+ * CONFIG_AUDIO_EXCLUDE_REWIND
*/
enum EMediaPlayerState
diff --git a/apps/include/nxplayer.h b/apps/include/nxplayer.h
index cd0517dcf..b6d157e7a 100644
--- a/apps/include/nxplayer.h
+++ b/apps/include/nxplayer.h
@@ -4,6 +4,10 @@
* Copyright (C) 2013 Ken Pettit. All rights reserved.
* Author: Ken Pettit <pettitkd@gmail.com>
*
+ * With updates, enhancements, and modifications by:
+ *
+ * Author: Gregory Nutt <gnutt@nuttx.org>
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -49,6 +53,20 @@
/****************************************************************************
* Public Type Declarations
****************************************************************************/
+/* Fast-forward and rewind by sub-sampling may be supported. If so, then
+ * this enumeration specifies the sub-sampling:
+ */
+
+enum nxplayer_subsample_e
+{
+ SUBSAMPLE_1X = 0, /* Normal speed (no direction change) */
+ SUBSAMPLE_2X,
+ SUBSAMPLE_4X,
+ SUBSAMPLE_8X,
+ SUBSAMPLE_16X
+};
+
+/* This structure describes the internal state of the NxPlayer */
struct nxplayer_s
{
@@ -89,10 +107,6 @@ typedef int (*nxplayer_func)(FAR struct nxplayer_s* pPlayer, char* pargs);
* Public Data
****************************************************************************/
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
@@ -123,7 +137,7 @@ extern "C"
*
* Input Parameters: None
*
- * Returned values:
+ * Returned Value:
* Pointer to created NxPlayer context or NULL if error.
*
**************************************************************************/
@@ -139,7 +153,8 @@ FAR struct nxplayer_s *nxplayer_create(void);
* Input Parameters:
* pPlayer Pointer to the NxPlayer context
*
- * Returned values: None
+ * Returned Value:
+ * None
*
**************************************************************************/
@@ -153,7 +168,8 @@ void nxplayer_release(FAR struct nxplayer_s *pPlayer);
* Input Parameters:
* pPlayer Pointer to the NxPlayer context
*
- * Returned values: None
+ * Returned Value:
+ * None
*
**************************************************************************/
@@ -172,7 +188,7 @@ void nxplayer_reference(FAR struct nxplayer_s *pPlayer);
* pPlayer - Pointer to the context to initialize
* device - Pointer to pathname of the preferred device
*
- * Returned values:
+ * Returned Value:
* OK if context initialized successfully, error code otherwise.
*
**************************************************************************/
@@ -195,7 +211,7 @@ int nxplayer_setdevice(FAR struct nxplayer_s *pPlayer, FAR const char *device);
* subfmt - Sub-Format of audio in filename if known, AUDIO_FMT_UNDEF
* to let nxplayer_playfile() determine automatically.
*
- * Returned values:
+ * Returned Value:
* OK if file found, device found, and playback started.
*
**************************************************************************/
@@ -211,7 +227,7 @@ int nxplayer_playfile(FAR struct nxplayer_s *pPlayer, FAR char *filename,
* Input Parameters:
* pPlayer - Pointer to the context to initialize
*
- * Returned values:
+ * Returned Value:
* OK if file found, device found, and playback started.
*
**************************************************************************/
@@ -228,7 +244,7 @@ int nxplayer_stop(FAR struct nxplayer_s *pPlayer);
* Input Parameters:
* pPlayer - Pointer to the context to initialize
*
- * Returned values:
+ * Returned Value:
* OK if file found, device found, and playback started.
*
**************************************************************************/
@@ -240,12 +256,12 @@ int nxplayer_pause(FAR struct nxplayer_s *pPlayer);
/****************************************************************************
* Name: nxplayer_resume
*
- * Resuems current playback.
+ * Resumes current playback.
*
* Input Parameters:
* pPlayer - Pointer to the context to initialize
*
- * Returned values:
+ * Returned Value:
* OK if file found, device found, and playback started.
*
**************************************************************************/
@@ -255,6 +271,77 @@ int nxplayer_resume(FAR struct nxplayer_s *pPlayer);
#endif
/****************************************************************************
+ * Name: nxplayer_fforward
+ *
+ * Selects to fast forward in the audio data stream. The fast forward
+ * operation can be cancelled by simply selected no sub-sampling with
+ * the SUBSAMPLE_1X argument returning to normal 1x forward play.
+ *
+ * The preferred way to cancel a fast forward operation is via
+ * nxplayer_cancel_motion() that provides the option to also return to
+ * paused, non-playing state.
+ *
+ * Input Parameters:
+ * pPlayer - Pointer to the context to initialize
+ * subsample - Identifies the fast forward rate (in terms of sub-sampling,
+ * but does not explicitly require sub-sampling)
+ *
+ * Returned Value:
+ * OK if fast forward operation successful.
+ *
+ **************************************************************************/
+
+#ifndef CONFIG_AUDIO_EXCLUDE_FFORWARD
+int nxplayer_fforward(FAR struct nxplayer_s *pPlayer,
+ enum nxplayer_subsample_e subsample);
+#endif
+
+/****************************************************************************
+ * Name: nxplayer_rewind
+ *
+ * Selects to rewind in the audio data stream. The rewind operation must
+ * be cancelled with nxplayer_cancel_motion.
+ *
+ * NOTE that cancellation of the rewind operation differs from
+ * cancellation of the fast forward operation because we must both restore
+ * the sub-sampling rate to 1x and also return to forward play.
+ *
+ * Input Parameters:
+ * pPlayer - Pointer to the context to initialize
+ * subsample - Identifies the rewind rate (in terms of sub-sampling, but
+ * does not explicitly require sub-sampling)
+ *
+ * Returned Value:
+ * OK if rewind operation successfully initiated.
+ *
+ **************************************************************************/
+
+#ifndef CONFIG_AUDIO_EXCLUDE_REWIND
+int nxplayer_rewind(FAR struct nxplayer_s *pPlayer,
+ enum nxplayer_subsample_e subsample);
+#endif
+
+/****************************************************************************
+ * Name: nxplayer_cancel_motion
+ *
+ * Cancel a rewind or fast forward operation and return to either the
+ * paused state or to the normal, forward play state.
+ *
+ * Input Parameters:
+ * pPlayer - Pointer to the context to initialize
+ * paused - True: return to the paused state, False: return to the 1X
+ * forward play state.
+ *
+ * Returned Value:
+ * OK if rewind operation successfully cancelled.
+ *
+ **************************************************************************/
+
+#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
+int nxplayer_cancel_motion(FAR struct nxplayer_s *pPlayer, bool paused);
+#endif
+
+/****************************************************************************
* Name: nxplayer_setvolume
*
* Sets the playback volume. The volume is represented in 1/10th of a
@@ -265,7 +352,7 @@ int nxplayer_resume(FAR struct nxplayer_s *pPlayer);
* pPlayer - Pointer to the context to initialize
* volume - Volume level to set in 1/10th percent increments
*
- * Returned values:
+ * Returned Value:
* OK if file found, device found, and playback started.
*
**************************************************************************/
@@ -285,7 +372,7 @@ int nxplayer_setvolume(FAR struct nxplayer_s *pPlayer, uint16_t volume);
* pPlayer - Pointer to the context to initialize
* balance - Balance level to set in 1/10th percent increments
*
- * Returned values:
+ * Returned Value:
* OK if file found, device found, and playback started.
*
**************************************************************************/
@@ -305,12 +392,37 @@ int nxplayer_setbalance(FAR struct nxplayer_s *pPlayer, uint16_t balance);
* pPlayer - Pointer to the context to initialize
* mediadir - Pointer to pathname of the media directory
*
+ * Returned Value:
+ * None
*
**************************************************************************/
void nxplayer_setmediadir(FAR struct nxplayer_s *pPlayer, FAR char *mediadir);
/****************************************************************************
+ * Name: nxplayer_setequalization
+ *
+ * Sets the level on each band of an equalizer. Each band setting is
+ * represented in one percent increments, so the range is 0-100.
+ *
+ * Input Parameters:
+ * pPlayer - Pointer to the context to initialize
+ * equalization - Pointer to array of equalizer settings of size
+ * CONFIG_AUDIO_EQUALIZER_NBANDS bytes. Each byte
+ * represents the setting for one band in the range of
+ * 0-100.
+ *
+ * Returned Value:
+ * OK if equalization was set correctly.
+ *
+ **************************************************************************/
+
+#ifndef CONFIG_AUDIO_EXCLUDE_EQUALIZER
+int nxplayer_setequalization(FAR struct nxplayer_s *pPlayer,
+ FAR uint8_t *equalization);
+#endif
+
+/****************************************************************************
* Name: nxplayer_setbass
*
* Sets the playback bass level. The bass is represented in one percent
@@ -320,8 +432,8 @@ void nxplayer_setmediadir(FAR struct nxplayer_s *pPlayer, FAR char *mediadir);
* pPlayer - Pointer to the context to initialize
* bass - Bass level to set in one percent increments
*
- * Returned values:
- * OK if file found, device found, and playback started.
+ * Returned Value:
+ * OK if the bass level was set successfully
*
**************************************************************************/
@@ -339,8 +451,8 @@ int nxplayer_setbass(FAR struct nxplayer_s *pPlayer, uint8_t bass);
* pPlayer - Pointer to the context to initialize
* treble - Treble level to set in one percent increments
*
- * Returned values:
- * OK if file found, device found, and playback started.
+ * Returned Value:
+ * OK if the treble level was set successfully
*
**************************************************************************/
@@ -357,7 +469,7 @@ int nxplayer_settreble(FAR struct nxplayer_s *pPlayer, uint8_t treble);
* Input Parameters:
* pPlayer - Pointer to the context to initialize
*
- * Returned values:
+ * Returned Value:
* OK if file found, device found, and playback started.
*
**************************************************************************/
diff --git a/apps/system/nxplayer/nxplayer.c b/apps/system/nxplayer/nxplayer.c
index c49fcdd5f..bbd9d5cec 100644
--- a/apps/system/nxplayer/nxplayer.c
+++ b/apps/system/nxplayer/nxplayer.c
@@ -905,6 +905,33 @@ int nxplayer_setvolume(FAR struct nxplayer_s *pPlayer, uint16_t volume)
#endif /* CONFIG_AUDIO_EXCLUDE_VOLUME */
/****************************************************************************
+ * Name: nxplayer_setequalization
+ *
+ * Sets the level on each band of an equalizer. Each band setting is
+ * represented in one percent increments, so the range is 0-100.
+ *
+ * Input Parameters:
+ * pPlayer - Pointer to the context to initialize
+ * equalization - Pointer to array of equalizer settings of size
+ * CONFIG_AUDIO_EQUALIZER_NBANDS bytes. Each byte
+ * represents the setting for one band in the range of
+ * 0-100.
+ *
+ * Returned Value:
+ * OK if equalization was set correctly.
+ *
+ **************************************************************************/
+
+#ifndef CONFIG_AUDIO_EXCLUDE_EQUALIZER
+int nxplayer_setequalization(FAR struct nxplayer_s *pPlayer,
+ FAR uint8_t *equalization)
+{
+#warning Missing logic
+ return -ENOSYS;
+}
+#endif
+
+/****************************************************************************
* Name: nxplayer_setbass
*
* nxplayer_setbass() sets the bass level and range.
@@ -1112,6 +1139,89 @@ int nxplayer_resume(FAR struct nxplayer_s *pPlayer)
#endif /* CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME */
/****************************************************************************
+ * Name: nxplayer_fforward
+ *
+ * Selects to fast forward in the audio data stream. The fast forward
+ * operation can be cancelled by simply selected no sub-sampling with
+ * the SUBSAMPLE_1X argument returning to normal 1x forward play.
+ *
+ * The preferred way to cancel a fast forward operation is via
+ * nxplayer_cancel_motion() that provides the option to also return to
+ * paused, non-playing state.
+ *
+ * Input Parameters:
+ * pPlayer - Pointer to the context to initialize
+ * subsample - Identifies the fast forward rate (in terms of sub-sampling,
+ * but does not explicitly require sub-sampling)
+ *
+ * Returned Value:
+ * OK if fast forward operation successful.
+ *
+ **************************************************************************/
+
+#ifndef CONFIG_AUDIO_EXCLUDE_FFORWARD
+int nxplayer_fforward(FAR struct nxplayer_s *pPlayer,
+ enum nxplayer_subsample_e subsample)
+{
+#warning Missing logic
+ return -ENOSYS;
+}
+#endif
+
+/****************************************************************************
+ * Name: nxplayer_rewind
+ *
+ * Selects to rewind in the audio data stream. The rewind operation must
+ * be cancelled with nxplayer_cancel_motion.
+ *
+ * NOTE that cancellation of the rewind operation differs from
+ * cancellation of the fast forward operation because we must both restore
+ * the sub-sampling rate to 1x and also return to forward play.
+ *
+ * Input Parameters:
+ * pPlayer - Pointer to the context to initialize
+ * subsample - Identifies the rewind rate (in terms of sub-sampling, but
+ * does not explicitly require sub-sampling)
+ *
+ * Returned Value:
+ * OK if rewind operation successfully initiated.
+ *
+ **************************************************************************/
+
+#ifndef CONFIG_AUDIO_EXCLUDE_REWIND
+int nxplayer_rewind(FAR struct nxplayer_s *pPlayer,
+ enum nxplayer_subsample_e subsample)
+{
+#warning Missing logic
+ return -ENOSYS;
+}
+#endif
+
+/****************************************************************************
+ * Name: nxplayer_cancel_motion
+ *
+ * Cancel a rewind or fast forward operation and return to either the
+ * paused state or to the normal, forward play state.
+ *
+ * Input Parameters:
+ * pPlayer - Pointer to the context to initialize
+ * paused - True: return to the paused state, False: return to the 1X
+ * forward play state.
+ *
+ * Returned Value:
+ * OK if rewind operation successfully cancelled.
+ *
+ **************************************************************************/
+
+#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
+int nxplayer_cancel_motion(FAR struct nxplayer_s *pPlayer, bool paused)
+{
+#warning Missing logic
+ return -ENOSYS;
+}
+#endif
+
+/****************************************************************************
* Name: nxplayer_setdevice
*
* nxplayer_setdevice() sets the perferred audio device to use with the
diff --git a/nuttx/audio/Kconfig b/nuttx/audio/Kconfig
index ef4bfe779..e68e82882 100644
--- a/nuttx/audio/Kconfig
+++ b/nuttx/audio/Kconfig
@@ -20,6 +20,8 @@ config AUDIO_MULTI_SESSION
Selecting this feature adds support for tracking multiple concurrent
sessions with the lower-level audio devices.
+menu "Audio Buffer Configuration"
+
config AUDIO_LARGE_BUFFERS
bool "Support Audio Buffers with greater than 65K samples"
default n
@@ -56,6 +58,8 @@ config AUDIO_DRIVER_SPECIFIC_BUFFERS
adds extra code which allows the lower-level audio device to specify
a partucular size and number of buffers.
+endmenu # Audio Buffer Configuration
+
menu "Supported Audio Formats"
config AUDIO_FORMAT_AC3
@@ -116,11 +120,28 @@ config AUDIO_EXCLUDE_BALANCE
---help---
Exclude building support for changing the balance.
+config AUDIO_EXCLUDE_EQUALIZER
+ bool "Exclude equalizer controls"
+ default y
+ ---help---
+ Exclude building support for setting equalization.
+
+config AUDIO_EQUALIZER_NBANDS
+ int "Number of equalizer bands"
+ default 8
+ depends on !AUDIO_EXCLUDE_EQUALIZER
+ ---help---
+ If equalizer support is not excluded, then it will be necessary to
+ provide the (maximum) number of equalization bands to be supported.
+
config AUDIO_EXCLUDE_TONE
bool "Exclude tone (bass and treble) controls"
- default n
+ default y if !AUDIO_EXCLUDE_EQUALIZER
+ default n if AUDIO_EXCLUDE_EQUALIZER
---help---
- Exclude building support for changing the bass and treble.
+ Exclude building support for changing the bass and treble. Normally
+ you would not select both tone controls and equalizer support unless
+ your underlying hardware supports both options.
config AUDIO_EXCLUDE_PAUSE_RESUME
bool "Exclude pause and resume controls"
@@ -137,11 +158,28 @@ config AUDIO_EXCLUDE_STOP
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
+ submitted. If the sound system is being used to play short sytem
+ notification or error type sounds that typically only last a second
or two, then there is no need (or chance) to stop the sound
playback once it has started.
+config AUDIO_EXCLUDE_FFORWARD
+ bool "Exclude fast forward controls"
+ default n if !AUDIO_EXCLUDE_STOP
+ default y if AUDIO_EXCLUDE_STOP
+ ---help---
+ Exclude building support for fast forwarding through audio files
+ once they are submitted. Selecting this option would only make
+ if the underlying audio decoding logic is capable of sub-sampling
+ in the stream of audio data.
+
+config AUDIO_EXCLUDE_REWIND
+ bool "Exclude rewind controls"
+ default y
+ ---help---
+ Rewind may be supported by some audio devices, but not the typical
+ device that receives a non-seekable, stream of audio buffers.
+
endmenu
config AUDIO_CUSTOM_DEV_PATH
diff --git a/nuttx/audio/audio.c b/nuttx/audio/audio.c
index f5f815431..5ed2ab176 100644
--- a/nuttx/audio/audio.c
+++ b/nuttx/audio/audio.c
@@ -34,10 +34,6 @@
****************************************************************************/
/****************************************************************************
- * Compilation Switches
- ****************************************************************************/
-
-/****************************************************************************
* Included Files
****************************************************************************/
diff --git a/nuttx/include/nuttx/audio/audio.h b/nuttx/include/nuttx/audio/audio.h
index 4e813f1f9..8ce09b0f8 100644
--- a/nuttx/include/nuttx/audio/audio.h
+++ b/nuttx/include/nuttx/audio/audio.h
@@ -126,6 +126,23 @@
* and low-level audio drivers. This ioctls are not used by the higher
* level audio logic and need be implemented only in low-level audio
* drivers that are driven by a decoder.
+ *
+ * AUDIOIOC_BITRATE - Set bit rate
+ *
+ * ioctl argument: Audio bit rate in bits per second
+ * Range: 1-65535 BPS (Compare to AUDIO_BIT_RATE_* definitions)
+ *
+ * AUDIOIOC_NCHANNELS - Set number of audio channels
+ *
+ * ioctl argument: Number of audio channels. 1=MONO, 2=STEREO, etc.
+ * Range: 1-255, however most drivers will support only
+ * 1 and possibly 2
+ *
+ * AUDIOIOC_SAMPWIDTH - Set sample bit width
+ *
+ * ioctl argument: Sample bit width: 8=8-bit data, 16=16-bit data, etc.
+ * Range: 1-255, however, many drivers will support only
+ * one sample bit width.
*/
#define AUDIOIOC_BITRATE _AUDIOIOC(17)
@@ -134,9 +151,9 @@
/* Audio Device Types *******************************************************/
/* The NuttX audio interface support different types of audio devices for
- * input, output, synthesis, and manupulation of audio data. A given driver/
+ * input, output, synthesis, and manipulation of audio data. A given driver/
* device could support a combination of these device type. The following
- * is a list of bit-field definitons for defining the device type.
+ * is a list of bit-field definitions for defining the device type.
*/
#define AUDIO_TYPE_QUERY 0x00
@@ -151,7 +168,7 @@
/* Audio Format Types *******************************************************/
/* The following defines the audio data format types in NuttX. During a
- * format query, these will be converted to bit positions withing the
+ * format query, these will be converted to bit positions within the
* ac_format field, meaning we currently only support up to 16 formats. To
* support more than that, we will use the FMT_OTHER entry, and the
* interfacing software can perform a second query to get the other formats.