"无法获取记录源1 QUOT音频输入;尝试初始化AudioRecord时 [英] "Could not get audio input for record source 1" when trying to initialize AudioRecord

查看:290
本文介绍了"无法获取记录源1 QUOT音频输入;尝试初始化AudioRecord时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断尝试初始化和AudioRecord对象时收到此错误,企图通过记录使用Eclipse模拟器的声音。

I keep getting this error when trying to initialize and AudioRecord object, in an attempt to record sounds using the emulator using Eclipse.

我曾尝试与不同比特采样率,8000是唯一一个是有效的,但错误继续出现。我曾尝试上的SDK,1.5,1.6,2,2.2和2.3.1的不同版本。 (和与AVD组合)。

I have tried with various bit sampling rates, 8000 is the only one that is valid, but the error continues to appear. I have tried on various versions of the sdk, 1.5, 1.6, 2, 2.2 and 2.3.1. (and combinations of with the AVD).

下面是code:

       Log.v(TAG, "About to initialize recording");
   //int[] samplingRates = {44100, 22050, 16000, 11025, 8000};
   int[] samplingRates = {8000};

    for (int i = 0; i < samplingRates.length; ++i)
    {
        try
        {
            Log.d(TAG,"Trying sampling rate: " + samplingRates[i]);
            int min = AudioRecord.getMinBufferSize(samplingRates[i], 
                    AudioFormat.CHANNEL_CONFIGURATION_MONO,
                    //AudioFormat.CHANNEL_IN_MONO,
                    AudioFormat.ENCODING_PCM_16BIT);
            Log.d(TAG,"MinBufferSize: " + min);

            AudioRecord record = new AudioRecord(MediaRecorder.AudioSource.MIC, samplingRates[i],
                    AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, min);
            if (record.getState() == AudioRecord.STATE_INITIALIZED)
            {
                Log.d("Recorder", "Audio recorder initialised at " + record.getSampleRate());
                return record;
            }
            record.release();
            record = null;
        }
        catch (IllegalArgumentException e)
        {
            // Try the next one.
            Log.d(TAG,"Initialization failed");
        }
    }
    // None worked.
    return null;

在实例化,AudioRecord纪录=新等。

The error occurs on instantiation, AudioRecord record = new etc.

已经看到了同样的问题人来说,这似乎是一个简单的请求,以便i'm惊讶,如果这一个bug,尤其是我不能把它与不同版本的工作。

Has anyone seen this same problem, it seems to be a straight forward request so i´m suprised if this a bug, particular as I can´t get it working with different versions.

我已创建了录音功能的自动真空淀积系统。还有什么我需要配置?

I have created the AVDs with Audio Record capabilities. Is there anything else I have to configure?

我看到一对夫妇对同一问题的其他职位,但没有回复。

I have seen a couple of other posts on the same issue, but no replies.

在此先感谢

克里斯

推荐答案

您的问题这里大概实际双重的。首先,你必须得到所有的参数正好适合AudioRecord,也就是说,我可以看到你尝试了所有不同的采样率和信道配置,但是你尝试不同的位深?如果你没有得到这一切刚刚好,这是行不通的。此外,它会出现一些Android设备似乎报告错误minBufferSize。

You problem here is probably actually twofold. First, you have to get all of the parameters just right for the AudioRecord, ie, I can see that you tried all the various sampling rates and channel configurations, but did you try different bit depths? If you don't get it all just right, it doesn't work. Furthermore, it would appear that some android devices seem to report the wrong minBufferSize.

但是,我认为您所遇到的实际问题是,自动真空淀积系统无法记录音频/视频(尽管如果配置它,以便他们可能不会抱怨):
http://developer.android.com/guide/topics/media/index.html

But, I think the actual problem you are experiencing is that the AVDs cannot record Audio/Video (even though they may not complain if you configure it so): http://developer.android.com/guide/topics/media/index.html

这三段:

请注意,该仿真器不具有硬件捕捉音频或视频,但实际的移动设备有可能提供这些功能,通过MediaRecorder类访问。

Note that the emulator doesn't have hardware to capture audio or video, but actual mobile devices are likely to provide these capabilities, accessible through the MediaRecorder class.

这篇关于&QUOT;无法获取记录源1 QUOT音频输入;尝试初始化AudioRecord时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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