CN107092545A - The method and system of client test earphone plug state - Google Patents
The method and system of client test earphone plug state Download PDFInfo
- Publication number
- CN107092545A CN107092545A CN201710189226.4A CN201710189226A CN107092545A CN 107092545 A CN107092545 A CN 107092545A CN 201710189226 A CN201710189226 A CN 201710189226A CN 107092545 A CN107092545 A CN 107092545A
- Authority
- CN
- China
- Prior art keywords
- audio
- state
- information
- data
- client
- 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.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/30—Monitoring
- G06F11/3051—Monitoring arrangements for monitoring the configuration of the computing system or of the computing system component, e.g. monitoring the presence of processing resources, peripherals, I/O links, software programs
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/542—Event management; Broadcasting; Multicasting; Notifications
Abstract
The invention discloses a kind of method and system of client test earphone plug state, it is related to audio frequency apparatus detection field.Steps of the method are:Audio file is opened in the system layer of client, the audio status data in audio file are read in real time, by the audio status data of this reading, the audio status data read with last time are compared, and obtain the change information of headset plugging state;The change information of headset plugging state is packaged, the change information of the headset plugging state after broadcast encapsulation.All flows of test earphone plug state of the present invention, are completed, and then while province's client resource has been saved, significantly improve the operating efficiency of client in the system layer of client.
Description
Technical field
The present invention relates to audio frequency apparatus detection field, and in particular to a kind of method of client test earphone plug state and
System.
Background technology
At present, the test earphone plug state in client (such as personal computer, mobile terminal, tablet personal computer)
Method is generally:Increase by one layer of centre on the operating system layer (such as the linux system layer of Android device) of client
Layer, by the plug state of intermediate layer monitoring headpone and notifies system layer.
But in use, there is following defect in the method for above-mentioned client test earphone plug state:What it is in client is
Increase intermediate layer on system layer, the resource of client can be taken, reduce the operating efficiency of client;At the same time, intermediate layer is monitored
The plug state of earphone and when notifying system layer, bridge joint and communication work between 2 layers can be formed, and then reduce further client
The operating efficiency at end.
The content of the invention
For defect present in prior art, present invention solves the technical problem that being:How client system layer,
The plug state of test earphone, the present invention while client resource is saved, can significantly improve the work effect of client
Rate, is very suitable for promoting.
To achieve the above objectives, the method for the client test earphone plug state that the present invention is provided, comprises the following steps:
S1:The file handle of audio file is obtained in the system layer of client, file handle is integer, judge file sentence
Handle whether > 0, if so, confirm audio file open successfully, go to S2;Otherwise confirm that audio file opens failure, shows audio
File open failed information, terminates;
S2:The audio status data in audio file are read in real time in system layer, if whether audio status data read
Success, goes to S3;If whether audio status data read failure, display data reads abnormal information, terminates;
S3:When definition audio status data are 0, represent that earphone is not inserted into client, when audio status data are 1, table
Show that earphone has been inserted into client;When the audio status data of this reading are 0, the audio status data that the last time reads are 1
When, the change information that headset plugging state is confirmed in system layer is earphone by access information;When the audio status of this reading
Data are 1, when the audio status data that the last time reads are 0, and the change information that headset plugging state is confirmed in system layer is
Earphone is pulled out information, goes to S4;
S4:The change information of headset plugging state is packaged in system layer, the headset plugging shape after broadcast encapsulation
The change information of state, terminates.
The system for the client test earphone plug state that the present invention is provided, including positioned at the audio text of FTP client FTP layer
Part opens module, audio status data read module, headset plugging state detection module and earphone status information broadcast module;
Audio file, which opens module, to be used for:The file handle of audio file is obtained, file handle is integer, judge file sentence
Handle whether > 0, if so, confirming that audio file is opened successfully, to the transmission audio status data reading of audio status data read module
The number of winning the confidence;Otherwise confirm that audio file opens failure, display audio file opens failure information;
Audio status data read module is used for:Receive after audio status data read signal, audio file is read in real time
In audio status data, if audio status digital independent success, to headset plugging state detection module send headset plugging shape
State detects signal;If audio status digital independent fails, display data reads abnormal information;
Headset plugging state detection module is used for:Receive after headset plugging state detection signal, the plug shape of test earphone
State:When definition audio status data are 0, represent that earphone is not inserted into client, when audio status data are 1, represented earphone
It is inserted into client;When the audio status data of this reading are 0, when the audio status data that the last time reads are 1, ear is confirmed
The change information of machine plug state is earphone by access information;When this reading audio status data be 1, last time read
When audio status data are 0, confirm that the change information of headset plugging state is pulled out information for earphone;The headset plugging that will confirm that
The change information of state is sent to earphone status information broadcast module;
Earphone status information broadcast module is used for:The change information of the headset plugging state received is packaged, broadcasted
The change information of headset plugging state after encapsulation.
Compared with prior art, the advantage of the invention is that:
(1) compared with test earphone plug state is carried out in increase intermediate layer in the prior art, test earphone of the present invention plugs shape
All flows of state, are completed in the system layer of client, and then while client resource is saved, significantly improve visitor
The operating efficiency at family end.
On this basis, the present invention sends the change information of headset plugging state by broadcast mechanism, and then to change
Information can be known by multiple application layers in client, significantly improve the efficiency of transmission for changing information, and change information
It can be packaged before being broadcast, be easy to subsequent applications layer to be parsed to changing message.
(2) present invention can return to audio text when opening audio file failure and reading audio status data failure
The path of part, behind operating personnel's quick positioning question source, is investigated and is repaired.
Brief description of the drawings
Fig. 1 be the embodiment of the present invention in client test earphone plug state method flow chart.
Embodiment
The present invention is described in further detail below in conjunction with drawings and Examples.
Shown in Figure 1, the method for the client test earphone plug state in inventive embodiments comprises the following steps:
S1:Audio file (device node) is opened in the system layer of client, judges whether audio file opens success,
If so, going to S2, otherwise show that audio file opens failure information, terminate;Audio file, which opens failure information, includes audio text
Part path, so that operating personnel can quickly position the position of audio file, and then improves the speed solved the problems, such as.
The unfolding mode of S1 middle pitch frequency files is following 3 kinds:Opened with read-only mode, with only WriteMode open file, with
Readable WriteMode is opened, above-mentioned 3 kinds of unfolding mode mutual exclusions, when opening audio file using any one unfolding mode, if finding
Audio file is not present, then automatically creates audio file.Only need to read audio file in the present embodiment, therefore with read-only mode
Open.
S1 judges whether audio file opens successful idiographic flow and be:
S101:Open functions (opening function) are called to obtain the file handle audio_fd of audio file, file handle is
Integer, implementation is:Int audio_fd=open ("/sys/class/switch/h2w/state ", O_RDONLY), turn
To S102.
S102:Judge file handle whether > 0, if so, then confirm audio file open successfully, go to S2;Otherwise confirm
Audio file opens failure, and display audio file opens failure information, such as printf (" open/sys/class/switch/
h2w/state audio device error!N "), terminate.
S2:The audio status data in audio file are read in real time, judge whether audio status data read success, if
It is to go to S3, otherwise display data reads abnormal information, digital independent abnormal information includes the audio status data for reading failure
The audio file path at place, so that operating personnel are capable of the audio status data of rapid abnormal, and then improve and solves the problems, such as
Speed, terminate.
S2 idiographic flow is:
S201:Read functions (function reading) are called to read the audio status data in audio file, implementation is:
Ssize_t read (int fd, void*buf, size_t count), wherein ssize_t (return value of read functions) are represented
The integer of how many data is read for marking, Fd represents to read the file handle of file, and buf represents that the data read will be deposited
It is placed in buf, count represents need that how many data read, and goes to S202.
S202:Judge ssize_t whether > 0, if, it is determined that audio status digital independent success (in the data of reading
First be audio status data), go to S3;Otherwise the failure of audio status digital independent is determined, display data reads different
Normal information, such as printf (" read/sys/class/switch/h2w/state audio device error!N "), knot
Beam.
In S2 using for circulation by the way of do not stop read audio file in audio status data, but for circulation in
Write nothing, and then promote for cycling conditions to be forever true when judgement, realize wireless circulating with this (i.e. in S2 in fact
When read audio file in audio status data) purpose.
S3:When the audio status data of this reading, and when different from the audio status data that the last time reads (it is identical, say
Bright headset plugging state does not change, now without any processing), confirm the change information of headset plugging state, go to
S4。
S3 idiographic flow is:When definition audio status data are 0, represent that earphone is not inserted into client, audio status
When data are 1, represent that earphone has been inserted into client, on this basis, S3 idiographic flow is:If this audio shape read
State data are 0, and the audio status data that the last time reads are 1, then the change information of headset plugging state is that earphone is believed by access
Cease (i.e. earphone is accessed to client);If this audio status data read is 1, the audio status number that the last time reads
According to for 0, then the change information of headset plugging state is that earphone is pulled out information (i.e. the earphone extraction from client).
S3 implementation is:Last time and this are preserved by this 2 variables of last_value and current_value
The audio status data of secondary reading;If if (last_value==0&&current_value==1) condition is set up, illustrate ear
Machine is accessed;If if (last_value==1&&current_value==0) condition is set up, illustrate that earphone is pulled out.
S4:After the change information of headset plugging state is packaged, by AM orders, (Google is supplied to developer's
One instrument, the instrument can start service, send broadcast, kill process, and the function such as monitoring system, is a powerful system
Instrument) the change information of headset plugging state is broadcasted, i.e., the change information of headset plugging state is broadcasted from system layer
To Java layers;Specifically broadcast mode is:
If the change information of headset plugging state be earphone by access information, broadcast mode is:am broadcast-a"
ACTION_AUDIO_PLUGIN"--es plugin_info"plug in";
If the change information of headset plugging state, which is earphone, is pulled out information, broadcast mode is:
am broadcast-a"ACTION_AUDIO_PLUGIN"--es plugin_info"plug out";
Wherein-a represents the event information for needing to broadcast, and the event information is a character string " ACTION_AUDIO_
PLUGIN " is used to uniquely indicate the broadcast, -- es represents the parameter information that the broadcast is carried;What the broadcast in the present embodiment was carried
It is a key-value pair information, wherein key is plugin_info, value is " plug in " (earphone is accessed) or " plug out "
(earphone is pulled out).
It was found from S4, the present embodiment sends the change information of headset plugging state by broadcast mechanism, and then to change
Information can be known that changing message by key-value pair during broadcast is packaged, and is easy to follow-up by multiple application layers in client
Application layer is parsed to changing message.
In actual applications, in order that the part of interface function above provided with system, those of ordinary skill in the art must
So understand, it is necessary to which it is #include to add the header file in the header file of correlation, the present embodiment before S1 is performed<sys/
types.h>、#include<sys/stat.h>And #include<fcntl.h>, this 3 header file is that file is operated
Header file essential to (the related read/write function provided using system).
The system of client test earphone plug state in the embodiment of the present invention, including positioned at the sound of FTP client FTP layer
Frequency file opens module, audio status data read module, headset plugging state detection module and earphone status information broadcast mould
Block.
Audio file, which opens module, to be used for:The file handle of audio file is obtained, file handle is integer, judge file sentence
Handle whether > 0, if so, confirming that audio file is opened successfully, to the transmission audio status data reading of audio status data read module
The number of winning the confidence;Otherwise confirm that audio file opens failure, display audio file, which is opened in failure information, file open failed information, to be wrapped
Include audio file path.
Audio status data read module is used for:Receive after audio status data read signal, audio file is read in real time
In audio status data, if audio status digital independent success, to headset plugging state detection module send headset plugging shape
State detects signal;If audio status digital independent fails, display data reads abnormal information, and digital independent abnormal information includes
Read the audio file path where the audio status of failure.Idiographic flow is:All data in audio file are read, are judged
Whether all data are empty, if so, then confirming the failure of audio status digital independent, display data reads abnormal information;Otherwise it is true
Recognize the success of audio status digital independent, by a data in all data, be used as audio status data.
Headset plugging state detection module is used for:Receive after headset plugging state detection signal, the plug shape of test earphone
State:When definition audio status data are 0, represent that earphone is not inserted into client, when audio status data are 1, represented earphone
It is inserted into client;When the audio status data of this reading are 0, when the audio status data that the last time reads are 1, ear is confirmed
The change information of machine plug state is earphone by access information;When this reading audio status data be 1, last time read
When audio status data are 0, confirm that the change information of headset plugging state is pulled out information for earphone;The headset plugging that will confirm that
The change information of state is sent to earphone status information broadcast module.
Earphone status information broadcast module is used for:After the change information of the headset plugging state received is packaged, lead to
The change information for the headset plugging state crossed after AM orders broadcast encapsulation.
So far, understand according to embodiments of the present invention, all flows of test earphone plug state of the present invention, in client
System layer in complete, with the prior art increase intermediate layer carry out test earphone plug state compared with, the present invention can save
While client resource, the operating efficiency of client is significantly improved.
Further, the present invention is not limited to the above-described embodiments, for those skilled in the art,
Without departing from the principles of the invention, some improvements and modifications can also be made, these improvements and modifications are also considered as the present invention
Protection domain within.The content not being described in detail in this specification belongs to existing skill known to professional and technical personnel in the field
Art.
Claims (10)
1. a kind of method of client test earphone plug state, it is characterised in that this method comprises the following steps:
S1:The file handle of audio file is obtained in the system layer of client, file handle is integer, judges that file handle is
No > 0, if so, confirming that audio file is opened successfully, goes to S2;Otherwise confirm that audio file opens failure, shows audio file
Failure information is opened, is terminated;
S2:The audio status data in audio file are read in real time in system layer, if the success of audio status digital independent, goes to
S3;If whether audio status data read failure, display data reads abnormal information, terminates;
S3:When definition audio status data are 0, represent that earphone is not inserted into client, when audio status data are 1, represent ear
Machine has been inserted into client;When the audio status data of this reading are 0, and the last audio status data read are 1,
The change information that headset plugging state is confirmed in system layer is earphone by access information;When the audio status data of this reading are
1, when the audio status data that the last time reads are 0, the change information that headset plugging state is confirmed in system layer is earphone quilt
Information is extracted, S4 is gone to;
S4:The change information of headset plugging state is packaged in system layer, the headset plugging state after broadcast encapsulation
Change information, terminate.
2. the method for client test earphone plug state as claimed in claim 1, it is characterised in that the idiographic flow in S2
For:All data in audio file are read, whether be empty, if so, then confirming audio status digital independent if judging all data
Failure;Otherwise confirm the success of audio status digital independent, by a data in all data, be used as audio status data.
3. the method for client test earphone plug state as claimed in claim 1, it is characterised in that:The text of audio described in S1
Part, which opens failure information, includes audio file path.
4. the method for client test earphone plug state as claimed in claim 1, it is characterised in that:Data described in S2 are read
Abnormal information is taken to include:Read the audio file path where the audio status of failure.
5. the method for the client test earphone plug state as described in any one of Claims 1-4, it is characterised in that:In S4
The change information of the headset plugging state is broadcasted by AM orders.
6. a kind of system of client test earphone plug state, it is characterised in that:The system includes being located at FTP client FTP layer
Audio file open module, audio status data read module, headset plugging state detection module and earphone status information it is wide
Broadcasting module;
Audio file, which opens module, to be used for:The file handle of audio file is obtained, file handle is integer, judges that file handle is
No > 0, if so, confirming that audio file is opened successfully, sending audio status digital independent to audio status data read module believes
Number;Otherwise confirm that audio file opens failure, display audio file opens failure information;
Audio status data read module is used for:Receive after audio status data read signal, read in real time in audio file
Audio status data, if the success of audio status digital independent, send headset plugging state to headset plugging state detection module and examine
Survey signal;If audio status digital independent fails, display data reads abnormal information;
Headset plugging state detection module is used for:Receive after headset plugging state detection signal, the plug state of test earphone:It is fixed
When adopted audio status data are 0, represent that earphone is not inserted into client, when audio status data are 1, represent that earphone has been inserted into
Client;When the audio status data of this reading are 0, when the audio status data that the last time reads are 1, headset plugging is confirmed
The change information of state is earphone by access information;When this reading audio status data be 1, last time read audio shape
When state data are 0, confirm that the change information of headset plugging state is pulled out information for earphone;The headset plugging state that will confirm that
Change information to send to earphone status information broadcast module;
Earphone status information broadcast module is used for:The change information of the headset plugging state received is packaged, broadcast encapsulation
The change information of headset plugging state afterwards.
7. the system of client test earphone plug state as claimed in claim 6, it is characterised in that:The audio status number
It is according to the specific workflow of read module:All data in audio file are read, whether judge all data is empty, if
It is then to confirm the failure of audio status digital independent, display data reads abnormal information;Otherwise confirm audio status digital independent into
Work(, by a data in all data, is used as audio status data.
8. the system of client test earphone plug state as claimed in claim 6, it is characterised in that:The audio file is beaten
The audio file that die sinking block is shown is opened in failure information, including audio file path.
9. the system of client test earphone plug state as claimed in claim 6, it is characterised in that:The audio status number
In the digital independent abnormal information shown according to read module, including read the audio file path where the audio status of failure.
10. the system of the client test earphone plug state as described in any one of claim 6 to 9, it is characterised in that:It is described
Earphone status information broadcast module is broadcasted the change information of headset plugging state by AM orders.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710189226.4A CN107092545B (en) | 2017-03-27 | 2017-03-27 | Method and system for detecting earphone plugging state by client |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201710189226.4A CN107092545B (en) | 2017-03-27 | 2017-03-27 | Method and system for detecting earphone plugging state by client |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107092545A true CN107092545A (en) | 2017-08-25 |
CN107092545B CN107092545B (en) | 2020-09-04 |
Family
ID=59649079
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201710189226.4A Active CN107092545B (en) | 2017-03-27 | 2017-03-27 | Method and system for detecting earphone plugging state by client |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN107092545B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102740185A (en) * | 2011-04-01 | 2012-10-17 | 富泰华工业(深圳)有限公司 | Audio device and earphone plug-pull silencing method thereof |
CN103324459A (en) * | 2013-06-14 | 2013-09-25 | Tcl集团股份有限公司 | Method and system for implementing USB (universal serial bus) headset devices |
CN103778806A (en) * | 2012-10-23 | 2014-05-07 | 中国电信股份有限公司 | Method, terminal and system for voiced reading |
CN105407442A (en) * | 2015-12-24 | 2016-03-16 | 广州艾想电子科技有限公司 | Plugging detection method and device for earphone apparatus |
CN106488281A (en) * | 2016-10-26 | 2017-03-08 | Tcl集团股份有限公司 | A kind of player method of television audio and control system, TV, communication system |
-
2017
- 2017-03-27 CN CN201710189226.4A patent/CN107092545B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102740185A (en) * | 2011-04-01 | 2012-10-17 | 富泰华工业(深圳)有限公司 | Audio device and earphone plug-pull silencing method thereof |
CN103778806A (en) * | 2012-10-23 | 2014-05-07 | 中国电信股份有限公司 | Method, terminal and system for voiced reading |
CN103324459A (en) * | 2013-06-14 | 2013-09-25 | Tcl集团股份有限公司 | Method and system for implementing USB (universal serial bus) headset devices |
CN105407442A (en) * | 2015-12-24 | 2016-03-16 | 广州艾想电子科技有限公司 | Plugging detection method and device for earphone apparatus |
CN106488281A (en) * | 2016-10-26 | 2017-03-08 | Tcl集团股份有限公司 | A kind of player method of television audio and control system, TV, communication system |
Also Published As
Publication number | Publication date |
---|---|
CN107092545B (en) | 2020-09-04 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106997314B (en) | Exception handling method, device and system for distributed system | |
CN106844137A (en) | The monitoring method and device of server | |
CN105684382A (en) | Packet control method, switch and controller | |
US20150193280A1 (en) | Method and device for monitoring api function scheduling in mobile terminal | |
WO2019051948A1 (en) | Method, apparatus, server, and storage medium for processing monitoring data | |
CN107645546B (en) | File monitoring method based on android system, intelligent device and storage medium | |
CN106210032A (en) | The method and device reported based on terminal data batch | |
CN112202635A (en) | Link monitoring method and device, storage medium and electronic device | |
CN111352847A (en) | Real-time debugging method and system for mobile application terminal | |
CN110278272B (en) | Universal method for simulating Socket request | |
CN104484176B (en) | A kind of Android system window object acquisition methods and device | |
CN111277569B (en) | Network message decoding method and device and electronic equipment | |
CN107770800A (en) | ESIM card informations management method, equipment and server | |
CN106549814B (en) | The method of calibration and equipment of device parameter validity | |
CN107092545A (en) | The method and system of client test earphone plug state | |
CN110198222A (en) | A kind of distribution power automation terminal plug and play test method and test main website | |
CN111262782B (en) | Message processing method, device and equipment | |
EP3035607A1 (en) | Service chain management | |
CN113067852B (en) | Application elasticity system and method for application deployed on platform | |
CN112235244B (en) | Construction method of abnormal message, detection method, device and medium of industrial control network equipment | |
CN109039822B (en) | BFD protocol message filtering method and system | |
CN101431435A (en) | Connection-oriented service configuration and management method | |
CN104994078B (en) | Information transmission, acquisition methods and device, information processing system in local area network | |
CN112311575B (en) | Clock ring forming detection method and system in optical transmission network management | |
CN112055058A (en) | Data storage method and device and computer readable 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 |