JCHATRawAudioDataPlayer.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //
  2. // JCHATRawAudioDataPlayer.h
  3. // OggSpeex
  4. //
  5. // Created by Jiang Chuncheng on 6/25/13.
  6. // Copyright (c) 2013 Sense Force. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <AudioToolbox/AudioToolbox.h>
  10. #import <AudioToolbox/AudioFile.h>
  11. #define QUEUE_BUFFER_SIZE 4 //队列缓冲个数
  12. #define EVERY_READ_LENGTH 1000 //每次从文件读取的长度
  13. #define MIN_SIZE_PER_FRAME 2000 //每侦最小数据长
  14. #define NOTIFICATION_PLAY_OVER @"playingOver"
  15. @interface JCHATRawAudioDataPlayer : NSObject {
  16. AudioStreamBasicDescription audioDescription;///音频参数
  17. AudioQueueRef audioQueue;//音频播放队列
  18. AudioQueueBufferRef audioQueueBuffers[QUEUE_BUFFER_SIZE];//音频缓存
  19. NSLock *synlock ;///同步控制
  20. Byte *pcmDataBuffer;//pcm的读文件数据区
  21. BOOL isDataInputOver;
  22. NSMutableData *mPcmData;
  23. NSUInteger readedBytes;
  24. NSMutableArray *emptyAudioQueueBufferIndexs;
  25. }
  26. @property (nonatomic, assign) BOOL isDataInputOver;
  27. #pragma clang diagnostic push
  28. #pragma clang diagnostic ignored "-Wunused-function"
  29. static void AudioPlayerAQInputCallback(void *input, AudioQueueRef inQ, AudioQueueBufferRef outQB);
  30. #pragma clang diagnostic pop
  31. - (void)startPlay;
  32. - (void)stopPlay;
  33. - (void)inputNewDataFromBuffer:(Byte *)buffer size:(int)bufferSize;
  34. @end