system: nxplayer & nxrecorder: nxstyle fixes

nxstyle fixes for nxplayer & nxrecorder apps

Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
This commit is contained in:
Alin Jerpelea 2020-04-21 17:32:44 +02:00 committed by patacongo
parent 1697c64994
commit 2749e6467b
7 changed files with 558 additions and 391 deletions

@ -82,7 +82,7 @@ namespace NxWM
struct SStartWindowMessage struct SStartWindowMessage
{ {
enum EStartWindowMessageOpcodes msgId; /**< The message opcode */ enum EStartWindowMessageOpcodes msg_id; /**< The message opcode */
FAR void *instance; /**< Object instance. */ FAR void *instance; /**< Object instance. */
}; };

@ -53,22 +53,23 @@
/**************************************************************************** /****************************************************************************
* Public Type Declarations * Public Type Declarations
****************************************************************************/ ****************************************************************************/
/* This structure describes the internal state of the NxPlayer */ /* This structure describes the internal state of the NxPlayer */
struct nxplayer_s struct nxplayer_s
{ {
int state; /* Current player state */ int state; /* Current player state */
int devFd; /* File descriptor of active device */ int dev_fd; /* File descriptor of active device */
mqd_t mq; /* Message queue for the playthread */ mqd_t mq; /* Message queue for the playthread */
char mqname[16]; /* Name of our message queue */ char mqname[16]; /* Name of our message queue */
pthread_t playId; /* Thread ID of the playthread */ pthread_t play_id; /* Thread ID of the playthread */
int crefs; /* Number of references to the player */ int crefs; /* Number of references to the player */
sem_t sem; /* Thread sync semaphore */ sem_t sem; /* Thread sync semaphore */
int fd; /* File descriptor of open file */ int fd; /* File descriptor of open file */
#ifdef CONFIG_NXPLAYER_INCLUDE_PREFERRED_DEVICE #ifdef CONFIG_NXPLAYER_INCLUDE_PREFERRED_DEVICE
char prefdevice[CONFIG_NAME_MAX]; /* Preferred audio device */ char prefdevice[CONFIG_NAME_MAX]; /* Preferred audio device */
int prefformat; /* Formats supported by preferred device */ int prefformat; /* Formats supported by preferred device */
int preftype; /* Types supported by preferred device */ int preftype; /* Types supported by preferred device */
#endif #endif
#ifdef CONFIG_NXPLAYER_INCLUDE_MEDIADIR #ifdef CONFIG_NXPLAYER_INCLUDE_MEDIADIR
char mediadir[CONFIG_NAME_MAX]; /* Root media directory where media is located */ char mediadir[CONFIG_NAME_MAX]; /* Root media directory where media is located */
@ -88,7 +89,7 @@ struct nxplayer_s
#endif #endif
}; };
typedef int (*nxplayer_func)(FAR struct nxplayer_s *pPlayer, char *pargs); typedef int (*nxplayer_func)(FAR struct nxplayer_s *pplayer, char *pargs);
/**************************************************************************** /****************************************************************************
* Public Data * Public Data
@ -138,14 +139,14 @@ FAR struct nxplayer_s *nxplayer_create(void);
* frees all memory used by the context. * frees all memory used by the context.
* *
* Input Parameters: * Input Parameters:
* pPlayer Pointer to the NxPlayer context * pplayer Pointer to the NxPlayer context
* *
* Returned Value: * Returned Value:
* None * None
* *
****************************************************************************/ ****************************************************************************/
void nxplayer_release(FAR struct nxplayer_s *pPlayer); void nxplayer_release(FAR struct nxplayer_s *pplayer);
/**************************************************************************** /****************************************************************************
* Name: nxplayer_reference * Name: nxplayer_reference
@ -153,14 +154,14 @@ void nxplayer_release(FAR struct nxplayer_s *pPlayer);
* Increments the reference count to the player. * Increments the reference count to the player.
* *
* Input Parameters: * Input Parameters:
* pPlayer Pointer to the NxPlayer context * pplayer Pointer to the NxPlayer context
* *
* Returned Value: * Returned Value:
* None * None
* *
****************************************************************************/ ****************************************************************************/
void nxplayer_reference(FAR struct nxplayer_s *pPlayer); void nxplayer_reference(FAR struct nxplayer_s *pplayer);
/**************************************************************************** /****************************************************************************
* Name: nxplayer_setdevice * Name: nxplayer_setdevice
@ -172,7 +173,7 @@ void nxplayer_reference(FAR struct nxplayer_s *pPlayer);
* playing an MP3 file, a WAV decoder device for a WAV file, etc.). * playing an MP3 file, a WAV decoder device for a WAV file, etc.).
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* device - Pointer to pathname of the preferred device * device - Pointer to pathname of the preferred device
* *
* Returned Value: * Returned Value:
@ -180,7 +181,7 @@ void nxplayer_reference(FAR struct nxplayer_s *pPlayer);
* *
****************************************************************************/ ****************************************************************************/
int nxplayer_setdevice(FAR struct nxplayer_s *pPlayer, int nxplayer_setdevice(FAR struct nxplayer_s *pplayer,
FAR const char *device); FAR const char *device);
/**************************************************************************** /****************************************************************************
@ -192,7 +193,7 @@ int nxplayer_setdevice(FAR struct nxplayer_s *pPlayer,
* found in the /dev/audio directory will be used. * found in the /dev/audio directory will be used.
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* filename - Pointer to pathname of the file to play * filename - Pointer to pathname of the file to play
* filefmt - Format of audio in filename if known, AUDIO_FMT_UNDEF * filefmt - Format of audio in filename if known, AUDIO_FMT_UNDEF
* to let nxplayer_playfile() determine automatically. * to let nxplayer_playfile() determine automatically.
@ -204,7 +205,7 @@ int nxplayer_setdevice(FAR struct nxplayer_s *pPlayer,
* *
****************************************************************************/ ****************************************************************************/
int nxplayer_playfile(FAR struct nxplayer_s *pPlayer, int nxplayer_playfile(FAR struct nxplayer_s *pplayer,
FAR const char *filename, int filefmt, int subfmt); FAR const char *filename, int filefmt, int subfmt);
/**************************************************************************** /****************************************************************************
@ -216,7 +217,7 @@ int nxplayer_playfile(FAR struct nxplayer_s *pPlayer,
* found in the /dev/audio directory will be used. * found in the /dev/audio directory will be used.
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* filename - Pointer to pathname of the file to play * filename - Pointer to pathname of the file to play
* nchannels channel num * nchannels channel num
* bpsampe bit width * bpsampe bit width
@ -227,7 +228,7 @@ int nxplayer_playfile(FAR struct nxplayer_s *pPlayer,
* *
****************************************************************************/ ****************************************************************************/
int nxplayer_playraw(FAR struct nxplayer_s *pPlayer, int nxplayer_playraw(FAR struct nxplayer_s *pplayer,
FAR const char *filename, uint8_t nchannels, FAR const char *filename, uint8_t nchannels,
uint8_t bpsamp, uint32_t samprate); uint8_t bpsamp, uint32_t samprate);
@ -237,7 +238,7 @@ int nxplayer_playraw(FAR struct nxplayer_s *pPlayer,
* Stops current playback. * Stops current playback.
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* *
* Returned Value: * Returned Value:
* OK if file found, device found, and playback started. * OK if file found, device found, and playback started.
@ -245,7 +246,7 @@ int nxplayer_playraw(FAR struct nxplayer_s *pPlayer,
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_STOP #ifndef CONFIG_AUDIO_EXCLUDE_STOP
int nxplayer_stop(FAR struct nxplayer_s *pPlayer); int nxplayer_stop(FAR struct nxplayer_s *pplayer);
#endif #endif
/**************************************************************************** /****************************************************************************
@ -254,7 +255,7 @@ int nxplayer_stop(FAR struct nxplayer_s *pPlayer);
* Pauses current playback. * Pauses current playback.
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* *
* Returned Value: * Returned Value:
* OK if file found, device found, and playback started. * OK if file found, device found, and playback started.
@ -262,7 +263,7 @@ int nxplayer_stop(FAR struct nxplayer_s *pPlayer);
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
int nxplayer_pause(FAR struct nxplayer_s *pPlayer); int nxplayer_pause(FAR struct nxplayer_s *pplayer);
#endif #endif
/**************************************************************************** /****************************************************************************
@ -271,7 +272,7 @@ int nxplayer_pause(FAR struct nxplayer_s *pPlayer);
* Resumes current playback. * Resumes current playback.
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* *
* Returned Value: * Returned Value:
* OK if file found, device found, and playback started. * OK if file found, device found, and playback started.
@ -279,7 +280,7 @@ int nxplayer_pause(FAR struct nxplayer_s *pPlayer);
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
int nxplayer_resume(FAR struct nxplayer_s *pPlayer); int nxplayer_resume(FAR struct nxplayer_s *pplayer);
#endif #endif
/**************************************************************************** /****************************************************************************
@ -294,7 +295,7 @@ int nxplayer_resume(FAR struct nxplayer_s *pPlayer);
* paused, non-playing state. * paused, non-playing state.
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* subsample - Identifies the fast forward rate (in terms of sub-sampling, * subsample - Identifies the fast forward rate (in terms of sub-sampling,
* but does not explicitly require sub-sampling). See * but does not explicitly require sub-sampling). See
* AUDIO_SUBSAMPLE_* definitions. * AUDIO_SUBSAMPLE_* definitions.
@ -305,7 +306,7 @@ int nxplayer_resume(FAR struct nxplayer_s *pPlayer);
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_FFORWARD #ifndef CONFIG_AUDIO_EXCLUDE_FFORWARD
int nxplayer_fforward(FAR struct nxplayer_s *pPlayer, uint8_t subsample); int nxplayer_fforward(FAR struct nxplayer_s *pplayer, uint8_t subsample);
#endif #endif
/**************************************************************************** /****************************************************************************
@ -321,7 +322,7 @@ int nxplayer_fforward(FAR struct nxplayer_s *pPlayer, uint8_t subsample);
* AUDIO_SUBSAMPLE_NONE is not a valid argument to this function. * AUDIO_SUBSAMPLE_NONE is not a valid argument to this function.
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* subsample - Identifies the rewind rate (in terms of sub-sampling, but * subsample - Identifies the rewind rate (in terms of sub-sampling, but
* does not explicitly require sub-sampling). See * does not explicitly require sub-sampling). See
* AUDIO_SUBSAMPLE_* definitions. * AUDIO_SUBSAMPLE_* definitions.
@ -332,7 +333,7 @@ int nxplayer_fforward(FAR struct nxplayer_s *pPlayer, uint8_t subsample);
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_REWIND #ifndef CONFIG_AUDIO_EXCLUDE_REWIND
int nxplayer_rewind(FAR struct nxplayer_s *pPlayer, uint8_t subsample); int nxplayer_rewind(FAR struct nxplayer_s *pplayer, uint8_t subsample);
#endif #endif
/**************************************************************************** /****************************************************************************
@ -342,7 +343,7 @@ int nxplayer_rewind(FAR struct nxplayer_s *pPlayer, uint8_t subsample);
* paused state or to the normal, forward play state. * paused state or to the normal, forward play state.
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* paused - True: return to the paused state, False: return to the 1X * paused - True: return to the paused state, False: return to the 1X
* forward play state. * forward play state.
* *
@ -352,7 +353,7 @@ int nxplayer_rewind(FAR struct nxplayer_s *pPlayer, uint8_t subsample);
****************************************************************************/ ****************************************************************************/
#if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND) #if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND)
int nxplayer_cancel_motion(FAR struct nxplayer_s *pPlayer, bool paused); int nxplayer_cancel_motion(FAR struct nxplayer_s *pplayer, bool paused);
#endif #endif
/**************************************************************************** /****************************************************************************
@ -363,7 +364,7 @@ int nxplayer_cancel_motion(FAR struct nxplayer_s *pPlayer, bool paused);
* 1%. * 1%.
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* volume - Volume level to set in 1/10th percent increments * volume - Volume level to set in 1/10th percent increments
* *
* Returned Value: * Returned Value:
@ -372,7 +373,7 @@ int nxplayer_cancel_motion(FAR struct nxplayer_s *pPlayer, bool paused);
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
int nxplayer_setvolume(FAR struct nxplayer_s *pPlayer, uint16_t volume); int nxplayer_setvolume(FAR struct nxplayer_s *pplayer, uint16_t volume);
#endif #endif
/**************************************************************************** /****************************************************************************
@ -383,7 +384,7 @@ int nxplayer_setvolume(FAR struct nxplayer_s *pPlayer, uint16_t volume);
* 1%. * 1%.
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* balance - Balance level to set in 1/10th percent increments * balance - Balance level to set in 1/10th percent increments
* *
* Returned Value: * Returned Value:
@ -393,7 +394,7 @@ int nxplayer_setvolume(FAR struct nxplayer_s *pPlayer, uint16_t volume);
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
#ifndef CONFIG_AUDIO_EXCLUDE_BALANCE #ifndef CONFIG_AUDIO_EXCLUDE_BALANCE
int nxplayer_setbalance(FAR struct nxplayer_s *pPlayer, uint16_t balance); int nxplayer_setbalance(FAR struct nxplayer_s *pplayer, uint16_t balance);
#endif #endif
#endif #endif
@ -403,7 +404,7 @@ int nxplayer_setbalance(FAR struct nxplayer_s *pPlayer, uint16_t balance);
* Sets the root media directory for non-path qualified file searches. * Sets the root media directory for non-path qualified file searches.
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* mediadir - Pointer to pathname of the media directory * mediadir - Pointer to pathname of the media directory
* *
* Returned Value: * Returned Value:
@ -411,7 +412,7 @@ int nxplayer_setbalance(FAR struct nxplayer_s *pPlayer, uint16_t balance);
* *
****************************************************************************/ ****************************************************************************/
void nxplayer_setmediadir(FAR struct nxplayer_s *pPlayer, void nxplayer_setmediadir(FAR struct nxplayer_s *pplayer,
FAR const char *mediadir); FAR const char *mediadir);
/**************************************************************************** /****************************************************************************
@ -421,7 +422,7 @@ void nxplayer_setmediadir(FAR struct nxplayer_s *pPlayer,
* represented in one percent increments, so the range is 0-100. * represented in one percent increments, so the range is 0-100.
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* equalization - Pointer to array of equalizer settings of size * equalization - Pointer to array of equalizer settings of size
* CONFIG_AUDIO_EQUALIZER_NBANDS bytes. Each byte * CONFIG_AUDIO_EQUALIZER_NBANDS bytes. Each byte
* represents the setting for one band in the range of * represents the setting for one band in the range of
@ -433,7 +434,7 @@ void nxplayer_setmediadir(FAR struct nxplayer_s *pPlayer,
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_EQUALIZER #ifndef CONFIG_AUDIO_EXCLUDE_EQUALIZER
int nxplayer_setequalization(FAR struct nxplayer_s *pPlayer, int nxplayer_setequalization(FAR struct nxplayer_s *pplayer,
FAR uint8_t *equalization); FAR uint8_t *equalization);
#endif #endif
@ -444,7 +445,7 @@ int nxplayer_setequalization(FAR struct nxplayer_s *pPlayer,
* increments, so the range is 0-100. * increments, so the range is 0-100.
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* bass - Bass level to set in one percent increments * bass - Bass level to set in one percent increments
* *
* Returned Value: * Returned Value:
@ -453,7 +454,7 @@ int nxplayer_setequalization(FAR struct nxplayer_s *pPlayer,
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_TONE #ifndef CONFIG_AUDIO_EXCLUDE_TONE
int nxplayer_setbass(FAR struct nxplayer_s *pPlayer, uint8_t bass); int nxplayer_setbass(FAR struct nxplayer_s *pplayer, uint8_t bass);
#endif #endif
/**************************************************************************** /****************************************************************************
@ -463,7 +464,7 @@ int nxplayer_setbass(FAR struct nxplayer_s *pPlayer, uint8_t bass);
* increments, so the range is 0-100. * increments, so the range is 0-100.
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* treble - Treble level to set in one percent increments * treble - Treble level to set in one percent increments
* *
* Returned Value: * Returned Value:
@ -472,7 +473,7 @@ int nxplayer_setbass(FAR struct nxplayer_s *pPlayer, uint8_t bass);
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_TONE #ifndef CONFIG_AUDIO_EXCLUDE_TONE
int nxplayer_settreble(FAR struct nxplayer_s *pPlayer, uint8_t treble); int nxplayer_settreble(FAR struct nxplayer_s *pplayer, uint8_t treble);
#endif #endif
/**************************************************************************** /****************************************************************************
@ -482,7 +483,7 @@ int nxplayer_settreble(FAR struct nxplayer_s *pPlayer, uint8_t treble);
* registered audio devices. * registered audio devices.
* *
* Input Parameters: * Input Parameters:
* pPlayer - Pointer to the context to initialize * pplayer - Pointer to the context to initialize
* *
* Returned Value: * Returned Value:
* OK if file found, device found, and playback started. * OK if file found, device found, and playback started.
@ -490,7 +491,7 @@ int nxplayer_settreble(FAR struct nxplayer_s *pPlayer, uint8_t treble);
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_NXPLAYER_INCLUDE_SYSTEM_RESET #ifdef CONFIG_NXPLAYER_INCLUDE_SYSTEM_RESET
int nxplayer_systemreset(FAR struct nxplayer_s *pPlayer); int nxplayer_systemreset(FAR struct nxplayer_s *pplayer);
#endif #endif
#undef EXTERN #undef EXTERN

@ -54,21 +54,22 @@
struct nxrecorder_s struct nxrecorder_s
{ {
int state; /* Current recorder state */ int state; /* Current recorder state */
int devFd; /* File descriptor of active device */ int dev_fd; /* File descriptor of active device */
mqd_t mq; /* Message queue for the recordthread */ mqd_t mq; /* Message queue for the recordthread */
char mqname[16]; /* Name of our message queue */ char mqname[16]; /* Name of our message queue */
pthread_t recordId; /* Thread ID of the recordthread */ pthread_t record_id; /* Thread ID of the recordthread */
int crefs; /* Number of references to the recorder */ int crefs; /* Number of references to the recorder */
sem_t sem; /* Thread sync semaphore */ sem_t sem; /* Thread sync semaphore */
int fd; /* File descriptor of open file */ int fd; /* File descriptor of open file */
char device[CONFIG_NAME_MAX]; /* Preferred audio device */ char device[CONFIG_NAME_MAX]; /* Preferred audio device */
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
FAR void *session; /* Session assignment from device */ FAR void *session; /* Session assignment from device */
#endif #endif
}; };
typedef int (*nxrecorder_func)(FAR struct nxrecorder_s *pRecorder, char *pargs); typedef int (*nxrecorder_func)(FAR struct nxrecorder_s *precorder,
char *pargs);
/**************************************************************************** /****************************************************************************
* Public Data * Public Data
@ -118,14 +119,14 @@ FAR struct nxrecorder_s *nxrecorder_create(void);
* frees all memory used by the context. * frees all memory used by the context.
* *
* Input Parameters: * Input Parameters:
* pRecorder Pointer to the NxRecorder context * precorder Pointer to the NxRecorder context
* *
* Returned Value: * Returned Value:
* None * None
* *
****************************************************************************/ ****************************************************************************/
void nxrecorder_release(FAR struct nxrecorder_s *pRecorder); void nxrecorder_release(FAR struct nxrecorder_s *precorder);
/**************************************************************************** /****************************************************************************
* Name: nxrecorder_reference * Name: nxrecorder_reference
@ -133,14 +134,14 @@ void nxrecorder_release(FAR struct nxrecorder_s *pRecorder);
* Increments the reference count to the recorder. * Increments the reference count to the recorder.
* *
* Input Parameters: * Input Parameters:
* pRecorder Pointer to the NxRecorder context * precorder Pointer to the NxRecorder context
* *
* Returned Value: * Returned Value:
* None * None
* *
****************************************************************************/ ****************************************************************************/
void nxrecorder_reference(FAR struct nxrecorder_s *pRecorder); void nxrecorder_reference(FAR struct nxrecorder_s *precorder);
/**************************************************************************** /****************************************************************************
* Name: nxrecorder_setdevice * Name: nxrecorder_setdevice
@ -152,7 +153,7 @@ void nxrecorder_reference(FAR struct nxrecorder_s *pRecorder);
* recording an MP3 file, a WAV decoder device for a WAV file, etc.). * recording an MP3 file, a WAV decoder device for a WAV file, etc.).
* *
* Input Parameters: * Input Parameters:
* pRecorder - Pointer to the context to initialize * precorder - Pointer to the context to initialize
* device - Pointer to pathname of the preferred device * device - Pointer to pathname of the preferred device
* *
* Returned Value: * Returned Value:
@ -160,7 +161,7 @@ void nxrecorder_reference(FAR struct nxrecorder_s *pRecorder);
* *
****************************************************************************/ ****************************************************************************/
int nxrecorder_setdevice(FAR struct nxrecorder_s *pRecorder, int nxrecorder_setdevice(FAR struct nxrecorder_s *precorder,
FAR const char *device); FAR const char *device);
/**************************************************************************** /****************************************************************************
@ -172,7 +173,7 @@ int nxrecorder_setdevice(FAR struct nxrecorder_s *pRecorder,
* found in the /dev/audio directory will be used. * found in the /dev/audio directory will be used.
* *
* Input Parameters: * Input Parameters:
* pRecorder - Pointer to the context to initialize * precorder - Pointer to the context to initialize
* filename - Pointer to pathname of the file to record * filename - Pointer to pathname of the file to record
* nchannels - channels num * nchannels - channels num
* bpsampe - bit width * bpsampe - bit width
@ -184,7 +185,7 @@ int nxrecorder_setdevice(FAR struct nxrecorder_s *pRecorder,
* *
****************************************************************************/ ****************************************************************************/
int nxrecorder_recordraw(FAR struct nxrecorder_s *pRecorder, int nxrecorder_recordraw(FAR struct nxrecorder_s *precorder,
FAR const char *filename, uint8_t nchannels, FAR const char *filename, uint8_t nchannels,
uint8_t bpsamp, uint32_t samprate); uint8_t bpsamp, uint32_t samprate);
@ -194,7 +195,7 @@ int nxrecorder_recordraw(FAR struct nxrecorder_s *pRecorder,
* Stops current recordback. * Stops current recordback.
* *
* Input Parameters: * Input Parameters:
* pRecorder - Pointer to the context to initialize * precorder - Pointer to the context to initialize
* *
* Returned Value: * Returned Value:
* OK if file found, device found, and recordback started. * OK if file found, device found, and recordback started.
@ -202,7 +203,7 @@ int nxrecorder_recordraw(FAR struct nxrecorder_s *pRecorder,
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_STOP #ifndef CONFIG_AUDIO_EXCLUDE_STOP
int nxrecorder_stop(FAR struct nxrecorder_s *pRecorder); int nxrecorder_stop(FAR struct nxrecorder_s *precorder);
#endif #endif
/**************************************************************************** /****************************************************************************
@ -211,7 +212,7 @@ int nxrecorder_stop(FAR struct nxrecorder_s *pRecorder);
* Pauses current recordback. * Pauses current recordback.
* *
* Input Parameters: * Input Parameters:
* pRecorder - Pointer to the context to initialize * precorder - Pointer to the context to initialize
* *
* Returned Value: * Returned Value:
* OK if file found, device found, and recordback started. * OK if file found, device found, and recordback started.
@ -219,7 +220,7 @@ int nxrecorder_stop(FAR struct nxrecorder_s *pRecorder);
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
int nxrecorder_pause(FAR struct nxrecorder_s *pRecorder); int nxrecorder_pause(FAR struct nxrecorder_s *precorder);
#endif #endif
/**************************************************************************** /****************************************************************************
@ -228,7 +229,7 @@ int nxrecorder_pause(FAR struct nxrecorder_s *pRecorder);
* Resumes current recordback. * Resumes current recordback.
* *
* Input Parameters: * Input Parameters:
* pRecorder - Pointer to the context to initialize * precorder - Pointer to the context to initialize
* *
* Returned Value: * Returned Value:
* OK if file found, device found, and recordback started. * OK if file found, device found, and recordback started.
@ -236,7 +237,7 @@ int nxrecorder_pause(FAR struct nxrecorder_s *pRecorder);
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
int nxrecorder_resume(FAR struct nxrecorder_s *pRecorder); int nxrecorder_resume(FAR struct nxrecorder_s *precorder);
#endif #endif
#undef EXTERN #undef EXTERN

@ -318,8 +318,8 @@ static int nxplayer_opendevice(FAR struct nxplayer_s *pplayer, int format,
/* Device supports the format. Open the device file. */ /* Device supports the format. Open the device file. */
pplayer->devFd = open(pplayer->prefdevice, O_RDWR); pplayer->dev_fd = open(pplayer->prefdevice, O_RDWR);
if (pplayer->devFd == -1) if (pplayer->dev_fd == -1)
{ {
int errcode = errno; int errcode = errno;
DEBUGASSERT(errcode > 0); DEBUGASSERT(errcode > 0);
@ -343,7 +343,7 @@ static int nxplayer_opendevice(FAR struct nxplayer_s *pplayer, int format,
#ifdef CONFIG_NXPLAYER_INCLUDE_DEVICE_SEARCH #ifdef CONFIG_NXPLAYER_INCLUDE_DEVICE_SEARCH
{ {
struct audio_caps_s caps; struct audio_caps_s caps;
FAR struct dirent *pDevice; FAR struct dirent *pdevice;
FAR DIR *dirp; FAR DIR *dirp;
char path[64]; char path[64];
uint8_t supported = true; uint8_t supported = true;
@ -370,7 +370,7 @@ static int nxplayer_opendevice(FAR struct nxplayer_s *pplayer, int format,
return -ENODEV; return -ENODEV;
} }
while ((pDevice = readdir(dirp)) != NULL) while ((pdevice = readdir(dirp)) != NULL)
{ {
/* We found the next device. Try to open it and /* We found the next device. Try to open it and
* get its audio capabilities. * get its audio capabilities.
@ -378,16 +378,16 @@ static int nxplayer_opendevice(FAR struct nxplayer_s *pplayer, int format,
#ifdef CONFIG_AUDIO_CUSTOM_DEV_PATH #ifdef CONFIG_AUDIO_CUSTOM_DEV_PATH
#ifdef CONFIG_AUDIO_DEV_ROOT #ifdef CONFIG_AUDIO_DEV_ROOT
snprintf(path, sizeof(path), "/dev/%s", pDevice->d_name); snprintf(path, sizeof(path), "/dev/%s", pdevice->d_name);
#else #else
snprintf(path, sizeof(path), CONFIG_AUDIO_DEV_PATH "/%s", snprintf(path, sizeof(path), CONFIG_AUDIO_DEV_PATH "/%s",
pDevice->d_name); pdevice->d_name);
#endif /* CONFIG_AUDIO_DEV_ROOT */ #endif /* CONFIG_AUDIO_DEV_ROOT */
#else #else
snprintf(path, sizeof(path), "/dev/audio/%s", pDevice->d_name); snprintf(path, sizeof(path), "/dev/audio/%s", pdevice->d_name);
#endif /* CONFIG_AUDIO_CUSTOM_DEV_PATH */ #endif /* CONFIG_AUDIO_CUSTOM_DEV_PATH */
if ((pplayer->devFd = open(path, O_RDWR)) != -1) if ((pplayer->dev_fd = open(path, O_RDWR)) != -1)
{ {
/* We have the device file open. Now issue an AUDIO ioctls to /* We have the device file open. Now issue an AUDIO ioctls to
* get the capabilities * get the capabilities
@ -397,7 +397,7 @@ static int nxplayer_opendevice(FAR struct nxplayer_s *pplayer, int format,
caps.ac_type = AUDIO_TYPE_QUERY; caps.ac_type = AUDIO_TYPE_QUERY;
caps.ac_subtype = AUDIO_TYPE_QUERY; caps.ac_subtype = AUDIO_TYPE_QUERY;
if (ioctl(pplayer->devFd, AUDIOIOC_GETCAPS, if (ioctl(pplayer->dev_fd, AUDIOIOC_GETCAPS,
(unsigned long)&caps) == caps.ac_len) (unsigned long)&caps) == caps.ac_len)
{ {
/* Test if this device supports the format we want */ /* Test if this device supports the format we want */
@ -409,15 +409,19 @@ static int nxplayer_opendevice(FAR struct nxplayer_s *pplayer, int format,
if (subfmt != AUDIO_FMT_UNDEF) if (subfmt != AUDIO_FMT_UNDEF)
{ {
/* Prepare to get sub-formats for this main format */ /* Prepare to get sub-formats for
* this main format
*/
caps.ac_subtype = format; caps.ac_subtype = format;
caps.ac_format.b[0] = 0; caps.ac_format.b[0] = 0;
while (ioctl(pplayer->devFd, AUDIOIOC_GETCAPS, while (ioctl(pplayer->dev_fd, AUDIOIOC_GETCAPS,
(unsigned long) &caps) == caps.ac_len) (unsigned long) &caps) == caps.ac_len)
{ {
/* Check the next set of 4 controls to find the subformat */ /* Check the next set of 4 controls
* to find the subformat
*/
for (x = 0; x < sizeof(caps.ac_controls); x++) for (x = 0; x < sizeof(caps.ac_controls); x++)
{ {
@ -427,7 +431,8 @@ static int nxplayer_opendevice(FAR struct nxplayer_s *pplayer, int format,
break; break;
} }
else if (caps.ac_controls.b[x] == AUDIO_SUBFMT_END) else if (caps.ac_controls.b[x] ==
AUDIO_SUBFMT_END)
{ {
/* Sub format not supported */ /* Sub format not supported */
@ -445,7 +450,9 @@ static int nxplayer_opendevice(FAR struct nxplayer_s *pplayer, int format,
break; break;
} }
/* Increment ac_format.b[0] to get next set of subformats */ /* Increment ac_format.b[0] to get next
* set of subformats
*/
caps.ac_format.b[0]++; caps.ac_format.b[0]++;
} }
@ -465,7 +472,7 @@ static int nxplayer_opendevice(FAR struct nxplayer_s *pplayer, int format,
/* Not this device! */ /* Not this device! */
close(pplayer->devFd); close(pplayer->dev_fd);
} }
} }
@ -478,7 +485,7 @@ static int nxplayer_opendevice(FAR struct nxplayer_s *pplayer, int format,
/* Device not found */ /* Device not found */
auderr("ERROR: Device not found\n"); auderr("ERROR: Device not found\n");
pplayer->devFd = -1; pplayer->dev_fd = -1;
return -ENODEV; return -ENODEV;
} }
@ -534,30 +541,30 @@ int nxplayer_getmidisubformat(int fd)
#ifdef CONFIG_NXPLAYER_FMT_FROM_EXT #ifdef CONFIG_NXPLAYER_FMT_FROM_EXT
static inline int nxplayer_fmtfromextension(FAR struct nxplayer_s *pplayer, static inline int nxplayer_fmtfromextension(FAR struct nxplayer_s *pplayer,
FAR const char *pFilename, FAR const char *pfilename,
FAR int *subfmt) FAR int *subfmt)
{ {
const char *pExt; const char *pext;
uint8_t x; uint8_t x;
uint8_t c; uint8_t c;
/* Find the file extension, if any */ /* Find the file extension, if any */
x = strlen(pFilename) - 1; x = strlen(pfilename) - 1;
while (x > 0) while (x > 0)
{ {
/* Search backward for the first '.' */ /* Search backward for the first '.' */
if (pFilename[x] == '.') if (pfilename[x] == '.')
{ {
/* First '.' found. Now compare with known extensions */ /* First '.' found. Now compare with known extensions */
pExt = &pFilename[x + 1]; pext = &pfilename[x + 1];
for (c = 0; c < g_known_ext_count; c++) for (c = 0; c < g_known_ext_count; c++)
{ {
/* Test for extension match */ /* Test for extension match */
if (strcasecmp(pExt, g_known_ext[c].ext) == 0) if (strcasecmp(pext, g_known_ext[c].ext) == 0)
{ {
/* Test if we have a sub-format detection routine */ /* Test if we have a sub-format detection routine */
@ -575,7 +582,7 @@ static inline int nxplayer_fmtfromextension(FAR struct nxplayer_s *pplayer,
/* Stop if we find a '/' */ /* Stop if we find a '/' */
if (pFilename[x] == '/') if (pfilename[x] == '/')
{ {
break; break;
} }
@ -613,7 +620,7 @@ static int nxplayer_fmtfromheader(FAR struct nxplayer_s *pplayer)
#if defined(CONFIG_NXPLAYER_MEDIA_SEARCH) && defined(CONFIG_NXPLAYER_INCLUDE_MEDIADIR) #if defined(CONFIG_NXPLAYER_MEDIA_SEARCH) && defined(CONFIG_NXPLAYER_INCLUDE_MEDIADIR)
static int nxplayer_mediasearch(FAR struct nxplayer_s *pplayer, static int nxplayer_mediasearch(FAR struct nxplayer_s *pplayer,
FAR const char *pFilename, FAR const char *pfilename,
FAR const char *path, int pathmax) FAR const char *path, int pathmax)
{ {
return -ENOENT; return -ENOENT;
@ -743,9 +750,9 @@ static int nxplayer_enqueuebuffer(FAR struct nxplayer_s *pplayer,
bufdesc.session = pplayer->session; bufdesc.session = pplayer->session;
#endif #endif
bufdesc.numbytes = apb->nbytes; bufdesc.numbytes = apb->nbytes;
bufdesc.u.pBuffer = apb; bufdesc.u.buffer = apb;
ret = ioctl(pplayer->devFd, AUDIOIOC_ENQUEUEBUFFER, ret = ioctl(pplayer->dev_fd, AUDIOIOC_ENQUEUEBUFFER,
(unsigned long)&bufdesc); (unsigned long)&bufdesc);
if (ret < 0) if (ret < 0)
{ {
@ -782,9 +789,9 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
bool failed = false; bool failed = false;
#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS #ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
struct ap_buffer_info_s buf_info; struct ap_buffer_info_s buf_info;
FAR struct ap_buffer_s **pbuffers; FAR struct ap_buffer_s **buffers;
#else #else
FAR struct ap_buffer_s *pbuffers[CONFIG_AUDIO_NUM_BUFFERS]; FAR struct ap_buffer_s *buffers[CONFIG_AUDIO_NUM_BUFFERS];
#endif #endif
unsigned int prio; unsigned int prio;
#ifdef CONFIG_DEBUG_FEATURES #ifdef CONFIG_DEBUG_FEATURES
@ -798,7 +805,7 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
/* Query the audio device for it's preferred buffer size / qty */ /* Query the audio device for it's preferred buffer size / qty */
#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS #ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
if ((ret = ioctl(pplayer->devFd, AUDIOIOC_GETBUFFERINFO, if ((ret = ioctl(pplayer->dev_fd, AUDIOIOC_GETBUFFERINFO,
(unsigned long) &buf_info)) != OK) (unsigned long) &buf_info)) != OK)
{ {
/* Driver doesn't report it's buffer size. Use our default. */ /* Driver doesn't report it's buffer size. Use our default. */
@ -809,9 +816,9 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
/* Create array of pointers to buffers */ /* Create array of pointers to buffers */
pbuffers = (FAR struct ap_buffer_s **) buffers = (FAR struct ap_buffer_s **)
malloc(buf_info.nbuffers * sizeof(FAR void *)); malloc(buf_info.nbuffers * sizeof(FAR void *));
if (pbuffers == NULL) if (buffers == NULL)
{ {
/* Error allocating memory for buffer storage! */ /* Error allocating memory for buffer storage! */
@ -824,7 +831,7 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
for (x = 0; x < buf_info.nbuffers; x++) for (x = 0; x < buf_info.nbuffers; x++)
{ {
pbuffers[x] = NULL; buffers[x] = NULL;
} }
for (x = 0; x < buf_info.nbuffers; x++) for (x = 0; x < buf_info.nbuffers; x++)
@ -832,7 +839,7 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
for (x = 0; x < CONFIG_AUDIO_NUM_BUFFERS; x++) for (x = 0; x < CONFIG_AUDIO_NUM_BUFFERS; x++)
{ {
pbuffers[x] = NULL; buffers[x] = NULL;
} }
for (x = 0; x < CONFIG_AUDIO_NUM_BUFFERS; x++) for (x = 0; x < CONFIG_AUDIO_NUM_BUFFERS; x++)
@ -848,9 +855,9 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
#else #else
buf_desc.numbytes = CONFIG_AUDIO_BUFFER_NUMBYTES; buf_desc.numbytes = CONFIG_AUDIO_BUFFER_NUMBYTES;
#endif #endif
buf_desc.u.ppBuffer = &pbuffers[x]; buf_desc.u.pbuffer = &buffers[x];
ret = ioctl(pplayer->devFd, AUDIOIOC_ALLOCBUFFER, ret = ioctl(pplayer->dev_fd, AUDIOIOC_ALLOCBUFFER,
(unsigned long) &buf_desc); (unsigned long) &buf_desc);
if (ret != sizeof(buf_desc)) if (ret != sizeof(buf_desc))
{ {
@ -872,7 +879,7 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
{ {
/* Read the next buffer of data */ /* Read the next buffer of data */
ret = nxplayer_readbuffer(pplayer, pbuffers[x]); ret = nxplayer_readbuffer(pplayer, buffers[x]);
if (ret != OK) if (ret != OK)
{ {
/* nxplayer_readbuffer will return an error if there is no further /* nxplayer_readbuffer will return an error if there is no further
@ -901,14 +908,15 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
else else
{ {
ret = nxplayer_enqueuebuffer(pplayer, pbuffers[x]); ret = nxplayer_enqueuebuffer(pplayer, buffers[x]);
if (ret != OK) if (ret != OK)
{ {
/* Failed to enqueue the buffer. The driver is not happy with /* Failed to enqueue the buffer.
* the buffer. Perhaps a decoder has detected something that it * The driver is not happy with the buffer.
* does not like in the stream and has stopped streaming. This * Perhaps a decoder has detected something that it
* would happen normally if we send a file in the incorrect * does not like in the stream and has stopped streaming.
* format to an audio decoder. * This would happen normally if we send a file in the
* incorrect format to an audio decoder.
* *
* We must stop streaming as gracefully as possible. Close the * We must stop streaming as gracefully as possible. Close the
* file so that no further data is read. * file so that no further data is read.
@ -918,8 +926,8 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
pplayer->fd = -1; pplayer->fd = -1;
/* We are no longer streaming data from the file. Be we will /* We are no longer streaming data from the file. Be we will
* need to wait for any outstanding buffers to be recovered. We * need to wait for any outstanding buffers to be recovered.
* also still expect the audio driver to send a * We also still expect the audio driver to send a
* AUDIO_MSG_COMPLETE message after all queued buffers have * AUDIO_MSG_COMPLETE message after all queued buffers have
* been returned. * been returned.
*/ */
@ -947,10 +955,10 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
if (running && !failed) if (running && !failed)
{ {
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
ret = ioctl(pplayer->devFd, AUDIOIOC_START, ret = ioctl(pplayer->dev_fd, AUDIOIOC_START,
(unsigned long) pplayer->session); (unsigned long) pplayer->session);
#else #else
ret = ioctl(pplayer->devFd, AUDIOIOC_START, 0); ret = ioctl(pplayer->dev_fd, AUDIOIOC_START, 0);
#endif #endif
if (ret < 0) if (ret < 0)
@ -1025,7 +1033,7 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
/* Perform operation based on message id */ /* Perform operation based on message id */
switch (msg.msgId) switch (msg.msg_id)
{ {
/* An audio buffer is being dequeued by the driver */ /* An audio buffer is being dequeued by the driver */
@ -1036,7 +1044,7 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
* least one buffer. * least one buffer.
*/ */
DEBUGASSERT(msg.u.pPtr && outstanding > 0); DEBUGASSERT(msg.u.ptr && outstanding > 0);
outstanding--; outstanding--;
#endif #endif
@ -1049,7 +1057,7 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
{ {
/* Read the next buffer of data */ /* Read the next buffer of data */
ret = nxplayer_readbuffer(pplayer, msg.u.pPtr); ret = nxplayer_readbuffer(pplayer, msg.u.ptr);
if (ret != OK) if (ret != OK)
{ {
/* Out of data. Stay in the loop until the device sends /* Out of data. Stay in the loop until the device sends
@ -1064,7 +1072,7 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
else else
{ {
ret = nxplayer_enqueuebuffer(pplayer, msg.u.pPtr); ret = nxplayer_enqueuebuffer(pplayer, msg.u.ptr);
if (ret != OK) if (ret != OK)
{ {
/* There is some issue from the audio driver. /* There is some issue from the audio driver.
@ -1106,10 +1114,10 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
audinfo("Stopping! outstanding=%d\n", outstanding); audinfo("Stopping! outstanding=%d\n", outstanding);
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
ioctl(pplayer->devFd, AUDIOIOC_STOP, ioctl(pplayer->dev_fd, AUDIOIOC_STOP,
(unsigned long) pplayer->session); (unsigned long) pplayer->session);
#else #else
ioctl(pplayer->devFd, AUDIOIOC_STOP, 0); ioctl(pplayer->dev_fd, AUDIOIOC_STOP, 0);
#endif #endif
/* Stay in the running loop (without sending more data). /* Stay in the running loop (without sending more data).
* we will need to recover our audio buffers. We will * we will need to recover our audio buffers. We will
@ -1140,27 +1148,27 @@ err_out:
audinfo("Clean-up and exit\n"); audinfo("Clean-up and exit\n");
#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS #ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
if (pbuffers != NULL) if (buffers != NULL)
{ {
audinfo("Freeing buffers\n"); audinfo("Freeing buffers\n");
for (x = 0; x < buf_info.nbuffers; x++) for (x = 0; x < buf_info.nbuffers; x++)
{ {
/* Fill in the buffer descriptor struct to issue a free request */ /* Fill in the buffer descriptor struct to issue a free request */
if (pbuffers[x] != NULL) if (buffers[x] != NULL)
{ {
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
buf_desc.session = pplayer->session; buf_desc.session = pplayer->session;
#endif #endif
buf_desc.u.pBuffer = pbuffers[x]; buf_desc.u.buffer = buffers[x];
ioctl(pplayer->devFd, AUDIOIOC_FREEBUFFER, ioctl(pplayer->dev_fd, AUDIOIOC_FREEBUFFER,
(unsigned long)&buf_desc); (unsigned long)&buf_desc);
} }
} }
/* Free the pointers to the buffers */ /* Free the pointers to the buffers */
free(pbuffers); free(buffers);
} }
#else #else
audinfo("Freeing buffers\n"); audinfo("Freeing buffers\n");
@ -1168,13 +1176,13 @@ err_out:
{ {
/* Fill in the buffer descriptor struct to issue a free request */ /* Fill in the buffer descriptor struct to issue a free request */
if (pbuffers[x] != NULL) if (buffers[x] != NULL)
{ {
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
buf_desc.session = pplayer->session; buf_desc.session = pplayer->session;
#endif #endif
buf_desc.u.pBuffer = pbuffers[x]; buf_desc.u.buffer = buffers[x];
ioctl(pplayer->devFd, AUDIOIOC_FREEBUFFER, ioctl(pplayer->dev_fd, AUDIOIOC_FREEBUFFER,
(unsigned long)&buf_desc); (unsigned long)&buf_desc);
} }
} }
@ -1182,12 +1190,12 @@ err_out:
/* Unregister the message queue and release the session */ /* Unregister the message queue and release the session */
ioctl(pplayer->devFd, AUDIOIOC_UNREGISTERMQ, (unsigned long) pplayer->mq); ioctl(pplayer->dev_fd, AUDIOIOC_UNREGISTERMQ, (unsigned long) pplayer->mq);
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
ioctl(pplayer->devFd, AUDIOIOC_RELEASE, (unsigned long) pplayer->session); ioctl(pplayer->dev_fd, AUDIOIOC_RELEASE, (unsigned long) pplayer->session);
#else #else
ioctl(pplayer->devFd, AUDIOIOC_RELEASE, 0); ioctl(pplayer->dev_fd, AUDIOIOC_RELEASE, 0);
#endif #endif
/* Cleanup */ /* Cleanup */
@ -1203,8 +1211,8 @@ err_out:
pplayer->fd = -1; /* Clear out the FD */ pplayer->fd = -1; /* Clear out the FD */
} }
close(pplayer->devFd); /* Close the device */ close(pplayer->dev_fd); /* Close the device */
pplayer->devFd = -1; /* Mark device as closed */ pplayer->dev_fd = -1; /* Mark device as closed */
mq_close(pplayer->mq); /* Close the message queue */ mq_close(pplayer->mq); /* Close the message queue */
mq_unlink(pplayer->mqname); /* Unlink the message queue */ mq_unlink(pplayer->mqname); /* Unlink the message queue */
pplayer->state = NXPLAYER_STATE_IDLE; /* Go to IDLE */ pplayer->state = NXPLAYER_STATE_IDLE; /* Go to IDLE */
@ -1262,7 +1270,7 @@ int nxplayer_setvolume(FAR struct nxplayer_s *pplayer, uint16_t volume)
cap_desc.caps.ac_type = AUDIO_TYPE_FEATURE; cap_desc.caps.ac_type = AUDIO_TYPE_FEATURE;
cap_desc.caps.ac_format.hw = AUDIO_FU_VOLUME; cap_desc.caps.ac_format.hw = AUDIO_FU_VOLUME;
cap_desc.caps.ac_controls.hw[0] = volume; cap_desc.caps.ac_controls.hw[0] = volume;
ret = ioctl(pplayer->devFd, AUDIOIOC_CONFIGURE, ret = ioctl(pplayer->dev_fd, AUDIOIOC_CONFIGURE,
(unsigned long)&cap_desc); (unsigned long)&cap_desc);
if (ret < 0) if (ret < 0)
{ {
@ -1350,7 +1358,7 @@ int nxplayer_setbass(FAR struct nxplayer_s *pplayer, uint8_t level)
cap_desc.caps.ac_type = AUDIO_TYPE_FEATURE; cap_desc.caps.ac_type = AUDIO_TYPE_FEATURE;
cap_desc.caps.ac_format.hw = AUDIO_FU_BASS; cap_desc.caps.ac_format.hw = AUDIO_FU_BASS;
cap_desc.caps.ac_controls.b[0] = level; cap_desc.caps.ac_controls.b[0] = level;
ioctl(pplayer->devFd, AUDIOIOC_CONFIGURE, (unsigned long) &cap_desc); ioctl(pplayer->dev_fd, AUDIOIOC_CONFIGURE, (unsigned long) &cap_desc);
} }
/* Store the volume setting */ /* Store the volume setting */
@ -1402,7 +1410,7 @@ int nxplayer_settreble(FAR struct nxplayer_s *pplayer, uint8_t level)
cap_desc.caps.ac_type = AUDIO_TYPE_FEATURE; cap_desc.caps.ac_type = AUDIO_TYPE_FEATURE;
cap_desc.caps.ac_format.hw = AUDIO_FU_TREBLE; cap_desc.caps.ac_format.hw = AUDIO_FU_TREBLE;
cap_desc.caps.ac_controls.b[0] = level; cap_desc.caps.ac_controls.b[0] = level;
ioctl(pplayer->devFd, AUDIOIOC_CONFIGURE, (unsigned long) &cap_desc); ioctl(pplayer->dev_fd, AUDIOIOC_CONFIGURE, (unsigned long) &cap_desc);
} }
/* Store the volume setting */ /* Store the volume setting */
@ -1450,7 +1458,7 @@ int nxplayer_setbalance(FAR struct nxplayer_s *pplayer, uint16_t balance)
cap_desc.caps.ac_type = AUDIO_TYPE_FEATURE; cap_desc.caps.ac_type = AUDIO_TYPE_FEATURE;
cap_desc.caps.ac_format.hw = AUDIO_FU_BALANCE; cap_desc.caps.ac_format.hw = AUDIO_FU_BALANCE;
cap_desc.caps.ac_controls.hw[0] = balance; cap_desc.caps.ac_controls.hw[0] = balance;
ioctl(pplayer->devFd, AUDIOIOC_CONFIGURE, (unsigned long) &cap_desc); ioctl(pplayer->dev_fd, AUDIOIOC_CONFIGURE, (unsigned long) &cap_desc);
} }
/* Store the volume setting */ /* Store the volume setting */
@ -1479,10 +1487,10 @@ int nxplayer_pause(FAR struct nxplayer_s *pplayer)
if (pplayer->state == NXPLAYER_STATE_PLAYING) if (pplayer->state == NXPLAYER_STATE_PLAYING)
{ {
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
ret = ioctl(pplayer->devFd, AUDIOIOC_PAUSE, ret = ioctl(pplayer->dev_fd, AUDIOIOC_PAUSE,
(unsigned long) pplayer->session); (unsigned long) pplayer->session);
#else #else
ret = ioctl(pplayer->devFd, AUDIOIOC_PAUSE, 0); ret = ioctl(pplayer->dev_fd, AUDIOIOC_PAUSE, 0);
#endif #endif
if (ret == OK) if (ret == OK)
{ {
@ -1509,10 +1517,10 @@ int nxplayer_resume(FAR struct nxplayer_s *pplayer)
if (pplayer->state == NXPLAYER_STATE_PAUSED) if (pplayer->state == NXPLAYER_STATE_PAUSED)
{ {
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
ret = ioctl(pplayer->devFd, AUDIOIOC_RESUME, ret = ioctl(pplayer->dev_fd, AUDIOIOC_RESUME,
(unsigned long) pplayer->session); (unsigned long) pplayer->session);
#else #else
ret = ioctl(pplayer->devFd, AUDIOIOC_RESUME, 0); ret = ioctl(pplayer->dev_fd, AUDIOIOC_RESUME, 0);
#endif #endif
if (ret == OK) if (ret == OK)
{ {
@ -1566,7 +1574,9 @@ int nxplayer_fforward(FAR struct nxplayer_s *pplayer, uint8_t subsample)
cap_desc.caps.ac_format.hw = AUDIO_PU_SUBSAMPLE_FORWARD; cap_desc.caps.ac_format.hw = AUDIO_PU_SUBSAMPLE_FORWARD;
cap_desc.caps.ac_controls.b[0] = subsample; cap_desc.caps.ac_controls.b[0] = subsample;
ret = ioctl(pplayer->devFd, AUDIOIOC_CONFIGURE, (unsigned long) &cap_desc); ret = ioctl(pplayer->dev_fd,
AUDIOIOC_CONFIGURE,
(unsigned long) &cap_desc);
if (ret < 0) if (ret < 0)
{ {
int errcode = errno; int errcode = errno;
@ -1622,7 +1632,9 @@ int nxplayer_rewind(FAR struct nxplayer_s *pplayer, uint8_t subsample)
cap_desc.caps.ac_format.hw = AUDIO_PU_SUBSAMPLE_REWIND; cap_desc.caps.ac_format.hw = AUDIO_PU_SUBSAMPLE_REWIND;
cap_desc.caps.ac_controls.b[0] = subsample; cap_desc.caps.ac_controls.b[0] = subsample;
ret = ioctl(pplayer->devFd, AUDIOIOC_CONFIGURE, (unsigned long) &cap_desc); ret = ioctl(pplayer->dev_fd,
AUDIOIOC_CONFIGURE,
(unsigned long) &cap_desc);
if (ret < 0) if (ret < 0)
{ {
int errcode = errno; int errcode = errno;
@ -1697,18 +1709,18 @@ int nxplayer_cancel_motion(FAR struct nxplayer_s *pplayer, bool paused)
#ifdef CONFIG_NXPLAYER_INCLUDE_PREFERRED_DEVICE #ifdef CONFIG_NXPLAYER_INCLUDE_PREFERRED_DEVICE
int nxplayer_setdevice(FAR struct nxplayer_s *pplayer, int nxplayer_setdevice(FAR struct nxplayer_s *pplayer,
FAR const char *pDevice) FAR const char *pdevice)
{ {
int tempFd; int temp_fd;
struct audio_caps_s caps; struct audio_caps_s caps;
DEBUGASSERT(pplayer != NULL); DEBUGASSERT(pplayer != NULL);
DEBUGASSERT(pDevice != NULL); DEBUGASSERT(pdevice != NULL);
/* Try to open the device */ /* Try to open the device */
tempFd = open(pDevice, O_RDWR); temp_fd = open(pdevice, O_RDWR);
if (tempFd == -1) if (temp_fd == -1)
{ {
/* Error opening the device */ /* Error opening the device */
@ -1720,21 +1732,21 @@ int nxplayer_setdevice(FAR struct nxplayer_s *pplayer,
caps.ac_len = sizeof(caps); caps.ac_len = sizeof(caps);
caps.ac_type = AUDIO_TYPE_QUERY; caps.ac_type = AUDIO_TYPE_QUERY;
caps.ac_subtype = AUDIO_TYPE_QUERY; caps.ac_subtype = AUDIO_TYPE_QUERY;
if (ioctl(tempFd, AUDIOIOC_GETCAPS, (unsigned long) &caps) != caps.ac_len) if (ioctl(temp_fd, AUDIOIOC_GETCAPS, (unsigned long) &caps) != caps.ac_len)
{ {
/* Not an Audio device! */ /* Not an Audio device! */
close(tempFd); close(temp_fd);
return -ENODEV; return -ENODEV;
} }
/* Close the file */ /* Close the file */
close(tempFd); close(temp_fd);
/* Save the path and format capabilities of the preferred device */ /* Save the path and format capabilities of the preferred device */
strncpy(pplayer->prefdevice, pDevice, sizeof(pplayer->prefdevice)); strncpy(pplayer->prefdevice, pdevice, sizeof(pplayer->prefdevice));
pplayer->prefformat = caps.ac_format.b[0] | (caps.ac_format.b[1] << 8); pplayer->prefformat = caps.ac_format.b[0] | (caps.ac_format.b[1] << 8);
pplayer->preftype = caps.ac_controls.b[0]; pplayer->preftype = caps.ac_controls.b[0];
@ -1774,15 +1786,15 @@ int nxplayer_stop(FAR struct nxplayer_s *pplayer)
/* Notify the playback thread that it needs to cancel the playback */ /* Notify the playback thread that it needs to cancel the playback */
term_msg.msgId = AUDIO_MSG_STOP; term_msg.msg_id = AUDIO_MSG_STOP;
term_msg.u.data = 0; term_msg.u.data = 0;
mq_send(pplayer->mq, (FAR const char *)&term_msg, sizeof(term_msg), mq_send(pplayer->mq, (FAR const char *)&term_msg, sizeof(term_msg),
CONFIG_NXPLAYER_MSG_PRIO); CONFIG_NXPLAYER_MSG_PRIO);
/* Join the thread. The thread will do all the cleanup. */ /* Join the thread. The thread will do all the cleanup. */
pthread_join(pplayer->playId, &value); pthread_join(pplayer->play_id, &value);
pplayer->playId = 0; pplayer->play_id = 0;
return OK; return OK;
} }
@ -1798,7 +1810,7 @@ int nxplayer_stop(FAR struct nxplayer_s *pplayer)
* *
* Input: * Input:
* pplayer Pointer to the initialized MPlayer context * pplayer Pointer to the initialized MPlayer context
* pFilename Pointer to the filename to play * pfilename Pointer to the filename to play
* filefmt Format of the file or AUD_FMT_UNDEF if unknown / to be * filefmt Format of the file or AUD_FMT_UNDEF if unknown / to be
* determined by nxplayer_playfile() * determined by nxplayer_playfile()
* nchannels channels num (raw data playback needed) * nchannels channels num (raw data playback needed)
@ -1816,7 +1828,7 @@ int nxplayer_stop(FAR struct nxplayer_s *pplayer)
****************************************************************************/ ****************************************************************************/
static int nxplayer_playinternal(FAR struct nxplayer_s *pplayer, static int nxplayer_playinternal(FAR struct nxplayer_s *pplayer,
FAR const char *pFilename, int filefmt, FAR const char *pfilename, int filefmt,
int subfmt, uint8_t nchannels, int subfmt, uint8_t nchannels,
uint8_t bpsamp, uint32_t samprate) uint8_t bpsamp, uint32_t samprate)
{ {
@ -1832,7 +1844,7 @@ static int nxplayer_playinternal(FAR struct nxplayer_s *pplayer,
int ret; int ret;
DEBUGASSERT(pplayer != NULL); DEBUGASSERT(pplayer != NULL);
DEBUGASSERT(pFilename != NULL); DEBUGASSERT(pfilename != NULL);
if (pplayer->state != NXPLAYER_STATE_IDLE) if (pplayer->state != NXPLAYER_STATE_IDLE)
{ {
@ -1840,42 +1852,42 @@ static int nxplayer_playinternal(FAR struct nxplayer_s *pplayer,
} }
audinfo("==============================\n"); audinfo("==============================\n");
audinfo("Playing file %s\n", pFilename); audinfo("Playing file %s\n", pfilename);
audinfo("==============================\n"); audinfo("==============================\n");
/* Test that the specified file exists */ /* Test that the specified file exists */
#ifdef CONFIG_NXPLAYER_HTTP_STREAMING_SUPPORT #ifdef CONFIG_NXPLAYER_HTTP_STREAMING_SUPPORT
if ((pplayer->fd = _open_with_http(pFilename)) == -1) if ((pplayer->fd = _open_with_http(pfilename)) == -1)
#else #else
if ((pplayer->fd = open(pFilename, O_RDONLY)) == -1) if ((pplayer->fd = open(pfilename, O_RDONLY)) == -1)
#endif #endif
{ {
/* File not found. Test if its in the mediadir */ /* File not found. Test if its in the mediadir */
#ifdef CONFIG_NXPLAYER_INCLUDE_MEDIADIR #ifdef CONFIG_NXPLAYER_INCLUDE_MEDIADIR
snprintf(path, sizeof(path), "%s/%s", pplayer->mediadir, pFilename); snprintf(path, sizeof(path), "%s/%s", pplayer->mediadir, pfilename);
if ((pplayer->fd = open(path, O_RDONLY)) == -1) if ((pplayer->fd = open(path, O_RDONLY)) == -1)
{ {
#ifdef CONFIG_NXPLAYER_MEDIA_SEARCH #ifdef CONFIG_NXPLAYER_MEDIA_SEARCH
/* File not found in the media dir. Do a search */ /* File not found in the media dir. Do a search */
if (nxplayer_mediasearch(pplayer, pFilename, path, if (nxplayer_mediasearch(pplayer, pfilename, path,
sizeof(path)) != OK) sizeof(path)) != OK)
{ {
auderr("ERROR: Could not find file\n"); auderr("ERROR: Could not find file\n");
return -ENOENT; return -ENOENT;
} }
#else #else
auderr("ERROR: Could not open %s or %s\n", pFilename, path); auderr("ERROR: Could not open %s or %s\n", pfilename, path);
return -ENOENT; return -ENOENT;
#endif /* CONFIG_NXPLAYER_MEDIA_SEARCH */ #endif /* CONFIG_NXPLAYER_MEDIA_SEARCH */
} }
#else /* CONFIG_NXPLAYER_INCLUDE_MEDIADIR */ #else /* CONFIG_NXPLAYER_INCLUDE_MEDIADIR */
auderr("ERROR: Could not open %s\n", pFilename); auderr("ERROR: Could not open %s\n", pfilename);
return -ENOENT; return -ENOENT;
#endif /* CONFIG_NXPLAYER_INCLUDE_MEDIADIR */ #endif /* CONFIG_NXPLAYER_INCLUDE_MEDIADIR */
} }
@ -1885,7 +1897,7 @@ static int nxplayer_playinternal(FAR struct nxplayer_s *pplayer,
if (filefmt == AUDIO_FMT_UNDEF) if (filefmt == AUDIO_FMT_UNDEF)
{ {
filefmt = nxplayer_fmtfromextension(pplayer, pFilename, &tmpsubfmt); filefmt = nxplayer_fmtfromextension(pplayer, pfilename, &tmpsubfmt);
} }
#endif #endif
@ -1930,10 +1942,10 @@ static int nxplayer_playinternal(FAR struct nxplayer_s *pplayer,
/* Try to reserve the device */ /* Try to reserve the device */
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
ret = ioctl(pplayer->devFd, AUDIOIOC_RESERVE, ret = ioctl(pplayer->dev_fd, AUDIOIOC_RESERVE,
(unsigned long)&pplayer->session); (unsigned long)&pplayer->session);
#else #else
ret = ioctl(pplayer->devFd, AUDIOIOC_RESERVE, 0); ret = ioctl(pplayer->dev_fd, AUDIOIOC_RESERVE, 0);
#endif #endif
if (ret < 0) if (ret < 0)
{ {
@ -1956,7 +1968,7 @@ static int nxplayer_playinternal(FAR struct nxplayer_s *pplayer,
cap_desc.caps.ac_controls.b[3] = samprate >> 16; cap_desc.caps.ac_controls.b[3] = samprate >> 16;
cap_desc.caps.ac_controls.b[2] = bpsamp; cap_desc.caps.ac_controls.b[2] = bpsamp;
ioctl(pplayer->devFd, AUDIOIOC_CONFIGURE, (unsigned long)&cap_desc); ioctl(pplayer->dev_fd, AUDIOIOC_CONFIGURE, (unsigned long)&cap_desc);
} }
/* Create a message queue for the playthread */ /* Create a message queue for the playthread */
@ -1981,15 +1993,15 @@ static int nxplayer_playinternal(FAR struct nxplayer_s *pplayer,
/* Register our message queue with the audio device */ /* Register our message queue with the audio device */
ioctl(pplayer->devFd, AUDIOIOC_REGISTERMQ, (unsigned long) pplayer->mq); ioctl(pplayer->dev_fd, AUDIOIOC_REGISTERMQ, (unsigned long) pplayer->mq);
/* Check if there was a previous thread and join it if there was /* Check if there was a previous thread and join it if there was
* to perform clean-up. * to perform clean-up.
*/ */
if (pplayer->playId != 0) if (pplayer->play_id != 0)
{ {
pthread_join(pplayer->playId, &value); pthread_join(pplayer->play_id, &value);
} }
/* Start the playfile thread to stream the media file to the /* Start the playfile thread to stream the media file to the
@ -2008,7 +2020,7 @@ static int nxplayer_playinternal(FAR struct nxplayer_s *pplayer,
*/ */
nxplayer_reference(pplayer); nxplayer_reference(pplayer);
ret = pthread_create(&pplayer->playId, &tattr, nxplayer_playthread, ret = pthread_create(&pplayer->play_id, &tattr, nxplayer_playthread,
(pthread_addr_t) pplayer); (pthread_addr_t) pplayer);
if (ret != OK) if (ret != OK)
{ {
@ -2018,12 +2030,12 @@ static int nxplayer_playinternal(FAR struct nxplayer_s *pplayer,
/* Name the thread */ /* Name the thread */
pthread_setname_np(pplayer->playId, "playthread"); pthread_setname_np(pplayer->play_id, "playthread");
return OK; return OK;
err_out: err_out:
close(pplayer->devFd); close(pplayer->dev_fd);
pplayer->devFd = -1; pplayer->dev_fd = -1;
err_out_nodev: err_out_nodev:
if (0 < pplayer->fd) if (0 < pplayer->fd)
@ -2045,7 +2057,7 @@ err_out_nodev:
* *
* Input: * Input:
* pplayer Pointer to the initialized MPlayer context * pplayer Pointer to the initialized MPlayer context
* pFilename Pointer to the filename to play * pfilename Pointer to the filename to play
* filefmt Format of the file or AUD_FMT_UNDEF if unknown / to be * filefmt Format of the file or AUD_FMT_UNDEF if unknown / to be
* determined by nxplayer_playfile() * determined by nxplayer_playfile()
* *
@ -2059,9 +2071,9 @@ err_out_nodev:
****************************************************************************/ ****************************************************************************/
int nxplayer_playfile(FAR struct nxplayer_s *pplayer, int nxplayer_playfile(FAR struct nxplayer_s *pplayer,
FAR const char *pFilename, int filefmt, int subfmt) FAR const char *pfilename, int filefmt, int subfmt)
{ {
return nxplayer_playinternal(pplayer, pFilename, filefmt, subfmt, 0, 0, 0); return nxplayer_playinternal(pplayer, pfilename, filefmt, subfmt, 0, 0, 0);
} }
/**************************************************************************** /****************************************************************************
@ -2074,7 +2086,7 @@ int nxplayer_playfile(FAR struct nxplayer_s *pplayer,
* *
* Input: * Input:
* pplayer Pointer to the initialized MPlayer context * pplayer Pointer to the initialized MPlayer context
* pFilename Pointer to the filename to play * pfilename Pointer to the filename to play
* nchannels channel num * nchannels channel num
* bpsampe bit width * bpsampe bit width
* samprate sample rate * samprate sample rate
@ -2089,7 +2101,7 @@ int nxplayer_playfile(FAR struct nxplayer_s *pplayer,
****************************************************************************/ ****************************************************************************/
int nxplayer_playraw(FAR struct nxplayer_s *pplayer, int nxplayer_playraw(FAR struct nxplayer_s *pplayer,
FAR const char *pFilename, uint8_t nchannels, FAR const char *pfilename, uint8_t nchannels,
uint8_t bpsamp, uint32_t samprate) uint8_t bpsamp, uint32_t samprate)
{ {
if (nchannels == 0) if (nchannels == 0)
@ -2107,7 +2119,7 @@ int nxplayer_playraw(FAR struct nxplayer_s *pplayer,
samprate = 48000; samprate = 48000;
} }
return nxplayer_playinternal(pplayer, pFilename, AUDIO_FMT_PCM, 0, return nxplayer_playinternal(pplayer, pfilename, AUDIO_FMT_PCM, 0,
nchannels, bpsamp, samprate); nchannels, bpsamp, samprate);
} }
@ -2155,7 +2167,7 @@ FAR struct nxplayer_s *nxplayer_create(void)
/* Initialize the context data */ /* Initialize the context data */
pplayer->state = NXPLAYER_STATE_IDLE; pplayer->state = NXPLAYER_STATE_IDLE;
pplayer->devFd = -1; pplayer->dev_fd = -1;
pplayer->fd = -1; pplayer->fd = -1;
#ifdef CONFIG_NXPLAYER_INCLUDE_PREFERRED_DEVICE #ifdef CONFIG_NXPLAYER_INCLUDE_PREFERRED_DEVICE
pplayer->prefdevice[0] = '\0'; pplayer->prefdevice[0] = '\0';
@ -2163,7 +2175,7 @@ FAR struct nxplayer_s *nxplayer_create(void)
pplayer->preftype = 0; pplayer->preftype = 0;
#endif #endif
pplayer->mq = NULL; pplayer->mq = NULL;
pplayer->playId = 0; pplayer->play_id = 0;
pplayer->crefs = 1; pplayer->crefs = 1;
#ifndef CONFIG_AUDIO_EXCLUDE_TONE #ifndef CONFIG_AUDIO_EXCLUDE_TONE
@ -2225,11 +2237,11 @@ void nxplayer_release(FAR struct nxplayer_s *pplayer)
/* Check if there was a previous thread and join it if there was */ /* Check if there was a previous thread and join it if there was */
if (pplayer->playId != 0) if (pplayer->play_id != 0)
{ {
sem_post(&pplayer->sem); sem_post(&pplayer->sem);
pthread_join(pplayer->playId, &value); pthread_join(pplayer->play_id, &value);
pplayer->playId = 0; pplayer->play_id = 0;
while (sem_wait(&pplayer->sem) < 0) while (sem_wait(&pplayer->sem) < 0)
{ {
@ -2322,12 +2334,12 @@ void nxplayer_detach(FAR struct nxplayer_s *pplayer)
} }
} }
if (pplayer->playId != NULL) if (pplayer->play_id != NULL)
{ {
/* Do a pthread detach */ /* Do a pthread detach */
pthread_detach(pplayer->playId); pthread_detach(pplayer->play_id);
pplayer->playId = NULL; pplayer->play_id = NULL;
} }
sem_post(&pplayer->sem); sem_post(&pplayer->sem);
@ -2345,7 +2357,7 @@ void nxplayer_detach(FAR struct nxplayer_s *pplayer)
#ifdef CONFIG_NXPLAYER_INCLUDE_SYSTEM_RESET #ifdef CONFIG_NXPLAYER_INCLUDE_SYSTEM_RESET
int nxplayer_systemreset(FAR struct nxplayer_s *pplayer) int nxplayer_systemreset(FAR struct nxplayer_s *pplayer)
{ {
struct dirent *pDevice; struct dirent *pdevice;
DIR *dirp; DIR *dirp;
char path[64]; char path[64];
@ -2365,7 +2377,7 @@ int nxplayer_systemreset(FAR struct nxplayer_s *pplayer)
return -ENODEV; return -ENODEV;
} }
while ((pDevice = readdir(dirp)) != NULL) while ((pdevice = readdir(dirp)) != NULL)
{ {
/* We found the next device. Try to open it and /* We found the next device. Try to open it and
* get its audio capabilities. * get its audio capabilities.
@ -2373,29 +2385,29 @@ int nxplayer_systemreset(FAR struct nxplayer_s *pplayer)
#ifdef CONFIG_AUDIO_CUSTOM_DEV_PATH #ifdef CONFIG_AUDIO_CUSTOM_DEV_PATH
#ifdef CONFIG_AUDIO_DEV_ROOT #ifdef CONFIG_AUDIO_DEV_ROOT
snprintf(path, sizeof(path), "/dev/%s", pDevice->d_name); snprintf(path, sizeof(path), "/dev/%s", pdevice->d_name);
#else #else
snprintf(path, sizeof(path), CONFIG_AUDIO_DEV_PATH "/%s", snprintf(path, sizeof(path), CONFIG_AUDIO_DEV_PATH "/%s",
pDevice->d_name); pdevice->d_name);
#endif #endif
#else #else
snprintf(path, sizeof(path), "/dev/audio/%s", pDevice->d_name); snprintf(path, sizeof(path), "/dev/audio/%s", pdevice->d_name);
#endif #endif
if ((pplayer->devFd = open(path, O_RDWR)) != -1) if ((pplayer->dev_fd = open(path, O_RDWR)) != -1)
{ {
/* We have the device file open. Now issue an /* We have the device file open. Now issue an
* AUDIO ioctls to perform a HW reset * AUDIO ioctls to perform a HW reset
*/ */
ioctl(pplayer->devFd, AUDIOIOC_HWRESET, 0); ioctl(pplayer->dev_fd, AUDIOIOC_HWRESET, 0);
/* Now close the device */ /* Now close the device */
close(pplayer->devFd); close(pplayer->dev_fd);
} }
} }
pplayer->devFd = -1; pplayer->dev_fd = -1;
return OK; return OK;
} }
#endif /* CONFIG_NXPLAYER_INCLUDE_SYSTEM_RESET */ #endif /* CONFIG_NXPLAYER_INCLUDE_SYSTEM_RESET */

@ -67,10 +67,11 @@
* Private Type Declarations * Private Type Declarations
****************************************************************************/ ****************************************************************************/
struct mp_cmd_s { struct mp_cmd_s
{
const char *cmd; /* The command text */ const char *cmd; /* The command text */
const char *arghelp; /* Text describing the args */ const char *arghelp; /* Text describing the args */
nxplayer_func pFunc; /* Pointer to command handler */ nxplayer_func pfunc; /* Pointer to command handler */
const char *help; /* The help text */ const char *help; /* The help text */
}; };
@ -78,45 +79,45 @@ struct mp_cmd_s {
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
static int nxplayer_cmd_quit(FAR struct nxplayer_s *pPlayer, char *parg); static int nxplayer_cmd_quit(FAR struct nxplayer_s *pplayer, char *parg);
static int nxplayer_cmd_play(FAR struct nxplayer_s *pPlayer, char *parg); static int nxplayer_cmd_play(FAR struct nxplayer_s *pplayer, char *parg);
static int nxplayer_cmd_playraw(FAR struct nxplayer_s *pPlayer, char *parg); static int nxplayer_cmd_playraw(FAR struct nxplayer_s *pplayer, char *parg);
#ifdef CONFIG_NXPLAYER_INCLUDE_SYSTEM_RESET #ifdef CONFIG_NXPLAYER_INCLUDE_SYSTEM_RESET
static int nxplayer_cmd_reset(FAR struct nxplayer_s *pPlayer, char *parg); static int nxplayer_cmd_reset(FAR struct nxplayer_s *pplayer, char *parg);
#endif #endif
#ifdef CONFIG_NXPLAYER_INCLUDE_PREFERRED_DEVICE #ifdef CONFIG_NXPLAYER_INCLUDE_PREFERRED_DEVICE
static int nxplayer_cmd_device(FAR struct nxplayer_s *pPlayer, char *parg); static int nxplayer_cmd_device(FAR struct nxplayer_s *pplayer, char *parg);
#endif #endif
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
static int nxplayer_cmd_pause(FAR struct nxplayer_s *pPlayer, char *parg); static int nxplayer_cmd_pause(FAR struct nxplayer_s *pplayer, char *parg);
static int nxplayer_cmd_resume(FAR struct nxplayer_s *pPlayer, char *parg); static int nxplayer_cmd_resume(FAR struct nxplayer_s *pplayer, char *parg);
#endif #endif
#ifdef CONFIG_NXPLAYER_INCLUDE_MEDIADIR #ifdef CONFIG_NXPLAYER_INCLUDE_MEDIADIR
static int nxplayer_cmd_mediadir(FAR struct nxplayer_s *pPlayer, char *parg); static int nxplayer_cmd_mediadir(FAR struct nxplayer_s *pplayer, char *parg);
#endif #endif
#ifndef CONFIG_AUDIO_EXCLUDE_STOP #ifndef CONFIG_AUDIO_EXCLUDE_STOP
static int nxplayer_cmd_stop(FAR struct nxplayer_s *pPlayer, char *parg); static int nxplayer_cmd_stop(FAR struct nxplayer_s *pplayer, char *parg);
#endif #endif
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
static int nxplayer_cmd_volume(FAR struct nxplayer_s *pPlayer, char *parg); static int nxplayer_cmd_volume(FAR struct nxplayer_s *pplayer, char *parg);
#ifndef CONFIG_AUDIO_EXCLUDE_BALANCE #ifndef CONFIG_AUDIO_EXCLUDE_BALANCE
static int nxplayer_cmd_balance(FAR struct nxplayer_s *pPlayer, char *parg); static int nxplayer_cmd_balance(FAR struct nxplayer_s *pplayer, char *parg);
#endif #endif
#endif #endif
#ifndef CONFIG_AUDIO_EXCLUDE_TONE #ifndef CONFIG_AUDIO_EXCLUDE_TONE
static int nxplayer_cmd_bass(FAR struct nxplayer_s *pPlayer, char *parg); static int nxplayer_cmd_bass(FAR struct nxplayer_s *pplayer, char *parg);
static int nxplayer_cmd_treble(FAR struct nxplayer_s *pPlayer, char *parg); static int nxplayer_cmd_treble(FAR struct nxplayer_s *pplayer, char *parg);
#endif #endif
#ifdef CONFIG_NXPLAYER_INCLUDE_HELP #ifdef CONFIG_NXPLAYER_INCLUDE_HELP
static int nxplayer_cmd_help(FAR struct nxplayer_s *pPlayer, char *parg); static int nxplayer_cmd_help(FAR struct nxplayer_s *pplayer, char *parg);
#endif #endif
/**************************************************************************** /****************************************************************************
@ -127,48 +128,134 @@ static struct mp_cmd_s g_nxplayer_cmds[] =
{ {
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
#ifndef CONFIG_AUDIO_EXCLUDE_BALANCE #ifndef CONFIG_AUDIO_EXCLUDE_BALANCE
{ "balance", "d%", nxplayer_cmd_balance, NXPLAYER_HELP_TEXT(Set balance percentage (< 50% means more left)) }, {
"balance",
"d%",
nxplayer_cmd_balance,
NXPLAYER_HELP_TEXT(Set balance percentage (< 50% means more left))
},
#endif #endif
#endif #endif
#ifndef CONFIG_AUDIO_EXCLUDE_TONE #ifndef CONFIG_AUDIO_EXCLUDE_TONE
{ "bass", "d%", nxplayer_cmd_bass, NXPLAYER_HELP_TEXT(Set bass level percentage) }, {
"bass",
"d%",
nxplayer_cmd_bass,
NXPLAYER_HELP_TEXT(Set bass level percentage)
},
#endif #endif
#ifdef CONFIG_NXPLAYER_INCLUDE_PREFERRED_DEVICE #ifdef CONFIG_NXPLAYER_INCLUDE_PREFERRED_DEVICE
{ "device", "devfile", nxplayer_cmd_device, NXPLAYER_HELP_TEXT(Specify a preferred audio device) }, {
"device",
"devfile",
nxplayer_cmd_device,
NXPLAYER_HELP_TEXT(Specify a preferred audio device)
},
#endif #endif
#ifdef CONFIG_NXPLAYER_INCLUDE_HELP #ifdef CONFIG_NXPLAYER_INCLUDE_HELP
{ "h", "", nxplayer_cmd_help, NXPLAYER_HELP_TEXT(Display help for commands) }, {
{ "help", "", nxplayer_cmd_help, NXPLAYER_HELP_TEXT(Display help for commands) }, "h",
"",
nxplayer_cmd_help,
NXPLAYER_HELP_TEXT(Display help for commands)
},
{
"help",
"",
nxplayer_cmd_help,
NXPLAYER_HELP_TEXT(Display help for commands)
},
#endif #endif
#ifdef CONFIG_NXPLAYER_INCLUDE_MEDIADIR #ifdef CONFIG_NXPLAYER_INCLUDE_MEDIADIR
{ "mediadir", "path", nxplayer_cmd_mediadir, NXPLAYER_HELP_TEXT(Change the media directory) }, {
"mediadir",
"path",
nxplayer_cmd_mediadir,
NXPLAYER_HELP_TEXT(Change the media directory)
},
#endif #endif
{ "play", "filename", nxplayer_cmd_play, NXPLAYER_HELP_TEXT(Play a media file) }, {
{ "playraw", "filename", nxplayer_cmd_playraw, NXPLAYER_HELP_TEXT(Play a raw data file) }, "play",
"filename",
nxplayer_cmd_play,
NXPLAYER_HELP_TEXT(Play a media file)
},
{
"playraw",
"filename",
nxplayer_cmd_playraw,
NXPLAYER_HELP_TEXT(Play a raw data file)
},
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
{ "pause", "", nxplayer_cmd_pause, NXPLAYER_HELP_TEXT(Pause playback) }, {
"pause",
"",
nxplayer_cmd_pause,
NXPLAYER_HELP_TEXT(Pause playback)
},
#endif #endif
#ifdef CONFIG_NXPLAYER_INCLUDE_SYSTEM_RESET #ifdef CONFIG_NXPLAYER_INCLUDE_SYSTEM_RESET
{ "reset", "", nxplayer_cmd_reset, NXPLAYER_HELP_TEXT(Perform a HW reset) }, {
"reset",
"",
nxplayer_cmd_reset,
NXPLAYER_HELP_TEXT(Perform a HW reset)
},
#endif #endif
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
{ "resume", "", nxplayer_cmd_resume, NXPLAYER_HELP_TEXT(Resume playback) }, {
"resume",
"",
nxplayer_cmd_resume,
NXPLAYER_HELP_TEXT(Resume playback)
},
#endif #endif
#ifndef CONFIG_AUDIO_EXCLUDE_STOP #ifndef CONFIG_AUDIO_EXCLUDE_STOP
{ "stop", "", nxplayer_cmd_stop, NXPLAYER_HELP_TEXT(Stop playback) }, {
"stop",
"",
nxplayer_cmd_stop,
NXPLAYER_HELP_TEXT(Stop playback)
},
#endif #endif
{ "tone", "freq secs", NULL, NXPLAYER_HELP_TEXT(Produce a pure tone) }, {
"tone",
"freq secs",
NULL,
NXPLAYER_HELP_TEXT(Produce a pure tone)
},
#ifndef CONFIG_AUDIO_EXCLUDE_TONE #ifndef CONFIG_AUDIO_EXCLUDE_TONE
{ "treble", "d%", nxplayer_cmd_treble, NXPLAYER_HELP_TEXT(Set treble level percentage) }, {
"treble",
"d%",
nxplayer_cmd_treble,
NXPLAYER_HELP_TEXT(Set treble level percentage)
},
#endif #endif
{ "q", "", nxplayer_cmd_quit, NXPLAYER_HELP_TEXT(Exit NxPlayer) }, {
{ "quit", "", nxplayer_cmd_quit, NXPLAYER_HELP_TEXT(Exit NxPlayer) }, "q",
"",
nxplayer_cmd_quit,
NXPLAYER_HELP_TEXT(Exit NxPlayer)
},
{
"quit",
"",
nxplayer_cmd_quit,
NXPLAYER_HELP_TEXT(Exit NxPlayer)
},
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
{ "volume", "d%", nxplayer_cmd_volume, NXPLAYER_HELP_TEXT(Set volume to level specified) } {
"volume",
"d%",
nxplayer_cmd_volume,
NXPLAYER_HELP_TEXT(Set volume to level specified)
}
#endif #endif
}; };
static const int g_nxplayer_cmd_count = sizeof(g_nxplayer_cmds) / sizeof(struct mp_cmd_s); static const int g_nxplayer_cmd_count = sizeof(g_nxplayer_cmds) /
sizeof(struct mp_cmd_s);
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
@ -182,13 +269,13 @@ static const int g_nxplayer_cmd_count = sizeof(g_nxplayer_cmds) / sizeof(struct
* *
****************************************************************************/ ****************************************************************************/
static int nxplayer_cmd_play(FAR struct nxplayer_s *pPlayer, char *parg) static int nxplayer_cmd_play(FAR struct nxplayer_s *pplayer, char *parg)
{ {
int ret; int ret;
/* Try to play the file specified */ /* Try to play the file specified */
ret = nxplayer_playfile(pPlayer, parg, AUDIO_FMT_UNDEF, AUDIO_FMT_UNDEF); ret = nxplayer_playfile(pplayer, parg, AUDIO_FMT_UNDEF, AUDIO_FMT_UNDEF);
/* nxplayer_playfile returned values: /* nxplayer_playfile returned values:
* *
@ -236,7 +323,7 @@ static int nxplayer_cmd_play(FAR struct nxplayer_s *pPlayer, char *parg)
* *
****************************************************************************/ ****************************************************************************/
static int nxplayer_cmd_playraw(FAR struct nxplayer_s *pPlayer, char *parg) static int nxplayer_cmd_playraw(FAR struct nxplayer_s *pplayer, char *parg)
{ {
int ret; int ret;
int channels = 0; int channels = 0;
@ -248,7 +335,7 @@ static int nxplayer_cmd_playraw(FAR struct nxplayer_s *pPlayer, char *parg)
/* Try to play the file specified */ /* Try to play the file specified */
ret = nxplayer_playraw(pPlayer, filename, channels, bpsamp, samprate); ret = nxplayer_playraw(pplayer, filename, channels, bpsamp, samprate);
/* nxplayer_playfile returned values: /* nxplayer_playfile returned values:
* *
@ -296,7 +383,7 @@ static int nxplayer_cmd_playraw(FAR struct nxplayer_s *pPlayer, char *parg)
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
static int nxplayer_cmd_volume(FAR struct nxplayer_s *pPlayer, char *parg) static int nxplayer_cmd_volume(FAR struct nxplayer_s *pplayer, char *parg)
{ {
uint16_t percent; uint16_t percent;
@ -304,14 +391,14 @@ static int nxplayer_cmd_volume(FAR struct nxplayer_s *pPlayer, char *parg)
if (parg == NULL || *parg == '\0') if (parg == NULL || *parg == '\0')
{ {
printf("volume: %d\n", pPlayer->volume / 10); printf("volume: %d\n", pplayer->volume / 10);
} }
else else
{ {
/* Get the percentage value from the argument */ /* Get the percentage value from the argument */
percent = (uint16_t) (atof(parg) * 10.0); percent = (uint16_t) (atof(parg) * 10.0);
nxplayer_setvolume(pPlayer, percent); nxplayer_setvolume(pplayer, percent);
} }
return OK; return OK;
@ -326,7 +413,7 @@ static int nxplayer_cmd_volume(FAR struct nxplayer_s *pPlayer, char *parg)
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_TONE #ifndef CONFIG_AUDIO_EXCLUDE_TONE
static int nxplayer_cmd_bass(FAR struct nxplayer_s *pPlayer, char *parg) static int nxplayer_cmd_bass(FAR struct nxplayer_s *pplayer, char *parg)
{ {
uint8_t level_percent; uint8_t level_percent;
@ -334,14 +421,14 @@ static int nxplayer_cmd_bass(FAR struct nxplayer_s *pPlayer, char *parg)
if (parg == NULL || *parg == '\0') if (parg == NULL || *parg == '\0')
{ {
printf("bass: %d\n", pPlayer->bass); printf("bass: %d\n", pplayer->bass);
} }
else else
{ {
/* Get the level and range percentage value from the argument */ /* Get the level and range percentage value from the argument */
level_percent = (uint8_t) atoi(parg); level_percent = (uint8_t) atoi(parg);
nxplayer_setbass(pPlayer, level_percent); nxplayer_setbass(pplayer, level_percent);
} }
return OK; return OK;
@ -356,7 +443,7 @@ static int nxplayer_cmd_bass(FAR struct nxplayer_s *pPlayer, char *parg)
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_TONE #ifndef CONFIG_AUDIO_EXCLUDE_TONE
static int nxplayer_cmd_treble(FAR struct nxplayer_s *pPlayer, char *parg) static int nxplayer_cmd_treble(FAR struct nxplayer_s *pplayer, char *parg)
{ {
uint8_t level_percent; uint8_t level_percent;
@ -364,14 +451,14 @@ static int nxplayer_cmd_treble(FAR struct nxplayer_s *pPlayer, char *parg)
if (parg == NULL || *parg == '\0') if (parg == NULL || *parg == '\0')
{ {
printf("treble: %d\n", pPlayer->treble); printf("treble: %d\n", pplayer->treble);
} }
else else
{ {
/* Get the level and range percentage value from the argument */ /* Get the level and range percentage value from the argument */
level_percent = (uint8_t) atoi(parg); level_percent = (uint8_t) atoi(parg);
nxplayer_settreble(pPlayer, level_percent); nxplayer_settreble(pplayer, level_percent);
} }
return OK; return OK;
@ -387,7 +474,7 @@ static int nxplayer_cmd_treble(FAR struct nxplayer_s *pPlayer, char *parg)
#ifndef CONFIG_AUDIO_EXCLUDE_VOLUME #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME
#ifndef CONFIG_AUDIO_EXCLUDE_BALANCE #ifndef CONFIG_AUDIO_EXCLUDE_BALANCE
static int nxplayer_cmd_balance(FAR struct nxplayer_s *pPlayer, char *parg) static int nxplayer_cmd_balance(FAR struct nxplayer_s *pplayer, char *parg)
{ {
uint16_t percent; uint16_t percent;
@ -395,14 +482,14 @@ static int nxplayer_cmd_balance(FAR struct nxplayer_s *pPlayer, char *parg)
if (parg == NULL || *parg == '\0') if (parg == NULL || *parg == '\0')
{ {
printf("balance: %d\n", pPlayer->volume / 10); printf("balance: %d\n", pplayer->volume / 10);
} }
else else
{ {
/* Get the percentage value from the argument */ /* Get the percentage value from the argument */
percent = (uint16_t) (atof(parg) * 10.0); percent = (uint16_t) (atof(parg) * 10.0);
nxplayer_setbalance(pPlayer, percent); nxplayer_setbalance(pplayer, percent);
} }
return OK; return OK;
@ -418,9 +505,9 @@ static int nxplayer_cmd_balance(FAR struct nxplayer_s *pPlayer, char *parg)
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_NXPLAYER_INCLUDE_SYSTEM_RESET #ifdef CONFIG_NXPLAYER_INCLUDE_SYSTEM_RESET
static int nxplayer_cmd_reset(FAR struct nxplayer_s *pPlayer, char *parg) static int nxplayer_cmd_reset(FAR struct nxplayer_s *pplayer, char *parg)
{ {
nxplayer_systemreset(pPlayer); nxplayer_systemreset(pplayer);
return OK; return OK;
} }
@ -435,14 +522,14 @@ static int nxplayer_cmd_reset(FAR struct nxplayer_s *pPlayer, char *parg)
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_NXPLAYER_INCLUDE_MEDIADIR #ifdef CONFIG_NXPLAYER_INCLUDE_MEDIADIR
static int nxplayer_cmd_mediadir(FAR struct nxplayer_s *pPlayer, char *parg) static int nxplayer_cmd_mediadir(FAR struct nxplayer_s *pplayer, char *parg)
{ {
/* If no arg given, then print current media dir */ /* If no arg given, then print current media dir */
if (parg == NULL || *parg == '\0') if (parg == NULL || *parg == '\0')
printf("%s\n", pPlayer->mediadir); printf("%s\n", pplayer->mediadir);
else else
nxplayer_setmediadir(pPlayer, parg); nxplayer_setmediadir(pplayer, parg);
return OK; return OK;
} }
@ -457,11 +544,11 @@ static int nxplayer_cmd_mediadir(FAR struct nxplayer_s *pPlayer, char *parg)
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_STOP #ifndef CONFIG_AUDIO_EXCLUDE_STOP
static int nxplayer_cmd_stop(FAR struct nxplayer_s *pPlayer, char *parg) static int nxplayer_cmd_stop(FAR struct nxplayer_s *pplayer, char *parg)
{ {
/* Stop the playback */ /* Stop the playback */
nxplayer_stop(pPlayer); nxplayer_stop(pplayer);
return OK; return OK;
} }
@ -476,11 +563,11 @@ static int nxplayer_cmd_stop(FAR struct nxplayer_s *pPlayer, char *parg)
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
static int nxplayer_cmd_pause(FAR struct nxplayer_s *pPlayer, char *parg) static int nxplayer_cmd_pause(FAR struct nxplayer_s *pplayer, char *parg)
{ {
/* Pause the playback */ /* Pause the playback */
nxplayer_pause(pPlayer); nxplayer_pause(pplayer);
return OK; return OK;
} }
@ -495,11 +582,11 @@ static int nxplayer_cmd_pause(FAR struct nxplayer_s *pPlayer, char *parg)
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
static int nxplayer_cmd_resume(FAR struct nxplayer_s *pPlayer, char *parg) static int nxplayer_cmd_resume(FAR struct nxplayer_s *pplayer, char *parg)
{ {
/* Resume the playback */ /* Resume the playback */
nxplayer_resume(pPlayer); nxplayer_resume(pplayer);
return OK; return OK;
} }
@ -513,14 +600,14 @@ static int nxplayer_cmd_resume(FAR struct nxplayer_s *pPlayer, char *parg)
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_NXPLAYER_INCLUDE_PREFERRED_DEVICE #ifdef CONFIG_NXPLAYER_INCLUDE_PREFERRED_DEVICE
static int nxplayer_cmd_device(FAR struct nxplayer_s *pPlayer, char *parg) static int nxplayer_cmd_device(FAR struct nxplayer_s *pplayer, char *parg)
{ {
int ret; int ret;
char path[32]; char path[32];
/* First try to open the file directly */ /* First try to open the file directly */
ret = nxplayer_setdevice(pPlayer, parg); ret = nxplayer_setdevice(pplayer, parg);
if (ret == -ENOENT) if (ret == -ENOENT)
{ {
/* Append the /dev/audio path and try again */ /* Append the /dev/audio path and try again */
@ -534,7 +621,7 @@ static int nxplayer_cmd_device(FAR struct nxplayer_s *pPlayer, char *parg)
#else #else
snprintf(path, sizeof(path), "/dev/audio/%s", parg); snprintf(path, sizeof(path), "/dev/audio/%s", parg);
#endif #endif
ret = nxplayer_setdevice(pPlayer, path); ret = nxplayer_setdevice(pplayer, path);
} }
/* Test if the device file exists */ /* Test if the device file exists */
@ -572,12 +659,12 @@ static int nxplayer_cmd_device(FAR struct nxplayer_s *pPlayer, char *parg)
* nxplayer_cmd_quit() terminates the application * nxplayer_cmd_quit() terminates the application
****************************************************************************/ ****************************************************************************/
static int nxplayer_cmd_quit(FAR struct nxplayer_s *pPlayer, char *parg) static int nxplayer_cmd_quit(FAR struct nxplayer_s *pplayer, char *parg)
{ {
/* Stop the playback if any */ /* Stop the playback if any */
#ifndef CONFIG_AUDIO_EXCLUDE_STOP #ifndef CONFIG_AUDIO_EXCLUDE_STOP
nxplayer_stop(pPlayer); nxplayer_stop(pplayer);
#endif #endif
return OK; return OK;
@ -591,7 +678,7 @@ static int nxplayer_cmd_quit(FAR struct nxplayer_s *pPlayer, char *parg)
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_NXPLAYER_INCLUDE_HELP #ifdef CONFIG_NXPLAYER_INCLUDE_HELP
static int nxplayer_cmd_help(FAR struct nxplayer_s *pPlayer, char *parg) static int nxplayer_cmd_help(FAR struct nxplayer_s *pplayer, char *parg)
{ {
int len; int len;
int maxlen = 0; int maxlen = 0;
@ -665,7 +752,7 @@ int main(int argc, FAR char *argv[])
char buffer[CONFIG_NSH_LINELEN]; char buffer[CONFIG_NSH_LINELEN];
int len, x, running; int len, x, running;
char *cmd, *arg; char *cmd, *arg;
FAR struct nxplayer_s *pPlayer; FAR struct nxplayer_s *pplayer;
printf("NxPlayer version " NXPLAYER_VER "\n"); printf("NxPlayer version " NXPLAYER_VER "\n");
printf("h for commands, q to exit\n"); printf("h for commands, q to exit\n");
@ -673,8 +760,8 @@ int main(int argc, FAR char *argv[])
/* Initialize our NxPlayer context */ /* Initialize our NxPlayer context */
pPlayer = nxplayer_create(); pplayer = nxplayer_create();
if (pPlayer == NULL) if (pplayer == NULL)
{ {
printf("Error: Out of RAM\n"); printf("Error: Out of RAM\n");
return -ENOMEM; return -ENOMEM;
@ -728,14 +815,14 @@ int main(int argc, FAR char *argv[])
{ {
/* Command found. Call it's handler if not NULL */ /* Command found. Call it's handler if not NULL */
if (g_nxplayer_cmds[x].pFunc != NULL) if (g_nxplayer_cmds[x].pfunc != NULL)
{ {
g_nxplayer_cmds[x].pFunc(pPlayer, arg); g_nxplayer_cmds[x].pfunc(pplayer, arg);
} }
/* Test if it is a quit command */ /* Test if it is a quit command */
if (g_nxplayer_cmds[x].pFunc == nxplayer_cmd_quit) if (g_nxplayer_cmds[x].pfunc == nxplayer_cmd_quit)
{ {
running = FALSE; running = FALSE;
} }
@ -759,9 +846,9 @@ int main(int argc, FAR char *argv[])
/* Release the NxPlayer context */ /* Release the NxPlayer context */
/* nxplayer_detach(pPlayer); */ /* nxplayer_detach(pplayer); */
nxplayer_release(pPlayer); nxplayer_release(pplayer);
return OK; return OK;
} }

@ -111,8 +111,8 @@ static int nxrecorder_opendevice(FAR struct nxrecorder_s *precorder)
/* Device supports the format. Open the device file. */ /* Device supports the format. Open the device file. */
precorder->devFd = open(precorder->device, O_RDWR); precorder->dev_fd = open(precorder->device, O_RDWR);
if (precorder->devFd == -1) if (precorder->dev_fd == -1)
{ {
int errcode = errno; int errcode = errno;
DEBUGASSERT(errcode > 0); DEBUGASSERT(errcode > 0);
@ -128,7 +128,7 @@ static int nxrecorder_opendevice(FAR struct nxrecorder_s *precorder)
/* Device not found */ /* Device not found */
auderr("ERROR: Device not found\n"); auderr("ERROR: Device not found\n");
precorder->devFd = -1; precorder->dev_fd = -1;
return -ENODEV; return -ENODEV;
} }
@ -186,10 +186,10 @@ static int nxrecorder_writebuffer(FAR struct nxrecorder_s *precorder,
* called with a buffer of data to be enqueued in the audio stream. * called with a buffer of data to be enqueued in the audio stream.
* *
* Be we may also receive an empty length buffer (with only the * Be we may also receive an empty length buffer (with only the
* AUDIO_APB_FINAL set) in the event of certain write error occurs or in the * AUDIO_APB_FINAL set) in the event of certain write error occurs or in
* event that the file was an exact multiple of the nmaxbytes size of the * the event that the file was an exact multiple of the nmaxbytes size of
* audio buffer. In that latter case, we have an end of file with no bytes * the audio buffer.
* written. * In that latter case, we have an end of file with no bytes written.
* *
* These infrequent zero length buffers have to be passed through because * These infrequent zero length buffers have to be passed through because
* the include the AUDIO_APB_FINAL flag that is needed to terminate the * the include the AUDIO_APB_FINAL flag that is needed to terminate the
@ -216,9 +216,9 @@ static int nxrecorder_enqueuebuffer(FAR struct nxrecorder_s *precorder,
bufdesc.session = precorder->session; bufdesc.session = precorder->session;
#endif #endif
bufdesc.numbytes = apb->nbytes; bufdesc.numbytes = apb->nbytes;
bufdesc.u.pBuffer = apb; bufdesc.u.pbuffer = apb;
ret = ioctl(precorder->devFd, AUDIOIOC_ENQUEUEBUFFER, ret = ioctl(precorder->dev_fd, AUDIOIOC_ENQUEUEBUFFER,
(unsigned long)&bufdesc); (unsigned long)&bufdesc);
if (ret < 0) if (ret < 0)
{ {
@ -271,7 +271,7 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
/* Query the audio device for it's preferred buffer size / qty */ /* Query the audio device for it's preferred buffer size / qty */
#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS #ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
if ((ret = ioctl(precorder->devFd, AUDIOIOC_GETBUFFERINFO, if ((ret = ioctl(precorder->dev_fd, AUDIOIOC_GETBUFFERINFO,
(unsigned long) &buf_info)) != OK) (unsigned long) &buf_info)) != OK)
{ {
/* Driver doesn't report it's buffer size. Use our default. */ /* Driver doesn't report it's buffer size. Use our default. */
@ -282,7 +282,8 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
/* Create array of pointers to buffers */ /* Create array of pointers to buffers */
pbuffers = (FAR struct ap_buffer_s **) malloc(buf_info.nbuffers * sizeof(FAR void *)); pbuffers = (FAR struct ap_buffer_s **) malloc(buf_info.nbuffers *
sizeof(FAR void *));
if (pbuffers == NULL) if (pbuffers == NULL)
{ {
/* Error allocating memory for buffer storage! */ /* Error allocating memory for buffer storage! */
@ -320,9 +321,9 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
#else #else
buf_desc.numbytes = CONFIG_AUDIO_BUFFER_NUMBYTES; buf_desc.numbytes = CONFIG_AUDIO_BUFFER_NUMBYTES;
#endif #endif
buf_desc.u.ppBuffer = &pbuffers[x]; buf_desc.u.pbuffer = &pbuffers[x];
ret = ioctl(precorder->devFd, AUDIOIOC_ALLOCBUFFER, ret = ioctl(precorder->dev_fd, AUDIOIOC_ALLOCBUFFER,
(unsigned long) &buf_desc); (unsigned long) &buf_desc);
if (ret != sizeof(buf_desc)) if (ret != sizeof(buf_desc))
{ {
@ -388,10 +389,10 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
if (running && !failed) if (running && !failed)
{ {
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
ret = ioctl(precorder->devFd, AUDIOIOC_START, ret = ioctl(precorder->dev_fd, AUDIOIOC_START,
(unsigned long) precorder->session); (unsigned long) precorder->session);
#else #else
ret = ioctl(precorder->devFd, AUDIOIOC_START, 0); ret = ioctl(precorder->dev_fd, AUDIOIOC_START, 0);
#endif #endif
if (ret < 0) if (ret < 0)
@ -410,7 +411,6 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
/* Indicate we are recording a file */ /* Indicate we are recording a file */
precorder->state = NXRECORDER_STATE_RECORDING; precorder->state = NXRECORDER_STATE_RECORDING;
} }
/* Loop until we specifically break. running == true means that we are /* Loop until we specifically break. running == true means that we are
@ -451,7 +451,7 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
/* Perform operation based on message id */ /* Perform operation based on message id */
switch (msg.msgId) switch (msg.msg_id)
{ {
/* An audio buffer is being dequeued by the driver */ /* An audio buffer is being dequeued by the driver */
@ -461,7 +461,7 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
* least one buffer. * least one buffer.
*/ */
DEBUGASSERT(msg.u.pPtr && outstanding > 0); DEBUGASSERT(msg.u.ptr && outstanding > 0);
outstanding--; outstanding--;
#endif #endif
@ -474,7 +474,7 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
{ {
/* Write the next buffer of data */ /* Write the next buffer of data */
ret = nxrecorder_writebuffer(precorder, msg.u.pPtr); ret = nxrecorder_writebuffer(precorder, msg.u.ptr);
if (ret != OK) if (ret != OK)
{ {
/* Out of data. Stay in the loop until the device sends /* Out of data. Stay in the loop until the device sends
@ -489,7 +489,7 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
else else
{ {
ret = nxrecorder_enqueuebuffer(precorder, msg.u.pPtr); ret = nxrecorder_enqueuebuffer(precorder, msg.u.ptr);
if (ret != OK) if (ret != OK)
{ {
/* There is some issue from the audio driver. /* There is some issue from the audio driver.
@ -525,15 +525,16 @@ static void *nxrecorder_recordthread(pthread_addr_t pvarg)
/* Someone wants to stop the recordback. */ /* Someone wants to stop the recordback. */
case AUDIO_MSG_STOP: case AUDIO_MSG_STOP:
/* Send a stop message to the device */ /* Send a stop message to the device */
audinfo("Stopping! outstanding=%d\n", outstanding); audinfo("Stopping! outstanding=%d\n", outstanding);
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
ioctl(precorder->devFd, AUDIOIOC_STOP, ioctl(precorder->dev_fd, AUDIOIOC_STOP,
(unsigned long) precorder->session); (unsigned long) precorder->session);
#else #else
ioctl(precorder->devFd, AUDIOIOC_STOP, 0); ioctl(precorder->dev_fd, AUDIOIOC_STOP, 0);
#endif #endif
/* Stay in the running loop (without sending more data). /* Stay in the running loop (without sending more data).
* we will need to recover our audio buffers. We will * we will need to recover our audio buffers. We will
@ -573,10 +574,12 @@ err_out:
if (pbuffers[x] != NULL) if (pbuffers[x] != NULL)
{ {
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
buf_desc.session = pPlayer->session; buf_desc.session = pplayer->session;
#endif #endif
buf_desc.u.pBuffer = pbuffers[x]; buf_desc.u.pbuffer = pbuffers[x];
ioctl(precorder->devFd, AUDIOIOC_FREEBUFFER, (unsigned long) &buf_desc); ioctl(precorder->dev_fd,
AUDIOIOC_FREEBUFFER,
(unsigned long) &buf_desc);
} }
} }
@ -593,21 +596,29 @@ err_out:
if (pbuffers[x] != NULL) if (pbuffers[x] != NULL)
{ {
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
buf_desc.session = pPlayer->session; buf_desc.session = pplayer->session;
#endif #endif
buf_desc.u.pBuffer = pbuffers[x]; buf_desc.u.pbuffer = pbuffers[x];
ioctl(precorder->devFd, AUDIOIOC_FREEBUFFER, (unsigned long) &buf_desc); ioctl(precorder->dev_fd,
AUDIOIOC_FREEBUFFER,
(unsigned long) &buf_desc);
} }
} }
#endif #endif
/* Unregister the message queue and release the session */ /* Unregister the message queue and release the session */
ioctl(precorder->devFd, AUDIOIOC_UNREGISTERMQ, (unsigned long) precorder->mq); ioctl(precorder->dev_fd,
AUDIOIOC_UNREGISTERMQ,
(unsigned long) precorder->mq);
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
ioctl(precorder->devFd, AUDIOIOC_RELEASE, (unsigned long) precorder->session); ioctl(precorder->dev_fd,
AUDIOIOC_RELEASE,
(unsigned long) precorder->session);
#else #else
ioctl(precorder->devFd, AUDIOIOC_RELEASE, 0); ioctl(precorder->dev_fd,
AUDIOIOC_RELEASE,
0);
#endif #endif
/* Cleanup */ /* Cleanup */
@ -624,8 +635,8 @@ err_out:
precorder->fd = -1; /* Clear out the FD */ precorder->fd = -1; /* Clear out the FD */
} }
close(precorder->devFd); /* Close the device */ close(precorder->dev_fd); /* Close the device */
precorder->devFd = -1; /* Mark device as closed */ precorder->dev_fd = -1; /* Mark device as closed */
mq_close(precorder->mq); /* Close the message queue */ mq_close(precorder->mq); /* Close the message queue */
mq_unlink(precorder->mqname); /* Unlink the message queue */ mq_unlink(precorder->mqname); /* Unlink the message queue */
precorder->state = NXRECORDER_STATE_IDLE; /* Go to IDLE */ precorder->state = NXRECORDER_STATE_IDLE; /* Go to IDLE */
@ -663,10 +674,10 @@ int nxrecorder_pause(FAR struct nxrecorder_s *precorder)
if (precorder->state == NXRECORDER_STATE_RECORDING) if (precorder->state == NXRECORDER_STATE_RECORDING)
{ {
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
ret = ioctl(precorder->devFd, AUDIOIOC_PAUSE, ret = ioctl(precorder->dev_fd, AUDIOIOC_PAUSE,
(unsigned long) precorder->session); (unsigned long) precorder->session);
#else #else
ret = ioctl(precorder->devFd, AUDIOIOC_PAUSE, 0); ret = ioctl(precorder->dev_fd, AUDIOIOC_PAUSE, 0);
#endif #endif
if (ret == OK) if (ret == OK)
{ {
@ -693,10 +704,10 @@ int nxrecorder_resume(FAR struct nxrecorder_s *precorder)
if (precorder->state == NXRECORDER_STATE_PAUSED) if (precorder->state == NXRECORDER_STATE_PAUSED)
{ {
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
ret = ioctl(precorder->devFd, AUDIOIOC_RESUME, ret = ioctl(precorder->dev_fd, AUDIOIOC_RESUME,
(unsigned long) precorder->session); (unsigned long) precorder->session);
#else #else
ret = ioctl(precorder->devFd, AUDIOIOC_RESUME, 0); ret = ioctl(precorder->dev_fd, AUDIOIOC_RESUME, 0);
#endif #endif
if (ret == OK) if (ret == OK)
{ {
@ -717,28 +728,28 @@ int nxrecorder_resume(FAR struct nxrecorder_s *precorder)
****************************************************************************/ ****************************************************************************/
int nxrecorder_setdevice(FAR struct nxrecorder_s *precorder, int nxrecorder_setdevice(FAR struct nxrecorder_s *precorder,
FAR const char *pDevice) FAR const char *pdevice)
{ {
int tempFd; int temp_fd;
DEBUGASSERT(precorder != NULL); DEBUGASSERT(precorder != NULL);
DEBUGASSERT(pDevice != NULL); DEBUGASSERT(pdevice != NULL);
/* Try to open the device */ /* Try to open the device */
tempFd = open(pDevice, O_RDWR); temp_fd = open(pdevice, O_RDWR);
if (tempFd == -1) if (temp_fd == -1)
{ {
/* Error opening the device */ /* Error opening the device */
return -ENOENT; return -ENOENT;
} }
close(tempFd); close(temp_fd);
/* Save the path and format capabilities of the device */ /* Save the path and format capabilities of the device */
strncpy(precorder->device, pDevice, sizeof(precorder->device)); strncpy(precorder->device, pdevice, sizeof(precorder->device));
return OK; return OK;
} }
@ -775,15 +786,15 @@ int nxrecorder_stop(FAR struct nxrecorder_s *precorder)
/* Notify the recordback thread that it needs to cancel the recordback */ /* Notify the recordback thread that it needs to cancel the recordback */
term_msg.msgId = AUDIO_MSG_STOP; term_msg.msg_id = AUDIO_MSG_STOP;
term_msg.u.data = 0; term_msg.u.data = 0;
mq_send(precorder->mq, (FAR const char *)&term_msg, sizeof(term_msg), mq_send(precorder->mq, (FAR const char *)&term_msg, sizeof(term_msg),
CONFIG_NXRECORDER_MSG_PRIO); CONFIG_NXRECORDER_MSG_PRIO);
/* Join the thread. The thread will do all the cleanup. */ /* Join the thread. The thread will do all the cleanup. */
pthread_join(precorder->recordId, &value); pthread_join(precorder->record_id, &value);
precorder->recordId = 0; precorder->record_id = 0;
return OK; return OK;
} }
@ -797,7 +808,7 @@ int nxrecorder_stop(FAR struct nxrecorder_s *precorder)
* device. * device.
* Input: * Input:
* precorder Pointer to the initialized MRecorder context * precorder Pointer to the initialized MRecorder context
* pFilename Pointer to the filename to record * pfilename Pointer to the filename to record
* nchannels channel num * nchannels channel num
* bpsampe bit width * bpsampe bit width
* samprate sample rate * samprate sample rate
@ -812,7 +823,7 @@ int nxrecorder_stop(FAR struct nxrecorder_s *precorder)
****************************************************************************/ ****************************************************************************/
int nxrecorder_recordraw(FAR struct nxrecorder_s *precorder, int nxrecorder_recordraw(FAR struct nxrecorder_s *precorder,
FAR const char *pFilename, uint8_t nchannels, FAR const char *pfilename, uint8_t nchannels,
uint8_t bpsamp, uint32_t samprate) uint8_t bpsamp, uint32_t samprate)
{ {
struct mq_attr attr; struct mq_attr attr;
@ -823,7 +834,7 @@ int nxrecorder_recordraw(FAR struct nxrecorder_s *precorder,
int ret; int ret;
DEBUGASSERT(precorder != NULL); DEBUGASSERT(precorder != NULL);
DEBUGASSERT(pFilename != NULL); DEBUGASSERT(pfilename != NULL);
if (precorder->state != NXRECORDER_STATE_IDLE) if (precorder->state != NXRECORDER_STATE_IDLE)
{ {
@ -831,17 +842,17 @@ int nxrecorder_recordraw(FAR struct nxrecorder_s *precorder,
} }
audinfo("==============================\n"); audinfo("==============================\n");
audinfo("Recording file %s\n", pFilename); audinfo("Recording file %s\n", pfilename);
audinfo("==============================\n"); audinfo("==============================\n");
/* Test that the specified file exists */ /* Test that the specified file exists */
if ((precorder->fd = open(pFilename, O_WRONLY | O_CREAT)) == -1) if ((precorder->fd = open(pfilename, O_WRONLY | O_CREAT)) == -1)
{ {
/* File not found. Test if its in the mediadir */ /* File not found. Test if its in the mediadir */
auderr("ERROR: Could not open %s\n", pFilename); auderr("ERROR: Could not open %s\n", pfilename);
return -ENOENT; return -ENOENT;
} }
/* Try to open the device */ /* Try to open the device */
@ -858,10 +869,10 @@ int nxrecorder_recordraw(FAR struct nxrecorder_s *precorder,
/* Try to reserve the device */ /* Try to reserve the device */
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
ret = ioctl(precorder->devFd, AUDIOIOC_RESERVE, ret = ioctl(precorder->dev_fd, AUDIOIOC_RESERVE,
(unsigned long)&precorder->session); (unsigned long)&precorder->session);
#else #else
ret = ioctl(precorder->devFd, AUDIOIOC_RESERVE, 0); ret = ioctl(precorder->dev_fd, AUDIOIOC_RESERVE, 0);
#endif #endif
if (ret < 0) if (ret < 0)
{ {
@ -881,7 +892,7 @@ int nxrecorder_recordraw(FAR struct nxrecorder_s *precorder,
cap_desc.caps.ac_controls.hw[0] = samprate ? samprate : 48000; cap_desc.caps.ac_controls.hw[0] = samprate ? samprate : 48000;
cap_desc.caps.ac_controls.b[3] = samprate >> 16; cap_desc.caps.ac_controls.b[3] = samprate >> 16;
cap_desc.caps.ac_controls.b[2] = bpsamp ? bpsamp : 16; cap_desc.caps.ac_controls.b[2] = bpsamp ? bpsamp : 16;
ret = ioctl(precorder->devFd, AUDIOIOC_CONFIGURE, ret = ioctl(precorder->dev_fd, AUDIOIOC_CONFIGURE,
(unsigned long)&cap_desc); (unsigned long)&cap_desc);
if (ret < 0) if (ret < 0)
{ {
@ -911,15 +922,17 @@ int nxrecorder_recordraw(FAR struct nxrecorder_s *precorder,
/* Register our message queue with the audio device */ /* Register our message queue with the audio device */
ioctl(precorder->devFd, AUDIOIOC_REGISTERMQ, (unsigned long)precorder->mq); ioctl(precorder->dev_fd,
AUDIOIOC_REGISTERMQ,
(unsigned long)precorder->mq);
/* Check if there was a previous thread and join it if there was /* Check if there was a previous thread and join it if there was
* to perform clean-up. * to perform clean-up.
*/ */
if (precorder->recordId != 0) if (precorder->record_id != 0)
{ {
pthread_join(precorder->recordId, &value); pthread_join(precorder->record_id, &value);
} }
/* Start the recordfile thread to stream the media file to the /* Start the recordfile thread to stream the media file to the
@ -938,7 +951,9 @@ int nxrecorder_recordraw(FAR struct nxrecorder_s *precorder,
*/ */
nxrecorder_reference(precorder); nxrecorder_reference(precorder);
ret = pthread_create(&precorder->recordId, &tattr, nxrecorder_recordthread, ret = pthread_create(&precorder->record_id,
&tattr,
nxrecorder_recordthread,
(pthread_addr_t) precorder); (pthread_addr_t) precorder);
if (ret != OK) if (ret != OK)
{ {
@ -948,12 +963,12 @@ int nxrecorder_recordraw(FAR struct nxrecorder_s *precorder,
/* Name the thread */ /* Name the thread */
pthread_setname_np(precorder->recordId, "recordthread"); pthread_setname_np(precorder->record_id, "recordthread");
return OK; return OK;
err_out: err_out:
close(precorder->devFd); close(precorder->dev_fd);
precorder->devFd = -1; precorder->dev_fd = -1;
err_out_nodev: err_out_nodev:
if (0 < precorder->fd) if (0 < precorder->fd)
@ -969,8 +984,8 @@ err_out_nodev:
* Name: nxrecorder_create * Name: nxrecorder_create
* *
* nxrecorder_create() allocates and initializes a nxrecorder context for * nxrecorder_create() allocates and initializes a nxrecorder context for
* use by further nxrecorder operations. This routine must be called before * use by further nxrecorder operations. This routine must be called
* to perform the create for proper reference counting. * before to perform the create for proper reference counting.
* *
* Input Parameters: None * Input Parameters: None
* *
@ -985,7 +1000,8 @@ FAR struct nxrecorder_s *nxrecorder_create(void)
/* Allocate the memory */ /* Allocate the memory */
precorder = (FAR struct nxrecorder_s *) malloc(sizeof(struct nxrecorder_s)); precorder = (FAR struct nxrecorder_s *) malloc(
sizeof(struct nxrecorder_s));
if (precorder == NULL) if (precorder == NULL)
{ {
return NULL; return NULL;
@ -994,11 +1010,11 @@ FAR struct nxrecorder_s *nxrecorder_create(void)
/* Initialize the context data */ /* Initialize the context data */
precorder->state = NXRECORDER_STATE_IDLE; precorder->state = NXRECORDER_STATE_IDLE;
precorder->devFd = -1; precorder->dev_fd = -1;
precorder->fd = -1; precorder->fd = -1;
precorder->device[0] = '\0'; precorder->device[0] = '\0';
precorder->mq = NULL; precorder->mq = NULL;
precorder->recordId = 0; precorder->record_id = 0;
precorder->crefs = 1; precorder->crefs = 1;
#ifdef CONFIG_AUDIO_MULTI_SESSION #ifdef CONFIG_AUDIO_MULTI_SESSION
@ -1044,11 +1060,11 @@ void nxrecorder_release(FAR struct nxrecorder_s *precorder)
/* Check if there was a previous thread and join it if there was */ /* Check if there was a previous thread and join it if there was */
if (precorder->recordId != 0) if (precorder->record_id != 0)
{ {
sem_post(&precorder->sem); sem_post(&precorder->sem);
pthread_join(precorder->recordId, &value); pthread_join(precorder->record_id, &value);
precorder->recordId = 0; precorder->record_id = 0;
while (sem_wait(&precorder->sem) < 0) while (sem_wait(&precorder->sem) < 0)
{ {

@ -71,7 +71,7 @@ struct mp_cmd_s
{ {
const char *cmd; /* The command text */ const char *cmd; /* The command text */
const char *arghelp; /* Text describing the args */ const char *arghelp; /* Text describing the args */
nxrecorder_func pFunc; /* Pointer to command handler */ nxrecorder_func pfunc; /* Pointer to command handler */
const char *help; /* The help text */ const char *help; /* The help text */
}; };
@ -79,27 +79,27 @@ struct mp_cmd_s
* Private Function Prototypes * Private Function Prototypes
****************************************************************************/ ****************************************************************************/
static int nxrecorder_cmd_quit(FAR struct nxrecorder_s *pRecorder, static int nxrecorder_cmd_quit(FAR struct nxrecorder_s *precorder,
FAR char *parg); FAR char *parg);
static int nxrecorder_cmd_recordraw(FAR struct nxrecorder_s *pRecorder, static int nxrecorder_cmd_recordraw(FAR struct nxrecorder_s *precorder,
FAR char *parg); FAR char *parg);
static int nxrecorder_cmd_device(FAR struct nxrecorder_s *pRecorder, static int nxrecorder_cmd_device(FAR struct nxrecorder_s *precorder,
FAR char *parg); FAR char *parg);
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
static int nxrecorder_cmd_pause(FAR struct nxrecorder_s *pRecorder, static int nxrecorder_cmd_pause(FAR struct nxrecorder_s *precorder,
FAR char *parg); FAR char *parg);
static int nxrecorder_cmd_resume(FAR struct nxrecorder_s *pRecorder, static int nxrecorder_cmd_resume(FAR struct nxrecorder_s *precorder,
FAR char *parg); FAR char *parg);
#endif #endif
#ifndef CONFIG_AUDIO_EXCLUDE_STOP #ifndef CONFIG_AUDIO_EXCLUDE_STOP
static int nxrecorder_cmd_stop(FAR struct nxrecorder_s *pRecorder, static int nxrecorder_cmd_stop(FAR struct nxrecorder_s *precorder,
FAR char *parg); FAR char *parg);
#endif #endif
#ifdef CONFIG_NXRECORDER_INCLUDE_HELP #ifdef CONFIG_NXRECORDER_INCLUDE_HELP
static int nxrecorder_cmd_help(FAR struct nxrecorder_s *pRecorder, static int nxrecorder_cmd_help(FAR struct nxrecorder_s *precorder,
FAR char *parg); FAR char *parg);
#endif #endif
@ -109,24 +109,70 @@ static int nxrecorder_cmd_help(FAR struct nxrecorder_s *pRecorder,
static const struct mp_cmd_s g_nxrecorder_cmds[] = static const struct mp_cmd_s g_nxrecorder_cmds[] =
{ {
{ "device", "devfile", nxrecorder_cmd_device, NXRECORDER_HELP_TEXT(Specify a preferred audio device) }, {
"device",
"devfile",
nxrecorder_cmd_device,
NXRECORDER_HELP_TEXT(Specify a preferred audio device)
},
#ifdef CONFIG_NXRECORDER_INCLUDE_HELP #ifdef CONFIG_NXRECORDER_INCLUDE_HELP
{ "h", "", nxrecorder_cmd_help, NXRECORDER_HELP_TEXT(Display help for commands) }, {
{ "help", "", nxrecorder_cmd_help, NXRECORDER_HELP_TEXT(Display help for commands) }, "h",
"",
nxrecorder_cmd_help,
NXRECORDER_HELP_TEXT(Display help for commands)
},
{
"help",
"",
nxrecorder_cmd_help,
NXRECORDER_HELP_TEXT(Display help for commands)
},
#endif #endif
{ "recordraw", "filename", nxrecorder_cmd_recordraw, NXRECORDER_HELP_TEXT(Record a pcm raw file) }, {
"recordraw",
"filename",
nxrecorder_cmd_recordraw,
NXRECORDER_HELP_TEXT(Record a pcm raw file)
},
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
{ "pause", "", nxrecorder_cmd_pause, NXRECORDER_HELP_TEXT(Pause record) }, {
{ "resume", "", nxrecorder_cmd_resume, NXRECORDER_HELP_TEXT(Resume record) }, "pause",
"",
nxrecorder_cmd_pause,
NXRECORDER_HELP_TEXT(Pause record)
},
{
"resume",
"",
nxrecorder_cmd_resume,
NXRECORDER_HELP_TEXT(Resume record)
},
#endif #endif
#ifndef CONFIG_AUDIO_EXCLUDE_STOP #ifndef CONFIG_AUDIO_EXCLUDE_STOP
{ "stop", "", nxrecorder_cmd_stop, NXRECORDER_HELP_TEXT(Stop record) }, {
"stop",
"",
nxrecorder_cmd_stop,
NXRECORDER_HELP_TEXT(Stop record)
},
#endif #endif
{ "q", "", nxrecorder_cmd_quit, NXRECORDER_HELP_TEXT(Exit NxRecorder) }, {
{ "quit", "", nxrecorder_cmd_quit, NXRECORDER_HELP_TEXT(Exit NxRecorder) }, "q",
"",
nxrecorder_cmd_quit,
NXRECORDER_HELP_TEXT(Exit NxRecorder)
},
{
"quit",
"",
nxrecorder_cmd_quit,
NXRECORDER_HELP_TEXT(Exit NxRecorder)
},
}; };
static const int g_nxrecorder_cmd_count = sizeof(g_nxrecorder_cmds) / sizeof(struct mp_cmd_s); static const int g_nxrecorder_cmd_count = sizeof(g_nxrecorder_cmds) /
sizeof(struct mp_cmd_s);
/**************************************************************************** /****************************************************************************
* Private Functions * Private Functions
@ -135,12 +181,12 @@ static const int g_nxrecorder_cmd_count = sizeof(g_nxrecorder_cmds) / sizeof(str
/**************************************************************************** /****************************************************************************
* Name: nxrecorder_cmd_recordraw * Name: nxrecorder_cmd_recordraw
* *
* nxrecorder_cmd_recordraw() records the raw data file using the nxrecorder * nxrecorder_cmd_recordraw() records the raw data file using the
* context. * nxrecorder context.
* *
****************************************************************************/ ****************************************************************************/
static int nxrecorder_cmd_recordraw(FAR struct nxrecorder_s *pRecorder, static int nxrecorder_cmd_recordraw(FAR struct nxrecorder_s *precorder,
FAR char *parg) FAR char *parg)
{ {
int ret; int ret;
@ -153,7 +199,11 @@ static int nxrecorder_cmd_recordraw(FAR struct nxrecorder_s *pRecorder,
/* Try to record the file specified */ /* Try to record the file specified */
ret = nxrecorder_recordraw(pRecorder, filename, channels, bpsamp, samprate); ret = nxrecorder_recordraw(precorder,
filename,
channels,
bpsamp,
samprate);
/* nxrecorder_recordfile returned values: /* nxrecorder_recordfile returned values:
* *
@ -202,12 +252,12 @@ static int nxrecorder_cmd_recordraw(FAR struct nxrecorder_s *pRecorder,
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_STOP #ifndef CONFIG_AUDIO_EXCLUDE_STOP
static int nxrecorder_cmd_stop(FAR struct nxrecorder_s *pRecorder, static int nxrecorder_cmd_stop(FAR struct nxrecorder_s *precorder,
FAR char *parg) FAR char *parg)
{ {
/* Stop the record */ /* Stop the record */
nxrecorder_stop(pRecorder); nxrecorder_stop(precorder);
return OK; return OK;
} }
@ -222,12 +272,12 @@ static int nxrecorder_cmd_stop(FAR struct nxrecorder_s *pRecorder,
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
static int nxrecorder_cmd_pause(FAR struct nxrecorder_s *pRecorder, static int nxrecorder_cmd_pause(FAR struct nxrecorder_s *precorder,
FAR char *parg) FAR char *parg)
{ {
/* Pause the record */ /* Pause the record */
nxrecorder_pause(pRecorder); nxrecorder_pause(precorder);
return OK; return OK;
} }
@ -242,12 +292,12 @@ static int nxrecorder_cmd_pause(FAR struct nxrecorder_s *pRecorder,
****************************************************************************/ ****************************************************************************/
#ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME
static int nxrecorder_cmd_resume(FAR struct nxrecorder_s *pRecorder, static int nxrecorder_cmd_resume(FAR struct nxrecorder_s *precorder,
FAR char *parg) FAR char *parg)
{ {
/* Resume the record */ /* Resume the record */
nxrecorder_resume(pRecorder); nxrecorder_resume(precorder);
return OK; return OK;
} }
@ -260,7 +310,7 @@ static int nxrecorder_cmd_resume(FAR struct nxrecorder_s *pRecorder,
* *
****************************************************************************/ ****************************************************************************/
static int nxrecorder_cmd_device(FAR struct nxrecorder_s *pRecorder, static int nxrecorder_cmd_device(FAR struct nxrecorder_s *precorder,
FAR char *parg) FAR char *parg)
{ {
int ret; int ret;
@ -268,7 +318,7 @@ static int nxrecorder_cmd_device(FAR struct nxrecorder_s *pRecorder,
/* First try to open the file directly */ /* First try to open the file directly */
ret = nxrecorder_setdevice(pRecorder, parg); ret = nxrecorder_setdevice(precorder, parg);
if (ret == -ENOENT) if (ret == -ENOENT)
{ {
/* Append the /dev/audio path and try again */ /* Append the /dev/audio path and try again */
@ -282,7 +332,7 @@ static int nxrecorder_cmd_device(FAR struct nxrecorder_s *pRecorder,
#else #else
snprintf(path, sizeof(path), "/dev/audio/%s", parg); snprintf(path, sizeof(path), "/dev/audio/%s", parg);
#endif #endif
ret = nxrecorder_setdevice(pRecorder, path); ret = nxrecorder_setdevice(precorder, path);
} }
/* Test if the device file exists */ /* Test if the device file exists */
@ -319,13 +369,13 @@ static int nxrecorder_cmd_device(FAR struct nxrecorder_s *pRecorder,
* nxrecorder_cmd_quit() terminates the application * nxrecorder_cmd_quit() terminates the application
****************************************************************************/ ****************************************************************************/
static int nxrecorder_cmd_quit(FAR struct nxrecorder_s *pRecorder, static int nxrecorder_cmd_quit(FAR struct nxrecorder_s *precorder,
FAR char *parg) FAR char *parg)
{ {
/* Stop the record if any */ /* Stop the record if any */
#ifndef CONFIG_AUDIO_EXCLUDE_STOP #ifndef CONFIG_AUDIO_EXCLUDE_STOP
nxrecorder_stop(pRecorder); nxrecorder_stop(precorder);
#endif #endif
return OK; return OK;
@ -339,7 +389,7 @@ static int nxrecorder_cmd_quit(FAR struct nxrecorder_s *pRecorder,
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_NXRECORDER_INCLUDE_HELP #ifdef CONFIG_NXRECORDER_INCLUDE_HELP
static int nxrecorder_cmd_help(FAR struct nxrecorder_s *pRecorder, static int nxrecorder_cmd_help(FAR struct nxrecorder_s *precorder,
FAR char *parg) FAR char *parg)
{ {
int len; int len;
@ -418,7 +468,7 @@ int main(int argc, FAR char *argv[])
int running; int running;
char *cmd; char *cmd;
char *arg; char *arg;
FAR struct nxrecorder_s *pRecorder; FAR struct nxrecorder_s *precorder;
printf("NxRecorder version " NXRECORDER_VER "\n"); printf("NxRecorder version " NXRECORDER_VER "\n");
printf("h for commands, q to exit\n"); printf("h for commands, q to exit\n");
@ -426,8 +476,8 @@ int main(int argc, FAR char *argv[])
/* Initialize our NxRecorder context */ /* Initialize our NxRecorder context */
pRecorder = nxrecorder_create(); precorder = nxrecorder_create();
if (pRecorder == NULL) if (precorder == NULL)
{ {
printf("Error: Out of RAM\n"); printf("Error: Out of RAM\n");
return -ENOMEM; return -ENOMEM;
@ -481,14 +531,14 @@ int main(int argc, FAR char *argv[])
{ {
/* Command found. Call it's handler if not NULL */ /* Command found. Call it's handler if not NULL */
if (g_nxrecorder_cmds[x].pFunc != NULL) if (g_nxrecorder_cmds[x].pfunc != NULL)
{ {
g_nxrecorder_cmds[x].pFunc(pRecorder, arg); g_nxrecorder_cmds[x].pfunc(precorder, arg);
} }
/* Test if it is a quit command */ /* Test if it is a quit command */
if (g_nxrecorder_cmds[x].pFunc == nxrecorder_cmd_quit) if (g_nxrecorder_cmds[x].pfunc == nxrecorder_cmd_quit)
{ {
running = FALSE; running = FALSE;
} }
@ -512,7 +562,7 @@ int main(int argc, FAR char *argv[])
/* Release the NxRecorder context */ /* Release the NxRecorder context */
nxrecorder_release(pRecorder); nxrecorder_release(precorder);
return OK; return OK;
} }