Background technology
In portable terminal, have the application that realizes various tasks, such as, short message editing application, MP3 (MPEGAudioLayer3) play application, caller identification application, quarter-bell application, short message prompt application, recreation application etc.
Portable terminal as shown in Figure 1 produces according to the outer signals (such as key information or call request etc.) that receives and interrupts, and down trigger operation application corresponding process is carried out function corresponding.For example, after the user carried out keyboard operation information, portable terminal produced the interruption of recreation request, and by this down trigger running game application process; When perhaps portable terminal receives the call request of network side, produce call request and interrupt, thus operation caller identification application process.
Often have a plurality of threads in the process of each application, each thread is in order to finish subtask corresponding in the application.Such as, in the recreation application process, comprise: game algorithm thread, game video Play Control thread, recreation voice playing control thread, be responsible for finishing game algorithm subtask, game video Play Control subtask, recreation voice playing control subtask respectively.
For the application that has the multimedia task in the portable terminal, play use, play application, caller identification application, quarter-bell application etc. such as MP3, all be useful on the thread (multimedia video Play Control thread or multimedia audio Play Control thread) of control multimedia in its application process.Multimedia control thread in the application process (comprising video playback control thread or voice playing control thread) is controlled audio frequency apparatus or display device by the system call (System Call) that calling system kernel (such as linux kernel) is provided, thereby realizes multimedia sound, video output.For example, multimedia audio Play Control thread uses the open system call, and (system call opens file,) write data to audio frequency apparatus, the DSP of audio frequency apparatus (Digital Signal Processing, digital signal processing) digital signal that writes is converted to simulating signal output, thus output sound.Because in carrying out the multimedia control procedure, need by DMA (Direct Memory Access, direct memory access (DMA)) constantly write data to hardware device, and the control of DMA needs CPU (Center Process Unit, CPU (central processing unit)) participate in, so application process to take more cpu resource in carrying out the multimedia process.
The present inventor finds, the portable terminal of prior art can be when two or more interruptions (such as the interruption of MP3 playing request, call request interruption, quarter-bell timing interruption etc.) that all need to carry out media play arrive, each interrupts corresponding application process operation simultaneously, cause these application processes might carry out multimedia control simultaneously, and cause system resource (comprising cpu resource, memory source and hardware device resources) nervous even to the conflict of resource occupation, make the portable terminal response slowly even can't respond.Even after linking up by mutual photos and sending messages between these application processes and coordinating, decision removes the sequencing of carrying out, avoiding the seizing of system resource, and communication between the application process and coordination process also will expend the long period, make portable terminal response still relatively slowly.
Therefore, the efficient of the portable terminal of prior art control multimedia is unsatisfactory, and response slowly and makes user experience not good when a plurality of multimedia demand is arranged.
Summary of the invention
The embodiment of the invention provides a kind of portable terminal and control method for playing multimedia thereof, in order to improve the mobile multimedia terminal playing efficiency, accelerates the response speed of portable terminal when a plurality of multimedia demand is arranged.
A kind of control method for playing multimedia comprises:
The multimedia control process of portable terminal receives the interruption with multimedia demand; And
According to the interrupt priority level that sets in advance, the application process of the interruption correspondence that preferential notification priority is high is carried out multimedia and is notified other to interrupt corresponding application process and suspend multimedia.
After the application process of the high interruption correspondence of described priority is carried out multimedia, also comprise:
After the application process of the high interruption correspondence of described priority is finished the multimedia task, the pairing interruption of described multimedia control this application process of process-kill.
After the pairing interruption of described multimedia control this application process of process-kill, also comprise:
Described multimedia control process is determined the remaining the highest interruption of interruption medium priority; And notify the described remaining the highest pairing application process of interruption of interruption medium priority to carry out multimedia.
A kind of portable terminal comprises: multimedia control process and the application process that corresponds respectively to the interruption that respectively has the multimedia demand;
Described multimedia control process is used to receive the interruption with multimedia demand, and according to the interrupt priority level that sets in advance, the application process of the interruption correspondence that preferential notification priority is high is carried out multimedia and is notified other to interrupt corresponding application process and suspend multimedia.
Described multimedia control process also is used for deleting the pairing interruption of this application process after the application process of the high interruption correspondence of described priority is finished the multimedia task.
Described multimedia control process the described priority of deletion high in have no progeny, determine the remaining the highest interruption of interruption medium priority; And notify the described remaining the highest pairing application process of interruption of interruption medium priority to carry out multimedia.
The interruption that respectively has the multimedia demand owing to the reception of employing multimedia control process in the portable terminal of the embodiment of the invention, and according to the interrupt priority level that sets in advance, judge to receive and interrupt the highest interruption of medium priority, and the multimedia in the pairing application process of interruption that preferentially the running priority level is the highest, thereby avoided when a plurality of interruptions with multimedia demand reach simultaneously, a plurality of application processes are seized system resource and are led to a conflict, perhaps carry out long communication negotiation and communication, thereby improved the mobile multimedia terminal playing efficiency, accelerated the response speed of portable terminal when a plurality of multimedia demand is arranged.
Embodiment
Be provided with multimedia control process in the portable terminal of the embodiment of the invention, in order to the interruption that respectively has the multimedia demand of mobile terminal receive.The interruption that what is called has the multimedia demand refers to: portable terminal can carry out multimedia when some interrupts in response, and then these interrupt the interruption for having the multimedia demand.Such as, when portable terminal response call request is interrupted, can play incoming ring tone (or incoming call music), then the interruption for having the multimedia demand is interrupted in call request; Perhaps, when the timing of portable terminal response quarter-bell is interrupted, can play the quarter-bell music, then the interruption for having the multimedia demand is interrupted in the quarter-bell timing.
Multimedia control process is according to the interruption with multimedia demand that receives, and according to the Interrupt Priority Level that sets in advance, the operation that comes united and coordinating respectively to have the pairing application process of interruption of multimedia demand, the preferential high pairing application process of interruption of notification priority is carried out multimedia.Thereby avoid each application process to carry out multimedia at the same time and produce conflict, improved the multimedia efficient of portable terminal, accelerated the response speed of portable terminal when a plurality of multimedia demand is arranged.
Because multimedia comprises that multimedia audio is play, multimedia video is play, therefore, in portable terminal, can voice playing control process be set in order to coordinate, to manage the voice playing demand of each application process according to actual conditions, video playback control process perhaps is set in order to coordinate, to manage the video playback demand of each application process, audio frequency, video playback demand that voice playing control process and video playback control process are come management coordination respectively, managed each application process can certainly be set simultaneously.
It is that example is told about concrete scheme that the embodiment of the invention is play with the control multimedia audio, and for the method that the control multimedia video is play, those skilled in the art can adopt the easy to do realization of the principle identical with the embodiment of the invention.
In the portable terminal as shown in Figure 2, comprising: voiceplaying control process 201 and a plurality of application process with voice playing demand.
Application process with voice playing demand can comprise: application process A202 is that MP3 plays application process; Application process B203 is the caller identification application process; Application process C204 is the quarter-bell application process; Application process D205 is the recreation application process.Certainly, portable terminal can also comprise other the application process with voice playing demand, has not enumerated one by one herein.
The corresponding respectively interruption separately of above-mentioned application process:
Application process A202 interrupts corresponding to the MP3 playing request, promptly produces the interruption of MP3 playing request when carrying out the MP3 broadcast when the user imports related key information, requirement, and application process A202 is used to be implemented in the function of carrying out the MP3 broadcast when MP3 playing request is interrupted arrival.
Application process B203 interrupts corresponding to call request, promptly produces call request and interrupt when call request arrives, and application process B203 is used for carrying out caller identification when call request is interrupted arriving to be handled.
Application process C204 interrupts corresponding to the quarter-bell timing, promptly produces the quarter-bell timing and interrupt when the quarter-bell timing arrives, and application process C204 then is used to handle handling of task when the quarter-bell timing is interrupted arriving.
Application process D205 asks interruption corresponding to playing, promptly when the user imports related key information, generation is played and asked interruption, application process D205 to be used to be implemented in the game function of being correlated with when interruption arrival is asked in recreation when requiring to play.
Voiceplaying control process 201 is used for receiving the interruption with audio frequency (multimedia) broadcast demand, and controls multimedia (audio frequency) broadcast of each application process according to the Interrupt Priority Level that sets in advance: the highest pairing application process of interruption of interruption medium priority that notice receives is carried out application process time-out multimedia (audio frequency) broadcast that the interruption correspondence with voice playing demand of other reception was play and notified to multimedia (audio frequency).
Between voiceplaying control process 201 and each application process, message channel is arranged, pass through message channel, voiceplaying control process 201 can be carried out information interaction with each application process: voiceplaying control process 201 can notify each application process to carry out or suspend multimedia (audio frequency) broadcast by message channel, and each application process also can send related news to voiceplaying control process 201 by message channel.
Voiceplaying control process 201 and each application process have all started behind mobile terminal-opening.But when not playing demand, these application processes are in free time or dormant state.Such as, portable terminal is not when receiving call request, and caller identification application process B203 then is an idle condition; When perhaps the user did not carry out the MP3 broadcast, application process A202 also was an idle condition.
Voiceplaying control process 201 can send notice or message to application process by message channel, and the application process that is in idle condition can operation get up to handle accordingly after message channel obtains notice or message.
Voiceplaying control process 201 is sending the broadcast notice by message channel to the pairing application process of the highest interruption of priority, and this application process receives the operation of notice back: the thread in the operation process, thus realization multimedia (audio frequency) is play.Interrupt corresponding application process for other, 201 of voice playing control processes send time-out by message channel to them and notify, other interrupts corresponding application process and suspends multimedia thread relevant in this process, plays thereby suspended multimedia (audio frequency).
So just avoided a plurality of application processes simultaneously audio frequency apparatus to be controlled, carried out voice playing simultaneously and the system resource that causes is nervous or conflict.Effectively the application process with multimedia demand is managed and coordinate to improve the efficient that multimedia system is play, avoid unnecessary resource contention.
Carry out receiving call request in the process that MP3 plays with portable terminal and carry out caller identification, continuing afterwards to play MP3 is example, tells about the method that portable terminal carries out multimedia control in detail.Particular flow sheet comprises the steps: as shown in Figure 3
S301: voiceplaying control process 201 receives the MP3 playing request and interrupts.
S302: voiceplaying control process 201 sends to application process A202 and plays notice.
Because it is the 201 current unique interruptions that receive of voice playing control process that the MP3 playing request is interrupted, and therefore also is that the highest priority was interrupted during reception was interrupted, then voiceplaying control process 201 sends the broadcast notice to application process A202.
S303: application process A202 carries out MP3 and plays.
Comprise a plurality of threads among the application process A202, finish the subtask of MP3 playing task respectively.Application process A202 plays after the notice operation gets up receiving, and can move these threads respectively.Wherein, the interface display thread corresponding operating information that is used on screen, carrying out the demonstration of MP3 player and receives the user; The encoding and decoding thread is used for audio file is carried out encoding and decoding; The voice playing thread then is used for control audio equipment and carries out voice playing.Application process A202 can carry out MP3 and play after operation is got up.
S304: voiceplaying control process 201 receives call request and interrupts.
S305: voiceplaying control process 201 is according to predefined interrupt priority level, determines in the interruption of reception to be the interruption of limit priority.
Preestablished interrupt priority level in voiceplaying control process 201, such as being interrupt priority level as shown in table 1 below:
Table 1
| Interrupt | Priority |
| The MP3 playing request is interrupted | 1 |
| Call request is interrupted | 4 |
| The quarter-bell timing is interrupted | 3 |
| The recreation request is interrupted | 2 |
According to last table as can be seen, the call request priority of interrupt is higher than MP3 playing request priority of interrupt, and therefore should preferentially carry out call request interrupts pairing application process B203.
S306: voice playingcontrol process 201 notice application process A202 suspend MP3 and play.
Voice playingcontrol process 201 sends to application process A202 by message channel suspends notice, the thread time-out that application process A202 will be correlated with and move, such as suspending the voice playing thread or can also suspend encoding and decoding thread, interface display thread etc., thereby application process A202 has also just suspended control to audio frequency apparatus, has suspended audio frequency output.
S307: voice playingcontrol process 201 sends to application process B203 and plays notice.
Interrupt because the call request priority of interrupt is higher than the MP3 playing request, therefore, voice playingcontrol process 201 preferential notice application process B203 carry out voice playing.Specifically, voice playingcontrol process 201 sends to application process B203 by message channel and plays notice, and application process B203 activates when receiving the broadcast notice and is running status, the thread in the process that brings into operation.
S308: application process B203 carries out incoming ring tone and plays.
Application process B203 also has a plurality of threads, comprising: the tinkle of bells that is used to carry out the interface display thread of the call treatment thread of call treatment, the animation display that is used to send a telegram here and is used to play incoming ring tone is play thread.After application process B203 moved, the tinkle of bells was play thread control audio equipment and is carried out the incoming ring tone broadcast.Because the paused MP3 of application process A202 plays before, operation when then having avoided application process A202 and application process B203, and the conflict that might cause.
S309: application process B203 task termination sends playing task to voice playingcontrol process 201 and finishes notice.
When application process B203 finishes in playing task, can send playing task to voice playingcontrol process 201 by message channel and finish notice.Owing to finish the sign that carries application process B203 in the notice in playing task, so voice playingcontrol process 201 is finished notice according to the playing task that receives and is learnt that application process B203 has finished playing task.
S310: voice playingcontrol process 201 is with the interruption deletion of application process B203 correspondence.
Voice playingcontrol process 201 is after knowing that application process B203 withdraws from, with interruption (being the interruption of the limit priority) deletion of application process B203 correspondence.
S311: voice playingcontrol process 201 is determined the interruption of limit priority in the remaining interruption, and sends the broadcast notice to application process A202.
Voice playingcontrol process 201 determines to receive the interruption of the limit priority in interrupting once more.Because call request is interrupted deleting, therefore remaining MP3 playing request interrupts being highest priority interrupt, and then voice playingcontrol process 201 sends to application process A202 and plays notice.
S312: application process A202 continues MP3 and plays.
Application process A202 activates the thread that suspends after receiving the broadcast notice, continues the MP3 broadcast.
Respectively has the interruption that multimedia (audio frequency) is play demand owing to adopt multimedia control process (voice playing control process) to receive in the portable terminal of the embodiment of the invention, and according to the interrupt priority level that sets in advance, judge to receive and interrupt the highest interruption of medium priority, and preferentially start the highest pairing application process of interruption of running priority level, thereby avoided when a plurality of interruptions with multimedia (audio frequency) broadcast demand reach simultaneously, a plurality of application processes are seized system resource and are led to a conflict, perhaps carry out long communication negotiation and communication, thereby improved mobile multimedia terminal (audio frequency) playing efficiency, accelerated the response speed of portable terminal when having a plurality of multimedias (audio frequency) to play demand.
Though it will be understood by those skilled in the art that in the above-mentioned explanation, for ease of understanding, the step of method has been adopted the succession description, should be pointed out that for the order of above-mentioned steps and do not do strict the restriction.
One of ordinary skill in the art will appreciate that all or part of step that realizes in the foregoing description method is to instruct relevant hardware to finish by program, this program can be stored in the computer read/write memory medium, as: ROM/RAM, magnetic disc, CD etc.
Will also be appreciated that the apparatus structure shown in accompanying drawing or the embodiment only is schematically, the presentation logic structure.Wherein the module that shows as separating component may or may not be physically to separate, and the parts that show as module may be or may not be physical modules.
The above only is a preferred implementation of the present invention; should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the principle of the invention; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.