Specific embodiment
It is described more fully with example embodiment referring now to accompanying drawing.However, example embodiment can be with multiple shapes
Formula is implemented, and is not understood as limited to example set forth herein;On the contrary, these embodiments are provided so that the present invention will more
Fully and completely, and by the design of example embodiment comprehensively convey to those skilled in the art.Accompanying drawing is only the present invention
Schematic illustrations, be not necessarily drawn to scale.In figure identical reference represents same or similar part, thus
Repetition thereof will be omitted.
Additionally, described feature, structure or characteristic can combine in one or more enforcements in any suitable manner
In mode.In the following description, many details are provided thus being given, embodiments of the present invention to be fully understood.So
And, it will be appreciated by persons skilled in the art that technical scheme can be put into practice and omit one of described specific detail
Or more, or other methods, constituent element, device, step etc. can be adopted.In other cases, it is not shown in detail or describe
Known features, method, device, realization or operation with avoid that a presumptuous guest usurps the role of the host and so that each aspect of the present invention thickens.
Fig. 1 is a kind of flow chart of the button prompting voice handling method according to illustrative embodiments.
As shown in figure 1, this button prompting voice handling method, it is applied to a terminal unit, described terminal unit has a sound
Amount key, comprises the following steps.
In the exemplary embodiment, described terminal unit can be that smart mobile phone, panel computer, notebook computer etc. are any
There is the electronic equipment of volume adjusting demand.The following examples all illustrate taking smart mobile phone as a example.
In the exemplary embodiment, described volume key can be the physical button of a physics, for example, be generally disposed at intelligence
The volume key of mobile phone side.In some other embodiment, described volume key can also be virtual key.The present invention does not make to this
Limit, correspondingly, " pressing " here may be considered click action when being directed to virtual key, regardless of the concrete shape of volume key
Formula, user operation mode, as long as the operation being capable of triggering regulation volume belongs within protection scope of the present invention.
Step s110, pre-builds a memory module, and described memory module is used for storing the sound that described terminal unit has
Sound type and the volume value of corresponding sound type, wherein said sound type at least includes a key prompting voice.
In the exemplary embodiment, described memory module is a data base.Certainly, in other embodiments, using any
The data base to replace the present invention for the storage form.
Various roles (role) have been pre-defined, for identifying the type of sound, such as smart mobile phone in system
, ringtone (sound of telephone bell), notification (sound of system prompt), media (mobile phone can be defined
The sound of music), system (sound of system), phone (sound of voice call), alarm (sound of alarm of mobile phone),
Keytone (sound of volume key) etc..The sound being currently played corresponds to ative role, identifies sound using keytone
The sound of amount key.It should be noted that the sound type of the present invention is not limited to these species exemplified as above and its name, tool
The sound type that body has independently can be arranged according to the type of terminal unit.
System has the data base for storing the corresponding volume of alternative sounds type, supports the corresponding volume of various role
The operation such as increase, delete, changing, looking into.
For example, as follows with the corresponding volume form of the various role of database purchase:
sink-input-by-media-role:ringtone xxx
sink-input-by-media-role:alarm xxx
Above-mentioned two is the storage form (xxx represents volume value) in data base for the volume of ringtone and alarm.
In system, the sound of each type all can specify a role, and the corresponding role of volume key is keytone, plays
The thread of prompt tone can go to read the volume value of keytone.
In the exemplary embodiment, when user's pressing volume key, if mobile phone does not now play any sound (for example
During cell phone standby), can arrange acquiescence active role is ringing sound of cell phone, now can adjust the volume of the tinkle of bells by volume key.When
So it is also possible to the other role of setting is acquiescence active role.
Step s120, when receiving the first trigger pressing described volume key, calls a first function to obtain institute
State the current sound type of terminal unit.
In the exemplary embodiment, described first function can be getactiverole ().Certainly, the invention is not restricted to
This, specifically call which kind of function can change according to the change of the system being adopted, and works as long as being capable of the present invention and obtaining
The function of front sound type belongs within protection scope of the present invention.
When user presses described volume key first time, this key-press event can be reported by the driving of kernel (kernel), is
System process (system-main) receives this key-press event, calls the regulation that audio manager (audiomanager) externally provides
The interface of volume, such as adjustvolume () adjust volume.
First pass through the current sound type (active role) that getactiverole () obtains described terminal unit, now
Ignore keytone.Because when playing, active role is keytone to prompt tone, at this moment presses volume key again, can adjust
The volume of keytone, such as you prepare to adjust the volume of the tinkle of bells, would not adjust the sound of the tinkle of bells in key prompting voice playing process again
Amount, so ignore keytone.
Describe how system-main obtains active role in detail below taking some specific functions as a example.But this
Bright it is not limited.
Simply introduce the several modules being related to: finger daemon pacd (pulseaudio control daemon) first,
Audiomanager is interacted with pulseaudio by calling the interface of pacd;System audio services (pulseaudio), is sound
The control core of frequency, pulseaudio stores volume by nemo module;Nemo is the mould for realizing various volume storages
Block.
Getactiverole () function does not have parameter, belongs to the interface that audiomanager externally provides, by system-
Main calls, for obtaining current active role.It implements and comprises the following steps.
First pass through and call pa_controller_get_active_role (pa_controller_st*
Controller) function obtains current active role.Wherein pa_controller_get_active_role () function
The interface of pacd offer is provided, is called by dbus by audiomanager.Parameter controller is a structure pointer, knot
The variable of active role is preserved inside structure body.
Then, by call context_get_sink_input_info_callback (pa_pdispatch*pd,
Uint32_t command, uint32_t tag, pa_tagstruct*t, void*userdata) function acquisition sink input
Various information, including active role.Context_get_sink_input_info_callback () function belongs to
The interface that pulseaudio provides, is called by pacd, mainly utilizes pa_tagstruct*t, pa_tagstruct is for sending
The structure of data, there is the variable for preserving active role the inside.
Then, pa_controller_sink_input_callback (pa_context*pa_ctx, const are called
Pa_sink_input_info*info, int eol, void*userdata) function.pa_controller_sink_input_
Callback () function is the call back function of a registration in pacd, as above-mentioned context_get_sink_input_
Info_callback () function obtains sink input information (including active role) in pulseaudio, can adjust back
This function pa_controller_sink_input_callback (), the structure preserving the information of active role is passed to
pacd.Wherein, mainly use pa_sink_input_info*info parameter, in structure, have the letter of active role
Breath.
Finally, active role information can be passed to by audiomanager by dbus, audiomanager with
The form of the return value of getactiverole () function is to system-main.So far system-main obtains active
The information of role.
Step s130, calls a second function to obtain the volume value of described current sound type from described memory module.
In the exemplary embodiment, described second function be adjustvolume (const am_role_type role,
Am_adjust_direction direction), for adjusting the volume of current sound type.Wherein parameter direction can
For representing the upper lower key of volume key, such as 0 is used for representing key (incremental volume value), and 1 is used for representing lower key (volume of successively decreasing
Value).Parameter role is exactly the return value being obtained by above-mentioned getactiverole () function.Adjustvolume () belongs to
The interface that audiomanager externally provides, is called by system-main.Current by calling adjustvolume () to obtain
The volume value of active role, and this volume is arranged keytone.
Step s140, the volume value of described current sound type is set to the volume value of described key prompting voice and protects
Deposit.
In the exemplary embodiment, when first time pressing volume key, current active role, Ran Houcong can be obtained
Read the volume value of active role in data base, and this volume is stored in data base as the volume of keytone.
In the exemplary embodiment, step s140 may comprise steps of further.
Step s141, the volume value of described current sound type is stored in as the volume value of described key prompting voice
hashmap.
Step s142, after the Preset Time of interval, the volume Value Data in described hashmap is write described data base
In.
In the exemplary embodiment, methods described sends the message to using synchronous dbus to realize between the process of methods described
Communication.
In the embodiment of the present invention, audiomanager is interacted with pacd and is realized by dbus message,
Audiomanager and pacd, not in a process, needs to communicate by dbus.
For example can be accomplished by:
Build message structure first to call long-range method:
Msg=
dbus_message_new_method_call(am_pa_controller_server,
am_pa_controller_dbus_path,
am_pa_controller_dbus_interface,
am_pa_controller_dbus_method_get_volume);
Then, variable is added in message:
dbus_message_append_args(msg,dbus_type_string,¶m,dbus_type_
invalid)
Then, it is connected to system bus daemon, because message will be sent in bus daemon, bus daemon
Search the bus name of target, message be sent to target process:
Bus=dbus_bus_get (dbus_bus_system, &err)
Then, send message, block to wait and reply:
Ret_msg=dbus_connection_send_with_reply_and_block (bus, msg, -1, &err)
Then, obtain effective information from the message replied:
dbus_message_get_args(ret_msg,&err,dbus_type_uint32,&volume,dbus_
type_invalid)
By the way of synchronization, dbus can block the response waiting remote object to the embodiment of the present invention, in the message of reply
The information wanted can be comprised.And asynchronous system will not be blocked, need oneself to realize call back function process to process the message of far-end.
The reply reliability that far-end can be received using the method for synchronization is higher than asynchronous system.
Dbus is a kind of low latency, low overhead, (inter-process communication, enters the ipc of high availability
Communicate between journey) mechanism.The present invention be by dbus send the message to realize, than adopt message processing facility and multiple process
Between communicate, flow process is more simple.Because message processing facility is asynchronous, a kind of risk will be implied, when system process is a certain
There occurs obstruction during individual message, now press volume key, the volume that on interface, volume bar shows has no problem, but the sound of reality
Amount does not but change, and the volume of same prompt tone also will not change, and the present invention would not have this to ask using synchronous dbus
Topic.
In the exemplary embodiment, also include: while playing described prompt tone, the display screen of described terminal unit
Upper display one volume bar, described volume bar is used for indicating the size of the volume value of described current sound type.
Similar, describe in detail below taking some specific functions as a example the volume value how obtaining active role and
How the volume value of active role to be realized being assigned to keytone by way of hashmap intermediate storage again unloading
's.But the present invention is not limited.
First pass through call int pa_controller_get_volume (pa_controller_st*controller,
Const char*role_name) function obtain specify role current volume.Wherein parameter controller is that structure refers to
Pin, has the variable preserving volume in structure.Parameter role_name is the role name specifying.pa_ext_stream_
Restore_read () function belongs to the interface that pacd is supplied to audiomanager.
Then, pa_operation*pa_ext_stream_restore_read (pa_context*c, pa_ext_ are called
Stream_restore_read_cb_t cb, void*userdata) function, it is a registered callbacks function, belongs to
The interface of pulseaudio.When obtaining the volume of role, call this registered callbacks function, disappear additionally by sending out to nemo module
The mode of breath, obtains volume value.Wherein parameter pa_ext_stream_restore_read_cb_t cb is the readjustment letter of registration
Number.
Then, extension_cb (pa_native_protocol*p, pa_module*m, pa_native_ are called
Connection*c, uint32_t tag, pa_tagstruct*t) function, it belongs to the interface of nemo offer, for volume
Read-write.This function receives the message that pulseaudio sends, and searches corresponding volume in hashmap according to role name, carries out
Read-write operation.Pulseaudio module can be sent to after reading volume.Wherein parameter pa_tagstruct*t is to carry data
Structure, inside has the variable preserving volume.
Then, call pa_controller_ext_stream_restore_read_callback (pa_context*
Pa_ctx, const pa_ext_stream_restore_info*info, void*userdata) function, this function belongs to
The call back function of pacd registration.After pulseaudio obtains volume, this function can be adjusted back, preserve the sound obtaining from pulseaudio
Amount.Wherein parameter pa_ext_stream_restore_info*info is used for preserving the volume obtaining from pulseaudio.Obtain
Volume be sent to audiomanager eventually through dbus, audiomanager calculates volume index value, returns to
System-main, system-main are used for showing current volume on screen.
Here volume index value could be arranged to 0~10 integer value, volume value could be arranged to 0~65535 whole
Numerical value, can mutually convert between the two.
Then, pa_controller_set_volume (pa_controller_st*controller, const are called
Char*role_name, int volume) function, this function belongs to the interface of pacd offer, is called by audiomanager, uses
In setting volume.Wherein parameter role_name represents role name to be adjusted, and parameter volume represents volume value to be adjusted.
Then, above-mentioned pa_ext_stream_restore_read () function and extension_cb () function are called,
By way of to nemo module messaging, obtain volume value.Recall above-mentioned pa_controller_ext_stream_
The volume that the preservation of restore_read_callback () function obtains from pulseaudio.
Then, call pa_controller_operate_static_volume_callback (pa_context*pa_
Ctx, const pa_ext_stream_restore_info*info, int eol, void*userdata) function, this function genus
The interface providing in pacd, for by role name and volume in pa_ext_stream_restore_info structure
It is placed in another structure, then call pa_ext_stream_restore_write () function to write volume
Hashmap stores.Wherein have in parameter pa_ext_stream_restore_info*info structure role name and
Volume information.
Wherein pa_operation*pa_ext_stream_restore_write (pa_context*c, pa_update_
mode_t mode,const pa_ext_stream_restore_info data[],unsignedn,int apply_
Immediately, pa_context_success_cb_t cb, void*userdata) function belong to pulseaudio offer
Interface, is used for sending data to nemo module, the volume data that will adjust is sent to nemo module stores.Wherein parameter
There are role name and volume information in pa_ext_stream_restore_info data [] structure.
The present embodiment obtains the volume value of active role first, and this volume is stored in as the volume of keytone
Hashmap, reads during reading from hashmap again, interval Preset Time (such as 5 seconds, but invention is not limited) again will afterwards
Data in hashmap is write in data base, so can reduce the number of times of read-write data base, saves system resource.
For example, it is assumed that in 5s, user has continuously pressed 5 volume keys, if directly by active will role volume
Value is written in data base it is necessary to write 5 secondary data in data base, simultaneously during playing alert tones, needs to read 5 from data base
Secondary data;And if by the way of the middle unloading of hashmap, often press a volume key and all can write data into hashmap
In (with respect to writing data base, occupying system resources very little, can ignore), write from hashmap once to data after 5s
Storehouse is such that it is able to save system resource.
Hashmap, the realization of the map interface based on Hash table.This realizes providing all optional map operations, and allows
Using null value and null key.This realizes supposing that element is suitably distributed between each bucket hash function, can be basic operation
(get and put) provides stable performance.Hashmap is the data structure that a kind of lightweight realizes data storage function, and read-write accounts for
Little with system resource.
Step s150, starts the volume value that a thread reads described key prompting voice, according to the sound of described key prompting voice
The size of value plays a prompt tone.
Start thread and remove playing alert tones, the volume value of keytone, playing alert tones in reading database.
In the exemplary embodiment, step s150 may include that described thread reads described button from described hashmap
The volume value of prompt tone.
In the exemplary embodiment, methods described also includes: when the second trigger receiving the described volume key of pressing
When, call described second function to adjust the volume value of described current sound type;Meanwhile, according to the described current sound after adjustment
The volume value of type, the volume value adjusting described key prompting voice is so that the volume value of described current sound type is pressed with described
The volume value of key prompt tone is consistent.
When user presses volume key for the second time, call the sound of the current active role of adjustvolume () adjustment
Amount index value, adjusts the volume value of keytone in pacd simultaneously, consistent with the volume value of active role.
When persistently pressing volume up or down key, volume increases or reduces a grade, by the current active after change
The volume of role and keytone is stored in data base or hashmap.Thread reads from data base or hashmap
The volume value of keytone, with this volume come playing alert tones.So user just can intuitively experience the size of volume.
Fig. 2 is the flow chart of another kind of button prompting voice handling method according to illustrative embodiments.
As shown in Fig. 2 this button prompting voice handling method, it is applied to a terminal unit, described terminal unit has a sound
Amount key, comprises the following steps.
Step s210, judges whether user presses described volume key.When receiving the trigger pressing described volume key
When, enter next step;Conversely, continuing to judge whether user presses described volume key.
Step s220, obtains current active role.
Step s230, obtains the volume value of active role from data base.
Step s240, this volume value is stored in hashmap as the volume value of keytone.
Step s250, starts the volume value that thread reads keytone from hashmap.
Step s260, according to the volume value playing alert tones of keytone.
Step s270, shows the volume bar of active role on the display screen of this terminal unit.
Step s280, judges whether to reach Preset Time;After reaching described Preset Time, enter next step;Conversely, continuing
Continue and judge whether to reach described Preset Time.
Step s290, by the data write into Databasce in hashmap.
When pressing volume key, current active role can be obtained, from data base, then obtain active role's
Volume value, and this volume is stored in hashmap as the volume of keytone.Start thread area playing alert tones, read
The volume of keytone in hashmap, arranges in prompt tone, and the size of prompt tone is exactly the size of the adjusted volume of user.
Other guide in the embodiment of the present invention, referring to above-described embodiment, will not be described here.
Fig. 3 is a kind of block diagram of the key prompting voice processing system according to illustrative embodiments.
According to illustrative embodiments of the disclosure, a kind of key prompting voice processing system 100 can be applicable to a terminal
Equipment, described terminal unit has a volume key.This system 100 mays include: a memory module 310, for storing described terminal
Sound type and the volume value of corresponding sound type that equipment has, wherein said sound type at least includes a button prompting
Sound;First calling module 320, for when receiving the first trigger pressing described volume key, calling a first function
Obtain the current sound type of described terminal unit;Second calling module 330, is used for calling a second function from described storage mould
The volume value of described current sound type is obtained in block;Setup module 340, for setting the volume value of described current sound type
It is set to the volume value of described key prompting voice and preserve;Playing alert tones module 350, reads described button for starting a thread
The volume value of prompt tone, the size of the volume value according to described key prompting voice plays a prompt tone.
In the exemplary embodiment, described volume key includes: one first volume key, described in being incremented by according to compression number
The volume value of current sound type;And one second volume key, for being successively decreased described current sound type according to compression number
Volume value.
In the exemplary embodiment, described memory module 310 is a data base, and described setup module 340 includes: one
Hashmap, for storing the volume value of described current sound type and being set to the volume value of described key prompting voice;Write
Enter module, after being spaced Preset Time, the volume Value Data in described hashmap is write in described data base.
Following for present system embodiment, can be used for executing the inventive method embodiment.Real for present system
Apply the details not disclosed in example, refer to the inventive method embodiment.
According to illustrative embodiments of the disclosure, provide a kind of terminal unit, described terminal unit has a volume
Key, comprising: processor;For storing the memorizer of processor executable;Wherein, described processor is configured to: in advance
Set up a memory module, described memory module is used for storing the sound type that described terminal unit has and corresponding sound type
Volume value, wherein said sound type at least includes a key prompting voice;When the first triggering receiving the described volume key of pressing
During signal, a first function is called to obtain the current sound type of described terminal unit;Call a second function from described storage
The volume value of described current sound type is obtained in module;The volume value of described current sound type is set to described button carry
Show the volume value of sound and preserve;Start the volume value that a thread reads described key prompting voice, according to described key prompting voice
The size of volume value plays a prompt tone.
Fig. 4 is a kind of mobile end for realizing button prompting voice handling method according to illustrative embodiments
The block diagram at end.
Fig. 4 schematically shows the common structure of described mobile terminal, with reference to the inside to common mobile terminal for the Fig. 4
Assembly, software and protocol architecture illustrate.
This mobile terminal has processor 410, and it is responsible for the integrated operation of mobile terminal, and can utilize any business
CPU, digital signal processor or any other electronic programmable logic device can be obtained realize.Processor 410 has
The memorizer 420 of association, this memorizer 420 includes but is not limited to ram memorizer, rom memorizer, eeprom memorizer, flash memory
Or a combination thereof.Memorizer 420 controls for numerous purposes by processor 400, and one of them is as various soft in mobile terminal
Part storage program instruction and data.
The software view of this mobile terminal includes real time operating system 440, the driver for man machine interface 460, application
Datatron 450 and various application.Described application is, for example, text editor 451, handwriting recognition application 452 and various other many matchmakers
Body application 453, typically this other multimedia application include such as audio call application, video call application, send and receive
Short Message Service (sms) messages application, multimedia information service (mms) application or e-mail applications, web browser, immediately
Information receiving and transmitting application, book applications, calendar application, control panel application, camera application, one or more video-game,
Notepad appli-cation etc..It should be noted that two or more of above-mentioned application can execute as same application.
Described mobile terminal also includes one or more hardware controls, for together with the driver of man machine interface 460
With display device 461, (such as speaker, vibrator, jingle bell are sent out for physical button 462, mike 463 and various other i/o equipment
Raw device, led indicator etc.) cooperation, to realize the man-machine interaction of described mobile terminal.Skilled artisan would appreciate that user
Mobile terminal can be operated by such man machine interface 460 being formed.
The software view of this mobile terminal can also include various modules, protocol stack, driver etc. and related the patrolling that communicate
Volume, it is summarized as communication interface 470 as shown in Figure 4, for for wireless radio interface 471 and be optionally blue tooth interface
472 and/or infrared interface 473 provide communication service (such as transmission, network and connectedness), to realize the net of described mobile terminal
Network is connective.Wireless radio interface 471 includes internal or external antenna and for setting up and safeguarding the radio chains leading to base station
The suitable radio circuit on road.As known to the skilled person, described radio circuit include a series of analog- and digital-
Electronic building brick, it forms radio receiver and transmitter together.These assemblies for example include band filter, amplifier, mix
Frequency device, local oscillator, low pass filter, ad/da transducer etc..
Mobile communication terminal can also include reader device 430, and this reader device 430 generally includes processor and data
Memorizer etc., for reading the information of sim card and taking this as a foundation what cooperation wireless radio interface 417 access carrier was provided
Network.
It will be appreciated by those skilled in the art that all or part of step realizing above-mentioned embodiment is implemented as being held by cpu
The computer program of row.When this computer program is executed by cpu, execution the present invention provide said method limited above-mentioned
Function.Described program can be stored in a kind of computer-readable recording medium, and this storage medium can be read only memory,
Disk or CD etc..
Further, it should be noted that above-mentioned accompanying drawing is only according to included by the method for exemplary embodiment of the invention
Process schematically illustrates, rather than limits purpose.It can be readily appreciated that above-mentioned process shown in the drawings is not intended that or limits these
The time sequencing processing.In addition, being also easy to understand, these process can for example either synchronously or asynchronously be executed in multiple modules
's.
It should be noted that the block diagram shown in above-mentioned accompanying drawing is functional entity, not necessarily must with physically or logically
Independent entity is corresponding.Can using software form realizing these functional entitys, or in one or more hardware modules or
Realize these functional entitys in integrated circuit, or realize in heterogeneous networks and/or processor device and/or microcontroller device
These functional entitys.
Button prompting voice handling method, system and terminal unit that the present invention provides, press volume key by user and adjust
Playing alert tones during volume, thus allow user can direct feel to adjusted volume size.In certain embodiments, this
Bright send the message to realize the present invention also by synchronous dbus so that handling process is simpler and will not occur to hinder due to message
Fill in the problem of the volume adjusting failure leading to.In further embodiments, the present invention is also by hashmap unloading current sound class
The volume value of type, such that it is able to save system resource, it is to avoid continually reads and writes data base.
Through the above description of the embodiments, those skilled in the art is it can be readily appreciated that example described herein is implemented
Mode can be realized by software it is also possible to be realized with reference to by way of necessary hardware by software.Therefore, according to the present invention
The technical scheme of embodiment can be embodied in the form of software product, this software product can be stored in one non-volatile
Property storage medium (can be cd-rom, u disk, portable hard drive etc.) in or network on, including some instructions so that a calculating
Equipment (can be personal computer, server, mobile terminal or network equipment etc.) executes according to embodiment of the present invention
Method.
More than it is particularly shown and described the illustrative embodiments of the present invention.It should be appreciated that the present invention does not limit
In detailed construction described herein, set-up mode or implementation method;On the contrary, it is intended to cover be included in claims
Spirit and scope in various modifications and equivalence setting.