📄 音频缓冲区的设置 - netwarning的专栏 - csdnblog.htm
字号:
href="http://blog.csdn.net/netwarning/category/236171.aspx">PLC</A><A
href="http://blog.csdn.net/netwarning/category/236171.aspx/rss">(RSS)</A>
<LI class=listitem><A
href="http://blog.csdn.net/netwarning/category/249733.aspx">VB.NET</A><A
href="http://blog.csdn.net/netwarning/category/249733.aspx/rss">(RSS)</A>
<LI class=listitem><A
href="http://blog.csdn.net/netwarning/category/259265.aspx">冰上运动</A><A
href="http://blog.csdn.net/netwarning/category/259265.aspx/rss">(RSS)</A>
<LI class=listitem><A
href="http://blog.csdn.net/netwarning/category/211479.aspx">随写</A><A
href="http://blog.csdn.net/netwarning/category/211479.aspx/rss">(RSS)</A></LI></UL>
<H3 class=listtitle>收藏</H3>
<UL class=list>
<LI class=listitem><A
href="http://blog.csdn.net/netwarning/category/283786.aspx">Internet编程</A></LI></UL>
<H3 class=listtitle>相册</H3><!--category title-->
<UL class=list>
<LI class=listitem><A
href="http://blog.csdn.net/netwarning/Gallery/246612.aspx">我的单位</A></LI></UL>
<H3 class=listtitle>JAVA</H3>
<UL class=list>
<LI class=listitem><A href="http://blog.csdn.net/i_like_cpp/"
target=_blank>Internet网络编程</A>
<LI class=listitem><A href="http://blog.csdn.net/unagain/"
target=_blank>Unagain的专栏</A></LI></UL>
<H3 class=listtitle>存档</H3>
<UL class=list>
<LI><A
href="http://blog.csdn.net/netwarning/archive/2007/04.aspx">2007年04月(2)</A>
<LI><A
href="http://blog.csdn.net/netwarning/archive/2007/03.aspx">2007年03月(10)</A>
<LI><A
href="http://blog.csdn.net/netwarning/archive/2007/02.aspx">2007年02月(2)</A>
<LI><A
href="http://blog.csdn.net/netwarning/archive/2006/11.aspx">2006年11月(2)</A>
<LI><A
href="http://blog.csdn.net/netwarning/archive/2006/10.aspx">2006年10月(4)</A>
<LI><A
href="http://blog.csdn.net/netwarning/archive/2006/09.aspx">2006年09月(3)</A>
<LI><A
href="http://blog.csdn.net/netwarning/archive/2006/06.aspx">2006年06月(4)</A>
<LI><A
href="http://blog.csdn.net/netwarning/archive/2006/05.aspx">2006年05月(1)</A></LI></UL><SPAN
id=Anthem_RecentComments1_ltlComments__><SPAN id=RecentComments1_ltlComments>
<H3 class=listtitle>最近评论</H3>
<UL class=list>
<LI class=listitem>crystal:<A title=点击查看《回复:断网了》
href="http://blog.csdn.net/netwarning/archive/2007/04/07/1556086.aspx#571489">还不错啊</A>
<LI class=listitem>仙女:<A title=点击查看《回复:我的单位》
href="http://blog.csdn.net/netwarning/archive/2006/10/14/1334814.aspx#571486">好漂亮的地方啊</A>
<LI class=listitem>Solomon Joh:<A title=点击查看《回复:断网了》
href="http://blog.csdn.net/netwarning/archive/2007/04/07/1556086.aspx#566717">看来你也有一阵没更新新了,和我一样。我过来帮你踩一踩人气,记得谢谢我哦。</A>
<LI class=listitem>lilimerci:<A title=点击查看《回复:JMF捕获技术(视频)》
href="http://blog.csdn.net/netwarning/archive/2006/06/07/779142.aspx#557797">您好,我最近在做个JMF项目。<BR>可否交流一下,谢谢。</A>
<LI class=listitem>DSD:<A title=点击查看《回复:JList中添加右键菜单(JPopupMenu)》
href="http://blog.csdn.net/netwarning/archive/2007/03/16/1531711.aspx#556963">顶</A></LI></UL></SPAN></SPAN>
<DIV class=spacer> </DIV></DIV>
<DIV class=centercolumn><SPAN class=PreAndNext
id=viewpost.ascx_PreviousAndNextEntriesUp>
<DIV align=center><A
href="http://blog.csdn.net/netwarning/archive/2006/10/12/1332264.aspx">上一篇: 克隆数据源(DataSource)
--JMF</A> | <A
href="http://blog.csdn.net/netwarning/archive/2006/09/14/1223591.aspx">下一篇: 生活带来的快乐</A></DIV></SPAN><BR>
<SCRIPT>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</SCRIPT>
<DIV class=post>
<DIV class=postTitle>
<SCRIPT src="音频缓冲区的设置 - netwarning的专栏 - CSDNBlog.files/vote.js"></SCRIPT>
<A href="http://blog.csdn.net/netwarning/archive/2006/10/11/1329504.aspx"><IMG
height=13 src="音频缓冲区的设置 - netwarning的专栏 - CSDNBlog.files/trans.gif" width=15
border=0> 音频缓冲区的设置</A>
<SCRIPT src="音频缓冲区的设置 - netwarning的专栏 - CSDNBlog.files/count.htm"></SCRIPT>
</DIV>
<DIV class=postText>
<P>设置音频数据捕获(capture)和提交(render)缓冲区的数值</P>
<P>问题:</P>
<P>
给音频信息的捕获和提交设置缓冲区数值.小一些的缓冲区会减少时钟周期,但是也会增加传输的次数.这些书只需要在不同的系统上测试.</P>
<P>解决方案:</P>
<P>
音频缓冲区控制(AudioBufferControl)包含于数据源(DataSource)和播放器(Player)中.捕获音频缓冲区数值(Capture
Buffer Size)由数据</P>
<P>源控制,提交缓冲区数值(render buffer size)由播放器控制.</P>
<P> requirements<BR> related
classes<BR> how to run this sample<BR>
source code</P>
<P> requirements</P>
<P>
平台
JDK 1.1.6 或更高版本<BR> JMF
API: 2.0
或更高版本<BR> Implementation
AJ(All Java),WPP(Windows Performance Pack),SPP(Solaris Performance Pack)</P>
<P> 相关的类</P>
<P> javax.media.Player<BR>
javax.media.control.BufferControl</P>
<P><BR> 如何执行这个例子</P>
<P> java AudioBufferControl [-c <capture buf size in
millisecs>] [-r <render buf size in millisecs>] <URL> </P>
<P> 例如: java AudioBufferControl -c 62 -r 400
javasound://44100 </P>
<P> 代码</P>
<P> </P>
<P><BR>import java.awt.*;<BR>import javax.media.*;<BR>import
javax.media.control.TrackControl;<BR>import
javax.media.control.BufferControl;<BR>import javax.media.format.*;<BR>import
javax.media.protocol.*;<BR>import javax.media.protocol.DataSource;</P>
<P><BR>/**<BR> * Sample program to playback the input URL and set the audio
capture <BR> * and rendering buffer sizes.<BR> */<BR>public class
AudioBufferControl extends Frame implements ControllerListener {</P>
<P> Processor p;<BR> Object waitSync = new
Object();<BR> boolean stateTransitionOK = true;</P>
<P> /**<BR> * Given a DataSource,
create a processor and use that processor<BR> * as a
player to playback the media.<BR>
*/<BR> public boolean open(DataSource ds, int captureBufSize,
int renderBufSize) {</P>
<P> System.err.println("create processor for: " + ds.getContentType());</P>
<P> // Check to see if there's a buffer control on the data
source.<BR> // It could be that we are using a capture data
source.<BR> Control c =
(Control)ds.getControl("javax.media.control.BufferControl");<BR> if (c !=
null)<BR>
((BufferControl)c).setBufferLength(captureBufSize);</P>
<P> try {<BR> p =
Manager.createProcessor(ds);<BR> } catch (Exception e)
{<BR> System.err.println("Failed to create a processor
from the given DataSource: " + e);<BR> return
false;<BR> }</P>
<P> p.addControllerListener(this);</P>
<P> // Put the Processor into configured
state.<BR> p.configure();<BR> if (!waitForState(p.Configured))
{<BR> System.err.println("Failed to configure the
processor.");<BR> return false;<BR> }</P>
<P> // So I can use it as a
player.<BR> p.setContentDescriptor(null);</P>
<P> p.realize();<BR> if (!waitForState(p.Realized))
{<BR> System.err.println("Failed to realize the
processor.");<BR> return false;<BR> }</P>
<P> // After the processor has been realized, we can now set
the<BR> // renderer's buffer size. We need to do this before
the<BR> // processor is prefetched.<BR> // We need to loop the array
of controls to make sure that we <BR> // are setting the size of the
correct buffer control since<BR> // the DataSource's controls are also
included in the list.<BR> Control cs[] = p.getControls();<BR> Object
owner;</P>
<P> for (int i = 0; i < cs.length; i++) {<BR> if
(cs[i] instanceof Owned && cs[i] instanceof BufferControl)
{<BR> owner = ((Owned)cs[i]).getOwner();<BR> if (owner
instanceof Renderer) {<BR>
((BufferControl)cs[i]).setBufferLength(renderBufSize);<BR> }<BR>
}<BR> }</P>
<P> // Prefetch the processor.<BR> p.prefetch();<BR> if
(!waitForState(p.Prefetched)) {<BR>
System.err.println("Failed to prefetch the
processor.");<BR> return false;<BR> }</P>
<P> // Display the visual & control component if there's one.</P>
<P> setLayout(new BorderLayout());</P>
<P> Component cc;</P>
<P> Component vc;<BR> if ((vc = p.getVisualComponent()) != null)
{<BR> add("Center", vc);<BR> }</P>
<P> if ((cc = p.getControlPanelComponent()) != null)
{<BR> add("South", cc);<BR> }</P>
<P> // Start the processor.<BR> p.start();</P>
<P> setVisible(true);</P>
<P> return true;<BR> }</P>
<P> public void addNotify()
{<BR> super.addNotify();<BR> pack();<BR> }</P>
<P> /**<BR> * Block until the
processor has transitioned to the given state.<BR> *
Return false if the transition failed.<BR>
*/<BR> boolean waitForState(int state) {<BR> synchronized
(waitSync) {<BR> try {<BR> while
(p.getState() < state &&
stateTransitionOK)<BR>
waitSync.wait();<BR> } catch (Exception e)
{}<BR> }<BR> return stateTransitionOK;<BR> }</P>
<P><BR> /**<BR> * Controller
Listener.<BR> */<BR> public void
controllerUpdate(ControllerEvent evt) {</P>
<P> if (evt instanceof ConfigureCompleteEvent
||<BR> evt instanceof RealizeCompleteEvent
||<BR> evt instanceof PrefetchCompleteEvent)
{<BR> synchronized (waitSync)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -