1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @addtogroup OHAudio 18 * @{ 19 * 20 * @brief Provide the definition of the C interface for the audio module. 21 * 22 * @syscap SystemCapability.Multimedia.Audio.Core 23 * 24 * @since 10 25 * @version 1.0 26 */ 27 28 /** 29 * @file native_audiostream_base.h 30 * 31 * @brief Declare the underlying data structure. 32 * 33 * @library libohaudio.so 34 * @syscap SystemCapability.Multimedia.Audio.Core 35 * @kit AudioKit 36 * @since 10 37 * @version 1.0 38 */ 39 40 #ifndef NATIVE_AUDIOSTREAM_BASE_H 41 #define NATIVE_AUDIOSTREAM_BASE_H 42 43 #include <stdint.h> 44 #include "multimedia/native_audio_channel_layout.h" 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /** 51 * @brief Define the result of the function execution. 52 * 53 * @since 10 54 */ 55 typedef enum { 56 /** 57 * @error The call was successful. 58 * 59 * @since 10 60 */ 61 AUDIOSTREAM_SUCCESS = 0, 62 63 /** 64 * @error This means that the function was executed with an invalid input parameter. 65 * 66 * @since 10 67 */ 68 AUDIOSTREAM_ERROR_INVALID_PARAM = 1, 69 70 /** 71 * @error Execution status exception. 72 * 73 * @since 10 74 */ 75 AUDIOSTREAM_ERROR_ILLEGAL_STATE = 2, 76 77 /** 78 * @error An system error has occurred. 79 * 80 * @since 10 81 */ 82 AUDIOSTREAM_ERROR_SYSTEM = 3, 83 84 /** 85 * @error Unsupported audio format, such as unsupported encoding type, sample format etc. 86 * 87 * @since 19 88 */ 89 AUDIOSTREAM_ERROR_UNSUPPORTED_FORMAT = 4 90 } OH_AudioStream_Result; 91 92 /** 93 * @brief Define the audio stream type. 94 * 95 * @since 10 96 */ 97 typedef enum { 98 /** 99 * The type for audio stream is renderer. 100 * 101 * @since 10 102 */ 103 AUDIOSTREAM_TYPE_RENDERER = 1, 104 105 /** 106 * The type for audio stream is capturer. 107 * 108 * @since 10 109 */ 110 AUDIOSTREAM_TYPE_CAPTURER = 2 111 } OH_AudioStream_Type; 112 113 /** 114 * @brief Define the audio stream sample format. 115 * 116 * @since 10 117 */ 118 typedef enum { 119 /** 120 * Unsigned 8 format. 121 * 122 * @since 10 123 */ 124 AUDIOSTREAM_SAMPLE_U8 = 0, 125 /** 126 * Signed 16 bit integer, little endian. 127 * 128 * @since 10 129 */ 130 AUDIOSTREAM_SAMPLE_S16LE = 1, 131 /** 132 * Signed 24 bit integer, little endian. 133 * 134 * @since 10 135 */ 136 AUDIOSTREAM_SAMPLE_S24LE = 2, 137 /** 138 * Signed 32 bit integer, little endian. 139 * 140 * @since 10 141 */ 142 AUDIOSTREAM_SAMPLE_S32LE = 3, 143 144 /** 145 * Float 32, little endian. 146 * 147 * @since 17 148 */ 149 AUDIOSTREAM_SAMPLE_F32LE = 4, 150 } OH_AudioStream_SampleFormat; 151 152 /** 153 * @brief Define the audio encoding type. 154 * 155 * @since 10 156 */ 157 typedef enum { 158 /** 159 * PCM encoding type. 160 * 161 * @since 10 162 */ 163 AUDIOSTREAM_ENCODING_TYPE_RAW = 0, 164 /** 165 * AudioVivid encoding type. 166 * 167 * @since 12 168 */ 169 AUDIOSTREAM_ENCODING_TYPE_AUDIOVIVID = 1, 170 /** 171 * E_AC3 encoding type. 172 * 173 * @since 19 174 */ 175 AUDIOSTREAM_ENCODING_TYPE_E_AC3 = 2, 176 } OH_AudioStream_EncodingType; 177 178 /** 179 * @brief Define the audio stream info structure, used to describe basic audio format. 180 * 181 * @since 19 182 */ 183 typedef struct OH_AudioStreamInfo { 184 /** 185 * @brief Audio sampling rate. 186 * 187 * @since 19 188 */ 189 int32_t samplingRate; 190 /** 191 * @brief Audio channel layout. 192 * 193 * @since 19 194 */ 195 OH_AudioChannelLayout channelLayout; 196 /** 197 * @brief Audio encoding format type. 198 * 199 * @since 19 200 */ 201 OH_AudioStream_EncodingType encodingType; 202 /** 203 * @brief Audio sample format. 204 * 205 * @since 19 206 */ 207 OH_AudioStream_SampleFormat sampleFormat; 208 } OH_AudioStreamInfo; 209 210 /** 211 * @brief Define the audio stream usage. 212 * Audio stream usage is used to describe what work scenario 213 * the current stream is used for. 214 * 215 * @since 10 216 */ 217 typedef enum { 218 /** 219 * Unknown usage. 220 * 221 * @since 10 222 */ 223 AUDIOSTREAM_USAGE_UNKNOWN = 0, 224 /** 225 * Music usage. 226 * 227 * @since 10 228 */ 229 AUDIOSTREAM_USAGE_MUSIC = 1, 230 /** 231 * Voice communication usage. 232 * 233 * @since 10 234 */ 235 AUDIOSTREAM_USAGE_VOICE_COMMUNICATION = 2, 236 /** 237 * Voice assistant usage. 238 * 239 * @since 10 240 */ 241 AUDIOSTREAM_USAGE_VOICE_ASSISTANT = 3, 242 /** 243 * Alarm usage. 244 * 245 * @since 10 246 */ 247 AUDIOSTREAM_USAGE_ALARM = 4, 248 /** 249 * Voice message usage. 250 * 251 * @since 10 252 */ 253 AUDIOSTREAM_USAGE_VOICE_MESSAGE = 5, 254 /** 255 * Ringtone usage. 256 * 257 * @since 10 258 */ 259 AUDIOSTREAM_USAGE_RINGTONE = 6, 260 /** 261 * Notification usage. 262 * 263 * @since 10 264 */ 265 AUDIOSTREAM_USAGE_NOTIFICATION = 7, 266 /** 267 * Accessibility usage, such as screen reader. 268 * 269 * @since 10 270 */ 271 AUDIOSTREAM_USAGE_ACCESSIBILITY = 8, 272 /** 273 * Movie or video usage. 274 * 275 * @since 10 276 */ 277 AUDIOSTREAM_USAGE_MOVIE = 10, 278 /** 279 * Game sound effect usage. 280 * 281 * @since 10 282 */ 283 AUDIOSTREAM_USAGE_GAME = 11, 284 /** 285 * Audiobook usage. 286 * 287 * @since 10 288 */ 289 AUDIOSTREAM_USAGE_AUDIOBOOK = 12, 290 /** 291 * Navigation usage. 292 * 293 * @since 10 294 */ 295 AUDIOSTREAM_USAGE_NAVIGATION = 13, 296 /** 297 * Video call usage. 298 * 299 * @since 12 300 */ 301 AUDIOSTREAM_USAGE_VIDEO_COMMUNICATION = 17, 302 } OH_AudioStream_Usage; 303 304 /** 305 * @brief Define the audio latency mode. 306 * 307 * @since 10 308 */ 309 typedef enum { 310 /** 311 * This is a normal audio scene. 312 * 313 * @since 10 314 */ 315 AUDIOSTREAM_LATENCY_MODE_NORMAL = 0, 316 /** 317 * This is a low latency audio scene. 318 * 319 * @since 10 320 */ 321 AUDIOSTREAM_LATENCY_MODE_FAST = 1 322 } OH_AudioStream_LatencyMode; 323 324 /** 325 * @brief Enumerates audio direct playback modes. 326 * 327 * @since 19 328 */ 329 typedef enum { 330 /** 331 * Direct playback is not supported. 332 * 333 * @since 19 334 */ 335 AUDIOSTREAM_DIRECT_PLAYBACK_NOT_SUPPORTED = 0, 336 /** 337 * Direct playback mode which is bitstream pass-through such as compressed pass-through. 338 * 339 * @since 19 340 */ 341 AUDIOSTREAM_DIRECT_PLAYBACK_BITSTREAM_SUPPORTED = 1, 342 /** 343 * Direct playback mode of pcm. 344 * 345 * @since 19 346 */ 347 AUDIOSTREAM_DIRECT_PLAYBACK_PCM_SUPPORTED = 2 348 } OH_AudioStream_DirectPlaybackMode; 349 350 /** 351 * @brief Define the audio event. 352 * 353 * @deprecated since 20 354 * @useinstead OH_AudioRenderer_OutputDeviceChangeCallback. 355 * @since 10 356 */ 357 typedef enum { 358 /** 359 * The routing of the audio has changed. 360 * 361 * @deprecated since 20 362 * @useinstead OH_AudioRenderer_OutputDeviceChangeCallback. 363 * @since 10 364 */ 365 AUDIOSTREAM_EVENT_ROUTING_CHANGED = 0 366 } OH_AudioStream_Event; 367 368 /** 369 * @brief The audio stream states 370 * 371 * @since 10 372 */ 373 typedef enum { 374 /** 375 * The invalid state. 376 * 377 * @since 10 378 */ 379 AUDIOSTREAM_STATE_INVALID = -1, 380 /** 381 * Create new instance state. 382 * 383 * @since 10 384 */ 385 AUDIOSTREAM_STATE_NEW = 0, 386 /** 387 * The prepared state. 388 * 389 * @since 10 390 */ 391 AUDIOSTREAM_STATE_PREPARED = 1, 392 /** 393 * The stream is running. 394 * 395 * @since 10 396 */ 397 AUDIOSTREAM_STATE_RUNNING = 2, 398 /** 399 * The stream is stopped. 400 * 401 * @since 10 402 */ 403 AUDIOSTREAM_STATE_STOPPED = 3, 404 /** 405 * The stream is released. 406 * 407 * @since 10 408 */ 409 AUDIOSTREAM_STATE_RELEASED = 4, 410 /** 411 * The stream is paused. 412 * 413 * @since 10 414 */ 415 AUDIOSTREAM_STATE_PAUSED = 5, 416 } OH_AudioStream_State; 417 418 /** 419 * @brief Defines the audio interrupt type. 420 * 421 * @since 10 422 */ 423 typedef enum { 424 /** 425 * Force type, system change audio state. 426 * 427 * @since 10 428 */ 429 AUDIOSTREAM_INTERRUPT_FORCE = 0, 430 /** 431 * Share type, application change audio state. 432 * 433 * @since 10 434 */ 435 AUDIOSTREAM_INTERRUPT_SHARE = 1 436 } OH_AudioInterrupt_ForceType; 437 438 /** 439 * @brief Defines the audio interrupt hint type. 440 * 441 * @since 10 442 */ 443 typedef enum { 444 /** 445 * None. 446 * 447 * @since 10 448 */ 449 AUDIOSTREAM_INTERRUPT_HINT_NONE = 0, 450 /** 451 * Resume the stream. 452 * 453 * @since 10 454 */ 455 AUDIOSTREAM_INTERRUPT_HINT_RESUME = 1, 456 /** 457 * Pause the stream. 458 * 459 * @since 10 460 */ 461 AUDIOSTREAM_INTERRUPT_HINT_PAUSE = 2, 462 /** 463 * Stop the stream. 464 * 465 * @since 10 466 */ 467 AUDIOSTREAM_INTERRUPT_HINT_STOP = 3, 468 /** 469 * Ducked the stream. 470 * 471 * @since 10 472 */ 473 AUDIOSTREAM_INTERRUPT_HINT_DUCK = 4, 474 /** 475 * Unducked the stream. 476 * 477 * @since 10 478 */ 479 AUDIOSTREAM_INTERRUPT_HINT_UNDUCK = 5, 480 /** 481 * Mute the stream. 482 * 483 * @since 20 484 */ 485 AUDIOSTREAM_INTERRUPT_HINT_MUTE = 6, 486 /** 487 * Unmute the stream. 488 * 489 * @since 20 490 */ 491 AUDIOSTREAM_INTERRUPT_HINT_UNMUTE = 7 492 } OH_AudioInterrupt_Hint; 493 494 /** 495 * @brief Defines the audio source type. 496 * 497 * @since 10 498 */ 499 typedef enum { 500 /** 501 * Invalid type. 502 * 503 * @since 10 504 */ 505 AUDIOSTREAM_SOURCE_TYPE_INVALID = -1, 506 /** 507 * Mic source type. 508 * 509 * @since 10 510 */ 511 AUDIOSTREAM_SOURCE_TYPE_MIC = 0, 512 /** 513 * Voice recognition source type. 514 * 515 * @since 10 516 */ 517 AUDIOSTREAM_SOURCE_TYPE_VOICE_RECOGNITION = 1, 518 /** 519 * Playback capture source type. 520 * 521 * @deprecated since 12 522 * @useinstead OH_AVScreenCapture in native interface. 523 * @since 10 524 */ 525 AUDIOSTREAM_SOURCE_TYPE_PLAYBACK_CAPTURE = 2, 526 /** 527 * Voice communication source type. 528 * 529 * @since 10 530 */ 531 AUDIOSTREAM_SOURCE_TYPE_VOICE_COMMUNICATION = 7, 532 /** 533 * Voice message source type. 534 * 535 * @since 12 536 */ 537 AUDIOSTREAM_SOURCE_TYPE_VOICE_MESSAGE = 10, 538 /** 539 * Camcorder source type. 540 * 541 * @since 13 542 */ 543 AUDIOSTREAM_SOURCE_TYPE_CAMCORDER = 13, 544 /** 545 * Unprocessed source type. 546 * 547 * @since 14 548 */ 549 AUDIOSTREAM_SOURCE_TYPE_UNPROCESSED = 14, 550 /** 551 * Live Broadcast source type. 552 * 553 * @since 20 554 */ 555 AUDIOSTREAM_SOURCE_TYPE_LIVE = 17 556 } OH_AudioStream_SourceType; 557 558 /** 559 * @brief Defines the audio interrupt mode. 560 * 561 * @since 12 562 */ 563 typedef enum { 564 /** 565 * Share mode 566 */ 567 AUDIOSTREAM_INTERRUPT_MODE_SHARE = 0, 568 /** 569 * Independent mode 570 */ 571 AUDIOSTREAM_INTERRUPT_MODE_INDEPENDENT = 1 572 } OH_AudioInterrupt_Mode; 573 574 /** 575 * @brief Defines the audio effect mode. 576 * 577 * @since 12 578 */ 579 typedef enum { 580 /** 581 * Audio Effect Mode effect none. 582 * 583 * @since 12 584 */ 585 EFFECT_NONE = 0, 586 /** 587 * Audio Effect Mode effect default. 588 * 589 * @since 12 590 */ 591 EFFECT_DEFAULT = 1, 592 } OH_AudioStream_AudioEffectMode; 593 594 /** 595 * @brief Defines the fast status. 596 * 597 * @since 20 598 */ 599 typedef enum { 600 /** 601 * normal status 602 */ 603 AUDIOSTREAM_FASTSTATUS_NORMAL = 0, 604 /** 605 * fast status 606 */ 607 AUDIOSTREAM_FASTSTATUS_FAST = 1 608 } OH_AudioStream_FastStatus; 609 610 /** 611 * @brief Declaring the audio stream builder. 612 * The instance of builder is used for creating audio stream. 613 * 614 * @since 10 615 */ 616 typedef struct OH_AudioStreamBuilderStruct OH_AudioStreamBuilder; 617 618 /** 619 * @brief Declaring the audio renderer stream. 620 * The instance of renderer stream is used for playing audio data. 621 * 622 * @since 10 623 */ 624 typedef struct OH_AudioRendererStruct OH_AudioRenderer; 625 626 /** 627 * @brief Declaring the audio capturer stream. 628 * The instance of renderer stream is used for capturing audio data. 629 * 630 * @since 10 631 */ 632 typedef struct OH_AudioCapturerStruct OH_AudioCapturer; 633 634 /** 635 * @brief Declaring the callback struct for renderer stream. 636 * 637 * @deprecated since 20 638 * @useinstead Use the callback type: OH_AudioRenderer_OnWriteDataCallback, OH_AudioRenderer_OutputDeviceChangeCallback, 639 * OH_AudioRenderer_OnInterruptEvent, OH_AudioRenderer_OnErrorCallback separately. 640 * @since 10 641 */ 642 typedef struct OH_AudioRenderer_Callbacks_Struct { 643 /** 644 * This function pointer will point to the callback function that 645 * is used to write audio data 646 * 647 * @deprecated since 20 648 * @useinstead OH_AudioRenderer_OnWriteDataCallback. 649 * @since 10 650 */ 651 int32_t (*OH_AudioRenderer_OnWriteData)( 652 OH_AudioRenderer* renderer, 653 void* userData, 654 void* buffer, 655 int32_t length); 656 657 /** 658 * This function pointer will point to the callback function that 659 * is used to handle audio renderer stream events. 660 * 661 * @deprecated since 20 662 * @useinstead OH_AudioRenderer_OutputDeviceChangeCallback. 663 * @since 10 664 */ 665 int32_t (*OH_AudioRenderer_OnStreamEvent)( 666 OH_AudioRenderer* renderer, 667 void* userData, 668 OH_AudioStream_Event event); 669 670 /** 671 * This function pointer will point to the callback function that 672 * is used to handle audio interrupt events. 673 * 674 * @deprecated since 20 675 * @useinstead OH_AudioRenderer_OnInterruptCallback. 676 * @since 10 677 */ 678 int32_t (*OH_AudioRenderer_OnInterruptEvent)( 679 OH_AudioRenderer* renderer, 680 void* userData, 681 OH_AudioInterrupt_ForceType type, 682 OH_AudioInterrupt_Hint hint); 683 684 /** 685 * This function pointer will point to the callback function that 686 * is used to handle audio error result. 687 * 688 * @deprecated since 20 689 * @useinstead OH_AudioRenderer_OnErrorCallback. 690 * @since 10 691 */ 692 int32_t (*OH_AudioRenderer_OnError)( 693 OH_AudioRenderer* renderer, 694 void* userData, 695 OH_AudioStream_Result error); 696 } OH_AudioRenderer_Callbacks; 697 698 /** 699 * @brief Declaring the callback struct for capturer stream. 700 * 701 * @deprecated since 20 702 * @useinstead Use the callback type: OH_AudioCapturer_OnReadDataCallback, OH_AudioCapturer_OnDeviceChangeCallback, 703 * OH_AudioCapturer_OnInterruptCallback and OH_AudioCapturer_OnErrorCallback separately. 704 * @since 10 705 */ 706 typedef struct OH_AudioCapturer_Callbacks_Struct { 707 /** 708 * This function pointer will point to the callback function that 709 * is used to read audio data. 710 * 711 * @deprecated since 20 712 * @useinstead OH_AudioCapturer_OnReadDataCallback 713 * @since 10 714 */ 715 int32_t (*OH_AudioCapturer_OnReadData)( 716 OH_AudioCapturer* capturer, 717 void* userData, 718 void* buffer, 719 int32_t length); 720 721 /** 722 * This function pointer will point to the callback function that 723 * is used to handle audio capturer stream events. 724 * 725 * @deprecated since 20 726 * @useinstead OH_AudioRenderer_OutputDeviceChangeCallback 727 * @since 10 728 */ 729 int32_t (*OH_AudioCapturer_OnStreamEvent)( 730 OH_AudioCapturer* capturer, 731 void* userData, 732 OH_AudioStream_Event event); 733 734 /** 735 * This function pointer will point to the callback function that 736 * is used to handle audio interrupt events. 737 * 738 * @deprecated since 20 739 * @useinstead OH_AudioCapturer_OnInterruptCallback 740 * @since 10 741 */ 742 int32_t (*OH_AudioCapturer_OnInterruptEvent)( 743 OH_AudioCapturer* capturer, 744 void* userData, 745 OH_AudioInterrupt_ForceType type, 746 OH_AudioInterrupt_Hint hint); 747 748 /** 749 * This function pointer will point to the callback function that 750 * is used to handle audio error result. 751 * 752 * @deprecated since 20 753 * @useinstead OH_AudioCapturer_OnErrorCallback 754 * @since 10 755 */ 756 int32_t (*OH_AudioCapturer_OnError)( 757 OH_AudioCapturer* capturer, 758 void* userData, 759 OH_AudioStream_Result error); 760 } OH_AudioCapturer_Callbacks; 761 762 /** 763 * @brief Defines reason for device changes of one audio stream. 764 * 765 * @since 11 766 */ 767 typedef enum { 768 /* Unknown. */ 769 REASON_UNKNOWN = 0, 770 /* New Device available. */ 771 REASON_NEW_DEVICE_AVAILABLE = 1, 772 /* Old Device unavailable. Applications should consider to pause the audio playback when this reason is 773 reported. */ 774 REASON_OLD_DEVICE_UNAVAILABLE = 2, 775 /* Device is overrode by user or system. */ 776 REASON_OVERRODE = 3, 777 /** 778 * @brief Device information when the audio session is activated. 779 * 780 * @since 20 781 */ 782 REASON_SESSION_ACTIVATED = 4, 783 /** 784 * @brief There is a higher-priority stream, causing the system device to change. 785 * 786 * @since 20 787 */ 788 REASON_STREAM_PRIORITY_CHANGED = 5, 789 } OH_AudioStream_DeviceChangeReason; 790 791 /** 792 * @brief Callback when the output device of an audio renderer changed. 793 * 794 * @param renderer AudioRenderer where this event occurs. 795 * @param userData User data which is passed by user. 796 * @param reason Indicates that why does the output device changes. 797 * @since 11 798 */ 799 typedef void (*OH_AudioRenderer_OutputDeviceChangeCallback)(OH_AudioRenderer* renderer, void* userData, 800 OH_AudioStream_DeviceChangeReason reason); 801 802 /** 803 * @brief Callback when the mark position reached. 804 * 805 * @param renderer AudioRenderer where this event occurs. 806 * @param samplePos Mark position in samples. 807 * @param userData User data which is passed by user. 808 * @since 12 809 */ 810 typedef void (*OH_AudioRenderer_OnMarkReachedCallback)(OH_AudioRenderer* renderer, uint32_t samplePos, void* userData); 811 812 /** 813 * @brief This function pointer will point to the callback function that 814 * is used to write audio data with metadata 815 * 816 * @param renderer AudioRenderer where this event occurs. 817 * @param userData User data which is passed by user. 818 * @param audioData Audio data which is written by user. 819 * @param audioDataSize Audio data size which is the size of audio data written by user. 820 * @param metadata Metadata which is written by user. 821 * @param metadataSize Metadata size which is the size of metadata written by user. 822 * @return Error code of the callback function returned by user. 823 * @since 12 824 */ 825 typedef int32_t (*OH_AudioRenderer_WriteDataWithMetadataCallback)(OH_AudioRenderer* renderer, 826 void* userData, void* audioData, int32_t audioDataSize, void* metadata, int32_t metadataSize); 827 828 /** 829 * @brief Defines Enumeration of audio stream privacy type for playback capture. 830 * 831 * @since 12 832 */ 833 typedef enum { 834 /** Privacy type that stream can be captured by third party applications. 835 * @since 12 836 */ 837 AUDIO_STREAM_PRIVACY_TYPE_PUBLIC = 0, 838 /** Privacy type that stream can not be captured. 839 * @since 12 840 */ 841 AUDIO_STREAM_PRIVACY_TYPE_PRIVATE = 1, 842 } OH_AudioStream_PrivacyType; 843 844 /** 845 * @brief Defines enumeration of audio data callback result. 846 * 847 * @since 12 848 */ 849 typedef enum { 850 /** Result of audio data callabck is invalid. */ 851 AUDIO_DATA_CALLBACK_RESULT_INVALID = -1, 852 /** Result of audio data callabck is valid. */ 853 AUDIO_DATA_CALLBACK_RESULT_VALID = 0, 854 } OH_AudioData_Callback_Result; 855 856 /** 857 * @brief Callback function of write data. 858 * 859 * This function is similar with OH_AudioRenderer_Callbacks_Struct.OH_AudioRenderer_OnWriteData instead of the return 860 * value. The return result of this function indicates whether the data filled in the buffer is valid or invalid. If 861 * result is invalid, the data filled by user will not be played. 862 * 863 * @param renderer AudioRenderer where this callback occurs. 864 * @param userData User data which is passed by user. 865 * @param audioData Audio data pointer, where user should fill in audio data. 866 * @param audioDataSize Size of audio data that user should fill in. 867 * @return Audio Data callback result. 868 * @see OH_AudioRenderer_Callbacks_Struct.OH_AudioRenderer_OnWriteData 869 * @since 12 870 */ 871 typedef OH_AudioData_Callback_Result (*OH_AudioRenderer_OnWriteDataCallback)(OH_AudioRenderer* renderer, void* userData, 872 void* audioData, int32_t audioDataSize); 873 874 /** 875 * @brief Define the audio stream volume mode. 876 * 877 * @since 19 878 */ 879 typedef enum { 880 /** 881 * Indicates this audio stream volume will be affected by system volume, also the default behavior. 882 * 883 * @since 19 884 */ 885 AUDIOSTREAM_VOLUMEMODE_SYSTEM_GLOBAL = 0, 886 887 /** 888 * Indicates this audio stream volume will be affected by app's individual volume percentage which set by yourself 889 * using the app volume api. 890 * 891 * @since 19 892 */ 893 AUDIOSTREAM_VOLUMEMODE_APP_INDIVIDUAL = 1 894 } OH_AudioStream_VolumeMode; 895 896 #ifdef __cplusplus 897 } 898 #endif 899 900 #endif // NATIVE_AUDIOSTREAM_BASE_H 901 /** @} */