Developer World
Spresense SDK Library v1.4.0-aa7f53a
audio_player_api.h
Go to the documentation of this file.
1 /****************************************************************************
2  * modules/include/audio/audio_player_api.h
3  *
4  * Copyright 2018 Sony Semiconductor Solutions Corporation
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in
14  * the documentation and/or other materials provided with the
15  * distribution.
16  * 3. Neither the name of Sony Semiconductor Solutions Corporation nor
17  * the names of its contributors may be used to endorse or promote
18  * products derived from this software without specific prior written
19  * permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
28  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  ****************************************************************************/
35 
36 #ifndef __MODULES_INCLUDE_AUDIO_AUDIO_PLAYER_API_H
37 #define __MODULES_INCLUDE_AUDIO_AUDIO_PLAYER_API_H
38 
53 /****************************************************************************
54  * Included Files
55  ****************************************************************************/
56 
57 #include <stdint.h>
58 #include <stdbool.h>
59 
63 #include "memutils/message/MsgPacket.h"
64 
65 /****************************************************************************
66  * Pre-processor Definitions
67  ****************************************************************************/
68 
69 /* Enable player feature. */
70 
71 #define AS_FEATURE_PLAYER_ENABLE
72 
73 /* Need to enable mixer feature when player feature is enabled.
74  * Because player feature always use mixer feature.
75  */
76 
77 #define AS_FEATURE_OUTPUTMIX_ENABLE
78 
84 #define LENGTH_INIT_PLAYER (9)
85 
88 #define LENGTH_INIT_SUBPLAYER (LENGTH_INIT_PLAYER)
89 
92 #define LENGTH_PLAY_PLAYER (2)
93 
96 #define LENGTH_PLAY_SUBPLAYER (LENGTH_PLAY_PLAYER)
97 
100 #define LENGTH_STOP_PLAYER (2)
101 
104 #define LENGTH_STOP_SUBPLAYER (LENGTH_STOP_PLAYER)
105 
108 #define LENGTH_CLK_RECOVERY (2)
109 
112 #define LENGTH_SET_GAIN (2)
113 
116 #define LENGTH_SENDPOSTCMD (10)
117 
120 /****************************************************************************
121  * Public Types
122  ****************************************************************************/
123 
126 typedef enum
127 {
131 
135 
139 
143 
147 
151 
152 } AsPlayerEvent;
153 
156 typedef enum
157 {
158  AS_PLAYER_ID_0 = 0,
159 
160  AS_PLAYER_ID_1,
161 
162 } AsPlayerId;
163 
166 typedef enum
167 {
171 
175 
179  AS_ACTPLAYER_NUM
181 
184 typedef enum
185 {
191 
197 
203 
207  AS_SETPLAYER_INPUTDEVICE_NUM
208 
210 
213 typedef enum
214 {
218 
222 
228  AS_SETPLAYER_OUTPUTDEVICE_NUM
230 
233 typedef enum
234 {
238 
242 
246 
249 typedef enum
250 {
254 
258 
263 
266 typedef enum
267 {
271 
275 
276 } AsPcmDataPath;
277 
280 typedef enum
281 {
282  AsNextNormalRequest = 0,
283  AsNextStopResRequest,
284 
285 } AsRequestNextType;
286 
287 /* for AsPlayerInputDeviceHdlrForRAM */
288 
294 
297 typedef struct
298 {
305 
311 
316 
319 #if defined(__CC_ARM)
320 #pragma anon_unions
321 #endif
322 
323 typedef struct
324 {
330  uint8_t input_device;
331 
337  uint8_t output_device;
338 
341  uint8_t reserved0;
342 
345  uint8_t reserved1;
346 
350 
352 
353 typedef bool (*MediaPlayerCallback)(AsPlayerEvent evtype, uint32_t result, uint32_t sub_result);
354 
355 typedef struct
356 {
360 
363  MediaPlayerCallback cb;
364 
366 
367 typedef struct
368 {
374  uint8_t active_player;
375 
378  uint8_t post0_enable;
379 
382  uint8_t post1_enable;
383 
386  uint8_t reserve0;
387 
391 
395 
396 #if !defined(__CC_ARM)
398 #else
399 } SetPlayerStsParam __attribute__((transparent_union));
400 #endif
401 
403 typedef struct
404 {
405  uint32_t reserve0;
407 
410 typedef void (*DecodeDoneCallback)(AsPcmDataParam param);
411 
412 typedef struct
413 {
419  uint8_t channel_number;
420 
426  uint8_t bit_length;
427 
433  uint8_t codec_type;
434 
437  uint8_t reserved1;
438 
444  uint32_t sampling_rate;
445 
448  char dsp_path[AS_AUDIO_DSP_PATH_LEN];
449 
451 
454 typedef union
455 {
461 
466  struct __st_pcm_msg
467  {
468  MsgQueId id;
469  uint32_t identifier;
470  } msg;
471 
472 } AsPcmDataDest;
473 
474 typedef struct
475 {
482  uint8_t pcm_path;
483 
491 
493 
496 typedef struct
497 {
503  uint8_t stop_mode;
505 
508 typedef struct
509 {
514  uint8_t l_gain;
515 
520  uint8_t r_gain;
522 
525 typedef struct
526 {
532  uint8_t type;
533 
535 
538 typedef struct
539 {
544  uint8_t player_id;
545 
546  union
547  {
548  AsActivatePlayer act_param;
549 
556 
562 
568 
569  AsRequestNextParam req_next_param;
570 
576 
582  };
583 } PlayerCommand;
584 
587 typedef struct
588 {
591  uint8_t player;
592 
595  uint8_t mng;
596 
599  uint8_t mixer;
600 
603  uint8_t dsp;
605 
608 typedef struct
609 {
613 
617 
621 
626 
627 
628 typedef struct{
631  uint8_t es;
632 
635  uint8_t pcm;
636 
639  uint8_t dsp;
640 
643  uint8_t src_work;
645 
648 typedef struct
649 {
653 
657 
659 
662 typedef struct
663 {
667 
671 
673 
674 /****************************************************************************
675  * Public Data
676  ****************************************************************************/
677 
678 /****************************************************************************
679  * Inline Functions
680  ****************************************************************************/
681 
682 /****************************************************************************
683  * Public Function Prototypes
684  ****************************************************************************/
685 
697 
710  FAR AsCreatePlayerParam_t *param,
711  AudioAttentionCb attcb);
712 
714  FAR AsCreatePlayerParams_t *param,
715  AudioAttentionCb attcb);
716 
717 __attribute__((deprecated(
718  "\n \
719  \n Deprecated create API is used. \
720  \n Use \"AS_CreatePlayerMulti(AsPlayerId, \
721  \n AsCreatePlayerParam_t *, \
722  \n AudioAttentionCb)\". \
723  \n \
724  \n")))
726 
728 
738 bool AS_ActivatePlayer(AsPlayerId id, FAR AsActivatePlayer *actparam);
739 
749 bool AS_InitPlayer(AsPlayerId id, FAR AsInitPlayerParam *initparam);
750 
760 bool AS_PlayPlayer(AsPlayerId id, FAR AsPlayPlayerParam *playparam);
761 
771 bool AS_StopPlayer(AsPlayerId id, FAR AsStopPlayerParam *stopparam);
772 
782 bool AS_SetPlayerGain(AsPlayerId id, FAR AsSetGainParam *gainparam);
783 
794 
804 bool AS_DeactivatePlayer(AsPlayerId id, FAR AsDeactivatePlayer *deactparam);
805 
813 bool AS_DeletePlayer(AsPlayerId id);
814 
823 
824 #endif /* __MODULES_INCLUDE_AUDIO_AUDIO_PLAYER_API_H */
825 
uint16_t id
Definition: video.h:77
bool AS_checkAvailabilityMediaPlayer(AsPlayerId id)
Check availability of MediaPlayer.
AsStopPlayerStopMode
Definition: audio_player_api.h:233
MemMgrLite::PoolId es
[in] Memory pool id of es data
Definition: audio_player_api.h:612
bool AS_PlayPlayer(AsPlayerId id, FAR AsPlayPlayerParam *playparam)
Play audio (sub)player.
uint8_t pcm
[in] Memory pool id of pcm data
Definition: audio_player_api.h:635
uint8_t input_device
[in] Select Player Input device
Definition: audio_player_api.h:330
uint8_t player_id
[in] target player id Use AsPlayerId enum type
Definition: audio_player_api.h:544
Definition: audio_common_defs.h:613
CXD5602 Audio Object Layer API.
void * simple_fifo_handler
[in] Set SimpleFifo handler
Definition: audio_player_api.h:304
uint8_t mixer
[in] Message queue id of output mixer
Definition: audio_player_api.h:599
AsSetPlayerOutputDevice
Definition: audio_player_api.h:213
uint8_t src_work
[in] Memory pool id of src work area
Definition: audio_player_api.h:643
AudioSimpleFifoReadDoneCallbackFunction callback_function
[in] Set callback function, Call this function when SimpleFifo was read
Definition: audio_player_api.h:310
bool AS_DeactivatePlayer(AsPlayerId id, FAR AsDeactivatePlayer *deactparam)
Deactivate (sub)player.
bool AS_RequestNextPlayerProcess(AsPlayerId id, FAR AsRequestNextParam *nextparam)
Request next process(decode) to (sub)player.
AsActivatePlayerParam player0
[in] Activation parameters for player0
Definition: audio_player_api.h:390
uint8_t reserve0
[in] reserved
Definition: audio_player_api.h:386
Activate sub player.
Definition: audio_player_api.h:174
Definition: audio_player_api.h:367
AsPlayerMsgQueId_t msgq_id
[in] ID for sending messages to each function
Definition: audio_player_api.h:666
bool AS_DeletePlayer(AsPlayerId id)
Deactivate audio main player.
Definition: audio_player_api.h:608
DecodeDoneCallback callback
[in] Decoded PCM notify callback
Definition: audio_player_api.h:460
uint8_t active_player
[in] Select activate player
Definition: audio_player_api.h:374
Play.
Definition: audio_player_api.h:138
uint8_t dsp
[in] Memory pool id of dsp command data
Definition: audio_player_api.h:639
uint8_t es
[in] Memory pool id of es data
Definition: audio_player_api.h:631
[in] Decoded PCM notify message
Definition: audio_player_api.h:466
uint8_t output_device
[in] Select Player Output device
Definition: audio_player_api.h:337
void(* AudioAttentionCb)(const ErrorAttentionParam *attparam)
Definition: audio_common_defs.h:721
uint8_t channel_number
[in] Select InitPlayer input channels
Definition: audio_player_api.h:419
Wait end of es.
Definition: audio_player_api.h:241
Definition: audio_player_api.h:508
bool AS_SetPlayerGain(AsPlayerId id, FAR AsSetGainParam *gainparam)
Set audio gain level of (sub)player.
Definition: audio_player_api.h:628
AsPlayPlayerParam play_param
[in] for PlayPlayer (header.command_code==AUDCMD_PLAYPLAYER)
Definition: audio_player_api.h:561
Adjust to the - direction.
Definition: audio_player_api.h:261
Definition: audio_player_api.h:412
I2S Output.
Definition: audio_player_api.h:221
Memory Handler API.
Activate main player.
Definition: audio_player_api.h:170
#define AS_AUDIO_DSP_PATH_LEN
Definition: audio_common_defs.h:604
AsSetGainParam set_gain_param
[in] for Adjust sound period (header.command_code==AUDCMD_CLKRECOVERY)
Definition: audio_player_api.h:575
void(* AudioSimpleFifoReadDoneCallbackFunction)(uint32_t size)
Definition: audio_player_api.h:293
Deactivate.
Definition: audio_player_api.h:146
MemMgrLite::PoolId pcm
[in] Memory pool id of pcm data
Definition: audio_player_api.h:616
eMMC FileSystem
Definition: audio_player_api.h:190
AsSetPlayerInputDevice
Definition: audio_player_api.h:184
AsClkRecoveryDirection
Definition: audio_player_api.h:249
MemMgrLite::PoolId src_work
[in] Memory pool id of src work area
Definition: audio_player_api.h:624
CXD5602 Audio Common Definitions.
Definition: audio_player_api.h:648
Definition: audio_player_api.h:538
uint8_t stop_mode
[in] Stop mode which indicates immediate or wait end of es
Definition: audio_player_api.h:503
AsPlayerPoolId_old_t pool_id
[in] ID of memory pool for processing data
Definition: audio_player_api.h:656
uint8_t pcm_path
[in] Decoded PCM data path
Definition: audio_player_api.h:482
AsPlayerEvent
Definition: audio_player_api.h:126
Decodec PCM data will be replied by callback.
Definition: audio_player_api.h:270
Definition: MemMgrTypes.h:88
__attribute__((deprecated("\eprecated attention callback type is used. \ \lease use \udioAttentionCb\as callback type. \ \))) int AS_CreateAudioManager(AudioSubSystemIDs ids
Activate AudioSubSystem[Deprecated] This API is to make it compatible with old application. Will delete most application seems to migrate to new API.
A2DP Media Packet FIFO.
Definition: audio_player_api.h:227
CXD5247 SP/HP.
Definition: audio_player_api.h:217
RAM.
Definition: audio_player_api.h:206
MemMgrLite::PoolId dsp
[in] Memory pool id of dsp command data
Definition: audio_player_api.h:620
void(* DecodeDoneCallback)(AsPcmDataParam param)
Definition: audio_player_api.h:410
Activate.
Definition: audio_player_api.h:130
Definition: audio_player_api.h:323
uint8_t dsp
[in] Message queue id of DSP
Definition: audio_player_api.h:603
Adjust to the + direction.
Definition: audio_player_api.h:253
Definition: audio_player_api.h:662
bool AS_StopPlayer(AsPlayerId id, FAR AsStopPlayerParam *stopparam)
Stop audio (sub)player.
Definition: audio_player_api.h:297
bool AS_ActivatePlayer(AsPlayerId id, FAR AsActivatePlayer *actparam)
Activate audio (sub)player.
uint8_t reserved1
[in] reserved
Definition: audio_player_api.h:345
Set gain.
Definition: audio_player_api.h:150
AsPlayerId
Definition: audio_player_api.h:156
AsPcmDataDest pcm_dest
[in] Decode done callback
Definition: audio_player_api.h:490
Normal stop (immediately stop)
Definition: audio_player_api.h:237
uint8_t codec_type
[in] Select InitPlayer codec type
Definition: audio_player_api.h:433
bool AS_InitPlayer(AsPlayerId id, FAR AsInitPlayerParam *initparam)
Initialize audio (sub)player.
Definition: audio_player_api.h:525
No adjust.
Definition: audio_player_api.h:257
uint8_t bit_length
[in] Select InitPlayer input bit length
Definition: audio_player_api.h:426
I2S input.
Definition: audio_player_api.h:202
AsSetActivatePlayer
Definition: audio_player_api.h:166
bool AS_CreatePlayer(AsPlayerId id, FAR AsCreatePlayerParam_t *param)
Create audio main player.
uint8_t type
[in] Request type
Definition: audio_player_api.h:532
AsActivatePlayerParam param
[in] MediaPlayer activation parameters
Definition: audio_player_api.h:359
uint8_t mng
[in] Message queue id of audio_manager
Definition: audio_player_api.h:595
uint16_t size
Definition: video.h:77
Definition: audio_player_api.h:587
uint8_t player
[in] Message queue id of player
Definition: audio_player_api.h:591
Activate main & sub player.
Definition: audio_player_api.h:178
uint32_t sampling_rate
[in] Select sampling rate of es data
Definition: audio_player_api.h:444
Definition: audio_player_api.h:496
uint8_t post1_enable
[in] post DSP 1 enable
Definition: audio_player_api.h:382
AsInitPlayerParam init_param
[in] for InitPlayer (header.command_code==AUDCMD_INITPLAYER) (Object Interface==AS_InitPlayer) ...
Definition: audio_player_api.h:555
Init.
Definition: audio_player_api.h:134
uint8_t post0_enable
[in] post DSP 0 enable
Definition: audio_player_api.h:378
AsPlayerMsgQueId_t msgq_id
[in] ID for sending messages to each function
Definition: audio_player_api.h:652
Decodec PCM data will be sent automatically.
Definition: audio_player_api.h:274
Definition: audio_player_api.h:454
Definition: audio_player_api.h:355
Forcibly stop at system failure.
Definition: audio_player_api.h:244
uint8_t reserved1
[in] reserved
Definition: audio_player_api.h:437
AsPlayerPoolId_t pool_id
[in] ID of memory pool for processing data
Definition: audio_player_api.h:670
Stop.
Definition: audio_player_api.h:142
AsStopPlayerParam stop_param
[in] for StopPlayer (header.command_code==AUDCMD_STOPPLAYER)
Definition: audio_player_api.h:567
AsActivatePlayerParam player1
[in] Activation parameters for player1
Definition: audio_player_api.h:394
uint8_t l_gain
[in] Gain level Lch Percentage 0 - 200 %
Definition: audio_player_api.h:514
uint8_t r_gain
[in] Gain level Rch Percentage 0 - 200 %
Definition: audio_player_api.h:520
AsPlayerInputDeviceHdlrForRAM * ram_handler
[in] Set Player Input device handler, refer following.
Definition: audio_player_api.h:349
AsPcmDataPath
Definition: audio_player_api.h:266
uint32_t notification_threshold_size
[in] Read size notification threshold
Definition: audio_player_api.h:314
uint8_t reserved0
[in] reserved
Definition: audio_player_api.h:341
A2DP Media Packet FIFO.
Definition: audio_player_api.h:196
Definition: audio_player_api.h:474
bool AS_CreatePlayerMulti(AsPlayerId id, FAR AsCreatePlayerParam_t *param, AudioAttentionCb attcb)
Create audio main player using memory pool in work area of src.
Definition: audio_player_api.h:403
AsDeactivatePlayer deact_param
[in] for deactivate player (header.command_code==AUDCMD_SETREADYSTATUS)
Definition: audio_player_api.h:581