音频流服务无法识别文件类型

音频流服务无法识别文件类型

本文介绍了音频流服务无法识别文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用音频流服务库(基于Matt Ghallager的)我在这部分继续崩溃:

I was working on streaming audio live using the Audio Streaming Services library (based on Matt Ghallager's tutorial) and I kept on crashing at this part:

err = AudioQueueStart(audioQueue, NULL);
if (err)
{
    [self failWithErrorCode:AS_AUDIO_QUEUE_START_FAILED];
    return;
}

错误代码为: ..这个人在CoreAudio / AudioHardware.h中定义,似乎是一个硬件相关问题。我在网上找不到有关此错误的有用信息。

the error code is: kAudioDeviceUnsupportedFormatError.. this guy is defined in CoreAudio/AudioHardware.h, which seems to be a hardware related problem. I couldn't find much useful information about this error on the web.

有趣的是,早些时候我在尝试这个时遇到了类似的问题:

The interesting part is that earlier on I faced a similar problem while attempting this:

// create the audio
err = AudioQueueNewOutput(&asbd, MyAudioQueueOutputCallback, self, NULL, NULL, 0, &
    if (err)
{
    [self failWithErrorCode:AS_AUDIO_QUEUE_CREATION_FAILED];
    return;
}

( 帖子面临同样的问题,但该帖子的作者错误地将其错误代码归因于 AudioQueueStart 而不是 AudioQueueNewOutput

(the same problem faced in this post, but the author of the post mistakenly attributed their error code to AudioQueueStart rather than AudioQueueNewOutput)

我收到此错误代码: ..我的补救措施是手动添加此代码:

I got this error code: kAudioFormatUnsupportedDataFormatError.. and my remedy was manually adding this code:

asbd.mFormatID = kAudioFormatMPEGLayer3;

因为我发现调用

AudioFileStreamGetProperty(inAudioFileStream, kAudioFileStreamProperty_DataFormat, &asbdSize, &asbd);

最初给了我作为mFormatID而不是,这是我正在播放的音频文件.mp3是。

initially gave me kAudioFormatMPEGLayer1 as the mFormatID rather than kAudioFormatMPEGLayer3, which is .mp3 which is what the audio file i'm playing actually is.

最后..可能是我第一次发现错误的地方是我最初调用此函数时:

Finally.. probably the first time I noticed something was wrong was when I initially called this function:

AudioFileStreamOpen((__bridge void*)streamer, ASPropertyListenerProc, ASPacketsProc,
                                        0, &(streamer->audioFileStream));

我第一次没有向导致了

AudioFileStreamParseBytes(streamer->audioFileStream, inDataByteSize, inData, 0);

调用无法解析字节..(具体来说......我得到了 Parse字节失败。错误:典型?1954115647 错误消息,这是kAudioFileUnsupportedFileTypeError)..

call to fail to parse the bytes.. (specifically.. I got the Parse bytes failed. err: typ? 1954115647 error message, which is kAudioFileUnsupportedFileTypeError)..

我绕过的方式是(你猜对了)手动添加文件类型提示:

the way I got around that was by (you guessed it) manually adding the file type hint:

    streamer->err = AudioFileStreamOpen((__bridge void*)streamer, ASPropertyListenerProc, ASPacketsProc,
                                        kAudioFileMP3Type, &(streamer->audioFileStream));

所以你可以看到..我在地毯下推的一个问题终于要来咬了我...但我不确定为什么解析器无法手动识别我的音频文件类型..为什么我必须继续硬编码该值...只是让它在最后失败。

so you can see.. a problem i've pushed under the rug is finally coming around to bite me.. but i'm not sure why the parser is failing to recognize my audio file type manually.. and why I have to keep on hardcoding that value.. only to have it fail at the end.

推荐答案

事实证明,我的数据包没有以正确的顺序出现(也没有完成)...我想通过使用的方式是一个十六进制程序(hexFiend)打开有问题的mp3文件,然后我将密钥包与实际发送的内容进行比较..我修复了这个差异,之后一切正常。

As it turns out, my packets were not coming in the right order (nor where they complete).. the way I figured that out was by using a hex program (hexFiend) to open the mp3 file in question, then I compared key packets with what was actually being sent over.. I fixed that discrepancy and everything worked fine after that.

这篇关于音频流服务无法识别文件类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 01:41