Developer World
Spresense SDK Library v1.4.2-3df2e9d
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  AS_PLAYER_ID_NUM,
163 
164 } AsPlayerId;
165 
168 typedef enum
169 {
173 
177 
181  AS_ACTPLAYER_NUM
183 
186 typedef enum
187 {
193 
199 
205 
209  AS_SETPLAYER_INPUTDEVICE_NUM
210 
212 
215 typedef enum
216 {
220 
224 
230  AS_SETPLAYER_OUTPUTDEVICE_NUM
232 
235 typedef enum
236 {
240 
244 
248 
251 typedef enum
252 {
256 
260 
265 
268 typedef enum
269 {
273 
277 
278 } AsPcmDataPath;
279 
282 typedef enum
283 {
284  AsNextNormalRequest = 0,
285  AsNextStopResRequest,
286 
287 } AsRequestNextType;
288 
289 /* for AsPlayerInputDeviceHdlrForRAM */
290 
296 
299 typedef struct
300 {
307 
313 
318 
321 #if defined(__CC_ARM)
322 #pragma anon_unions
323 #endif
324 
325 typedef struct
326 {
332  uint8_t input_device;
333 
339  uint8_t output_device;
340 
343  uint8_t reserved0;
344 
347  uint8_t reserved1;
348 
352 
354 
355 typedef bool (*MediaPlayerCallback)(AsPlayerEvent evtype, uint32_t result, uint32_t sub_result);
356 
357 typedef struct
358 {
362 
365  MediaPlayerCallback cb;
366 
368 
369 typedef struct
370 {
376  uint8_t active_player;
377 
380  uint8_t post0_enable;
381 
384  uint8_t post1_enable;
385 
388  uint8_t reserve0;
389 
393 
397 
398 #if !defined(__CC_ARM)
400 #else
401 } SetPlayerStsParam __attribute__((transparent_union));
402 #endif
403 
405 typedef struct
406 {
407  uint32_t reserve0;
409 
412 typedef void (*DecodeDoneCallback)(AsPcmDataParam param);
413 
414 typedef struct
415 {
421  uint8_t channel_number;
422 
428  uint8_t bit_length;
429 
435  uint8_t codec_type;
436 
439  uint8_t reserved1;
440 
446  uint32_t sampling_rate;
447 
450  char dsp_path[AS_AUDIO_DSP_PATH_LEN];
451 
453 
456 typedef union
457 {
463 
468  struct __st_pcm_msg
469  {
470  MsgQueId id;
471  uint32_t identifier;
472  } msg;
473 
474 } AsPcmDataDest;
475 
476 typedef struct
477 {
484  uint8_t pcm_path;
485 
493 
495 
498 typedef struct
499 {
505  uint8_t stop_mode;
507 
510 typedef struct
511 {
516  uint8_t l_gain;
517 
522  uint8_t r_gain;
524 
527 typedef struct
528 {
534  uint8_t type;
535 
537 
540 typedef struct
541 {
546  uint8_t player_id;
547 
548  union
549  {
550  AsActivatePlayer act_param;
551 
558 
564 
570 
571  AsRequestNextParam req_next_param;
572 
578 
584  };
585 } PlayerCommand;
586 
589 typedef struct
590 {
593  uint8_t player;
594 
597  uint8_t mng;
598 
601  uint8_t mixer;
602 
605  uint8_t dsp;
607 
610 typedef struct
611 {
615 
619 
623 
628 
629 
630 typedef struct{
633  uint8_t es;
634 
637  uint8_t pcm;
638 
641  uint8_t dsp;
642 
645  uint8_t src_work;
647 
650 typedef struct
651 {
655 
659 
661 
664 typedef struct
665 {
669 
673 
675 
676 /****************************************************************************
677  * Public Data
678  ****************************************************************************/
679 
680 /****************************************************************************
681  * Inline Functions
682  ****************************************************************************/
683 
684 /****************************************************************************
685  * Public Function Prototypes
686  ****************************************************************************/
687 
699 
712  FAR AsCreatePlayerParam_t *param,
713  AudioAttentionCb attcb);
714 
716  FAR AsCreatePlayerParams_t *param,
717  AudioAttentionCb attcb);
718 
719 __attribute__((deprecated(
720  "\n \
721  \n Deprecated create API is used. \
722  \n Use \"AS_CreatePlayerMulti(AsPlayerId, \
723  \n AsCreatePlayerParam_t *, \
724  \n AudioAttentionCb)\". \
725  \n \
726  \n")))
728 
730 
740 bool AS_ActivatePlayer(AsPlayerId id, FAR AsActivatePlayer *actparam);
741 
751 bool AS_InitPlayer(AsPlayerId id, FAR AsInitPlayerParam *initparam);
752 
762 bool AS_PlayPlayer(AsPlayerId id, FAR AsPlayPlayerParam *playparam);
763 
773 bool AS_StopPlayer(AsPlayerId id, FAR AsStopPlayerParam *stopparam);
774 
784 bool AS_SetPlayerGain(AsPlayerId id, FAR AsSetGainParam *gainparam);
785 
796 
806 bool AS_DeactivatePlayer(AsPlayerId id, FAR AsDeactivatePlayer *deactparam);
807 
815 bool AS_DeletePlayer(AsPlayerId id);
816 
825 
826 #endif /* __MODULES_INCLUDE_AUDIO_AUDIO_PLAYER_API_H */
827 
uint16_t id
Definition: video.h:77
bool AS_checkAvailabilityMediaPlayer(AsPlayerId id)
Check availability of MediaPlayer.
AsStopPlayerStopMode
Definition: audio_player_api.h:235
MemMgrLite::PoolId es
[in] Memory pool id of es data
Definition: audio_player_api.h:614
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:637
uint8_t input_device
[in] Select Player Input device
Definition: audio_player_api.h:332
uint8_t player_id
[in] target player id Use AsPlayerId enum type
Definition: audio_player_api.h:546
Definition: audio_common_defs.h:613
CXD5602 Audio Object Layer API.
void * simple_fifo_handler
[in] Set SimpleFifo handler
Definition: audio_player_api.h:306
uint8_t mixer
[in] Message queue id of output mixer
Definition: audio_player_api.h:601
AsSetPlayerOutputDevice
Definition: audio_player_api.h:215
uint8_t src_work
[in] Memory pool id of src work area
Definition: audio_player_api.h:645
AudioSimpleFifoReadDoneCallbackFunction callback_function
[in] Set callback function, Call this function when SimpleFifo was read
Definition: audio_player_api.h:312
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:392
uint8_t reserve0
[in] reserved
Definition: audio_player_api.h:388
Activate sub player.
Definition: audio_player_api.h:176
Definition: audio_player_api.h:369
AsPlayerMsgQueId_t msgq_id
[in] ID for sending messages to each function
Definition: audio_player_api.h:668
bool AS_DeletePlayer(AsPlayerId id)
Deactivate audio main player.
Definition: audio_player_api.h:610
DecodeDoneCallback callback
[in] Decoded PCM notify callback
Definition: audio_player_api.h:462
uint8_t active_player
[in] Select activate player
Definition: audio_player_api.h:376
Play.
Definition: audio_player_api.h:138
uint8_t dsp
[in] Memory pool id of dsp command data
Definition: audio_player_api.h:641
uint8_t es
[in] Memory pool id of es data
Definition: audio_player_api.h:633
[in] Decoded PCM notify message
Definition: audio_player_api.h:468
uint8_t output_device
[in] Select Player Output device
Definition: audio_player_api.h:339
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:421
Wait end of es.
Definition: audio_player_api.h:243
Definition: audio_player_api.h:510
bool AS_SetPlayerGain(AsPlayerId id, FAR AsSetGainParam *gainparam)
Set audio gain level of (sub)player.
Definition: audio_player_api.h:630
AsPlayPlayerParam play_param
[in] for PlayPlayer (header.command_code==AUDCMD_PLAYPLAYER)
Definition: audio_player_api.h:563
Adjust to the - direction.
Definition: audio_player_api.h:263
Definition: audio_player_api.h:414
I2S Output.
Definition: audio_player_api.h:223
Memory Handler API.
Activate main player.
Definition: audio_player_api.h:172
#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:577
void(* AudioSimpleFifoReadDoneCallbackFunction)(uint32_t size)
Definition: audio_player_api.h:295
Deactivate.
Definition: audio_player_api.h:146
MemMgrLite::PoolId pcm
[in] Memory pool id of pcm data
Definition: audio_player_api.h:618
eMMC FileSystem
Definition: audio_player_api.h:192
AsSetPlayerInputDevice
Definition: audio_player_api.h:186
AsClkRecoveryDirection
Definition: audio_player_api.h:251
MemMgrLite::PoolId src_work
[in] Memory pool id of src work area
Definition: audio_player_api.h:626
CXD5602 Audio Common Definitions.
Definition: audio_player_api.h:650
Definition: audio_player_api.h:540
uint8_t stop_mode
[in] Stop mode which indicates immediate or wait end of es
Definition: audio_player_api.h:505
AsPlayerPoolId_old_t pool_id
[in] ID of memory pool for processing data
Definition: audio_player_api.h:658
uint8_t pcm_path
[in] Decoded PCM data path
Definition: audio_player_api.h:484
AsPlayerEvent
Definition: audio_player_api.h:126
Decodec PCM data will be replied by callback.
Definition: audio_player_api.h:272
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:229
CXD5247 SP/HP.
Definition: audio_player_api.h:219
RAM.
Definition: audio_player_api.h:208
MemMgrLite::PoolId dsp
[in] Memory pool id of dsp command data
Definition: audio_player_api.h:622
void(* DecodeDoneCallback)(AsPcmDataParam param)
Definition: audio_player_api.h:412
Activate.
Definition: audio_player_api.h:130
Definition: audio_player_api.h:325
uint8_t dsp
[in] Message queue id of DSP
Definition: audio_player_api.h:605
Adjust to the + direction.
Definition: audio_player_api.h:255
Definition: audio_player_api.h:664
bool AS_StopPlayer(AsPlayerId id, FAR AsStopPlayerParam *stopparam)
Stop audio (sub)player.
Definition: audio_player_api.h:299
bool AS_ActivatePlayer(AsPlayerId id, FAR AsActivatePlayer *actparam)
Activate audio (sub)player.
uint8_t reserved1
[in] reserved
Definition: audio_player_api.h:347
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:492
Normal stop (immediately stop)
Definition: audio_player_api.h:239
uint8_t codec_type
[in] Select InitPlayer codec type
Definition: audio_player_api.h:435
bool AS_InitPlayer(AsPlayerId id, FAR AsInitPlayerParam *initparam)
Initialize audio (sub)player.
Definition: audio_player_api.h:527
No adjust.
Definition: audio_player_api.h:259
uint8_t bit_length
[in] Select InitPlayer input bit length
Definition: audio_player_api.h:428
I2S input.
Definition: audio_player_api.h:204
AsSetActivatePlayer
Definition: audio_player_api.h:168
bool AS_CreatePlayer(AsPlayerId id, FAR AsCreatePlayerParam_t *param)
Create audio main player.
uint8_t type
[in] Request type
Definition: audio_player_api.h:534
AsActivatePlayerParam param
[in] MediaPlayer activation parameters
Definition: audio_player_api.h:361
uint8_t mng
[in] Message queue id of audio_manager
Definition: audio_player_api.h:597
uint16_t size
Definition: video.h:77
Definition: audio_player_api.h:589
uint8_t player
[in] Message queue id of player
Definition: audio_player_api.h:593
Activate main & sub player.
Definition: audio_player_api.h:180
uint32_t sampling_rate
[in] Select sampling rate of es data
Definition: audio_player_api.h:446
Definition: audio_player_api.h:498
uint8_t post1_enable
[in] post DSP 1 enable
Definition: audio_player_api.h:384
AsInitPlayerParam init_param
[in] for InitPlayer (header.command_code==AUDCMD_INITPLAYER) (Object Interface==AS_InitPlayer) ...
Definition: audio_player_api.h:557
Init.
Definition: audio_player_api.h:134
uint8_t post0_enable
[in] post DSP 0 enable
Definition: audio_player_api.h:380
AsPlayerMsgQueId_t msgq_id
[in] ID for sending messages to each function
Definition: audio_player_api.h:654
Decodec PCM data will be sent automatically.
Definition: audio_player_api.h:276
Definition: audio_player_api.h:456
Definition: audio_player_api.h:357
Forcibly stop at system failure.
Definition: audio_player_api.h:246
uint8_t reserved1
[in] reserved
Definition: audio_player_api.h:439
AsPlayerPoolId_t pool_id
[in] ID of memory pool for processing data
Definition: audio_player_api.h:672
Stop.
Definition: audio_player_api.h:142
AsStopPlayerParam stop_param
[in] for StopPlayer (header.command_code==AUDCMD_STOPPLAYER)
Definition: audio_player_api.h:569
AsActivatePlayerParam player1
[in] Activation parameters for player1
Definition: audio_player_api.h:396
uint8_t l_gain
[in] Gain level Lch Percentage 0 - 200 %
Definition: audio_player_api.h:516
uint8_t r_gain
[in] Gain level Rch Percentage 0 - 200 %
Definition: audio_player_api.h:522
AsPlayerInputDeviceHdlrForRAM * ram_handler
[in] Set Player Input device handler, refer following.
Definition: audio_player_api.h:351
AsPcmDataPath
Definition: audio_player_api.h:268
uint32_t notification_threshold_size
[in] Read size notification threshold
Definition: audio_player_api.h:316
uint8_t reserved0
[in] reserved
Definition: audio_player_api.h:343
A2DP Media Packet FIFO.
Definition: audio_player_api.h:198
Definition: audio_player_api.h:476
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:405
AsDeactivatePlayer deact_param
[in] for deactivate player (header.command_code==AUDCMD_SETREADYSTATUS)
Definition: audio_player_api.h:583