Methods and apparatus for playing audio, electronic devices and storage media
By using audio partitioning information and XML file configuration, audio partitioning playback in different areas of the vehicle is achieved, solving the problem of mute operation when navigation and music are running simultaneously, improving user experience, reducing costs, and making it suitable for ordinary family cars.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-15
- Publication Date
- 2026-03-10
AI Technical Summary
Existing technology mutes music when navigation and music are running simultaneously, affecting the user experience. It also mutes other sounds when answering calls, failing to meet the needs of all passengers. Furthermore, existing solutions are expensive and unsuitable for ordinary family cars.
By mapping audio playback devices to different audio partitions using audio partition information and configuring different playback types, and storing audio partition information using XML file format, different playback types of sound can be played on the corresponding audio playback devices, avoiding hardware modifications and reducing costs.
It enables separate audio playback in different areas of the car, improving the passenger experience and avoiding the high costs associated with hardware modifications, making it suitable for ordinary family cars.
Smart Images

Figure CN115424640B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of audio playing, and in particular to a method and apparatus for playing audio, an electronic device and a storage medium. BACKGROUND
[0002] With the development of technology and the increasing popularity of cars, the use of car machines (in-car infotainment products installed in cars) based on the Android system is also increasing. Users can play music, navigate, and answer the phone through the car machine. However, there are various problems in actual use, for example: in the case of simultaneous navigation and music playing, the music will be muted when the navigation prompt sound appears, and if the navigation sound appears continuously, the music will be interrupted, affecting the user's experience; when answering the phone, all other sounds will be muted, which is friendly to the person answering the phone, but when there are other people in the car, the other people in the car can only wait until the call is over to continue enjoying the music, and the experience of all people in the car cannot be taken into account.
[0003] To solve the above problems, the existing method is usually to install independent control panels in different seat areas of the car and equip them with independent car audio with strong directional function. This solution is effective but expensive, suitable for high-end cars, and not suitable for ordinary family cars. SUMMARY
[0004] The present application provides a method and apparatus for playing audio, an electronic device and a storage medium, which can realize low-cost in-car audio partitioning.
[0005] In one aspect of the present application, a method for playing audio is provided. The method comprises: parsing audio partition information, the audio partition information comprising audio playing device information and playing type information associated with an audio partition; associating an audio playing device corresponding to the audio playing device information with the audio partition according to the audio partition information; and playing audio corresponding to the playing type information through the audio playing device according to the audio partition information.
[0006] In some embodiments, after receiving the audio partition information, the method further comprises: associating the audio playing device corresponding to the audio playing device information with the audio partition according to the audio partition information comprises: associating the audio playing device with a sound card corresponding to the audio partition.
[0007] In some embodiments, the method further comprises: associating the audio playing device with a sound card corresponding to the audio partition comprises: binding the audio playing devices corresponding to the same audio partition on the same sound card.
[0008] In some embodiments, playing the audio corresponding to the play type information through the audio playing device according to the audio partition information comprises: obtaining an audio playing request, reading a play type in the audio playing request; obtaining an audio partition corresponding to the play type according to the play type information; and playing the audio corresponding to the play type in the audio playing request through the audio playing device corresponding to the audio partition.
[0009] In some embodiments, the method further comprises: configuring a default audio playing device; and playing the audio corresponding to the play type in the audio playing request through the default audio playing device if the audio partition corresponding to the play type is not obtained according to the play type information.
[0010] In some embodiments, playing the audio corresponding to the play type in the audio playing request through the audio playing device corresponding to the audio partition comprises: obtaining a sound card associated with the audio playing device; and playing the audio through the sound card.
[0011] In some embodiments, the method further comprises: configuring the audio partition information in an XML file format.
[0012] In another aspect of the present application, an apparatus for playing audio is provided. The apparatus comprises: a partition analyzing module configured to analyze audio partition information, the audio partition information comprising audio playing device information associated with an audio partition and play type information; a binding module configured to associate an audio playing device corresponding to the audio playing device information with the audio partition according to the audio partition information; and a sound emitting module configured to play audio corresponding to the play type information through the audio playing device according to the audio partition information.
[0013] In some embodiments, the binding module is configured to associate the audio playing device with a sound card corresponding to the audio partition.
[0014] In some embodiments, the sound emitting module is configured to: obtain an audio playing request, read a play type in the audio playing request; obtain an audio partition corresponding to the play type according to the play type information; and play the audio corresponding to the play type in the audio playing request through the audio playing device corresponding to the audio partition.
[0015] In still another aspect of the present application, a computer readable medium is provided. The medium has stored thereon a computer program which, when executed by a processor, implements the steps of the above-mentioned method for playing audio.
[0016] According to the application, the audio partition information corresponds the audio playing device to different audio partitions, and the configuration information corresponds the audio partition to different playing types, so that the sound of different playing types corresponds to different audio partitions, that is, the sound of different playing types can be played on the audio playing device corresponding to the different audio partitions, realizing the dynamic mobilization of the audio playing device in different areas in the vehicle, avoiding the uncomfortable use experience of all audio playing devices performing the same operation to the passengers in the vehicle, and each audio playing device can perform different audio playing actions according to the playing type corresponding to the audio partition where the audio playing device is located, realizing the low-cost audio partition in the vehicle. BRIEF DESCRIPTION OF DRAWINGS
[0017] Figure 1 Flow chart of the method for playing audio according to the embodiment of the application;
[0018] Figure 2 Schematic diagram of the audio partition division method according to the embodiment of the application;
[0019] Figure 3 Correspondence diagram of system audio partition and sound card according to the embodiment of the application;
[0020] Figure 4 Flow chart of the method for playing audio according to the embodiment of the application in actual scene;
[0021] Figure 5 Block diagram of the device for playing audio according to the embodiment of the application;
[0022] Figure 6 Block diagram of the electronic device according to the embodiment of the application. DETAILED DESCRIPTION
[0023] To explain the technical content, the achieved purposes and effects of the application in detail, the following will be explained in combination with the embodiments and the drawings.
[0024] In the prior art, the audio partition in the vehicle is usually realized by installing independent control panels in different seat areas of the vehicle and equipping the vehicle with independent sound boxes with directional function, which is relatively high in cost.
[0025] To solve at least the above technical problems, the present disclosure provides a method for playing audio. According to the present disclosure, all audio playing devices are respectively corresponding to different audio partitions through audio partition information, and each audio partition corresponds to different playing types through configuration information, so that different playing types of sound can be played through different audio playing devices. In this way, unless there is only one sound card in the vehicle, at least one sound card needs to be added, and according to the embodiments of the present disclosure, the partitioned playing of audio can be realized without modifying the original audio playing device and other hardware, thereby reducing the cost of realizing audio partition.
[0026] Hereinafter, the technical solutions according to the present disclosure will be described with reference to specific embodiments and in conjunction with the accompanying drawings.
[0027] Figure 1 is a flowchart showing a method 100 for playing audio according to an embodiment of the present disclosure. Referring to Figure 1 , the method 100 includes the following steps 102 to 106.
[0028] In step 102, audio partition information is parsed, the audio partition information including audio playing device information and playing type information associated with an audio partition. In some embodiments, the audio partition information configured in an XML file format is received to derive the audio playing device information and the playing type information associated with the audio partition from the audio partition information. In some embodiments, the audio partition corresponding to an audio playing device is divided according to the position information of the audio playing device. In some embodiments, the audio playing devices are divided into different audio partitions with the seats in the vehicle as the dividing line. In this way, audio playing targeted for passengers in different positions is realized.
[0029] In step 104, the audio playing device corresponding to the audio playing device information is associated with the audio partition according to the audio partition information. In some embodiments, the audio playing device is associated with a sound card corresponding to the audio partition. In some embodiments, the audio playing devices corresponding to the same audio partition can be bound on the same sound card. In this way, the partitioned output of system sound can be realized through each sound card.
[0030] In step 106, the audio corresponding to the playing type information is played through the audio playing device according to the audio partition information. In this way, independent audio output of each audio partition is realized.
[0031] In some embodiments, an audio playback request is obtained, and the playback type in the audio playback request is read. Then, an audio partition corresponding to the playback type is obtained based on the playback type information. Then, the audio corresponding to the playback type in the audio playback request is played through the audio playback device corresponding to the audio partition. In some embodiments, a sound card associated with the audio playback device is obtained, and the audio is played through the sound card. In this way, after receiving an audio playback request, the playback type of the audio is first determined, the corresponding audio partition is found based on the playback type, and the audio is played only in the audio playback device corresponding to that audio partition. This achieves audio partition playback after receiving an audio playback request without relying on hardware devices.
[0032] In some embodiments, the method 100 may further include: configuring a default audio playback device; if no audio partition corresponding to the playback type is obtained according to the playback type information, then playing the audio corresponding to the playback type in the audio playback request through the default audio playback device. In this way, while achieving partitioned playback of audio, it avoids situations where audio cannot be played due to incorrect audio partition information or missing audio partition information.
[0033] According to an embodiment of the present invention, the audio playback devices are configured to belong to different audio zones, and different audio zones are responsible for playing sounds corresponding to different application types or sound types. The audio zones are divided according to the location of the audio playback devices, so as to output different audio content to passengers in different positions in the vehicle and improve the passenger experience.
[0034] In one optional implementation, when playing an audio clip, the system first checks if the configuration information includes a configured application type. If so, the audio is played in sections based on the application type. Otherwise, the system checks if the configuration information includes a configured sound type, and plays the audio in sections based on the sound type. This avoids audio playback conflicts caused by haphazard configuration. Specifically, the following logic can be added to the code: if the configuration information includes a configured application package name, the system first checks if the application package name corresponds to the audio playback request; only if there is no application package name or the package name does not correspond does the system check if the sound type corresponds to the audio playback request. This avoids situations where the audio section information is associated with section 1 and APP1, or section 2 and a notification sound, leading to logical confusion when receiving a notification sound from APP1.
[0035] Figure 2 This is a schematic diagram illustrating an audio partitioning method according to an embodiment of the present disclosure, with reference to... Figure 2In ordinary family vehicles, the interior space is divided into front and rear areas based on the front seats. The audio playback device in the front area corresponds to audio zone 1, and the audio playback device in the rear area corresponds to audio zone 2.
[0036] In some embodiments, playback type information includes application type information and sound type information. This allows sounds from different applications and different types of system sounds to be played through different audio playback devices, improving the quality of audio zoning.
[0037] In one optional embodiment, the application type information can be the application category or a specific application whitelist. For example, entertainment applications such as music playback applications and video playback applications correspond to one audio partition, while work applications such as navigation applications, telephone applications, and alarm clock applications correspond to another audio partition. Furthermore, specific applications can be stored as whitelists corresponding to their respective audio partitions. For example, applications A, B, and C can be saved as a whitelist for one audio partition, and applications D, E, and F as a whitelist for another audio partition, where A to F represent the identifiers corresponding to specific applications. The sound type information can be the type of system sound or a specific system sound type whitelist. For example, prompt tones such as key tones correspond to one audio partition, while notification tones such as message notification tones and call tones correspond to another audio partition. Alternatively, G and H can be set as whitelists corresponding to one partition, and I and J as whitelists corresponding to another partition, where G to J represent the identifiers corresponding to a specific sound (such as key tones, call tones, or message notification tones).
[0038] In one alternative implementation, the Android system defines many sound types, such as: AUDIO_STREAM_RING (ringtone), AUDIO_STREAM_VOICE_CALL (phone call), AUDIO_STREAM_NOTIFICATION (notification tone), AUDIO_STREAM_ALARM (alarm), and AUDIO_STREAM_MUSIC (music). For example, if you want navigation sounds (notification tones) and music to be separate, you can configure AUDIO_STREAM_NOTIFICATION and AUDIO_STREAM_MUSIC in the audio partition information to associate different audio partitions, thus achieving sound partitioning, that is, playing a specific sound in different audio partitions. For example, if a user wants KuGou and QQ Music to output from different audio partitions, this cannot be achieved by using audio types. The Android system will recognize the audio type played by these two applications as AUDIO_STREAM_MUSIC, and can only be determined by the app's package name. Therefore, audio type and application type complement each other, and users can configure audio partition information according to their own needs.
[0039] Figure 3 This is a diagram illustrating the correspondence between system audio partitions and sound cards according to an embodiment of this disclosure. (Refer to...) Figure 3 In some embodiments, the audio playback devices corresponding to the same audio partition are bound to the same sound card. In this way, audio playback devices (which can be one or more) for the same partition are bound to a single sound card, achieving normal audio output while conserving sound card resources.
[0040] In one alternative embodiment, the audio partition information and the associated information are both stored in XML file format. They can be stored in a single XML file configuration file or separately in different XML file configuration files, which is not limited here.
[0041] In one optional implementation, an example of storing audio partition information and associated information is provided, which is stored in the audio_partitions_conf.xml file, with the following configuration content:
[0042] <?xml version="1.0" encoding="UTF-8"?> / * Header, declaring that the XML version used is 1.0 and the encoding method is UTF-8 * /
[0043] <audio_partitions_conf version="1.0"> / * Declare the version of the audio_partitions_conf.xml file as 1.0 * /
[0044] <modules> / * two modules tags between modules * /
[0045] <module name="Audio Partitions First"> / * define module name as Audio Partitions First, first audio partition * /
[0046] <profile name="Driver Zone" device="AUDIO_DEVICE_OUT_SPEAKER" / > / * define first audio partition profile name as Driver Zone, audio playback device information as speaker in Android system, namely AUDIO_DEVICE_OUT_SPEAKER * /
[0047] <apps> / * Define the application white list * /
[0048] <packages name="com.baidu.BaiduMap"> / * Identify the application according to the package name of the application * /
[0049] <packages name="com.autonavi.minimap">
[0050] <packages name="com.google.android.apps.maps">
[0051] < / apps>
[0052] <streamtypes> / * Define a white list of sound types * /
[0053] <type name="AUDIO_STREAM_RING"> / * Identify the sound type according to the sound type name in the Android system * /
[0054] <type name="AUDIO_STREAM_VOICE_CALL">
[0055] <type name="AUDIO_STREAM_NOTIFICATION">
[0056] <type name="AUDIO_STREAM_ALARM">
[0057] < / streamtypes>
[0058]
[0059] <module name="Audio Partitions Second">
[0060] <profile name="Passenger Zone" device="AUDIO_DEVICE_OUT_AUX_DIGITAL" / > / * define second audio partition profile name as Passenger Zone, audio playback device information as HDMI audio output in Android system, namely AUDIO_DEVICE_OUT_AUX_DIGITAL * /
[0061] <apps>
[0062] <packages name="com.tencent.qqmusic">
[0063] < / apps>
[0064] <streamtypes>
[0065] <type name="AUDIO_STREAM_MUSIC">
[0066] < / streamtypes>
[0067]
[0068] < / modules>
[0069] < / audio_partitiopns_conf>
[0070] Two audio partitions are defined: Audio Partition 1 (Driver's Area) is configured with a whitelist of specific applications (map applications) and a whitelist of specific sound types (ringtones, notification sounds, phone calls, alarms); Audio Partition 2 (Passenger's Area) is configured with a whitelist of specific applications (QQ Music) and a whitelist of specific sound types (music). Each partition corresponds to a different audio playback device, or a different sound card, thus quickly implementing the two partitions: the driver's area and the passenger's area.
[0071] The specific steps for parsing this XML file are as follows:
[0072] ① The Android C++ layer implements the AudioPartitionsXmlParser class. This class parses XML files, reads the values of elements such as module, profile, device, Apps, and StreamTypes, and creates an audio partition linked list, an application whitelist linked list corresponding to the audio partition, and a sound type whitelist linked list corresponding to the audio partition. ② During system startup, the AudioFlinger service starts. This service calls the AudioPartitionsXmlParser class at the corresponding location in the startup code to parse audio_partitions_conf.xml and complete the creation of the three linked lists in step ①. ③ When the Android system plays audio, it goes through AudioTrack (Android audio system). The application package name and audio type can be obtained from AudioTrack. The obtained application package name or audio type is searched from the linked list created in step ② to match the specific audio partition device and complete the audio partition creation.
[0073] Figure 4 This is a flowchart illustrating a method for playing audio according to an embodiment of the present invention in a real-world scenario, with reference to... Figure 4 The method includes steps 201 to 210.
[0074] In step 201, start the car.
[0075] In step 202, the vehicle's infotainment system is started, and the audio service is activated.
[0076] In step 203, the XML format file is parsed, which includes audio partition information.
[0077] In step 204, the audio service startup completion signal is received.
[0078] In step 205, determine whether an audio playback request has been received. If so, determine whether the playback type in the audio playback request is an application type or a sound type. If it is an application type, proceed to step 206; if it is a sound type, proceed to step 210. The sound generated by the application after opening an application (such as a map, music, or video application) is the application type, and the sound generated by operating the original system (such as key tones or telephone call tones) is the sound type.
[0079] In step 206, iterate through the application whitelists corresponding to all audio partitions in the audio partition information, and determine whether the application corresponding to the playback type is in the application whitelist of the first audio partition. If so, proceed to steps 207 to 208; otherwise, proceed to step 209.
[0080] In step 207, the first audio playback device information corresponding to the first audio partition is obtained based on the audio partition information.
[0081] In step 208, sound is output from the sound card corresponding to the first audio playback device.
[0082] In step 209, sound is output through the system's default sound card.
[0083] In step 210, traverse the whitelist of sound types corresponding to all audio partitions in the audio partition information, and determine whether the sound type corresponding to the playback type is in the whitelist of sound types of the first audio partition. If so, proceed to steps 207 to 209; otherwise, proceed to step 209.
[0084] According to another aspect of the invention, Figure 5 This is a block diagram illustrating an apparatus 300 for playing audio according to an embodiment of the present invention. (Refer to...) Figure 5 The device 300 includes a partition resolution module 302, a binding module 304, and a sound output module 306.
[0085] The partition parsing module 302 is configured to parse audio partition information, which includes audio playback device information and playback type information associated with the audio partition. The partition parsing module 302 is further configured to receive the audio partition information configured in XML file format.
[0086] The binding module 304 is configured to associate an audio playback device corresponding to the audio playback device information with the audio partition based on the audio partition information. The binding module 304 is also configured to associate the audio playback device with the sound card corresponding to the audio partition.
[0087] The sound output module 306 is configured to play audio corresponding to the playback type information through the audio playback device according to the audio partition information. The sound output module 306 is configured to: acquire an audio playback request; read the playback type in the audio playback request; acquire the audio partition corresponding to the playback type according to the playback type information; and play the audio corresponding to the playback type in the audio playback request through the audio playback device corresponding to the audio partition.
[0088] In some embodiments, the sound output module 306 is configured to play sound from a specified sound card via AudioFlinger and AudioHal. AudioFlinger is the executor of audio policies in the Audio Services of the Android system, responsible for managing input and output stream devices and processing and transmitting PCM (native audio data in the Android system). AudioHal is the hardware abstraction layer in the Android system, located between Audio Services and the kernel (Android system kernel), responsible for the interaction between audio and hardware devices, and is called by AudioFlinger.
[0089] Furthermore, in some embodiments, the partition resolution module 302, the binding module 304, and the sound output module 306 may be configured to perform the corresponding steps or actions in the method 100 described above, the details of which are omitted here.
[0090] According to another aspect of the invention, Figure 6 This is a schematic diagram illustrating an electronic device 400 according to an embodiment of the present invention. (Refer to...) Figure 6 The electronic device 400 includes a memory 402, a processor 404, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the various steps or actions of the method for playing audio as described above.
[0091] According to another aspect of the present invention, a computer-readable medium is provided. The computer-readable medium stores a computer program that is executed by a processor to implement the method described above for compatibility with different interface specifications.
[0092] In summary, the method, apparatus, electronic device, and storage medium for playing audio provided by this invention utilize XML format files to configure the association between audio partitions and audio playback devices, as well as the association between audio partitions and playback types. Upon receiving an audio playback request, the system can match the playback type in the request to the corresponding audio playback device in the audio partition for audio playback. This allows different audio playback devices to be invoked based on different playback types. Furthermore, when associating audio playback devices with audio partitions, the system can provide different audio playback services to passengers in different locations based on the location of the audio playback device, improving the passenger experience. Moreover, no hardware modifications or upgrades are required; only software settings are needed, significantly reducing costs.
[0093] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent modifications made based on the content of the present invention specification and drawings, or direct or indirect applications in related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A method for playing audio, characterized by, The method comprises: parsing audio partition information, the audio partition information comprising audio playback device information associated with an audio partition and playback type information, the playback type information comprising application type information and sound type information; associating, according to the audio partition information, an audio playback device corresponding to the audio playback device information with a sound card corresponding to the audio partition; obtaining an audio playback request, reading a playback type in the audio playback request; obtaining, according to the playback type information, an audio partition corresponding to the playback type, comprising: when playing an audio, first determining whether there is configured application type in configuration information, the configuration information corresponding audio partitions with different playback types; if yes, preferentially determining a corresponding audio partition according to the application type information; otherwise, determining whether there is configured sound type in the configuration information, and determining a corresponding audio partition according to the sound type information; and playing, through an audio playback device corresponding to the audio partition, an audio corresponding to the playback type in the audio playback request.
2. The method of claim 1, wherein, The associating, with a sound card corresponding to the audio partition, of an audio playback device corresponding to the audio playback device information comprises: binding the audio playback devices corresponding to the same audio partition on the same sound card.
3. The method of claim 1, wherein, The method further comprises: configuring a default audio playback device; and if an audio partition corresponding to the playback type is not obtained according to the playback type information, playing, through the default audio playback device, an audio corresponding to the playback type in the audio playback request. The playing, through an audio playback device corresponding to the audio partition, of an audio corresponding to the playback type in the audio playback request comprises:
4. The method of claim 1, wherein, obtaining a sound card associated with the audio playback device; and playing the audio through the sound card. The method further comprises:
5. The method of claim 1, wherein, configuring the audio partition information in an XML file format. The method comprises:
6. An apparatus for playing audio, the apparatus comprising: a partition parsing module configured to parse audio partition information, the audio partition information comprising audio playback device information associated with an audio partition and playback type information, the playback type information comprising application type information and sound type information; a binding module configured to associate, according to the audio partition information, an audio playback device corresponding to the audio playback device information with a sound card corresponding to the audio partition; and a sound output module configured to: obtain an audio playback request, read a playback type in the audio playback request; obtain, according to the playback type information, an audio partition corresponding to the playback type; and play, through an audio playback device corresponding to the audio partition, an audio corresponding to the playback type in the audio playback request, wherein the sound output module is configured to: when playing an audio, first determine whether there is configured application type in configuration information, the configuration information corresponding audio partitions with different playback types; if yes, preferentially determine a corresponding audio partition according to the application type information; otherwise, determine whether there is configured sound type in the configuration information, and determine a corresponding audio partition according to the sound type information. The method comprises:
7. An electronic device, comprising: a memory configured to store a computer program; and a processor configured to execute the computer program. a processor configured to execute the computer program to perform the method according to any one of claims 1 to 5.
8. A computer readable medium having stored thereon a computer program, characterized in that the computer program is executed by a processor to implement the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method, device and system for multi-sound-area audio playing management
CN113407762A
Audio processing method and vehicle-mounted multimedia equipment
CN114501296A