音频数据流在iPhone中具有延迟问题

时间:2010-07-22 08:31:55

标签: iphone audio-streaming

我使用AudioQue在iPhone上编写了一个语音流应用程序。在音频录制开始时,我启动了网络连接并将NSAudioOutStream的实例传递给 AudioInputCallback使用inUserData引用。

void AudioInputCallback(
  void *inUserData, 
  AudioQueueRef inAQ, 
  AudioQueueBufferRef inBuffer, 
  const AudioTimeStamp *inStartTime, 
  UInt32 inNumberPacketDescriptions, 
  const AudioStreamPacketDescription *inPacketDescs) {
      RecordState* recordState = (RecordState*)inUserData;
      if(!recordState->recording) {
         NSLog(@"Record ending...");
      }
      else{
        [recordState->soStream write:inBuffer->mAudioData maxLength:inBuffer->mAudioDataByteSize];
        NSLog([NSString stringWithFormat:@"Count:%d Size:%d¥n", sentCnt++, inBuffer->mAudioDataByteSize]); 
      } 
      recordState->currentPacket += inNumberPacketDescriptions;
      AudioQueueEnqueueBuffer(recordState->queue, inBuffer, 0, NULL); 
  }

根据AudioQueue的init参数,inBuffer的长度为16000字节。但是,在WIFi应用程序中的工作毫无疑问。但在3G网络中,客户端 - 服务器的换向并不稳定。 任何人都有相同的经验或有人可以建议解决这个问题。

1 个答案:

答案 0 :(得分:0)