⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 音频缓冲区的设置 - netwarning的专栏 - csdnblog.htm

📁 JMF编程的基础教程。。。 html格式配有源码。。。 非常适合初学者学习
💻 HTM
📖 第 1 页 / 共 3 页
字号:
  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>&nbsp;</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">上一篇:&nbsp;克隆数据源(DataSource) 
--JMF</A>&nbsp;|&nbsp;<A 
href="http://blog.csdn.net/netwarning/archive/2006/09/14/1223591.aspx">下一篇:&nbsp;生活带来的快乐</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>&nbsp;音频缓冲区的设置</A>&nbsp;&nbsp;
<SCRIPT src="音频缓冲区的设置 - netwarning的专栏 - CSDNBlog.files/count.htm"></SCRIPT>
 </DIV>
<DIV class=postText>
<P>设置音频数据捕获(capture)和提交(render)缓冲区的数值</P>
<P>问题:</P>
<P>&nbsp;&nbsp;&nbsp; 
给音频信息的捕获和提交设置缓冲区数值.小一些的缓冲区会减少时钟周期,但是也会增加传输的次数.这些书只需要在不同的系统上测试.</P>
<P>解决方案:</P>
<P>&nbsp;&nbsp; 
音频缓冲区控制(AudioBufferControl)包含于数据源(DataSource)和播放器(Player)中.捕获音频缓冲区数值(Capture 
Buffer Size)由数据</P>
<P>源控制,提交缓冲区数值(render buffer size)由播放器控制.</P>
<P>&nbsp;&nbsp;&nbsp; requirements<BR>&nbsp;&nbsp;&nbsp; related 
classes<BR>&nbsp;&nbsp;&nbsp; how to run this sample<BR>&nbsp;&nbsp;&nbsp; 
source code</P>
<P>&nbsp;&nbsp;&nbsp; requirements</P>
<P>&nbsp;&nbsp;&nbsp; 
平台&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
JDK 1.1.6 或更高版本<BR>&nbsp;&nbsp;&nbsp; JMF 
API:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.0 
或更高版本<BR>&nbsp;&nbsp;&nbsp; Implementation&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
AJ(All Java),WPP(Windows Performance Pack),SPP(Solaris Performance Pack)</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; 相关的类</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; javax.media.Player<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
javax.media.control.BufferControl</P>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp; 如何执行这个例子</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; java AudioBufferControl [-c &lt;capture buf size in 
millisecs&gt;] [-r &lt;render buf size in millisecs&gt;] &lt;URL&gt; </P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; 例如: java AudioBufferControl -c 62 -r 400 
javasound://44100 </P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; 代码</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; </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>&nbsp;* Sample program to playback the input URL and set the audio 
capture <BR>&nbsp;* and rendering buffer sizes.<BR>&nbsp;*/<BR>public class 
AudioBufferControl extends Frame implements ControllerListener {</P>
<P>&nbsp;&nbsp;&nbsp; Processor p;<BR>&nbsp;&nbsp;&nbsp; Object waitSync = new 
Object();<BR>&nbsp;&nbsp;&nbsp; boolean stateTransitionOK = true;</P>
<P>&nbsp;&nbsp;&nbsp; /**<BR>&nbsp;&nbsp;&nbsp;&nbsp; * Given a DataSource, 
create a processor and use that processor<BR>&nbsp;&nbsp;&nbsp;&nbsp; * as a 
player to playback the media.<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
*/<BR>&nbsp;&nbsp;&nbsp; public boolean open(DataSource ds, int captureBufSize, 
int renderBufSize) {</P>
<P>&nbsp;System.err.println("create processor for: " + ds.getContentType());</P>
<P>&nbsp;// Check to see if there's a buffer control on the data 
source.<BR>&nbsp;// It could be that we are using a capture data 
source.<BR>&nbsp;Control c = 
(Control)ds.getControl("javax.media.control.BufferControl");<BR>&nbsp;if (c != 
null)<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
((BufferControl)c).setBufferLength(captureBufSize);</P>
<P>&nbsp;try {<BR>&nbsp;&nbsp;&nbsp;&nbsp; p = 
Manager.createProcessor(ds);<BR>&nbsp;} catch (Exception e) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp; System.err.println("Failed to create a processor 
from the given DataSource: " + e);<BR>&nbsp;&nbsp;&nbsp;&nbsp; return 
false;<BR>&nbsp;}</P>
<P>&nbsp;p.addControllerListener(this);</P>
<P>&nbsp;// Put the Processor into configured 
state.<BR>&nbsp;p.configure();<BR>&nbsp;if (!waitForState(p.Configured)) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp; System.err.println("Failed to configure the 
processor.");<BR>&nbsp;&nbsp;&nbsp;&nbsp; return false;<BR>&nbsp;}</P>
<P>&nbsp;// So I can use it as a 
player.<BR>&nbsp;p.setContentDescriptor(null);</P>
<P>&nbsp;p.realize();<BR>&nbsp;if (!waitForState(p.Realized)) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp; System.err.println("Failed to realize the 
processor.");<BR>&nbsp;&nbsp;&nbsp;&nbsp; return false;<BR>&nbsp;}</P>
<P>&nbsp;// After the processor has been realized, we can now set 
the<BR>&nbsp;// renderer's buffer size.&nbsp; We need to do this before 
the<BR>&nbsp;// processor is prefetched.<BR>&nbsp;// We need to loop the array 
of controls to make sure that we <BR>&nbsp;// are setting the size of the 
correct buffer control since<BR>&nbsp;// the DataSource's controls are also 
included in the list.<BR>&nbsp;Control cs[] = p.getControls();<BR>&nbsp;Object 
owner;</P>
<P>&nbsp;for (int i = 0; i &lt; cs.length; i++) {<BR>&nbsp;&nbsp;&nbsp;&nbsp; if 
(cs[i] instanceof Owned &amp;&amp; cs[i] instanceof BufferControl) 
{<BR>&nbsp;&nbsp;owner = ((Owned)cs[i]).getOwner();<BR>&nbsp;&nbsp;if (owner 
instanceof Renderer) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
((BufferControl)cs[i]).setBufferLength(renderBufSize);<BR>&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
}<BR>&nbsp;}</P>
<P>&nbsp;// Prefetch the processor.<BR>&nbsp;p.prefetch();<BR>&nbsp;if 
(!waitForState(p.Prefetched)) {<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
System.err.println("Failed to prefetch the 
processor.");<BR>&nbsp;&nbsp;&nbsp;&nbsp; return false;<BR>&nbsp;}</P>
<P>&nbsp;// Display the visual &amp; control component if there's one.</P>
<P>&nbsp;setLayout(new BorderLayout());</P>
<P>&nbsp;Component cc;</P>
<P>&nbsp;Component vc;<BR>&nbsp;if ((vc = p.getVisualComponent()) != null) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp; add("Center", vc);<BR>&nbsp;}</P>
<P>&nbsp;if ((cc = p.getControlPanelComponent()) != null) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp; add("South", cc);<BR>&nbsp;}</P>
<P>&nbsp;// Start the processor.<BR>&nbsp;p.start();</P>
<P>&nbsp;setVisible(true);</P>
<P>&nbsp;return true;<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp; public void addNotify() 
{<BR>&nbsp;super.addNotify();<BR>&nbsp;pack();<BR>&nbsp;&nbsp;&nbsp; }</P>
<P>&nbsp;&nbsp;&nbsp; /**<BR>&nbsp;&nbsp;&nbsp;&nbsp; * Block until the 
processor has transitioned to the given state.<BR>&nbsp;&nbsp;&nbsp;&nbsp; * 
Return false if the transition failed.<BR>&nbsp;&nbsp;&nbsp;&nbsp; 
*/<BR>&nbsp;&nbsp;&nbsp; boolean waitForState(int state) {<BR>&nbsp;synchronized 
(waitSync) {<BR>&nbsp;&nbsp;&nbsp;&nbsp; try {<BR>&nbsp;&nbsp;while 
(p.getState() &lt; state &amp;&amp; 
stateTransitionOK)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
waitSync.wait();<BR>&nbsp;&nbsp;&nbsp;&nbsp; } catch (Exception e) 
{}<BR>&nbsp;}<BR>&nbsp;return stateTransitionOK;<BR>&nbsp;&nbsp;&nbsp; }</P>
<P><BR>&nbsp;&nbsp;&nbsp; /**<BR>&nbsp;&nbsp;&nbsp;&nbsp; * Controller 
Listener.<BR>&nbsp;&nbsp;&nbsp;&nbsp; */<BR>&nbsp;&nbsp;&nbsp; public void 
controllerUpdate(ControllerEvent evt) {</P>
<P>&nbsp;if (evt instanceof ConfigureCompleteEvent 
||<BR>&nbsp;&nbsp;&nbsp;&nbsp; evt instanceof RealizeCompleteEvent 
||<BR>&nbsp;&nbsp;&nbsp;&nbsp; evt instanceof PrefetchCompleteEvent) 
{<BR>&nbsp;&nbsp;&nbsp;&nbsp; synchronized (waitSync) 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -