CN110321099B - Sound card control method, device, terminal and storage medium - Google Patents

Sound card control method, device, terminal and storage medium Download PDF

Info

Publication number
CN110321099B
CN110321099B CN201910579178.9A CN201910579178A CN110321099B CN 110321099 B CN110321099 B CN 110321099B CN 201910579178 A CN201910579178 A CN 201910579178A CN 110321099 B CN110321099 B CN 110321099B
Authority
CN
China
Prior art keywords
registration
sound card
subsystem
thread
state
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910579178.9A
Other languages
Chinese (zh)
Other versions
CN110321099A (en
Inventor
裴琨
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Guangdong Oppo Mobile Telecommunications Corp Ltd
Original Assignee
Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Guangdong Oppo Mobile Telecommunications Corp Ltd filed Critical Guangdong Oppo Mobile Telecommunications Corp Ltd
Priority to CN201910579178.9A priority Critical patent/CN110321099B/en
Publication of CN110321099A publication Critical patent/CN110321099A/en
Application granted granted Critical
Publication of CN110321099B publication Critical patent/CN110321099B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/16Sound input; Sound output
    • G06F3/162Interface to dedicated audio devices, e.g. audio drivers, interface to CODECs

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephone Function (AREA)

Abstract

The embodiment of the invention discloses a sound card control method, a sound card control device, a sound card control terminal and a storage medium. The method comprises the following steps: the method comprises the steps that a first thread executes a sound card registration process, wherein the sound card registration comprises registration of a plurality of subsystems, and a second thread acquires the registration state of a first subsystem of a sound card in the sound card registration process; the first subsystem is registered successfully or unsuccessfully in the current registration represented by the registration state; determining that sound card registration performed by the first thread fails; and when the registration state of the first subsystem obtained by the second thread delay represents that the registration of the first subsystem is successful, triggering the sound card to register again.

Description

Sound card control method, device, terminal and storage medium
Technical Field
The invention relates to the technical field of intelligent terminals, in particular to a sound card control method, a sound card control device, terminal equipment and a storage medium.
Background
With the development of intelligent terminal technology, the functions of terminal devices (such as smart phones, tablet computers, wearable intelligent devices and the like) are becoming more and more abundant. The sound card is a commonly used structural module for realizing the audio playing function of the terminal equipment, and whether the sound card can be registered successfully or not directly influences whether the audio of the terminal equipment can be played normally or not.
The registration process of the sound card of the intelligent terminal comprises the registration processes of a plurality of subsystems, if any subsystem in the subsystems is not successfully registered, the whole sound card fails to be registered, and thus the serious silent problem can occur after the terminal is started.
Disclosure of Invention
In order to solve the related technical problems, embodiments of the present invention provide a method and an apparatus for controlling a sound card, a terminal device, and a storage medium.
The embodiment of the invention provides a control method of a sound card, which comprises the following steps:
the method comprises the steps that a first thread executes a sound card registration process, wherein the sound card registration comprises registration of a plurality of subsystems, and a second thread acquires the registration state of a first subsystem of a sound card in the sound card registration process; the obtained registration state representation is registered successfully or unsuccessfully in the first subsystem in the current registration;
determining that sound card registration performed by the first thread fails;
and when the registration state of the first subsystem acquired by the second thread delay represents that the registration of the first subsystem is successful, triggering the sound card to register again.
In the foregoing solution, the acquiring the registration status of the first subsystem of the sound card includes:
and acquiring the registration state of the first subsystem in the sound card registration process based on a preset time rule.
In the above scheme, acquiring the registration state of the first subsystem in the sound card registration process based on a preset time rule includes:
and periodically acquiring the registration state of the first subsystem in the sound card registration process until the registration state of the first subsystem is acquired.
In the foregoing solution, the acquiring the registration status of the first subsystem of the sound card includes:
obtaining a registration status of the first subsystem from the first subsystem through an Application Programming Interface (API).
In the foregoing solution, the triggering the sound card to register again includes:
and triggering the sound card to register again in a mode of adding virtual equipment.
In the foregoing solution, when the registration state of the first subsystem obtained by the second thread delay indicates that the registration of the first subsystem is successful, triggering the sound card to perform registration again includes:
determining that the sound card registration failure executed by the first thread is generated when the first thread does not acquire a registration state representing the successful registration of the first subsystem within a first preset time;
and when the registration state of the first subsystem obtained by the second thread after the first preset time period represents that the registration of the first subsystem is successful, triggering the sound card to register again.
In the above solution, the determining that the sound card failure executed by the first thread is generated when the first thread does not acquire the registration state indicating that the registration of the first subsystem is successful within a first preset time period includes:
traversing the registration states of all subsystems of the sound card in the current registration within a corresponding preset time length;
and determining that the sound card registration failure executed by the first thread is generated because the first thread does not acquire the registration state representing the successful registration of the first subsystem within a first preset time length based on the registration states of all subsystems within corresponding preset time lengths in the current registration.
In the foregoing solution, the acquiring a registration status of the first subsystem of the sound card includes:
the second thread acquires the registration state of the first subsystem from a preset storage space; after the registration is finished, the first subsystem stores the registration state of the first subsystem to a preset storage space.
The embodiment of the invention also provides a control device of the sound card, which comprises:
a first processing unit for performing a process of sound card registration by a first thread, the sound card registration including registration of a plurality of subsystems;
the second processing unit is used for acquiring the registration state of the first subsystem of the sound card in the sound card registration process by a second thread; the obtained registration state representation is registered successfully or unsuccessfully in the first subsystem in the current registration;
the trigger unit is used for determining that the sound card registration executed by the first thread fails; and when the registration state of the first subsystem acquired by the second thread delay is determined to represent that the registration of the first subsystem is successful, triggering the sound card to register again.
An embodiment of the present invention further provides a terminal, including: a processor and a memory for storing a computer program capable of running on the processor,
wherein the processor is configured to perform the steps of any of the above methods when running the computer program.
An embodiment of the present invention further provides a storage medium, on which a computer program is stored, where the computer program implements the steps of any one of the above methods when executed by a processor.
According to the control method and device of the sound card, the terminal device and the storage medium provided by the embodiment of the invention, a first thread executes the process of sound card registration, the sound card registration comprises the registration of a plurality of subsystems, and a second thread acquires the registration state of the first subsystem of the sound card in the process of sound card registration; the obtained registration state representation is registered successfully or unsuccessfully in the first subsystem in the current registration; determining that sound card registration performed by the first thread fails; and when the registration state of the first subsystem obtained by the second thread in a delayed manner represents that the registration of the first subsystem is successful, triggering the sound card to re-register, synchronously obtaining the registration state of the first subsystem in the registration process of the sound card, and registering a virtual device when the registration state of the first subsystem is updated to be successful and the registration of the sound card fails, and further triggering the sound card to re-register, thereby ensuring the successful registration of the sound card.
Drawings
Fig. 1 is a schematic structural diagram of a mobile terminal according to an embodiment of the present invention;
fig. 2 is a schematic flow chart of a control method of a sound card according to an embodiment of the present invention;
FIG. 3 is a schematic flow chart of sound card registration according to an embodiment of the present invention;
fig. 4 is a schematic flow chart of a related art sound card registration;
fig. 5 is a schematic structural diagram of a control device of a sound card according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention are clearly and completely described below with reference to the drawings in the embodiments of the present invention. It is to be understood that the specific embodiments described herein are for purposes of illustration and not limitation. It should be further noted that for convenience of description, only some of the structures associated with the present application, but not all of them, are illustrated in the accompanying drawings.
In some flows of embodiments of the invention involving a plurality of operations occurring in a particular order, it should be clear that these operations may be performed out of order or in parallel as they occur herein, the order of the operations, such as 201, 202, etc., described below, merely distinguishing between various operations, and the order of the operations themselves does not represent any order of performance. Additionally, the flows may include more or fewer operations, and the operations may be performed sequentially or in parallel.
For convenience of description, only the parts related to the embodiments of the present invention are shown, and details of the specific techniques are not disclosed, please refer to the method part in the embodiments of the present invention. Further, it should be noted that a "terminal" as used in embodiments of the present invention may include, but is not limited to, a device configured to receive/transmit communication signals via a wireline connection, such as via a public-switched telephone network (PSTN), a Digital Subscriber Line (DSL), a digital cable, a direct cable connection, and/or via another data connection/network, and/or via a wireless interface, such as with respect to a cellular network, a Wireless Local Area Network (WLAN), a digital television network such as a DVB-H network, a satellite network, an AM-FM broadcast transmitter, and/or another communication terminal. A terminal that is arranged to communicate over a wireless interface may be referred to as a "wireless communication terminal", "wireless terminal", or "mobile terminal". Examples of mobile terminals include, but are not limited to, satellite or cellular telephones; a Personal Communications System (PCS) terminal that may combine a cellular radiotelephone with data processing, facsimile and data communications capabilities; PDAs that may include radiotelephones, pagers, internet/intranet access, web browsers, notepads, calendars, and/or Global Positioning System (GPS) receivers; and conventional laptop and/or palmtop receivers or other electronic devices that include a radiotelephone transceiver.
In addition, the terminal according to the embodiment of the present invention may further include a mobile power source, where the mobile power source is capable of receiving the charging of the adapter, so as to store energy and provide energy for other electronic devices, including but not limited to electric vehicles, notebook mobile computers, unmanned aerial vehicles, tablet computers, electronic books, smart electronic devices including smart speakers, such as watches, bracelets, smart glasses, sweeping robots, or other electronic products that may use or may use sound devices such as sound cards and speakers, or wireless headsets, electric toothbrushes, charging mice, and the like that implement a sound generation function.
In the following description, a mobile terminal will be exemplified, and it will be understood by those skilled in the art that the construction according to the embodiment of the present invention can be applied to a mobile terminal of a stationary type, in addition to elements particularly used for moving purposes.
Fig. 1 is a hardware structure diagram of a partial structure of a mobile terminal related to an embodiment of a method provided in an embodiment of the present invention. As shown in fig. 1, the mobile phone may include: radio Frequency (RF) circuit 110, memory 120, input unit 130, display unit 140, sensor 150, audio circuit 160, wireless-fidelity (Wi-Fi) module 170, processor 180, and power supply 190. Those skilled in the art will appreciate that a mobile terminal having various components is illustrated in fig. 1, but it is understood that not all illustrated components are required to be implemented, and that more or fewer components may alternatively be implemented.
The various components of the mobile terminal are described in greater detail below in conjunction with fig. 1.
The RF circuit 110 may be used for receiving and transmitting signals during information transmission or communication; specifically, the downlink information of the base station is received and then processed by the processor 180; in addition, the uplink data is transmitted to the base station. In general, the RF circuitry 110 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like. In addition, the RF circuitry 110 may also communicate with networks and other devices via wireless communications. The wireless communication may use any communication standard or protocol including, but not limited to, global system for mobile communications (GSM), general Packet Radio Service (GPRS), code Division Multiple Access (CDMA), wideband Code Division Multiple Access (WCDMA), long Term Evolution (LTE), email, short Message Service (SMS), etc.
The memory 120 may be used to store software programs and modules, and the processor 180 executes various functional applications and data processing of the mobile terminal by operating the software programs and modules stored in the memory. The memory 120 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program (such as a sound playing function) required by at least one function, and the like; the storage data area may store data (such as audio data) created according to the use of the mobile terminal, and the like. Further, the memory 120 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device, that is, the memory 120 may be either volatile memory or non-volatile memory, and may also include both volatile and non-volatile memory. Among them, the nonvolatile Memory may be a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), an Electrically Erasable Programmable Read-Only Memory (EEPROM), a magnetic random access Memory (FRAM), a Flash Memory (Flash Memory), a magnetic surface Memory, an optical Disc, or a Compact Disc Read-Only Memory (CD-ROM); the magnetic surface storage may be disk storage or tape storage. Volatile Memory can be Random Access Memory (RAM), which acts as external cache Memory. By way of illustration, and not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), synchronous Static Random Access Memory (SSRAM), dynamic Random Access Memory (DRAM), synchronous Dynamic Random Access Memory (SDRAM), double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), double Data Rate Synchronous Random Access Memory (ESDRAM), enhanced Synchronous Dynamic Random Access Memory (ESDRAM), enhanced Synchronous Random Access Memory (DRAM), synchronous Random Access Memory (DRAM), direct Random Access Memory (DRmb Access Memory). The memory 120 described in embodiments of the invention is intended to comprise, without being limited to, these and any other suitable types of memory.
The input unit 130 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the mobile terminal. Specifically, the input unit 130 may include a touch panel 131. Here, the touch panel 131, also referred to as a touch screen, may collect touch operations of a user (e.g., operations of a user on or near the touch panel using any suitable object or accessory such as a finger or a stylus) thereon or nearby, and drive the corresponding connection device according to a preset program. The touch panel 131 may include two parts of a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device and converts it to touch point coordinates, which are then provided to the processor 180 and can receive commands from the processor and execute them. In addition, the touch panel may be implemented in various types such as a resistive type, a capacitive type, an infrared ray, and a surface acoustic wave. The input unit may include other input devices 132 in addition to the touch panel. In particular, other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 140 may be used to display information input by a user or information provided to the user and various menus of the mobile phone. The display unit may include a display panel 141, and the display panel 141 may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light Emitting Diode (OLED), or the like. Further, the touch panel 131 can cover the display panel 141, and when the touch panel 131 detects a touch operation on or near the touch panel 131, the touch operation is transmitted to the processor 180 to determine the type of the touch event, and then the processor 180 provides a corresponding visual output on the display panel 141 according to the type of the touch event. Although in fig. 1, the touch panel 131 and the display panel 141 are implemented as two separate components to implement the input and output functions of the mobile terminal, in some embodiments, the touch panel 131 and the display panel 141 may be integrated to implement the input and output functions of the mobile terminal.
The mobile terminal may also include at least one sensor 150, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor that adjusts the brightness of the display panel according to the brightness of ambient light, and a proximity sensor that turns off the display panel and/or the backlight when the mobile phone is moved to the ear. As one of the motion sensors, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when stationary, and can be used for applications of recognizing the gesture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer gesture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; the mobile terminal may also be configured with other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which will not be described herein.
For the audio circuit 160, a speaker and microphone may provide an audio interface between the user and the mobile terminal. The audio circuit 160 may transmit the electrical signal converted from the received audio data to a speaker, and convert the electrical signal into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electric signal, which is received by the audio circuit 160 and converted into audio data, which is then processed by the audio data output processor 180, and then transmitted to, for example, another mobile terminal via the RF circuit 110, or the audio data is output to the memory 120 for further processing.
WiFi belongs to a short-distance wireless transmission technology, and the mobile terminal can help a user to send and receive e-mails, browse webpages, access streaming media and the like through the WiFi module 170, and provides wireless broadband internet access for the user. Although fig. 1 shows the WiFi module 170, it is understood that it does not belong to the essential constitution of the mobile terminal, and may be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 180 is a control center of the mobile terminal, connects various parts of the entire mobile phone using various interfaces and lines, and performs various functions of the mobile phone and processes data by running or executing applications and/or modules stored in the memory 120 and calling data stored in the memory 120, thereby integrally monitoring the mobile terminal.
In practical applications, the mobile terminal further includes a power supply 190 (such as a battery) for supplying power to each component, and the power supply 190 may be logically connected to the processor 180 through a power management system, so as to implement functions of managing charging, discharging, and power consumption management through the power management system.
Although not shown, the mobile terminal may further include a camera, etc., which will not be described in detail herein.
In addition, the memory 120 stores a computer program, and the processor 180 implements the steps of any one of the methods according to the embodiments of the present invention when running the computer program.
In another aspect, the present invention provides a storage medium, specifically a computer storage medium, for example, a memory 120 storing a computer program, which is executable by a processor 180 of a mobile terminal to perform the steps of any one of the methods of the embodiments of the present invention. The computer readable storage medium may be Memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash Memory, magnetic surface Memory, optical disk, or CD-ROM.
Viewed from another aspect, embodiments of the present invention also provide a terminal comprising a processor and a memory storing a computer program capable of running on the processor,
wherein the processor is configured to execute the steps of any one of the methods according to the embodiments of the present invention when the computer program is executed.
Currently, the intelligent terminal of the mainstream Android (Android) system uses an ASOC audio system based on Linux, in the starting process of the Android system, an ASOC sound card can be started and registered, the sound card comprises a plurality of subsystems (also called sub-modules), and the registration failure of any subsystem can cause the registration failure of the ASOC sound card, so that the abnormality of the sound function is caused.
As mentioned above, the registration process of the sound card includes registration processes of many subsystems, and a failure of registration of any subsystem results in a failure of registration of the sound card. The inventor finds out in the process of implementing the invention that: there are various reasons why a subsystem registration of a sound card fails, but one of the common reasons is that: the successful registration state update is delayed due to the time consumption of the registration of the subsystem, in other words, the time consumption of the registration of the subsystem causes that the successful registration state of the subsystem cannot be known in time, thereby causing the registration failure of the sound card. In practical application, for the state update delay caused by the registration time consumption of the subsystem itself, a preset time length may be set during implementation, and if the registration time consumption of the subsystem itself is greater than the preset time length, the state update delay may be estimated as the update delay, that is, the state update delay caused by the registration time consumption of the subsystem itself is determined. It should be noted that the foregoing embodiments do not limit the method for determining the time-consuming delay for subsystem registration.
Based on this, in various embodiments of the present invention, in the registration process of the sound card, the registration state of the subsystem is synchronously obtained, until the registration state is updated to be a successful state by the subsystem and the sound card registration fails, a virtual device is registered, and further the sound card is triggered to be re-registered, thereby ensuring that the sound card registration is successful.
Fig. 2 is a schematic flow chart of a method for controlling a sound card according to an embodiment of the present invention. As shown in fig. 2, the method for controlling a sound card according to the embodiment of the present invention includes:
step 201: a first thread executes a process of sound card registration, wherein the sound card registration comprises a plurality of sound card subsystems including at least a first subsystem, and a second thread acquires the registration state of the first subsystem of the sound card in the process of sound card registration;
step 202: determining that the sound card registration executed by the first thread fails;
step 203: and when the registration state of the first subsystem acquired by the second thread delay represents that the registration of the first subsystem is successful, triggering the sound card to register again.
In step 201, during the process of performing sound card registration by the first thread, the second thread synchronously acquires the registration state of the first subsystem.
And the obtained registration state representation shows that the first subsystem is successfully registered or fails to be registered in the current registration.
Here, the embodiment of the present invention does not specify the concrete expression form of the acquired registration state; accordingly, the specific characteristics for judging the success or failure of registration are different, and the specific characteristics for success or failure of registration can be set according to actual needs. For example, a parameter may be set, the value of the parameter may be set to 1 when registration is successful, the value of the parameter may be set to 0 when registration is failed, and so on.
In practical applications, the first subsystem may be any subsystem of the multiple subsystems of the sound card, and which subsystem of the sound card is used as the first subsystem may also be determined as needed. For example, the sound problem caused by the delay of the successful registration status update of the subsystem of the sound card is determined, that is, the preset sound problem of the mobile terminal is determined, before the sound card is registered, all the subsystems of the sound card are traversed, the subsystem related to the preset sound problem of the mobile terminal is determined, and the determined subsystem is used as a first subsystem, and in practical application, the first subsystem may be an ADSP module and/or a bluetooth module in the sound card.
In practical application, the related threads can be created and executed to traverse all subsystems of the sound card, blocks can be divided into the subsystems according to functions which can be realized by the sound card subsystems, each block at least comprises two subsystems, and the threads are individually created and executed to traverse each block so as to determine the sound card subsystem related to the preset sound problem. Of course, it is to be understood that: traversing all subsystems of the sound card may also be in other manners, which is not limited by the embodiment of the present invention.
Here, in actual application, the number of the first subsystems is at least one.
In practical application, when the first subsystem is any subsystem of the multiple subsystems of the sound card, in implementing the scheme of the embodiment of the present invention, the second thread traverses all the sound card subsystems to acquire the registration states of all the sound card subsystems of the sound card. In an embodiment, when the second thread traverses the subsystems of the sound card, the registration state of the corresponding subsystem may be obtained after each subsystem starts to register for a corresponding preset time period (the first thread determines whether the corresponding subsystem successfully registers according to whether the preset time period obtains the registration state update).
The first thread is used for realizing the registration of the sound card, so the first thread can be understood as a main thread. Accordingly, the second thread is at least used for acquiring the registration status of the first subsystem, and therefore, the second thread may be understood as a child thread and may also be understood as a work queue.
In an embodiment, the second thread may obtain the registration status of the first subsystem by calling the API, that is, obtain the registration status of the first subsystem from the first subsystem by calling the API.
Certainly, in practical applications, the first subsystem may further store the registration state of the first subsystem in a preset storage space after the first subsystem completes registration (success or failure), and the second thread acquires the registration state of the first subsystem from the preset storage space by calling the API.
In actual application, in order to save resources and ensure that the second thread can acquire the registration state of the first subsystem, the second thread may acquire the registration state of the first subsystem based on a certain time rule.
Based on this, in an embodiment, the acquiring the registration status of the first subsystem of the sound card includes:
and acquiring the registration state of the first subsystem in the sound card registration process based on a preset time rule.
Here, in practical applications, the preset time rule may be determined as needed, and one implementation manner is that the second thread periodically obtains the registration status of the first subsystem.
Based on this, in an embodiment, acquiring the registration state of the first subsystem in the sound card registration process based on a preset time rule includes:
in the sound card registration process, the registration state of the first subsystem is obtained periodically (a time interval may be set as needed, for example, at an interval of 100ms, etc.), until the registration state of the first subsystem is obtained. For example, the periodic acquisition of the registration status of the first subsystem may be implemented by setting a timer.
Certainly, the preset time rule may also be that the registration state of the first subsystem is obtained a plurality of times aperiodically until the registration state of the first subsystem is obtained, that is, a time interval between two adjacent obtaining operations in the plurality of obtaining operations is not fixed but is variable, and assuming that the registration state of the first subsystem is obtained after obtaining five times, since the registration process is time-consuming, the time interval may be set from long to short, that is, the time interval is gradually shortened, so as to ensure that the registration state can be obtained in time after the registration of the first subsystem is completed, and therefore the time interval may be set to be 120ms, 100ms, 80ms, and 60ms, respectively.
In practice, steps 202-203 may be performed by a third thread different from the first thread and the second thread, or may be performed by the second thread.
In practical application, the first thread may store the registration result (for example, the registration success is set to 1, the registration failure is set to 0, and the like) of the successful or failed registration of the sound card in this time into a preset storage space, the thread (the second thread or the third thread) executing steps 202 to 203 may obtain the registration result from the preset storage space, and the successful or failed registration of the sound card in this time is determined according to the obtained registration result.
In step 202, during actual application, the thread executing steps 202 to 203 may first determine whether the sound card registration failure is caused by a status update delay caused by registration success due to time consumption of registration of the first subsystem, and then trigger the sound card to re-register when it is determined that the sound card registration failure is caused by the status update delay caused by registration success due to time consumption of registration of the first subsystem, so as to further ensure success of sound card registration.
Based on this, in an embodiment, it is determined that the sound card registration failure performed by the first thread is generated when the first thread does not acquire a registration state representing that the first subsystem is successfully registered within a first preset time period;
and when the registration state of the first subsystem, which is acquired by the second thread after the first preset time, represents that the registration of the first subsystem is successful, triggering the sound card to register again.
Here, in practical application, the thread executing steps 202 to 203 may determine whether the registration of the sound card at this time fails due to a state update delay caused by successful registration because of time consumption of registration of the first subsystem by traversing all subsystems of the sound card.
Based on this, in an embodiment, the determining that the sound card failure of the first thread execution is caused by the first thread failing to acquire the registration status indicating that the first subsystem registration is successful within a first preset time period includes:
traversing the registration states of all subsystems of the sound card in the current registration within a corresponding preset time length;
and determining that the sound card registration failure executed by the first thread is generated because the first thread does not acquire the registration state representing the successful registration of the first subsystem within the first preset time length based on the registration states of all the subsystems within the corresponding preset time length in the current registration.
When steps 202 to 203 are executed by the third thread, the third thread may acquire the registration status of the first subsystem acquired by the second thread in many ways, for example, the second thread may notify the acquired registration status of the first subsystem to the third thread, and for example, the acquired registration status of the first system may be stored in the preset storage space, and the third thread acquires the registration status of the first system from the preset storage space.
In step 203, in an embodiment, the triggering the sound card to re-register includes:
and triggering the sound card to register again in a mode of adding virtual equipment.
For example, when the audio system is a Linux system, a platform _ device _ add (pdev) interface function may be set to implement adding a virtual device.
In the method for controlling a sound card provided by the embodiment of the present invention, a first thread executes a process of sound card registration, the sound card registration includes registration of a plurality of subsystems, and a second thread acquires a registration state of the first subsystem of the sound card during the sound card registration process; the obtained registration state representation is registered successfully or unsuccessfully in the first subsystem in the current registration; determining that sound card registration performed by the first thread fails; and when the registration state of the first subsystem obtained by the second thread in a delayed manner represents that the registration of the first subsystem is successful, triggering the sound card to re-register, synchronously obtaining the registration state of the first subsystem in the registration process of the sound card, and registering a virtual device when the registration state of the first subsystem is updated to be successful and the registration of the sound card fails, and further triggering the sound card to re-register, thereby ensuring the successful registration of the sound card.
The present invention will be described in detail with reference to the following application examples.
In the embodiment of the application, the mobile phone operating system is Android, the audio system is a Linux-based ASOC audio system, the audio system is based on an Advanced Linux Sound Architecture (ALSA) audio system, and in the starting process of the Android system, a sound card of the ASOC audio system is started and registered.
As shown in fig. 3, the process of registering a sound card in the embodiment of the present application includes the following steps:
step 301: the first thread starts sound card registration;
step 302: registering each subsystem of the sound card, wherein in the registering process, a second thread acquires the registering state of a preset subsystem (a first subsystem), namely, a work queue is started to acquire the registering state of the preset subsystem, and then step 303 is executed;
step 303: the first thread judges whether the registration of the sound card is successful according to the registration state of each subsystem, if the registration is successful, the mobile phone starts the sound to be normal, and if the registration is failed, step 304 is executed;
step 304: when the sound card is registered, judging whether the registration state of the preset subsystem acquired by the work queue represents the registration state of the preset subsystem, if so, executing a step 306, otherwise, executing a step 305;
step 305: after waiting for a preset duration, acquiring the registration state of the preset subsystem again, and then executing step 304;
step 306: adding a virtual device (in a platform _ device _ add (pdev) mode) triggers the sound card to re-register, and then executing step 301.
In step 303, the first thread may obtain the registration state of each subsystem within the corresponding preset time, and in this registration, due to the delayed update of the registration state of the preset subsystem, the first thread does not obtain the registration state of the preset subsystem for local registration within the preset time, so that the first thread determines that the sound card registration fails.
In step 305, in the process of acquiring the registration state of the preset subsystem (i.e. the process of synchronously waiting for the registration state of the current preset subsystem), when the registration state of the subsystem is not acquired once, the registration state of the preset subsystem may be acquired again after delaying a preset time (e.g. 100 ms), that is, waiting for the preset time.
Here, it should be noted that, in the embodiment of the present invention, the manner in which the second thread acquires the registration status of the first subsystem is a delayed acquisition, that is, there is a time difference between the time when the second thread acquires the registration status of the first subsystem and the time when the first thread executes the update of the sound card registration status.
In the related art, the process of registering the sound card, as shown in fig. 4, includes the following steps:
step 401: the first thread starts sound card registration;
step 402: registering each subsystem of the sound card;
step 403: the first thread judges whether the sound card is successfully registered according to the registration state of each subsystem, if the registration is successful, the mobile phone starts to sound normally, and if the registration is failed, the mobile phone starts to sound soundless.
From the above description, it can be seen that, in the application embodiment of the present invention, in the process of sound card registration, it can be understood that the registration state of the subsystem is obtained by time-delay obtaining, that is, the registration state of the subsystem is obtained circularly when one-time obtaining is not available, pertinence is strong, and no matter how long the update of the registration state of the subsystem is delayed, as long as the subsystem updates the registration state in the process of sound card mounting, and the registration state represents that the subsystem is successfully registered, the sound card registration can be triggered to be re-registered, so that the correct flow of sound card registration is ensured, and the sound function is ensured to be normal after the product is started.
It should be noted that, in actual application, because there are many subsystems of the sound card, such as an ADSP module and a bluetooth module, and these subsystems may have the problem of delay in updating the registration status during the registration process, the scheme of the embodiment of the present invention may be adopted.
In order to implement the method according to the embodiment of the present invention, an embodiment of the present invention further provides a control apparatus for a sound card, which is disposed on a mobile terminal, and as shown in fig. 5, the apparatus includes:
a first processing unit 51 for performing a process of sound card registration including registration of a plurality of subsystems by a first thread;
the second processing unit 52 is configured to obtain, by the second thread, a registration status of the first subsystem of the sound card in a sound card registration process; the obtained registration state representation is registered successfully or unsuccessfully in the first subsystem in the current registration;
a trigger unit 53, configured to determine that the sound card registration executed by the first thread fails; and when the registration state of the first subsystem acquired by the second thread delay is determined to represent that the registration of the first subsystem is successful, triggering the sound card to register again.
In an embodiment, the second processing unit 52 is specifically configured to:
and acquiring the registration state of the first subsystem by calling the API.
More specifically, the second processing unit 52 may obtain the registration status of the first subsystem from the first subsystem by calling the API, and the second processing unit 52 may also obtain the registration status of the first subsystem from the preset storage space by calling the API.
In order to save resources and ensure that the second thread can acquire the registration status of the first subsystem, the registration status of the first subsystem may be acquired based on a certain time rule.
Based on this, in an embodiment, the second processing unit 52 is specifically configured to:
and acquiring the registration state of the first subsystem in the sound card registration process based on a preset time rule.
In an embodiment, the triggering unit 53 is specifically configured to:
determining that the sound card registration failure executed by the first thread is generated when the first thread does not acquire a registration state representing the successful registration of the first subsystem within a first preset time;
and when the registration state of the first subsystem, which is acquired by the second thread after the first preset time, represents that the registration of the first subsystem is successful, triggering the sound card to register again.
In an embodiment, the triggering unit 53 is specifically configured to:
and triggering the sound card to register again in a mode of adding virtual equipment.
In actual application, the first processing unit 51, the second processing unit 52 and the triggering unit 53 can be implemented by a processor in a control device of a sound card, and the processor needs to run a computer program in a memory to implement the functions of the above modules.
It should be noted that: in the control device for a sound card provided in the above embodiment, when the sound card is controlled, only the division of the program modules is illustrated, and in practical applications, the processing distribution may be completed by different program modules according to needs, that is, the internal structure of the device may be divided into different program modules to complete all or part of the processing described above. In addition, the control device of the sound card and the control method of the sound card provided by the above embodiments belong to the same concept, and the specific implementation process thereof is described in detail in the method embodiments, and is not described herein again.
It should be noted that: "first," "second," and the like are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
In addition, the technical solutions described in the embodiments of the present invention may be arbitrarily combined without conflict.
The above description is only a preferred embodiment of the present invention, and is not intended to limit the scope of the present invention.

Claims (10)

1. A control method of a sound card is characterized by comprising the following steps:
the method comprises the steps that a first thread executes a sound card registration process, wherein the sound card registration comprises registration of a plurality of subsystems, and a second thread acquires the registration state of a first subsystem of a sound card in the sound card registration process; when the first thread does not acquire the registration state representing the successful registration of the first subsystem within a first preset time length, determining that the sound card registration executed by the first thread fails;
and when the registration state of the first subsystem obtained by the second thread after the first preset time period represents that the registration of the first subsystem is successful, triggering the sound card to register again.
2. The method for controlling the sound card according to claim 1, wherein the obtaining the registration status of the first subsystem of the sound card comprises:
and acquiring the registration state of the first subsystem in the sound card registration process based on a preset time rule.
3. The sound card control method according to claim 2, wherein acquiring the registration status of the first subsystem in a sound card registration process based on a preset time rule comprises:
and periodically acquiring the registration state of the first subsystem in the sound card registration process until the registration state of the first subsystem is acquired.
4. The method for controlling the sound card according to claim 1, wherein the obtaining the registration status of the first subsystem of the sound card comprises:
and acquiring the registration state of the first subsystem from the first subsystem through an Application Programming Interface (API).
5. The method for controlling the sound card according to claim 1, wherein the triggering the sound card to re-register comprises:
and triggering the sound card to register again in a mode of adding virtual equipment.
6. The sound card control method according to claim 1, wherein the determining that the sound card failure of the first thread execution is caused by the first thread failing to acquire a registration status indicating that the first subsystem registration is successful within a first preset time period includes:
traversing the registration states of all subsystems of the sound card in the current registration within a corresponding preset time length;
and determining that the sound card registration failure executed by the first thread is generated because the first thread does not acquire the registration state representing the successful registration of the first subsystem within a first preset time length based on the registration states of all subsystems within corresponding preset time lengths in the current registration.
7. The method for controlling the sound card according to claim 1, wherein the obtaining the registration status of the first subsystem of the sound card comprises:
the second thread acquires the registration state of the first subsystem from a preset storage space; after the registration is finished, the first subsystem stores the registration state of the first subsystem to a preset storage space.
8. A control apparatus for a sound card, comprising:
a first processing unit for executing a process of sound card registration by a first thread, the sound card registration including registration of a plurality of subsystems;
the second processing unit is used for acquiring the registration state of the first subsystem of the sound card in the sound card registration process by a second thread; when the first thread does not acquire the registration state representing the successful registration of the first subsystem within a first preset time length, determining that the sound card registration executed by the first thread fails;
and the triggering unit is used for triggering the sound card to register again when the registration state of the first subsystem obtained by the second thread after the first preset time period represents that the first subsystem is successfully registered.
9. A terminal, comprising: a processor and a memory for storing a computer program capable of running on the processor,
wherein the processor is adapted to perform the steps of the method of any one of claims 1 to 7 when running the computer program.
10. A storage medium on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN201910579178.9A 2019-06-28 2019-06-28 Sound card control method, device, terminal and storage medium Active CN110321099B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910579178.9A CN110321099B (en) 2019-06-28 2019-06-28 Sound card control method, device, terminal and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910579178.9A CN110321099B (en) 2019-06-28 2019-06-28 Sound card control method, device, terminal and storage medium

