Developer World
Spresense SDK Library v2.0.1-3834d32
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 
261 } AsPcmDataPath;
262 
265 typedef enum
266 {
267  AsNextNormalRequest = 0,
268  AsNextStopResRequest,
269 
270 } AsRequestNextType;
271 
272 /* for AsPlayerInputDeviceHdlrForRAM */
273 
279 
282 typedef struct
283 {
290 
296 
301 
304 #if defined(__CC_ARM)
305 #pragma anon_unions
306 #endif
307 
308 typedef struct
309 {
315  uint8_t input_device;
316 
322  uint8_t output_device;
323 
326  uint8_t reserved0;
327 
330  uint8_t reserved1;
331 
335 
337 
338 typedef bool (*MediaPlayerCallback)(AsPlayerEvent evtype, uint32_t result, uint32_t sub_result);
339 
340 typedef struct
341 {
345 
348  MediaPlayerCallback cb;
349 
351 
352 typedef struct
353 {
359  uint8_t active_player;
360 
363  uint8_t post0_enable;
364 
367  uint8_t post1_enable;
368 
371  uint8_t reserve0;
372 
376 
380 
381 #if !defined(__CC_ARM)
383 #else
384 } SetPlayerStsParam __attribute__((transparent_union));
385 #endif
386 
388 typedef struct
389 {
390  uint32_t reserve0;
392 
395 typedef void (*DecodeDoneCallback)(AsPcmDataParam param);
396 
397 typedef struct
398 {
404  uint8_t channel_number;
405 
411  uint8_t bit_length;
412 
418  uint8_t codec_type;
419 
422  uint8_t reserved1;
423 
429  uint32_t sampling_rate;
430 
433  char dsp_path[AS_AUDIO_DSP_PATH_LEN];
434 
436 
439 typedef union
440 {
446 
451  struct __st_pcm_msg
452  {
453  MsgQueId id;
454  uint32_t identifier;
455  } msg;
456 
457 } AsPcmDataDest;
458 
459 typedef struct
460 {
467  uint8_t pcm_path;
468 
476 
478 
481 typedef struct
482 {
488  uint8_t stop_mode;
490 
493 typedef struct
494 {
499  uint8_t l_gain;
500 
505  uint8_t r_gain;
507 
510 typedef struct
511 {
517  uint8_t type;
518 
520 
523 typedef struct
524 {
529  uint8_t player_id;
530 
531  union
532  {
533  AsActivatePlayer act_param;
534 
541 
547 
553 
554  AsRequestNextParam req_next_param;
555 
561 
567  };
568 } PlayerCommand;
569 
572 typedef struct
573 {
576  uint8_t player;
577 
580  uint8_t mng;
581 
584  uint8_t mixer;
585 
588  uint8_t dsp;
590 
593 typedef struct
594 {
598 
602 
606 
611 
612 
613 typedef struct{
616  uint8_t es;
617 
620  uint8_t pcm;
621 
624  uint8_t dsp;
625 
628  uint8_t src_work;
630 
633 typedef struct
634 {
638 
642 
644 
647 typedef struct
648 {
652 
656 
658 
659 /****************************************************************************
660  * Public Data
661  ****************************************************************************/
662 
663 /****************************************************************************
664  * Inline Functions
665  ****************************************************************************/
666 
667 /****************************************************************************
668  * Public Function Prototypes
669  ****************************************************************************/
670 
682 
695  FAR AsCreatePlayerParam_t *param,
696  AudioAttentionCb attcb);
697 
699  FAR AsCreatePlayerParams_t *param,
700  AudioAttentionCb attcb);
701 
702 __attribute__((deprecated(
703  "\n \
704  \n Deprecated create API is used. \
705  \n Use \"AS_CreatePlayerMulti(AsPlayerId, \
706  \n AsCreatePlayerParam_t *, \
707  \n AudioAttentionCb)\". \
708  \n \
709  \n")))
711 
713 
723 bool AS_ActivatePlayer(AsPlayerId id, FAR AsActivatePlayer *actparam);
724 
734 bool AS_InitPlayer(AsPlayerId id, FAR AsInitPlayerParam *initparam);
735 
745 bool AS_PlayPlayer(AsPlayerId id, FAR AsPlayPlayerParam *playparam);
746 
756 bool AS_StopPlayer(AsPlayerId id, FAR AsStopPlayerParam *stopparam);
757 
767 bool AS_SetPlayerGain(AsPlayerId id, FAR AsSetGainParam *gainparam);
768 
779 
789 bool AS_DeactivatePlayer(AsPlayerId id, FAR AsDeactivatePlayer *deactparam);
790 
798 bool AS_DeletePlayer(AsPlayerId id);
799 
808 
809 #endif /* __MODULES_INCLUDE_AUDIO_AUDIO_PLAYER_API_H */
810 
uint16_t id
Definition: video.h:86
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:597
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:620
uint8_t input_device
[in] Select Player Input device
Definition: audio_player_api.h:315
uint8_t player_id
[in] target player id Use AsPlayerId enum type
Definition: audio_player_api.h:529
Definition: audio_common_defs.h:698
CXD5602 Audio Object Layer API.
void * simple_fifo_handler
[in] Set SimpleFifo handler
Definition: audio_player_api.h:289
uint8_t mixer
[in] Message queue id of output mixer
Definition: audio_player_api.h:584
AsSetPlayerOutputDevice
Definition: audio_player_api.h:215
uint8_t src_work
[in] Memory pool id of src work area
Definition: audio_player_api.h:628
AudioSimpleFifoReadDoneCallbackFunction callback_function
[in] Set callback function, Call this function when SimpleFifo was read
Definition: audio_player_api.h:295
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:375
uint8_t reserve0
[in] reserved
Definition: audio_player_api.h:371
Activate sub player.
Definition: audio_player_api.h:176
Definition: audio_player_api.h:352
AsPlayerMsgQueId_t msgq_id
[in] ID for sending messages to each function
Definition: audio_player_api.h:651
bool AS_DeletePlayer(AsPlayerId id)
Deactivate audio main player.
Definition: audio_player_api.h:593
DecodeDoneCallback callback
[in] Decoded PCM notify callback
Definition: audio_player_api.h:445
uint8_t active_player
[in] Select activate player
Definition: audio_player_api.h:359
Play.
Definition: audio_player_api.h:138
uint8_t dsp
[in] Memory pool id of dsp command data
Definition: audio_player_api.h:624
uint8_t es
[in] Memory pool id of es data
Definition: audio_player_api.h:616
[in] Decoded PCM notify message
Definition: audio_player_api.h:451
uint8_t output_device
[in] Select Player Output device
Definition: audio_player_api.h:322
void(* AudioAttentionCb)(const ErrorAttentionParam *attparam)
Definition: audio_common_defs.h:806
uint8_t channel_number
[in] Select InitPlayer input channels
Definition: audio_player_api.h:404
Wait end of es.
Definition: audio_player_api.h:243
Definition: audio_player_api.h:493
bool AS_SetPlayerGain(AsPlayerId id, FAR AsSetGainParam *gainparam)
Set audio gain level of (sub)player.
Definition: audio_player_api.h:613
AsPlayPlayerParam play_param
[in] for PlayPlayer (header.command_code==AUDCMD_PLAYPLAYER)
Definition: audio_player_api.h:546
Definition: audio_player_api.h:397
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:689
AsSetGainParam set_gain_param
[in] for Adjust sound period (header.command_code==AUDCMD_CLKRECOVERY)
Definition: audio_player_api.h:560
void(* AudioSimpleFifoReadDoneCallbackFunction)(uint32_t size)
Definition: audio_player_api.h:278
Deactivate.
Definition: audio_player_api.h:146
MemMgrLite::PoolId pcm
[in] Memory pool id of pcm data
Definition: audio_player_api.h:601
eMMC FileSystem
Definition: audio_player_api.h:192
AsSetPlayerInputDevice
Definition: audio_player_api.h:186
MemMgrLite::PoolId src_work
[in] Memory pool id of src work area
Definition: audio_player_api.h:609
CXD5602 Audio Common Definitions.
Definition: audio_player_api.h:633
Definition: audio_player_api.h:523
uint8_t stop_mode
[in] Stop mode which indicates immediate or wait end of es
Definition: audio_player_api.h:488
AsPlayerPoolId_old_t pool_id
[in] ID of memory pool for processing data
Definition: audio_player_api.h:641
uint8_t pcm_path
[in] Decoded PCM data path
Definition: audio_player_api.h:467
AsPlayerEvent
Definition: audio_player_api.h:126
Decodec PCM data will be replied by callback.
Definition: audio_player_api.h:255
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:605
void(* DecodeDoneCallback)(AsPcmDataParam param)
Definition: audio_player_api.h:395
Activate.
Definition: audio_player_api.h:130
Definition: audio_player_api.h:308
uint8_t dsp
[in] Message queue id of DSP
Definition: audio_player_api.h:588
Definition: audio_player_api.h:647
bool AS_StopPlayer(AsPlayerId id, FAR AsStopPlayerParam *stopparam)
Stop audio (sub)player.
Definition: audio_player_api.h:282
bool AS_ActivatePlayer(AsPlayerId id, FAR AsActivatePlayer *actparam)
Activate audio (sub)player.
uint8_t reserved1
[in] reserved
Definition: audio_player_api.h:330
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:475
Normal stop (immediately stop)
Definition: audio_player_api.h:239
uint8_t codec_type
[in] Select InitPlayer codec type
Definition: audio_player_api.h:418
bool AS_InitPlayer(AsPlayerId id, FAR AsInitPlayerParam *initparam)
Initialize audio (sub)player.
Definition: audio_player_api.h:510
uint8_t bit_length
[in] Select InitPlayer input bit length
Definition: audio_player_api.h:411
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:517
AsActivatePlayerParam param
[in] MediaPlayer activation parameters
Definition: audio_player_api.h:344
uint8_t mng
[in] Message queue id of audio_manager
Definition: audio_player_api.h:580
uint16_t size
Definition: video.h:86
Definition: audio_player_api.h:572
uint8_t player
[in] Message queue id of player
Definition: audio_player_api.h:576
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:429
Definition: audio_player_api.h:481
uint8_t post1_enable
[in] post DSP 1 enable
Definition: audio_player_api.h:367
AsInitPlayerParam init_param
[in] for InitPlayer (header.command_code==AUDCMD_INITPLAYER) (Object Interface==AS_InitPlayer) ...
Definition: audio_player_api.h:540
Init.
Definition: audio_player_api.h:134
uint8_t post0_enable
[in] post DSP 0 enable
Definition: audio_player_api.h:363
AsPlayerMsgQueId_t msgq_id
[in] ID for sending messages to each function
Definition: audio_player_api.h:637
Decodec PCM data will be sent automatically.
Definition: audio_player_api.h:259
Definition: audio_player_api.h:439
Definition: audio_player_api.h:340
Forcibly stop at system failure.
Definition: audio_player_api.h:246
uint8_t reserved1
[in] reserved
Definition: audio_player_api.h:422
AsPlayerPoolId_t pool_id
[in] ID of memory pool for processing data
Definition: audio_player_api.h:655
Stop.
Definition: audio_player_api.h:142
AsStopPlayerParam stop_param
[in] for StopPlayer (header.command_code==AUDCMD_STOPPLAYER)
Definition: audio_player_api.h:552
AsActivatePlayerParam player1
[in] Activation parameters for player1
Definition: audio_player_api.h:379
uint8_t l_gain
[in] Gain level Lch Percentage 0 - 200 %
Definition: audio_player_api.h:499
uint8_t r_gain
[in] Gain level Rch Percentage 0 - 200 %
Definition: audio_player_api.h:505
AsPlayerInputDeviceHdlrForRAM * ram_handler
[in] Set Player Input device handler, refer following.
Definition: audio_player_api.h:334
AsPcmDataPath
Definition: audio_player_api.h:251
uint32_t notification_threshold_size
[in] Read size notification threshold
Definition: audio_player_api.h:299
uint8_t reserved0
[in] reserved
Definition: audio_player_api.h:326
A2DP Media Packet FIFO.
Definition: audio_player_api.h:198
Definition: audio_player_api.h:459
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:388
AsDeactivatePlayer deact_param
[in] for deactivate player (header.command_code==AUDCMD_SETREADYSTATUS)
Definition: audio_player_api.h:566