mirror of
https://github.com/apache/nuttx-apps.git
synced 2025-07-06 20:00:45 +08:00
Remove trailing whitespace
This commit is contained in:
parent
96a778cf46
commit
52464a4412
@ -96,12 +96,12 @@ typedef int (*nxplayer_func)(FAR struct nxplayer_s* pPlayer, char* pargs);
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxplayer_create
|
* Name: nxplayer_create
|
||||||
*
|
*
|
||||||
* Allocates and Initializes a NxPlayer context that is passed to all
|
* Allocates and Initializes a NxPlayer context that is passed to all
|
||||||
* nxplayer routines. The player MUST be destroyed using the
|
* nxplayer routines. The player MUST be destroyed using the
|
||||||
* nxplayer_destroy() routine since the context is reference counted.
|
* nxplayer_destroy() routine since the context is reference counted.
|
||||||
* The context can be used in a mode where the caller creates the
|
* The context can be used in a mode where the caller creates the
|
||||||
* context, starts a file playing, and then forgets about the context
|
* context, starts a file playing, and then forgets about the context
|
||||||
* and it will self free. This is because the nxplayer_playfile
|
* and it will self free. This is because the nxplayer_playfile
|
||||||
* will also create a reference to the context, so the client calling
|
* will also create a reference to the context, so the client calling
|
||||||
* nxplayer_destroy() won't actually de-allocate anything. The freeing
|
* nxplayer_destroy() won't actually de-allocate anything. The freeing
|
||||||
* will occur after the playthread has completed.
|
* will occur after the playthread has completed.
|
||||||
@ -150,10 +150,10 @@ void nxplayer_reference(FAR struct nxplayer_s *pPlayer);
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxplayer_setdevice
|
* Name: nxplayer_setdevice
|
||||||
*
|
*
|
||||||
* Sets the preferred Audio device to use with the instance of the
|
* Sets the preferred Audio device to use with the instance of the
|
||||||
* nxplayer. Without a preferred device set, the nxplayer will search
|
* nxplayer. Without a preferred device set, the nxplayer will search
|
||||||
* the audio subsystem to find a suitable device depending on the
|
* the audio subsystem to find a suitable device depending on the
|
||||||
* type of audio operation requested (i.e. an MP3 decoder device when
|
* type of audio operation requested (i.e. an MP3 decoder device when
|
||||||
* 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:
|
||||||
@ -172,13 +172,13 @@ int nxplayer_setdevice(FAR struct nxplayer_s *pPlayer, char* device);
|
|||||||
*
|
*
|
||||||
* Plays the specified media file (from the filesystem) using the
|
* Plays the specified media file (from the filesystem) using the
|
||||||
* Audio system. If a preferred device has been set, that device
|
* Audio system. If a preferred device has been set, that device
|
||||||
* will be used for the playback, otherwise the first suitable device
|
* will be used for the playback, otherwise the first suitable device
|
||||||
* 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.
|
||||||
*
|
*
|
||||||
* Returned values:
|
* Returned values:
|
||||||
@ -193,7 +193,7 @@ int nxplayer_playfile(FAR struct nxplayer_s *pPlayer, char* filename,
|
|||||||
* Name: nxplayer_stop
|
* Name: nxplayer_stop
|
||||||
*
|
*
|
||||||
* Stops current playback.
|
* Stops current playback.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* pPlayer - Pointer to the context to initialize
|
* pPlayer - Pointer to the context to initialize
|
||||||
*
|
*
|
||||||
@ -210,7 +210,7 @@ int nxplayer_stop(FAR struct nxplayer_s *pPlayer);
|
|||||||
* Name: nxplayer_pause
|
* Name: nxplayer_pause
|
||||||
*
|
*
|
||||||
* Pauses current playback.
|
* Pauses current playback.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* pPlayer - Pointer to the context to initialize
|
* pPlayer - Pointer to the context to initialize
|
||||||
*
|
*
|
||||||
@ -227,7 +227,7 @@ int nxplayer_pause(FAR struct nxplayer_s *pPlayer);
|
|||||||
* Name: nxplayer_resume
|
* Name: nxplayer_resume
|
||||||
*
|
*
|
||||||
* Resuems current playback.
|
* Resuems current playback.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* pPlayer - Pointer to the context to initialize
|
* pPlayer - Pointer to the context to initialize
|
||||||
*
|
*
|
||||||
@ -245,8 +245,8 @@ int nxplayer_resume(FAR struct nxplayer_s *pPlayer);
|
|||||||
*
|
*
|
||||||
* Sets the playback volume. The volume is represented in 1/10th of a
|
* Sets the playback volume. The volume is represented in 1/10th of a
|
||||||
* percent increments, so the range is 0-1000. A value of 10 would mean
|
* percent increments, so the range is 0-1000. A value of 10 would mean
|
||||||
* 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
|
||||||
@ -265,8 +265,8 @@ int nxplayer_setvolume(FAR struct nxplayer_s *pPlayer, uint16_t volume);
|
|||||||
*
|
*
|
||||||
* Sets the playback balance. The balance is represented in 1/10th of a
|
* Sets the playback balance. The balance is represented in 1/10th of a
|
||||||
* percent increments, so the range is 0-1000. A value of 10 would mean
|
* percent increments, so the range is 0-1000. A value of 10 would mean
|
||||||
* 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
|
||||||
@ -300,8 +300,8 @@ inline void nxplayer_setmediadir(FAR struct nxplayer_s *pPlayer, char* mediadir)
|
|||||||
* Name: nxplayer_setbass
|
* Name: nxplayer_setbass
|
||||||
*
|
*
|
||||||
* Sets the playback bass level. The bass is represented in one percent
|
* Sets the playback bass level. The bass is represented in one percent
|
||||||
* 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
|
||||||
@ -319,8 +319,8 @@ int nxplayer_setbass(FAR struct nxplayer_s *pPlayer, uint8_t bass);
|
|||||||
* Name: nxplayer_settreble
|
* Name: nxplayer_settreble
|
||||||
*
|
*
|
||||||
* Sets the playback treble level. The bass is represented in one percent
|
* Sets the playback treble level. The bass is represented in one percent
|
||||||
* 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
|
||||||
@ -339,7 +339,7 @@ int nxplayer_settreble(FAR struct nxplayer_s *pPlayer, uint8_t treble);
|
|||||||
*
|
*
|
||||||
* Performs an audio system reset, including a hardware reset on all
|
* Performs an audio system reset, including a hardware reset on all
|
||||||
* registered audio devices.
|
* registered audio devices.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* pPlayer - Pointer to the context to initialize
|
* pPlayer - Pointer to the context to initialize
|
||||||
*
|
*
|
||||||
|
@ -55,7 +55,7 @@ config NXPLAYER_FMT_FROM_EXT
|
|||||||
---help---
|
---help---
|
||||||
Compiles in extra code to determine audio format based
|
Compiles in extra code to determine audio format based
|
||||||
on the filename extension for known file types.
|
on the filename extension for known file types.
|
||||||
This feature is used if the format is not manually
|
This feature is used if the format is not manually
|
||||||
specified, and will take priority over the more lengthy
|
specified, and will take priority over the more lengthy
|
||||||
file content detection approach.
|
file content detection approach.
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ ROOTDEPPATH = --dep-path .
|
|||||||
|
|
||||||
# Common build
|
# Common build
|
||||||
|
|
||||||
VPATH =
|
VPATH =
|
||||||
|
|
||||||
all: .built
|
all: .built
|
||||||
.PHONY: context depend clean distclean
|
.PHONY: context depend clean distclean
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
#include <apps/nxplayer.h>
|
#include <apps/nxplayer.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define NXPLAYER_STATE_IDLE 0
|
#define NXPLAYER_STATE_IDLE 0
|
||||||
@ -117,7 +117,7 @@ static const struct nxplayer_ext_fmt_s g_known_ext[] = {
|
|||||||
{ "ogg", AUDIO_FMT_OGG_VORBIS }
|
{ "ogg", AUDIO_FMT_OGG_VORBIS }
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
static const int g_known_ext_count = sizeof(g_known_ext) /
|
static const int g_known_ext_count = sizeof(g_known_ext) /
|
||||||
sizeof(struct nxplayer_ext_fmt_s);
|
sizeof(struct nxplayer_ext_fmt_s);
|
||||||
#endif /* CONFIG_NXPLAYER_FMT_FROM_EXT */
|
#endif /* CONFIG_NXPLAYER_FMT_FROM_EXT */
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ static int nxplayer_opendevice(FAR struct nxplayer_s *pPlayer, int format)
|
|||||||
* format is specified by the device
|
* format is specified by the device
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (((pPlayer->prefformat & format) == 0) ||
|
if (((pPlayer->prefformat & format) == 0) ||
|
||||||
((pPlayer->preftype & AUDIO_TYPE_OUTPUT) == 0))
|
((pPlayer->preftype & AUDIO_TYPE_OUTPUT) == 0))
|
||||||
{
|
{
|
||||||
/* Format not supported by the device */
|
/* Format not supported by the device */
|
||||||
@ -223,13 +223,13 @@ static int nxplayer_opendevice(FAR struct nxplayer_s *pPlayer, int format)
|
|||||||
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(pPlayer->devFd, AUDIOIOC_GETCAPS, (unsigned long) &caps)
|
if (ioctl(pPlayer->devFd, AUDIOIOC_GETCAPS, (unsigned long) &caps)
|
||||||
== caps.ac_len)
|
== caps.ac_len)
|
||||||
{
|
{
|
||||||
/* Test if this device supports the format we want */
|
/* Test if this device supports the format we want */
|
||||||
|
|
||||||
int ac_format = caps.ac_format[0] | (caps.ac_format[1] << 8);
|
int ac_format = caps.ac_format[0] | (caps.ac_format[1] << 8);
|
||||||
if (((ac_format & format) != 0) &&
|
if (((ac_format & format) != 0) &&
|
||||||
(caps.ac_controls[0] & AUDIO_TYPE_OUTPUT))
|
(caps.ac_controls[0] & AUDIO_TYPE_OUTPUT))
|
||||||
{
|
{
|
||||||
/* Yes, it supports this format. Use this device */
|
/* Yes, it supports this format. Use this device */
|
||||||
@ -244,13 +244,13 @@ static int nxplayer_opendevice(FAR struct nxplayer_s *pPlayer, int format)
|
|||||||
close(pPlayer->devFd);
|
close(pPlayer->devFd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Close the directory */
|
/* Close the directory */
|
||||||
|
|
||||||
closedir(dirp);
|
closedir(dirp);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_NXPLAYER_INCLUDE_DEVICE_SEARCH */
|
#endif /* CONFIG_NXPLAYER_INCLUDE_DEVICE_SEARCH */
|
||||||
|
|
||||||
/* Device not found */
|
/* Device not found */
|
||||||
|
|
||||||
pPlayer->devFd = -1;
|
pPlayer->devFd = -1;
|
||||||
@ -293,11 +293,11 @@ static int nxplayer_fmtfromextension(char* pFilename)
|
|||||||
|
|
||||||
return g_known_ext[c].format;
|
return g_known_ext[c].format;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stop if we find a '/' */
|
/* Stop if we find a '/' */
|
||||||
|
|
||||||
if (pFilename[x] == '/')
|
if (pFilename[x] == '/')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -342,13 +342,13 @@ static int nxplayer_mediasearch(FAR struct nxplayer_s *pPlayer, char *pFilename,
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxplayer_enqueuebuffer
|
* Name: nxplayer_enqueuebuffer
|
||||||
*
|
*
|
||||||
* Reads the next block of data from the media file into the specified
|
* Reads the next block of data from the media file into the specified
|
||||||
* buffer and enqueues it to the audio device.
|
* buffer and enqueues it to the audio device.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static int nxplayer_enqueuebuffer(struct nxplayer_s *pPlayer,
|
static int nxplayer_enqueuebuffer(struct nxplayer_s *pPlayer,
|
||||||
struct ap_buffer_s* pBuf)
|
struct ap_buffer_s* pBuf)
|
||||||
{
|
{
|
||||||
struct audio_buf_desc_s bufdesc;
|
struct audio_buf_desc_s bufdesc;
|
||||||
@ -382,7 +382,7 @@ static int nxplayer_enqueuebuffer(struct nxplayer_s *pPlayer,
|
|||||||
#endif
|
#endif
|
||||||
bufdesc.numbytes = pBuf->nbytes;
|
bufdesc.numbytes = pBuf->nbytes;
|
||||||
bufdesc.u.pBuffer = pBuf;
|
bufdesc.u.pBuffer = pBuf;
|
||||||
ret = ioctl(pPlayer->devFd, AUDIOIOC_ENQUEUEBUFFER, (unsigned long)
|
ret = ioctl(pPlayer->devFd, AUDIOIOC_ENQUEUEBUFFER, (unsigned long)
|
||||||
&bufdesc);
|
&bufdesc);
|
||||||
if (ret >= 0)
|
if (ret >= 0)
|
||||||
ret = OK;
|
ret = OK;
|
||||||
@ -394,7 +394,7 @@ static int nxplayer_enqueuebuffer(struct nxplayer_s *pPlayer,
|
|||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxplayer_thread_playthread
|
* Name: nxplayer_thread_playthread
|
||||||
*
|
*
|
||||||
* This is the thread that reads the audio file file and enqueue's /
|
* This is the thread that reads the audio file file and enqueue's /
|
||||||
* dequeues buffers to the selected and opened audio device.
|
* dequeues buffers to the selected and opened audio device.
|
||||||
*
|
*
|
||||||
@ -467,7 +467,7 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
|
|||||||
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.ppBuffer = &pBuffers[x];
|
||||||
ret = ioctl(pPlayer->devFd, AUDIOIOC_ALLOCBUFFER,
|
ret = ioctl(pPlayer->devFd, AUDIOIOC_ALLOCBUFFER,
|
||||||
(unsigned long) &buf_desc);
|
(unsigned long) &buf_desc);
|
||||||
if (ret != sizeof(buf_desc))
|
if (ret != sizeof(buf_desc))
|
||||||
{
|
{
|
||||||
@ -480,7 +480,7 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Fill up the pipeline with enqueued buffers */
|
/* Fill up the pipeline with enqueued buffers */
|
||||||
|
|
||||||
#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
|
#ifdef CONFIG_AUDIO_DRIVER_SPECIFIC_BUFFERS
|
||||||
for (x = 0; x < buf_info.nbuffers; x++)
|
for (x = 0; x < buf_info.nbuffers; x++)
|
||||||
#else
|
#else
|
||||||
@ -500,13 +500,13 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
|
|||||||
playing = FALSE;
|
playing = FALSE;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start the audio device */
|
/* Start the audio device */
|
||||||
|
|
||||||
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
||||||
ret = ioctl(pPlayer->devFd, AUDIOIOC_START,
|
ret = ioctl(pPlayer->devFd, AUDIOIOC_START,
|
||||||
(unsigned long) pPlayer->session);
|
(unsigned long) pPlayer->session);
|
||||||
#else
|
#else
|
||||||
ret = ioctl(pPlayer->devFd, AUDIOIOC_START, 0);
|
ret = ioctl(pPlayer->devFd, AUDIOIOC_START, 0);
|
||||||
@ -562,7 +562,7 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
|
|||||||
|
|
||||||
case AUDIO_MSG_DEQUEUE:
|
case AUDIO_MSG_DEQUEUE:
|
||||||
|
|
||||||
/* Read data from the file directly into this buffer
|
/* Read data from the file directly into this buffer
|
||||||
* and re-enqueue it.
|
* and re-enqueue it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -573,7 +573,7 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
|
|||||||
{
|
{
|
||||||
/* Out of data. Stay in the loop until the
|
/* Out of data. Stay in the loop until the
|
||||||
* device sends us a COMPLETE message, but stop
|
* device sends us a COMPLETE message, but stop
|
||||||
* trying to play more data.
|
* trying to play more data.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
playing = FALSE;
|
playing = FALSE;
|
||||||
@ -588,7 +588,7 @@ static void *nxplayer_playthread(pthread_addr_t pvarg)
|
|||||||
/* Send a stop message to the device */
|
/* Send a stop message to the device */
|
||||||
|
|
||||||
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
#ifdef CONFIG_AUDIO_MULTI_SESSION
|
||||||
ioctl(pPlayer->devFd, AUDIOIOC_STOP,
|
ioctl(pPlayer->devFd, AUDIOIOC_STOP,
|
||||||
(unsigned long) pPlayer->session);
|
(unsigned long) pPlayer->session);
|
||||||
#else
|
#else
|
||||||
ioctl(pPlayer->devFd, AUDIOIOC_STOP, 0);
|
ioctl(pPlayer->devFd, AUDIOIOC_STOP, 0);
|
||||||
@ -618,9 +618,9 @@ err_out:
|
|||||||
|
|
||||||
ioctl(pPlayer->devFd, AUDIOIOC_UNREGISTERMQ, (unsigned long) pPlayer->mq);
|
ioctl(pPlayer->devFd, 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->devFd, AUDIOIOC_RELEASE, (unsigned long) pPlayer->session);
|
||||||
#else
|
#else
|
||||||
ioctl(pPlayer->devFd, AUDIOIOC_RELEASE, 0);
|
ioctl(pPlayer->devFd, AUDIOIOC_RELEASE, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Cleanup */
|
/* Cleanup */
|
||||||
@ -680,7 +680,7 @@ err_out:
|
|||||||
* actually cause the context to be freed if the creator has already
|
* actually cause the context to be freed if the creator has already
|
||||||
* abandoned (released) the context too.
|
* abandoned (released) the context too.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nxplayer_release(pPlayer);
|
nxplayer_release(pPlayer);
|
||||||
|
|
||||||
auddbg("Exit\n");
|
auddbg("Exit\n");
|
||||||
@ -905,7 +905,7 @@ 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->devFd, AUDIOIOC_PAUSE,
|
||||||
(unsigned long) pPlayer->session);
|
(unsigned long) pPlayer->session);
|
||||||
#else
|
#else
|
||||||
ret = ioctl(pPlayer->devFd, AUDIOIOC_PAUSE, 0);
|
ret = ioctl(pPlayer->devFd, AUDIOIOC_PAUSE, 0);
|
||||||
@ -933,7 +933,7 @@ 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->devFd, AUDIOIOC_RESUME,
|
||||||
(unsigned long) pPlayer->session);
|
(unsigned long) pPlayer->session);
|
||||||
#else
|
#else
|
||||||
ret = ioctl(pPlayer->devFd, AUDIOIOC_RESUME, 0);
|
ret = ioctl(pPlayer->devFd, AUDIOIOC_RESUME, 0);
|
||||||
@ -950,7 +950,7 @@ int nxplayer_resume(FAR struct nxplayer_s *pPlayer)
|
|||||||
* Name: nxplayer_setdevice
|
* Name: nxplayer_setdevice
|
||||||
*
|
*
|
||||||
* nxplayer_setdevice() sets the perferred audio device to use with the
|
* nxplayer_setdevice() sets the perferred audio device to use with the
|
||||||
* provided nxplayer context.
|
* provided nxplayer context.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
@ -972,7 +972,7 @@ int nxplayer_setdevice(FAR struct nxplayer_s *pPlayer, char* pDevice)
|
|||||||
|
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Validate it's an Audio device by issuing an AUDIOIOC_GETCAPS ioctl */
|
/* Validate it's an Audio device by issuing an AUDIOIOC_GETCAPS ioctl */
|
||||||
|
|
||||||
caps.ac_len = sizeof(caps);
|
caps.ac_len = sizeof(caps);
|
||||||
@ -981,7 +981,7 @@ int nxplayer_setdevice(FAR struct nxplayer_s *pPlayer, char* pDevice)
|
|||||||
if (ioctl(tempFd, AUDIOIOC_GETCAPS, (unsigned long) &caps) != caps.ac_len)
|
if (ioctl(tempFd, AUDIOIOC_GETCAPS, (unsigned long) &caps) != caps.ac_len)
|
||||||
{
|
{
|
||||||
/* Not an Audio device! */
|
/* Not an Audio device! */
|
||||||
|
|
||||||
close(tempFd);
|
close(tempFd);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
@ -1104,7 +1104,7 @@ int nxplayer_playfile(FAR struct nxplayer_s *pPlayer, char* pFilename, int filef
|
|||||||
{
|
{
|
||||||
#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, sizeof(path)) != OK)
|
if (nxplayer_mediasearch(pPlayer, pFilename, path, sizeof(path)) != OK)
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
#else
|
#else
|
||||||
@ -1115,7 +1115,7 @@ int nxplayer_playfile(FAR struct nxplayer_s *pPlayer, char* pFilename, int filef
|
|||||||
#else /* CONFIG_NXPLAYER_INCLUDE_MEDIADIR */
|
#else /* CONFIG_NXPLAYER_INCLUDE_MEDIADIR */
|
||||||
return -ENOENT;
|
return -ENOENT;
|
||||||
#endif /* CONFIG_NXPLAYER_INCLUDE_MEDIADIR */
|
#endif /* CONFIG_NXPLAYER_INCLUDE_MEDIADIR */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Try to determine the format of audio file based on the extension */
|
/* Try to determine the format of audio file based on the extension */
|
||||||
|
|
||||||
@ -1150,11 +1150,11 @@ int nxplayer_playfile(FAR struct nxplayer_s *pPlayer, char* pFilename, int filef
|
|||||||
|
|
||||||
goto err_out_nodev;
|
goto err_out_nodev;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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, (unsigned long)
|
ret = ioctl(pPlayer->devFd, AUDIOIOC_RESERVE, (unsigned long)
|
||||||
&pPlayer->session);
|
&pPlayer->session);
|
||||||
#else
|
#else
|
||||||
ret = ioctl(pPlayer->devFd, AUDIOIOC_RESERVE, 0);
|
ret = ioctl(pPlayer->devFd, AUDIOIOC_RESERVE, 0);
|
||||||
@ -1197,7 +1197,7 @@ int nxplayer_playfile(FAR struct nxplayer_s *pPlayer, char* pFilename, int filef
|
|||||||
pthread_join(pPlayer->playId, &value);
|
pthread_join(pPlayer->playId, &value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start the playfile thread to stream the media file to the
|
/* Start the playfile thread to stream the media file to the
|
||||||
* audio device.
|
* audio device.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1205,13 +1205,13 @@ int nxplayer_playfile(FAR struct nxplayer_s *pPlayer, char* pFilename, int filef
|
|||||||
sparam.sched_priority = sched_get_priority_max(SCHED_FIFO) - 9;
|
sparam.sched_priority = sched_get_priority_max(SCHED_FIFO) - 9;
|
||||||
pthread_attr_setschedparam(&tattr, &sparam);
|
pthread_attr_setschedparam(&tattr, &sparam);
|
||||||
|
|
||||||
/* Add a reference count to the player for the thread and start the
|
/* Add a reference count to the player for the thread and start the
|
||||||
* thread. We increment for the thread to avoid thread start-up
|
* thread. We increment for the thread to avoid thread start-up
|
||||||
* race conditions.
|
* race conditions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
nxplayer_reference(pPlayer);
|
nxplayer_reference(pPlayer);
|
||||||
ret = pthread_create(&pPlayer->playId, &tattr, nxplayer_playthread,
|
ret = pthread_create(&pPlayer->playId, &tattr, nxplayer_playthread,
|
||||||
(pthread_addr_t) pPlayer);
|
(pthread_addr_t) pPlayer);
|
||||||
if (ret != OK)
|
if (ret != OK)
|
||||||
{
|
{
|
||||||
@ -1250,8 +1250,8 @@ void nxplayer_setmediadir(FAR struct nxplayer_s *pPlayer, char *mediadir)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxplayer_create
|
* Name: nxplayer_create
|
||||||
*
|
*
|
||||||
* nxplayer_create() allocates and initializes a nxplayer context for
|
* nxplayer_create() allocates and initializes a nxplayer context for
|
||||||
* use by further nxplayer operations. This routine must be called before
|
* use by further nxplayer operations. This routine must be called before
|
||||||
* to perform the create for proper reference counting.
|
* to perform the create for proper reference counting.
|
||||||
*
|
*
|
||||||
* Input Parameters: None
|
* Input Parameters: None
|
||||||
@ -1305,7 +1305,7 @@ FAR struct nxplayer_s *nxplayer_create(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_NXPLAYER_INCLUDE_MEDIADIR
|
#ifdef CONFIG_NXPLAYER_INCLUDE_MEDIADIR
|
||||||
strncpy(pPlayer->mediadir, CONFIG_NXPLAYER_DEFAULT_MEDIADIR,
|
strncpy(pPlayer->mediadir, CONFIG_NXPLAYER_DEFAULT_MEDIADIR,
|
||||||
sizeof(pPlayer->mediadir));
|
sizeof(pPlayer->mediadir));
|
||||||
#endif
|
#endif
|
||||||
sem_init(&pPlayer->sem, 0, 1);
|
sem_init(&pPlayer->sem, 0, 1);
|
||||||
@ -1316,7 +1316,7 @@ FAR struct nxplayer_s *nxplayer_create(void)
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: nxplayer_release
|
* Name: nxplayer_release
|
||||||
*
|
*
|
||||||
* nxplayer_release() reduces the reference count by one and if it
|
* nxplayer_release() reduces the reference count by one and if it
|
||||||
* reaches zero, frees the context.
|
* reaches zero, frees the context.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
@ -1341,7 +1341,7 @@ void nxplayer_release(FAR struct nxplayer_s* pPlayer)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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->playId != 0)
|
||||||
@ -1396,7 +1396,7 @@ void nxplayer_reference(FAR struct nxplayer_s* pPlayer)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Increment the reference count */
|
/* Increment the reference count */
|
||||||
|
|
||||||
pPlayer->crefs++;
|
pPlayer->crefs++;
|
||||||
@ -1407,7 +1407,7 @@ void nxplayer_reference(FAR struct nxplayer_s* pPlayer)
|
|||||||
* Name: nxplayer_detach
|
* Name: nxplayer_detach
|
||||||
*
|
*
|
||||||
* nxplayer_detach() detaches from the playthread to make it independant
|
* nxplayer_detach() detaches from the playthread to make it independant
|
||||||
* so the caller can abandon the context while the file is still
|
* so the caller can abandon the context while the file is still
|
||||||
* being played.
|
* being played.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
@ -1432,7 +1432,7 @@ void nxplayer_detach(FAR struct nxplayer_s* pPlayer)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pPlayer->playId != NULL)
|
if (pPlayer->playId != NULL)
|
||||||
{
|
{
|
||||||
/* Do a pthread detach */
|
/* Do a pthread detach */
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
#include <apps/nxplayer.h>
|
#include <apps/nxplayer.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define NXPLAYER_VER "1.04"
|
#define NXPLAYER_VER "1.04"
|
||||||
@ -123,7 +123,7 @@ static int nxplayer_cmd_help(FAR struct nxplayer_s *pPlayer, char* parg);
|
|||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
static struct mp_cmd_s g_nxplayer_cmds[] =
|
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
|
||||||
@ -213,7 +213,7 @@ static int nxplayer_cmd_play(FAR struct nxplayer_s *pPlayer, char* parg)
|
|||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* File playing successfully */
|
/* File playing successfully */
|
||||||
@ -490,7 +490,7 @@ static int nxplayer_cmd_device(FAR struct nxplayer_s *pPlayer, char* parg)
|
|||||||
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Device set successfully */
|
/* Device set successfully */
|
||||||
@ -564,8 +564,8 @@ static int nxplayer_cmd_help(FAR struct nxplayer_s *pPlayer, char* parg)
|
|||||||
* nxplayer() reads in commands from the console using the readline
|
* nxplayer() reads in commands from the console using the readline
|
||||||
* system add-in and implemets a command-line based media player that
|
* system add-in and implemets a command-line based media player that
|
||||||
* uses the NuttX audio system to play media files read in from the
|
* uses the NuttX audio system to play media files read in from the
|
||||||
* file system. Commands are provided for setting volume, base and
|
* file system. Commands are provided for setting volume, base and
|
||||||
* other audio features, as well as for pausing and stoping the
|
* other audio features, as well as for pausing and stoping the
|
||||||
* playback.
|
* playback.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
@ -602,7 +602,7 @@ int nxplayer_main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Loop until the user exits */
|
/* Loop until the user exits */
|
||||||
|
|
||||||
running = TRUE;
|
running = TRUE;
|
||||||
while (running)
|
while (running)
|
||||||
{
|
{
|
||||||
@ -638,7 +638,7 @@ int nxplayer_main(int argc, char *argv[])
|
|||||||
if (strcmp(cmd, g_nxplayer_cmds[x].cmd) == 0)
|
if (strcmp(cmd, g_nxplayer_cmds[x].cmd) == 0)
|
||||||
{
|
{
|
||||||
/* 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);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user