Publications (2)

Publication Number Publication Date
CN110321099A CN110321099A (en) 2019-10-11
CN110321099B true CN110321099B (en) 2023-03-17

Family

ID=68120668

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910579178.9A Active CN110321099B (en) 2019-06-28 2019-06-28 Sound card control method, device, terminal and storage medium

Country Status (1)

Country Link
CN (1) CN110321099B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018045835A1 (en) * 2016-09-07 2018-03-15 北京金山安全软件有限公司 Method and apparatus for restoring sounds of terminal, and electronic device
CN109769279A (en) * 2019-01-15 2019-05-17 深圳市万普拉斯科技有限公司 Non-service state control method, device and mobile terminal

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2018045835A1 (en) * 2016-09-07 2018-03-15 北京金山安全软件有限公司 Method and apparatus for restoring sounds of terminal, and electronic device
CN109769279A (en) * 2019-01-15 2019-05-17 深圳市万普拉斯科技有限公司 Non-service state control method, device and mobile terminal

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
一种嵌入式Linux系统下SIP终端智能注册的设计与实现;王艳艳等;《微计算机信息》;20100815(第23期);全文 *

Also Published As

Publication number Publication date
CN110321099A (en) 2019-10-11

Similar Documents

Publication Publication Date Title
CN107342801B (en) Beam processing method, user equipment and base station
CN110168483B (en) Shortcut menu for displaying different applications on different screens
CN104093123B (en) The information-pushing method of application program, device and system, mobile terminal
CN104765591A (en) Method and system for updating software configuration parameter, and terminal server
CN112148579B (en) User interface testing method and device
CN104980455A (en) Multi-terminal data synchronization method based on cloud storage, device and system thereof
CN105760203A (en) Software upgrading method and terminal equipment
CN104954159A (en) Network information statistics method and device
EP2869604A1 (en) Method, apparatus and device for processing a mobile terminal resource
CN104809055A (en) Application program test method and device based on cloud platform
CN103546632A (en) Method and device for alarm ringing of mobile terminal and mobile terminal
CN111885591A (en) Network connection method, device, storage medium and terminal
US20150070360A1 (en) Method and mobile terminal for drawing sliding trace
CN104918130A (en) Methods for transmitting and playing multimedia information, devices and system
CN104702643A (en) A webpage access method, device and system
CN103457832A (en) Information management method, device and terminal
CN110321099B (en) Sound card control method, device, terminal and storage medium
CN104717283A (en) File downloading control method, terminal and logic processing server
CN106210325B (en) Method, device and terminal for setting incoming call ringtone of social application
CN105282628A (en) Video playing method and device
CN105094869A (en) Target program determination method and apparatus
CN109388487B (en) Application program processing method and device, electronic equipment and computer readable storage medium
CN111132282B (en) Application processor awakening method and device applied to mobile terminal
US20140366094A1 (en) Communication method, communication apparatus and terminal
CN110913022A (en) Method, device and system for downloading network file of mobile terminal and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant