无法访问AudioRecorder [英] Cannot access AudioRecorder

查看:276
本文介绍了无法访问AudioRecorder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把小录音找到服务声音pressure级别而Android不会给我访问硬件。我得到以下错误的logcat的:

I am trying to take small recordings to find the Sound Pressure Level from a service but Android wont give me access to the hardware. I get the following errors in Logcat:

这个错误来自以下code:

The error comes from the following code:

AudioRecord recordInstance = null;

    // We're important...
    android.os.Process
            .setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);

    short bufferSize = 4096;// 2048;


    recordInstance = new AudioRecord(MediaRecorder.AudioSource.MIC, this //line 167
            .getFrequency(), this.getChannelConfiguration(), this
            .getAudioEncoding(), bufferSize); //object not created

    tempBuffer = new short[bufferSize];
    recordInstance.startRecording();

什么情况是,recordInstance永远不会正确创建,所以当它到达终点,并调用recordInstance.startRecording(),recordInstance仍然是空。 Android的拒绝我的程序在定义请求。有谁知道这些错误号的说明什么?我无法在网上找到一个列表。

What happens is that recordInstance is never properly created and so when it gets to the end and calls recordInstance.startRecording(), recordInstance is still null. Android rejects my programs request at the definition. Does anyone know what those errno's indicate? I couldn't find a list online.

AudioRecord文档

感谢

推荐答案

检查三件事情:


  1. 您的权限(你需要给出RECORD_AUDIO许可)

  1. Your permissions (you need to give permission for RECORD_AUDIO)

你有没有运行此一次,不叫recordInstance.release()?如果是这样,你可能已经绑起来音频资源,直到你重新启动手机,将有可能无法正常工作。我发现,在我的经验呢。

Have you run this once and not called recordInstance.release()? If so you may have tied up audio resources and it will likely not work until you restart the phone. I have found that in my experience anyway.

3,缓冲区大小。有一个静态方法AudioRecord.getMinBufferSize()

3.The buffer size. There is a static method AudioRecord.getMinBufferSize()

这篇关于无法访问AudioRecorder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