简体   繁体   English

使用AudioFileStreamParseBytes通过读取文件来解析字节不会调用kAudioFileStreamProperty_ReadyToProducePackets

[英]Using AudioFileStreamParseBytes to parse bytes by reading from a file does not call kAudioFileStreamProperty_ReadyToProducePackets

I am trying to parse bytes by opening a audio file (M4A), reading 2048 bytes in a loop and passing it to AudioFileStreamParseBytes. 我试图通过打开音频文件(M4A),在循环中读取2048个字节并将其传递给AudioFileStreamParseBytes来解析字节。 This does not call the callback with the property kAudioFileStreamProperty_ReadyToProducePackets . 这不会使用属性kAudioFileStreamProperty_ReadyToProducePackets调用回调。 But the property kAudioFileStreamProperty_FileFormat is being successfully called. 但是属性kAudioFileStreamProperty_FileFormat被成功调用。 (So I know the callback mechanism is working.) (所以我知道回调机制正在起作用。)

Questions : 问题

  1. Can I use AudioFileStreamParseBytes to parse audio data by reading from a local file ? 我可以使用AudioFileStreamParseBytes通过读取本地文件来解析音频数据吗? Most examples show how to use AudioFileStreamParseBytes by parsing HTTP stream data, but not reading from a local file. 大多数示例显示了如何通过解析HTTP流数据来使用AudioFileStreamParseBytes ,而不是从本地文件读取数据。
  2. Has anyone tried to do the above and has been successful processing audio files ? 有没有人尝试执行上述操作并成功处理了音频文件?

NOTE : The reason I am not using AudioFileOpenWithCallbacks to open the m4a file is that the api call is failing to open the following file after downloading it locally ( http://www.arsenal-music.com/podcast/arsenal-podcast-05.m4a ). 注意 :我不使用AudioFileOpenWithCallbacks打开m4a文件的原因是api调用在本地下载以下文件后无法打开以下文件( http://www.arsenal-music.com/podcast/arsenal-podcast-05 .m4a )。 This m4a file has images embedded in it and AudioFileOpenWithCallbacks is not able to parse the file. 此m4a文件中嵌入了图像, AudioFileOpenWithCallbacks无法解析该文件。 At the same time I have used Matt Gallagher AudioStreamer code that opens this file, parses it and plays it fine. 同时,我使用了Matt Gallagher AudioStreamer代码打开该文件,对其进行解析并可以正常播放。 So I am leaning towards using AudioFileStreamerParseBytes by reading data from a local file. 因此,我倾向于通过从本地文件读取数据来使用AudioFileStreamerParseBytes (As far as I understand there should be no difference whether the data is coming from HTTP stream or a local file. But I could be wrong.) (据我了解,数据是来自HTTP流还是来自本地文件,应该没有区别。但是我可能是错的。)

I do not see any errors in the any API calls (just in case someone asks me this question). 我看不到任何API调用中的任何错误(以防万一有人问我这个问题)。 I can paste the code if needed, but all I want to know is if the approach of reading from file and passing it to AudioFileStreamParseBytes will work or not ? 我可以根据需要粘贴代码,但我想知道的是从文件读取并将其传递给AudioFileStreamParseBytes是否可行?

After some testing I found that one can use AudioFileStreamParseBytes to parse bytes that are read from a local file. 经过一些测试,我发现可以使用AudioFileStreamParseBytes解析从本地文件读取的字节。 Data need not come from a Http stream. 数据不必来自Http流。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM