通常网上的mp3音乐的比特率128kps,每秒的信息量大小为128/8=16kb
kNumAQBufs * kAQBufSize == 16x2048 == 32kb.
一次缓冲能能播2秒。如果能在2秒之内缓冲到下个一系列的音频数据,就不会出现要断断续续的情况。如果网络足够快的话肯定不会出现断断续续的情况。
如果不能在2秒之内完成下16个buffer的填充,就出现断断续续的情况。
试想将mp3音乐的比特率改为64kps,每秒的信息量的大小为64/8=8kb,就有4秒的时间来抓取下个16个buffer的数据,如果为32kb的音频数据,信息量在小为32/8=4kb,则有32/4=8秒的时间来了获取下一个16个buffer的数据(16*2048/1024=32K)。
如果网速是2M( 2000000/8/1024= 224kb)每秒,如果的移动终端的话,下载速度可能只是几十kb, 因为128kps的mp3在网速不好的情况的肯定是断断续续的。
NSURL *url = [NSURLURLWithString:@"http://domain/test.mp3"];
streamer = [[AudioStreameralloc] initWithURL:url];
128kps,位速,也叫比特率。44.1KHz,采样率。这是mp3使用最多压缩率。
而有关Audio Buffer的设置如下:
#define kNumAQBufs16// Number of audio queue buffers we allocate.
// Needs to be big enough to keep audio pipeline
// busy (non-zero number of queued buffers) but
// not so big that audio takes too long to begin
// (kNumAQBufs * kAQBufSize of data must be
// loaded before playback will start).
//
// Set LOG_QUEUED_BUFFERS to 1 to log how many
// buffers are queued at any time -- if it drops
// to zero too often, this value may need to
// increase. Min 3, typical 8-24.
#define kAQDefaultBufSize 2048// Number of bytes in each audio queue buffer
// Needs to be big enough to hold a packet of
// audio from the audio file. If number is too
// large, queuing of audio before playback starts
// will take too long.
// Highly compressed files can use smaller
// numbers (512 or less). 2048 should hold all
// but the largest packets. A buffer size error
// will occur if this number is too small.
#define kAQMaxPacketDescs 512// Number of packet descriptions in our array