CN104269185A - Method and system for realizing sound mixing play in Java virtual machine - Google Patents

Method and system for realizing sound mixing play in Java virtual machine Download PDF

Info

Publication number
CN104269185A
CN104269185A CN201410454859.XA CN201410454859A CN104269185A CN 104269185 A CN104269185 A CN 104269185A CN 201410454859 A CN201410454859 A CN 201410454859A CN 104269185 A CN104269185 A CN 104269185A
Authority
CN
China
Prior art keywords
audio
interface
play
media
player
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
Application number
CN201410454859.XA
Other languages
Chinese (zh)
Other versions
CN104269185B (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.)
Fiberhome Telecommunication Technologies Co Ltd
Original Assignee
Fiberhome Telecommunication Technologies Co 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 Fiberhome Telecommunication Technologies Co Ltd filed Critical Fiberhome Telecommunication Technologies Co Ltd
Priority to CN201410454859.XA priority Critical patent/CN104269185B/en
Publication of CN104269185A publication Critical patent/CN104269185A/en
Application granted granted Critical
Publication of CN104269185B publication Critical patent/CN104269185B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Signal Processing For Digital Recording And Reproducing (AREA)
  • Reverberation, Karaoke And Other Acoustics (AREA)

Abstract

The invention discloses a method and a system for realizing sound mixing play in a Java virtual machine, relating to the field of Java application. The method comprises the following steps: obtaining a KNI expansion interface related to audio by using an expansion part JSR135 (Java Specification Requests) of the Java virtual machine; realizing an audio play interface of hardware equipment according to the KNI expansion interface related to audio, wherein the KNI expansion interface is provided by the JSR135 part; supporting creation of two players and simultaneous play by the hardware equipment, realizing an audio playing interface by expanding of a software development kit based on the hardware equipment, initializing the hardware equipment, creating a main player and a slave player, realizing sound mixing play control of the main player and the slave player; and compiling the expansion part JSR135 into the Java virtual machine, and generating a Java virtual machine client supporting audio play and sound mixing play. The Java virtual machine disclosed by the invention realizes sound mixing play by virtue of the main player and the slave player, and is capable of ensuring the stability of the sound mixing play.

Description

The method and system that audio mixing is play are realized in Java Virtual Machine
Technical field
The present invention relates to Java application, specifically relate to a kind of method and system realizing audio mixing and play in Java Virtual Machine.
Background technology
IPTV (Internet Protocol Television, Internet Protocol Television/IPTV) be the multiple technologies such as one utilizes broadband cable net, integrates internet, multimedia, communication, the brand-new technology of the multiple interactive services comprising Digital Television is provided to domestic consumer.IPTV service is roughly divided into the large class of basic service and value-added service two, and the basic service of IPTV refers to the video content services based on audio-visual content, comprises live, program request, carousel, time shift etc.; And the value-added service of IPTV comprises game, instant messaging, E-Payment and Karaoke etc., wherein, game is divided into web game and Java to play two kinds, is the important component part of IPTV value-added service.
Java ME was called J2ME in the past, be Set Top Box, mobile phone and PDA (PersonalDigital Assistant, personal digital assistant) and so on the Java language platform that provides of embedded consumer-elcetronics devices, comprise the Java API (Application Programming Interface, application programming interface) of virtual machine and series of standards.It forms three large paper editions of Java technology together with Java SE, Java EE, and be equally by JCP (Java Community Process, to describe be proposed to join in Java system specification and technology) work out.
In embedded device environment, often on equipment a treatment mechanism had nothing to do with hardware is installed as Java Virtual Machine, to allow to download and to run on equipment.Equipment allows a Java Virtual Machine to use the language irrelevant with hardware, such as Java language.Java language is the cross-platform OO high-level programming language that Sun Microsystems releases, and is just obtaining in every field at present and is applying more and more widely, becoming one of most important programming language.Java Virtual Machine is an abstract computing machine, its main task is the bytecode loading Java class file and perform wherein, Java class file operates in the binary file in the hardware platform of any support Java Virtual Machine and operating system, is responsible for running java applet.
The existing Java game service based on IPTV system is transplanted in IPTV system by Java game (i.e. J2ME program) to run.Therefore, Java Virtual Machine that be arranged on set top box side, that run Java game directly or indirectly uses Java Virtual Machine mostly.The process such as telecommand process, image display, audio frequency broadcasting are mainly carried out in Java game based on IPTV, and along with respective Set Top Box manufacturer chip selection is different, realization all there are differences its sound intermediate frequency broadcasting part.Java Virtual Machine client will realize audio playing function except based on J2ME specification expansion related audio interface, also will having come in conjunction with the hardware audio player method of chip manufacturer.
Current Java Virtual Machine playback interface and the Broadcast Control processing mode of logical and hardware device cannot be connected, and the audio frequency of Java Virtual Machine is play and generally realized audio frequency broadcasting by single player, does not support that audio mixing is play.
Summary of the invention
The object of the invention is the deficiency in order to overcome above-mentioned background technology, providing a kind of method and system realizing audio mixing and play in Java Virtual Machine, Java Virtual Machine realizes audio mixing by principal and subordinate's player and plays, and effectively can guarantee the stability that audio mixing is play.
The invention provides a kind of method realizing audio mixing and play in Java Virtual Machine, comprise the following steps:
S1, the widening parts JSR135 of Java Virtual Machine is utilized to obtain the KNI expansion interface relevant to audio frequency;
S2, the audio frequency provided according to JSR135 parts are correlated with KNI expansion interface, realize the audio frequency play interface of hardware device, described audio frequency play interface comprises that audio frequency creates media_create interface, audio frequency closes media_close interface, audio frequency release media_release_device interface, voice data media_do_buffering interface is set, starts that audio frequency is play media_start interface, stopped playing media_stop interface, audio frequency destroys media_destroy interface; Hardware device support creates two players and plays simultaneously, described audio frequency play interface is realized by the SDK (Software Development Kit) SDK expansion based on hardware device, initiating hardware equipment, creates main player, from player, realizes the audio mixing Play Control of master and slave player;
S3, JSR135 parts are enrolled in Java Virtual Machine, generate and support audio frequency to play and the Java Virtual Machine client of audio mixing broadcasting.
On the basis of technique scheme, the flow process realizing the audio frequency play interface of hardware device described in step S2 is as follows:
S201, establishment the audio frequency realizing being used for audio plays creates media_create interface, described media_create interface is used for initiating hardware equipment, creates main player and from player, and generate audio stream sign in conjunction with media_create parameter, by media_create optimum configurations in pointer rreturn value, to import use into when calling other broadcast control method; The global state mark of master and slave player is set: broadcast state, time-out broadcast state and broadcasting halted state;
S202, establishment realize media_do_buffering interface for arranging voice data, by the audio stream to be played that imports into stored in the audio file of internal memory, and from the pointer that Java Virtual Machine imports into, take out the audio file name created when calling media_create interface, as the sign of this audio stream;
S203, establishment and realize for start audio frequency play media_start interface, audio stream according to the audio frequency to be played stored in the pointer that Java Virtual Machine imports into indicates, create separate threads, the audio stream data that media_do_buffering interface imports into is read in circulation, and be stored in the audio stream that in internal memory, this audio stream sign is corresponding, the audio stream of reading transferred to corresponding master or carry out audio frequency broadcasting from player, realizing the audio mixing Play Control of master and slave player;
S204, establishment and realize audio frequency destroy media_destroy interface, by the audio frequency destroying method that the SDK called based on hardware device provides, realize the release of player used resource to creating and destruction, and will to create before and audio file stored in internal memory is removed;
S205, establishment realize other audio frequency play interface, realized by the corresponding SDK Broadcast Control interface of combined with hardware equipment or method: create play suspend media_pause interface time, by the player global state traffic sign placement of correspondence for playing halted state; When creating stopping and playing media_stop interface, be halted state by the player global state traffic sign placement of correspondence; Realize media_set_volume interface for arranging volume: function or method are set by the volume calling hardware device, and this interface is imported into volume parameter and carry out arranging as volume value.
On the basis of technique scheme, the parameter of media_create described in step S201 comprises playerId, mimeType, mimeLength, and wherein, playerId presentation medium is play and indicated, each audio frequency unique sign in gaming; MimeType represents audio types; MimeLength represents the length of mimeType; Audio stream indicates and is described sign by media play sign playerId and audio types mimeType.
On the basis of technique scheme, the pointer that Java Virtual Machine described in step S202 imports into comprises playing and indicates ID, audio stream total length, audio types, audio stream filename, the channel number of wave formatted audio files, bit rate and sampling rate, wherein, play the long shaping of sign ID to represent, the shaping of audio stream total length represents, audio types shaping represents, for indicating the type of current audio stream; Audio stream filename character type represents, be stored in internal memory or equipment read-write region in; The channel number of wave formatted audio files, bit rate, sampling rate all represent with shaping.
On the basis of technique scheme, when the audio stream of reading being transferred in step S203 corresponding master or carry out audio frequency broadcasting from player, the global state mark of this player of real-time judge, if main player or be in broadcasting halted state from player, then this player is set and suspends and play corresponding audio stream; If main player or be in broadcasting halted state from player, then the broadcasting that this player stops corresponding audio stream is immediately set; Master and slave player is when starting audio plays, and the global state arranging corresponding player is masked as broadcast state; At the end of audio plays, then the global state arranging corresponding player is masked as broadcasting halted state, i.e. idle condition.
On the basis of technique scheme, correspondence described in step S203 is led or is judged by master and slave player status from player, if first audio frequency transfers to main player to play, then main player is in seizure condition, and second audio frequency is just transferred to play from player; If principal and subordinate's player is simultaneously in broadcasting, then show that principal and subordinate's player is all in seizure condition, after the audio frequency to be played such as the 3rd just waits one of them to play, transfer to player idle in principal and subordinate's player to continue to play again.
The present invention also provides a kind of and in Java Virtual Machine, realizes for what realize said method the system that audio mixing plays, comprises the relevant KNI expansion interface acquiring unit of audio frequency, audio frequency play interface realizes unit, Java Virtual Machine client generation unit, wherein:
The KNI expansion interface acquiring unit that described audio frequency is relevant is used for: utilize the widening parts JSR135 of Java Virtual Machine to obtain the KNI expansion interface relevant to audio frequency;
Described audio frequency play interface realizes unit and to be correlated with KNI expansion interface for: the audio frequency provided according to JSR135 parts, realize the audio frequency play interface of hardware device, described audio frequency play interface comprises that audio frequency creates media_create interface, audio frequency closes media_close interface, audio frequency release media_release_device interface, voice data media_do_buffering interface is set, starts that audio frequency is play media_start interface, stopped playing media_stop interface, audio frequency destroys media_destroy interface; Hardware device support creates two players and plays simultaneously, described audio frequency play interface is realized by the SDK (Software Development Kit) SDK expansion based on hardware device, initiating hardware equipment, creates main player, from player, realizes the audio mixing Play Control of master and slave player;
Described Java Virtual Machine client generation unit is used for: enroll in Java Virtual Machine by JSR135 parts, generates the Java Virtual Machine client supporting that audio frequency is play and audio mixing is play.
On the basis of technique scheme, described audio frequency play interface realizes that unit comprises media_create Interface realization subelement, media_do_buffering Interface realization subelement, media_start Interface realization subelement, other audio frequency play interface realize subelement, wherein:
Described media_create Interface realization subelement is used for: create and realize the audio frequency establishment media_create interface for audio plays, described media_create interface is used for initiating hardware equipment, creates main player and from player, and generate audio stream sign in conjunction with media_create parameter, by media_create optimum configurations in pointer rreturn value, to import use into when calling other broadcast control method; The global state mark of master and slave player is set: broadcast state, time-out broadcast state and broadcasting halted state;
Described media_do_buffering Interface realization subelement is used for: create and realize the media_do_buffering interface for arranging voice data, by the audio stream to be played that imports into stored in internal memory, and from the pointer that Java Virtual Machine imports into, take out the audio file name created when calling media_create interface, as the sign of this audio stream;
Described media_start Interface realization subelement is used for: create and realize the media_start interface for starting audio frequency broadcasting, audio stream according to the audio frequency to be played stored in the pointer that Java Virtual Machine imports into indicates, create separate threads, the audio stream data that media_do_buffering interface imports into is read in circulation, and be stored in the audio stream that in internal memory, this audio stream sign is corresponding, the audio stream of reading transferred to corresponding master or carry out audio frequency broadcasting from player, realizing the audio mixing Play Control of master and slave player;
Other audio frequency play interface described realize subelement for: create and realize other audio frequency play interface, the player global state traffic sign placement of correspondence is broadcasting halted state by corresponding SDK Broadcast Control interface or method realization by combined with hardware equipment: when creating broadcasting and suspending media_pause interface; When creating stopping and playing media_stop interface, be halted state by the player global state traffic sign placement of correspondence; Realize media_set_volume interface for arranging volume: function or method are set by the volume calling hardware device, and this interface is imported into volume parameter and carry out arranging as volume value.
On the basis of technique scheme, described media_create parameter comprises playerId, mimeType, mimeLength, and wherein, playerId presentation medium is play and indicated, each audio frequency unique sign in gaming; MimeType represents audio types; MimeLength represents the length of mimeType; Audio stream indicates and is described sign by media play sign playerId and audio types mimeType.
On the basis of technique scheme, the pointer that described Java Virtual Machine imports into comprises playing and indicates ID, audio stream total length, audio types, audio stream filename, the channel number of wave formatted audio files, bit rate and sampling rate, wherein, play the long shaping of sign ID to represent, the shaping of audio stream total length represents, audio types shaping represents, for indicating the type of current audio stream; Audio stream filename character type represents, be stored in internal memory or equipment read-write region in; The channel number of wave formatted audio files, bit rate, sampling rate all represent with shaping.
Compared with prior art, advantage of the present invention is as follows:
Java Virtual Machine in the present invention realizes audio mixing by principal and subordinate's player and plays, and effectively can guarantee the stability that audio mixing is play.
Accompanying drawing explanation
Fig. 1 is the process flow diagram realizing the method that audio mixing is play in the embodiment of the present invention in Java Virtual Machine.
Fig. 2 is the process flow diagram of the audio frequency play interface realizing hardware device in the embodiment of the present invention.
Embodiment
Below in conjunction with drawings and the specific embodiments, the present invention is described in further detail.
Shown in Figure 1, the embodiment of the present invention provides a kind of method realizing audio mixing and play in Java Virtual Machine, comprises the following steps:
S1, the widening parts JSR135 of Java Virtual Machine is utilized to obtain the KNI expansion interface relevant to audio frequency.KNI expansion interface in Java Virtual Machine comprises frequency/audio-frequency broadcasting control interface, video Broadcast Control interface and volume interface etc., and the KNI expansion interface relevant to audio frequency comprises frequency/audio-frequency broadcasting control interface and volume interface.
Being the system ensemble of the multisystem of an integrated multi-environment due to Java Virtual Machine, is only that example is described with Qt (a kind of cross-platform C++ graphical user interface application program development framework) environment under linux operating system here.Wherein multi-environment comprises Qte (Qte and Qt/embedded, it is a version of Qt), fb (i.e. DirectFB, a lightweight Hardware graphics acceleration is provided, input equipment process and abstract shape library), (Windows Embedded Compact (i.e. Windows CE) is that Microsoft is embedded to wince, the basis of mobile computing platform, it is an opening, upgradeable 32 embedded OSs), win32 (32 environment of Microsoft Windows operating system) etc., and multisystem comprises windows, linux etc., the Java Virtual Machine source code that Sun Microsystems provides is supported in compiling in these environment and system and generates corresponding Java Virtual Machine client.
S2, the audio frequency provided according to JSR135 parts are correlated with KNI expansion interface, realize the audio frequency play interface of hardware device.
The embodiment of the present invention utilizes KNI expansion interface (the i.e. local interface of JSR135, the local method call mechanism that the Java Virtual Machine of Sun Microsystems uses) realize the audio frequency play interface of hardware device, its KNI expansion interface is from the KNI Direct Player.c in the primary code of JSR135 and KNI Direct Volume.c two class files, audio frequency play interface mainly comprises: media_create (audio frequency establishment), media_close (audio frequency closedown), media_release_device (audio frequency release), media_do_buffering (voice data is set), media_start (starting audio frequency to play), media_stop (stopping playing), media_destroy (audio frequency destruction) etc.Hardware device support creates two players and plays simultaneously, by SDK (the Software Development Kit based on hardware device, SDK (Software Development Kit)) expansion realize above-mentioned audio frequency play interface, initiating hardware equipment, create main player, from player, realize the audio mixing Play Control of master and slave player.
Shown in Figure 2, the flow process realizing the audio frequency play interface of hardware device in step S2 is as follows:
S201, establishment realize being used for media_create (audio frequency establishment) interface of audio plays, media_create interface is used for initiating hardware equipment, creates main player and from player, and generate audio stream sign in conjunction with media_create parameter, by media_create optimum configurations in pointer rreturn value, to import use into when calling other broadcast control method.Media_create parameter comprises playerId, mimeType, mimeLength, and wherein, playerId presentation medium is play and indicated, each audio frequency unique sign in gaming; MimeType represents audio types; MimeLength represents the length of mimeType.Audio stream indicates and is described sign, such as (1001.wav) by media play sign playerId and audio types.Audio types comprises wav, midi, mp3, amr, MPEG4, TONE etc.
The global state mark of master and slave player is set: broadcast state, time-out broadcast state and broadcasting halted state (free time).
S202, establishment realize media_do_buffering (voice data is set) interface for arranging voice data, by the audio stream to be played that imports into stored in the audio file of internal memory, and from the pointer that Java Virtual Machine imports into, take out the audio file name created when calling media_create (audio frequency establishment) interface, as the sign of this audio stream.
The pointer that Java Virtual Machine imports into comprises playing and indicates ID, audio stream total length, audio types, audio stream filename, the channel number of wave formatted audio files, bit rate and sampling rate, wherein, play the long shaping of sign ID to represent, the shaping of audio stream total length represents, audio types shaping represents, for indicating the type of current audio stream; Audio stream filename character type represents, be stored in internal memory or equipment read-write region in; The channel number of wave formatted audio files, bit rate, sampling rate all represent with shaping.
Media_start (the start audio frequency play) interface that S203, establishment realizing are play for starting audio frequency, audio stream according to the audio frequency to be played stored in the pointer that Java Virtual Machine imports into indicates, create separate threads, the audio stream data that media_do_buffering (arranging voice data) interface imports into is read in circulation, and be stored in the audio stream that in internal memory, this audio stream sign is corresponding, the audio stream of reading transferred to corresponding master or carry out audio frequency broadcasting from player, realizing the audio mixing Play Control of master and slave player.
When the audio stream of reading being transferred to corresponding master or carry out audio frequency broadcasting from player, need the global state mark of this player of real-time judge.If main player or be in broadcasting halted state from player, then this player is set and suspends and play corresponding audio stream; If main player or be in broadcasting halted state from player, then the broadcasting that this player stops corresponding audio stream is immediately set.Master and slave player is when starting audio plays, and the global state arranging corresponding player is masked as broadcast state; At the end of audio plays, then the global state arranging corresponding player is masked as broadcasting halted state, i.e. idle condition.
Above-mentioned correspondence is led or is judged by master and slave player status from player, if first audio frequency transfers to main player to play, then main player is in seizure condition, and second audio frequency is just transferred to play from player; If principal and subordinate's player is simultaneously in broadcasting, then show that principal and subordinate's player is all in seizure condition, after the audio frequency to be played such as the 3rd just waits one of them to play, transfer to player idle in principal and subordinate's player to continue to play again.
S204, establishment and realize audio frequency destroy media_destroy (audio frequency destruction) interface, by the audio frequency destroying method that the SDK called based on hardware device provides, realize the release of player used resource to creating and destruction, and will to create before and audio file stored in internal memory is removed.
S205, establishment realize other audio frequency play interface, realized by the corresponding SDK Broadcast Control interface of combined with hardware equipment or method.Because KNI expansion interface is Java Virtual Machine unified definition, and be known, do not illustrate one by one here.Such as: when creating media_pause (play and suspend) interface, need by the player global state traffic sign placement of correspondence for playing halted state; When creating media_stop (stopping playing) interface, need be halted state by the player global state traffic sign placement of correspondence; Realize media_set_volume interface for arranging volume: function or method are set by the volume calling hardware device, and this interface is imported into volume parameter and carry out arranging as volume value.
S3, JSR135 parts are enrolled in Java Virtual Machine, generate and support audio frequency to play and the Java Virtual Machine client of audio mixing broadcasting.
The embodiment of the present invention also provides a kind of system realizing audio mixing broadcasting in Java Virtual Machine for realizing said method, comprise the relevant KNI expansion interface acquiring unit of audio frequency, audio frequency play interface realizes unit, Java Virtual Machine client generation unit, wherein:
The KNI expansion interface acquiring unit that audio frequency is relevant is used for: utilize the widening parts JSR135 of Java Virtual Machine to obtain the KNI expansion interface relevant to audio frequency;
Audio frequency play interface realizes unit and to be correlated with KNI expansion interface for: the audio frequency provided according to JSR135 parts, realize the audio frequency play interface of hardware device, audio frequency play interface comprises that audio frequency creates media_create interface, audio frequency closes media_close interface, audio frequency release media_release_device interface, voice data media_do_buffering interface is set, starts that audio frequency is play media_start interface, stopped playing media_stop interface, audio frequency destroys media_destroy interface; Hardware device support creates two players and plays simultaneously, described audio frequency play interface is realized by the SDK (Software Development Kit) SDK expansion based on hardware device, initiating hardware equipment, creates main player, from player, realizes the audio mixing Play Control of master and slave player;
Java Virtual Machine client generation unit is used for: enroll in Java Virtual Machine by JSR135 parts, generates the Java Virtual Machine client supporting that audio frequency is play and audio mixing is play.
Audio frequency play interface realizes that unit comprises media_create Interface realization subelement, media_do_buffering Interface realization subelement, media_start Interface realization subelement, other audio frequency play interface realize subelement, wherein:
Media_create Interface realization subelement is used for: create and realize the audio frequency establishment media_create interface for audio plays, described media_create interface is used for initiating hardware equipment, creates main player and from player, and generate audio stream sign in conjunction with media_create parameter, by media_create optimum configurations in pointer rreturn value, to import use into when calling other broadcast control method; The global state mark of master and slave player is set: broadcast state, time-out broadcast state and broadcasting halted state; Media_create parameter comprises playerId, mimeType, mimeLength, and wherein, playerId presentation medium is play and indicated, each audio frequency unique sign in gaming; MimeType represents audio types; MimeLength represents the length of mimeType; Audio stream indicates and is described sign by media play sign playerId and audio types mimeType.
Media_do_buffering Interface realization subelement is used for: create and realize the media_do_buffering interface for arranging voice data, by the audio stream to be played that imports into stored in internal memory, and from the pointer that Java Virtual Machine imports into, take out the audio file name created when calling media_create interface, as the sign of this audio stream; The pointer that Java Virtual Machine imports into comprises playing and indicates ID, audio stream total length, audio types, audio stream filename, the channel number of wave formatted audio files, bit rate and sampling rate, wherein, play the long shaping of sign ID to represent, the shaping of audio stream total length represents, audio types shaping represents, for indicating the type of current audio stream; Audio stream filename character type represents, be stored in internal memory or equipment read-write region in; The channel number of wave formatted audio files, bit rate, sampling rate all represent with shaping.
Media_start Interface realization subelement is used for: create and realize the media_start interface for starting audio frequency broadcasting, audio stream according to the audio frequency to be played stored in the pointer that Java Virtual Machine imports into indicates, create separate threads, the audio stream data that media_do_buffering interface imports into is read in circulation, and be stored in the audio stream that in internal memory, this audio stream sign is corresponding, the audio stream of reading transferred to corresponding master or carry out audio frequency broadcasting from player, realizing the audio mixing Play Control of master and slave player.
Other audio frequency play interface realize subelement for: create and realize other audio frequency play interface, the player global state traffic sign placement of correspondence is broadcasting halted state by corresponding SDK Broadcast Control interface or method realization by combined with hardware equipment: when creating broadcasting and suspending media_pause interface; When creating stopping and playing media_stop interface, be halted state by the player global state traffic sign placement of correspondence; Realize media_set_volume interface for arranging volume: function or method are set by the volume calling hardware device, and this interface is imported into volume parameter and carry out arranging as volume value.
The principle of the embodiment of the present invention is elaborated as follows:
The Java Virtual Machine of increasing income that the Java Virtual Machine that the embodiment of the present invention adopts provides for Sun Microsystems, the broadcasting of its audio frequency is widening parts JSR135 (the Java Specification Requests 135 by Java Virtual Machine, Java code requirement 135) realize, JSR135 is that Sun Microsystems increases income the modular unit of Java Virtual Machine, is that the Java that Java standardization body submits to Sun Microsystems develops draft.The audio treatment part that JSR135 achieves based on J2ME standard divides, and device-dependent KNI playback interface then needs terminal device to carry out expansion realization voluntarily.
The audio frequency process of Java Virtual Machine achieves on the basis based on J2ME specification, and be all need the KNI Interface Expanding based on JSR135 to realize for the method that audio stream carries out final broadcasting by equipment, and its play operation only rests on the direct Broadcast Control operation to audio stream.The present invention is by the KNI interface of expansion JSR135, realize creating main player and from player, allow Java play to realize two-way audio and can play simultaneously become possibility, and avoid a player in prior art and switch broadcasting back and forth to the reproduction of multiple audio streams that upper strata Java Virtual Machine imports into, and the audio frequency that may cause is discontinuous or audio frequency and the problem such as picture does not mate.
Create main player when realizing audio frequency establishment interface and from player, the media play of current play parameter indicated and is stored in a pointer.When realizing arranging audio frequency data interface, by receive upper strata Java Virtual Machine call this interface and the audio stream that imports into is stored in internal memory or in equipment read-write region file in.The pointer that imported into by Java Virtual Machine is obtained media play and indicates, and in conjunction with the audio file name (as 1001.wav) of this audio frequency of audio types generating identification belonging to audio stream.When realizing starting audio frequency play interface, obtain media play sign according to the pointer that Java Virtual Machine imports into, and create audio frequency broadcasting thread.This thread is according to the Broadcast Control idle condition of principal and subordinate's player, and the diaphone frequency file obtaining read-write region in the audio stream that is stored in internal memory or equipment is indicated according to media play, ceaselessly read by thread and in the audio buffer district specified to hardware, write to realize audio frequency and play.Current affiliated main player or the using state from player is reset in playing process.
Judge that the Broadcast Control idle condition of principal and subordinate's player is that player for present video being switched to idle condition in master and slave player is play.In audio frequency playing process, when calling media_pause (play and suspend), then this broadcasting thread suspends, and in the audio buffer district that hardware is specified, writes audio stream to reach the function suspended and play; When calling media_stop (stopping playing), then this broadcasting thread stops writing audio stream in the audio buffer district that hardware is specified, and terminates to exit this thread.
Those skilled in the art can carry out various modifications and variations to the embodiment of the present invention, if these amendments and modification are within the scope of the claims in the present invention and equivalent technologies thereof, then these revise and modification also within protection scope of the present invention.
The prior art that the content do not described in detail in instructions is known to the skilled person.

Claims (10)

1. in Java Virtual Machine, realize the method that audio mixing is play, it is characterized in that, comprise the following steps:
S1, the widening parts JSR135 of Java Virtual Machine is utilized to obtain the KNI expansion interface relevant to audio frequency;
S2, the audio frequency provided according to JSR135 parts are correlated with KNI expansion interface, realize the audio frequency play interface of hardware device, described audio frequency play interface comprises that audio frequency creates media_create interface, audio frequency closes media_close interface, audio frequency release media_release_device interface, voice data media_do_buffering interface is set, starts that audio frequency is play media_start interface, stopped playing media_stop interface, audio frequency destroys media_destroy interface; Hardware device support creates two players and plays simultaneously, described audio frequency play interface is realized by the SDK (Software Development Kit) SDK expansion based on hardware device, initiating hardware equipment, creates main player, from player, realizes the audio mixing Play Control of master and slave player;
S3, JSR135 parts are enrolled in Java Virtual Machine, generate and support audio frequency to play and the Java Virtual Machine client of audio mixing broadcasting.
2. in Java Virtual Machine, realize the method that audio mixing is play as claimed in claim 1, it is characterized in that: the flow process realizing the audio frequency play interface of hardware device described in step S2 is as follows:
S201, establishment the audio frequency realizing being used for audio plays creates media_create interface, described media_create interface is used for initiating hardware equipment, creates main player and from player, and generate audio stream sign in conjunction with media_create parameter, by media_create optimum configurations in pointer rreturn value, to import use into when calling other broadcast control method; The global state mark of master and slave player is set: broadcast state, time-out broadcast state and broadcasting halted state;
S202, establishment realize media_do_buffering interface for arranging voice data, by the audio stream to be played that imports into stored in the audio file of internal memory, and from the pointer that Java Virtual Machine imports into, take out the audio file name created when calling media_create interface, as the sign of this audio stream;
S203, establishment and realize for start audio frequency play media_start interface, audio stream according to the audio frequency to be played stored in the pointer that Java Virtual Machine imports into indicates, create separate threads, the audio stream data that media_do_buffering interface imports into is read in circulation, and be stored in the audio stream that in internal memory, this audio stream sign is corresponding, the audio stream of reading transferred to corresponding master or carry out audio frequency broadcasting from player, realizing the audio mixing Play Control of master and slave player;
S204, establishment and realize audio frequency destroy media_destroy interface, by the audio frequency destroying method that the SDK called based on hardware device provides, realize the release of player used resource to creating and destruction, and will to create before and audio file stored in internal memory is removed;
S205, establishment realize other audio frequency play interface, realized by the corresponding SDK Broadcast Control interface of combined with hardware equipment or method: create play suspend media_pause interface time, by the player global state traffic sign placement of correspondence for playing halted state; When creating stopping and playing media_stop interface, be halted state by the player global state traffic sign placement of correspondence; Realize media_set_volume interface for arranging volume: function or method are set by the volume calling hardware device, and this interface is imported into volume parameter and carry out arranging as volume value.
3. in Java Virtual Machine, realize the method that audio mixing is play as claimed in claim 2, it is characterized in that: the parameter of media_create described in step S201 comprises playerId, mimeType, mimeLength, wherein, playerId presentation medium is play and is indicated, each audio frequency unique sign in gaming; MimeType represents audio types; MimeLength represents the length of mimeType; Audio stream indicates and is described sign by media play sign playerId and audio types mimeType.
4. in Java Virtual Machine, realize the method that audio mixing is play as claimed in claim 2, it is characterized in that: the pointer that Java Virtual Machine described in step S202 imports into comprises playing and indicates ID, audio stream total length, audio types, audio stream filename, the channel number of wave formatted audio files, bit rate and sampling rate, wherein, play the long shaping of sign ID to represent, the shaping of audio stream total length represents, audio types shaping represents, for indicating the type of current audio stream; Audio stream filename character type represents, be stored in internal memory or equipment read-write region in; The channel number of wave formatted audio files, bit rate, sampling rate all represent with shaping.
5. in Java Virtual Machine, realize the method that audio mixing is play as claimed in claim 2, it is characterized in that: when the audio stream of reading being transferred in step S203 corresponding master or carry out audio frequency broadcasting from player, the global state mark of this player of real-time judge, if main player or be in broadcasting halted state from player, then this player is set and suspends and play corresponding audio stream; If main player or be in broadcasting halted state from player, then the broadcasting that this player stops corresponding audio stream is immediately set; Master and slave player is when starting audio plays, and the global state arranging corresponding player is masked as broadcast state; At the end of audio plays, then the global state arranging corresponding player is masked as broadcasting halted state, i.e. idle condition.
6. the method realizing audio mixing broadcasting in Java Virtual Machine according to any one of claim 2 to 5, it is characterized in that: correspondence described in step S203 is led or is judged by master and slave player status from player, if first audio frequency transfers to main player to play, then main player is in seizure condition, and second audio frequency is just transferred to play from player; If principal and subordinate's player is simultaneously in broadcasting, then show that principal and subordinate's player is all in seizure condition, after the audio frequency to be played such as the 3rd just waits one of them to play, transfer to player idle in principal and subordinate's player to continue to play again.
7. for realizing the system realizing audio mixing broadcasting in Java Virtual Machine of method according to any one of claim 1 to 6, it is characterized in that: comprise the relevant KNI expansion interface acquiring unit of audio frequency, audio frequency play interface realizes unit, Java Virtual Machine client generation unit, wherein:
The KNI expansion interface acquiring unit that described audio frequency is relevant is used for: utilize the widening parts JSR135 of Java Virtual Machine to obtain the KNI expansion interface relevant to audio frequency;
Described audio frequency play interface realizes unit and to be correlated with KNI expansion interface for: the audio frequency provided according to JSR135 parts, realize the audio frequency play interface of hardware device, described audio frequency play interface comprises that audio frequency creates media_create interface, audio frequency closes media_close interface, audio frequency release media_release_device interface, voice data media_do_buffering interface is set, starts that audio frequency is play media_start interface, stopped playing media_stop interface, audio frequency destroys media_destroy interface; Hardware device support creates two players and plays simultaneously, described audio frequency play interface is realized by the SDK (Software Development Kit) SDK expansion based on hardware device, initiating hardware equipment, creates main player, from player, realizes the audio mixing Play Control of master and slave player;
Described Java Virtual Machine client generation unit is used for: enroll in Java Virtual Machine by JSR135 parts, generates the Java Virtual Machine client supporting that audio frequency is play and audio mixing is play.
8. in Java Virtual Machine, realize the system that audio mixing is play as claimed in claim 7, it is characterized in that: described audio frequency play interface realizes that unit comprises media_create Interface realization subelement, media_do_buffering Interface realization subelement, media_start Interface realization subelement, other audio frequency play interface realize subelement, wherein:
Described media_create Interface realization subelement is used for: create and realize the audio frequency establishment media_create interface for audio plays, described media_create interface is used for initiating hardware equipment, creates main player and from player, and generate audio stream sign in conjunction with media_create parameter, by media_create optimum configurations in pointer rreturn value, to import use into when calling other broadcast control method; The global state mark of master and slave player is set: broadcast state, time-out broadcast state and broadcasting halted state;
Described media_do_buffering Interface realization subelement is used for: create and realize the media_do_buffering interface for arranging voice data, by the audio stream to be played that imports into stored in internal memory, and from the pointer that Java Virtual Machine imports into, take out the audio file name created when calling media_create interface, as the sign of this audio stream;
Described media_start Interface realization subelement is used for: create and realize the media_start interface for starting audio frequency broadcasting, audio stream according to the audio frequency to be played stored in the pointer that Java Virtual Machine imports into indicates, create separate threads, the audio stream data that media_do_buffering interface imports into is read in circulation, and be stored in the audio stream that in internal memory, this audio stream sign is corresponding, the audio stream of reading transferred to corresponding master or carry out audio frequency broadcasting from player, realizing the audio mixing Play Control of master and slave player;
Other audio frequency play interface described realize subelement for: create and realize other audio frequency play interface, the player global state traffic sign placement of correspondence is broadcasting halted state by corresponding SDK Broadcast Control interface or method realization by combined with hardware equipment: when creating broadcasting and suspending media_pause interface; When creating stopping and playing media_stop interface, be halted state by the player global state traffic sign placement of correspondence; Realize media_set_volume interface for arranging volume: function or method are set by the volume calling hardware device, and this interface is imported into volume parameter and carry out arranging as volume value.
9. in Java Virtual Machine, realize the system that audio mixing is play as claimed in claim 8, it is characterized in that: described media_create parameter comprises playerId, mimeType, mimeLength, wherein, playerId presentation medium is play and is indicated, each audio frequency unique sign in gaming; MimeType represents audio types; MimeLength represents the length of mimeType; Audio stream indicates and is described sign by media play sign playerId and audio types mimeType.
10. in Java Virtual Machine, realize the system that audio mixing is play as claimed in claim 8, it is characterized in that: the pointer that described Java Virtual Machine imports into comprises playing and indicates ID, audio stream total length, audio types, audio stream filename, the channel number of wave formatted audio files, bit rate and sampling rate, wherein, play the long shaping of sign ID to represent, the shaping of audio stream total length represents, audio types shaping represents, for indicating the type of current audio stream; Audio stream filename character type represents, be stored in internal memory or equipment read-write region in; The channel number of wave formatted audio files, bit rate, sampling rate all represent with shaping.
CN201410454859.XA 2014-09-09 2014-09-09 Method and system for realizing sound mixing play in Java virtual machine Active CN104269185B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410454859.XA CN104269185B (en) 2014-09-09 2014-09-09 Method and system for realizing sound mixing play in Java virtual machine

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410454859.XA CN104269185B (en) 2014-09-09 2014-09-09 Method and system for realizing sound mixing play in Java virtual machine

Publications (2)

Publication Number Publication Date
CN104269185A true CN104269185A (en) 2015-01-07
CN104269185B CN104269185B (en) 2017-04-12

Family

ID=52160699

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410454859.XA Active CN104269185B (en) 2014-09-09 2014-09-09 Method and system for realizing sound mixing play in Java virtual machine

Country Status (1)

Country Link
CN (1) CN104269185B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109032559A (en) * 2018-07-25 2018-12-18 南京创维信息技术研究院有限公司 A kind of configuration method and system of the same sound pick-up outfit of more Application shares
CN114302243A (en) * 2021-11-30 2022-04-08 四川天邑康和通信股份有限公司 Method for realizing operation of J2ME game audio file by IPTV set-top box

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7668936B1 (en) * 2000-05-26 2010-02-23 Krikorian Thomas M Continuous media playback system controlled over a distributed communication system
US7835625B2 (en) * 2004-12-01 2010-11-16 Panasonic Corporation Recording medium, playback apparatus, management program and playback method
CN101442586B (en) * 2008-12-31 2012-06-27 中兴通讯股份有限公司 Method and terminal for playing multimedia

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
陆芸芸等: "JSR135的设计与实现", 《计算机工程与应用》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109032559A (en) * 2018-07-25 2018-12-18 南京创维信息技术研究院有限公司 A kind of configuration method and system of the same sound pick-up outfit of more Application shares
CN114302243A (en) * 2021-11-30 2022-04-08 四川天邑康和通信股份有限公司 Method for realizing operation of J2ME game audio file by IPTV set-top box

Also Published As

Publication number Publication date
CN104269185B (en) 2017-04-12

Similar Documents

Publication Publication Date Title
CN102568517B (en) Interfaces for digital media processing
Brinkmann et al. Embedding pure data with libpd
CN111625214B (en) Audio control method, device, equipment and storage medium
US8938674B2 (en) Managing media player sound output
US20070219937A1 (en) Automated visualization for enhanced music playback
WO2006042300A2 (en) System and method for creating, distributing, and executing rich multimedia applications
JP2010288301A (en) System for multimedia rendering in portable device
CN102333246A (en) User interface system based on Flash middleware of set top box
CN102609302A (en) Multimedia application concurrent-management method and multimedia application concurrent-management device
CN111261133A (en) Singing processing method and device, electronic equipment and storage medium
Wyatt et al. Animated music notation on the iPad
CN104269185A (en) Method and system for realizing sound mixing play in Java virtual machine
CN104822095A (en) Composite beat special effect system and composite beat special effect processing method
CN109669691A (en) Platform universal control method and system based on built-in Linux audio player
CN103051946A (en) General real time streaming protocol (RTSP) stream player based on Android system
CN104822094A (en) Polyrhythm special-effect system and polyrhythm special-effect processing method
CN111290746A (en) Object access method, device, equipment and storage medium
CN1801913A (en) Universal video player
WO2006027605A2 (en) Extendible media content rendering system
CN112791407B (en) Sound effect control method and device
CN108650544A (en) A kind of media playing method, device and media play system
WO2013078891A1 (en) Portable multimedia device and operating method therefor
KR101468411B1 (en) Apparatus for playing and editing MIDI music and Method for the same with user orientation
CN101820496B (en) Digital audio/video playing system with music appreciating and explaining functions
CN107077872A (en) Android carries the method for developing functions and multimedia play system of multimedia player

Legal Events

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