Sound capture in android-x86

634 views
Skip to first unread message

Shady

unread,
Dec 17, 2011, 12:21:49 PM12/17/11
to andro...@googlegroups.com
Recently tried the honeycomb-x86 and I'm loving it. Almost everything is working. One thing that i couldn't get working is sound capture. I've tried every version of android except ICS.

I would like to know if it's related to my netbook only or is this a common problem. Can anybody record audio using android-x86?

Looking for some feedback.
Thanks in advance.

PatMan

unread,
Dec 17, 2011, 4:20:18 PM12/17/11
to andro...@googlegroups.com
Got the same thing here, eee 900 on 3.2 - "Audio Problem" every time I try to do a voice search...

Also, camera works - kinda. Takes pics, but the screen is black (can't see the preview) - checking that out now...

Shady Rasheed

unread,
Dec 18, 2011, 8:03:15 AM12/18/11
to andro...@googlegroups.com
I tested recording from the command line and it works just fine. I tried alsa_aplay -C -t wav -d 10 /sdcard/test.wav and played it back just fine
I event tried S16_LE format and rate of 16000 and 44100 it also records and plays fine.

For some reason it cannot record from within the android framework... it gives following in logcat

(#Intent;action=android.speech.action.WEB_SEARCH;launchFlags=0x10000000;component=com.google.android.voicesearch/.RecognitionActivity;B.fullRecognitionResultsRequest=true;l.android.speech.extras.SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS=750;B.useLocation=true;B.contact_auth=true;l.android.speech.extras.SPEECH_INPUT_POSSIBLY_COMPLETE_SILENCE_LENGTH_MILLIS=-1;end)
I/RecognitionControllerImpl( 2258): State change: STARTING -> STARTING
W/AudioHardwareInterface( 1488): getInputBufferSize bad sampling rate: 16000
E/AudioRecord( 2258): Unsupported configuration: sampleRate 16000, format 1, channelCount 1
D/ALSAModule( 1488): open called for devices 00040000 in mode 0...
E/ALSAModule( 1488): Unable to set buffer size to 2048:  Invalid argument
I/ALSAModule( 1488): Initialized ALSA CAPTURE device default
D/ALSAModule( 1488): open called for devices 00040000 in mode 0...
E/ALSAModule( 1488): Unable to set buffer size to 2048:  Invalid argument
I/ALSAModule( 1488): Initialized ALSA CAPTURE device default
E/AudioRecord( 2258): Could not get audio input for record source 6
E/AudioRecord-JNI( 2258): Error creating AudioRecord instance: initialization check failed.
E/AudioRecord-Java( 2258): [ android.media.AudioRecord ] Error code -20 when initializing native AudioRecord object.
E/RecognitionControllerImpl( 2258): Audio error
E/RecognitionControllerImpl( 2258): java.io.IOException: not open
E/RecognitionControllerImpl( 2258): at com.google.android.voicesearch.endpointer.MicrophoneInputStream.<init>(MicrophoneInputStream.java:65)
E/RecognitionControllerImpl( 2258): at com.google.android.voicesearch.speechservice.MicrophoneManagerImpl.getMicInputStream(MicrophoneManagerImpl.java:108)
E/RecognitionControllerImpl( 2258): at com.google.android.voicesearch.speechservice.MicrophoneManagerImpl.setupMicrophone(MicrophoneManagerImpl.java:96)
E/RecognitionControllerImpl( 2258): at com.google.android.voicesearch.speechservice.RecognitionControllerImpl.startRecognition(RecognitionControllerImpl.java:362)
E/RecognitionControllerImpl( 2258): at com.google.android.voicesearch.speechservice.RecognitionControllerImpl.access$100(RecognitionControllerImpl.java:82)
E/RecognitionControllerImpl( 2258): at com.google.android.voicesearch.speechservice.RecognitionControllerImpl$1.handleMessage(RecognitionControllerImpl.java:251)
E/RecognitionControllerImpl( 2258): at android.os.Handler.dispatchMessage(Handler.java:99)
E/RecognitionControllerImpl( 2258): at android.os.Looper.loop(Looper.java:132)
E/RecognitionControllerImpl( 2258): at android.os.HandlerThread.run(HandlerThread.java:60)
E/RecognitionControllerImpl( 2258): ERROR_AUDIO
I/AudioService( 1513):  AudioFocus  abandonAudioFocus() from android.media.AudioManager@9e595900
W/InputManagerService( 1513): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@9e705780 (uid=10035 pid=1594)

Any input is highly appreciated 
Regards,

 
On Sun, Dec 18, 2011 at 1:20 AM, PatMan <onlyp...@gmail.com> wrote:
Got the same thing here, eee 900 on 3.2 - "Audio Problem" every time I try to do a voice search...

Also, camera works - kinda. Takes pics, but the screen is black (can't see the preview) - checking that out now...

--
You received this message because you are subscribed to the Google Groups "Android-x86" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-x86/-/zN_fHJtLOlsJ.

To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-x86...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-x86?hl=en.

Chih-Wei Huang

unread,
Dec 18, 2011, 10:44:26 AM12/18/11
to andro...@googlegroups.com
Have you tested AudioRecorder.apk?
It works just fine in my device.

2011/12/18 Shady Rasheed <rashee...@gmail.com>:

Shady Rasheed

unread,
Dec 19, 2011, 12:46:52 AM12/19/11
to andro...@googlegroups.com
Yes I have tried it. Along with other applications, it appears to be a problem with Android / alsa.

In hardware/alsa_sound/alsa_default.cpp

static alsa_handle_t _defaultsIn = {
    module      : 0,
    devices     : AudioSystem::DEVICE_IN_ALL,
    curDev      : 0,
    curMode     : 0,
    handle      : 0,
    format      : SND_PCM_FORMAT_S16_LE, // AudioSystem::PCM_16_BIT
    channels    : 1,
    sampleRate  : AudioRecord::DEFAULT_SAMPLE_RATE,
    latency     : 250000, // Desired Delay in usec
    bufferSize  : 2048, // Desired Number of samples
    modPrivate  : 0,
};

Changing the buffersize from 2048 to 320 or 640 and managed to record using speech recorder in 8000 Hz, but not in 11000 Hz. After making this change, AudioRecorder.apk works.

Even with this change voice search doesn't work.
 

--
You received this message because you are subscribed to the Google Groups "Android-x86" group.

Shady Rasheed

unread,
Dec 19, 2011, 1:20:36 AM12/19/11
to andro...@googlegroups.com
I believe the following in frameworks/base/services/audioflinger/AudioHardwareInterface.cpp is causing the apps not to record in anything other than 8000Hz
 
// default implementation
size_t AudioHardwareBase::getInputBufferSize(uint32_t sampleRate, int format, int channelCount)
{
    if (sampleRate != 8000) {
        LOGW("getInputBufferSize bad sampling rate: %d", sampleRate);
        return 0;
    }
    if (format != AudioSystem::PCM_16_BIT) {
        LOGW("getInputBufferSize bad format: %d", format);
        return 0;
    }
    if (channelCount != 1) {
        LOGW("getInputBufferSize bad channel count: %d", channelCount);
        return 0;
    }
    return 320;
}

Commenting out the return 0 statements allowed the speechrecorder to use 11Khz
Unfortunately, since this is obviously the wrong way to fix things, it caused voice search application to force close at startup, while before it used to report an audio problem.



in the same file the following caught my attention:

AudioHardwareInterface* AudioHardwareInterface::create()
{
    /*
     * FIXME: This code needs to instantiate the correct audio device
     * interface. For now - we use compile-time switches.
     */
    AudioHardwareInterface* hw = 0;
    char value[PROPERTY_VALUE_MAX];
#ifdef GENERIC_AUDIO
    hw = new AudioHardwareGeneric();
#else
    // if running in emulation - use the emulator driver
    if (property_get("ro.kernel.qemu", value, 0)) {
        LOGD("Running in emulation - using generic audio driver");
        hw = new AudioHardwareGeneric();
    }
    else {
        LOGV("Creating Vendor Specific AudioHardware");
        hw = createAudioHardware();
    }
#endif
    if (hw->initCheck() != NO_ERROR) {
        LOGW("Using stubbed audio hardware. No sound will be produced.");
        delete hw;
        hw = new AudioHardwareStub();
    }
    
#ifdef WITH_A2DP
    hw = new A2dpAudioInterface(hw);
#endif
#ifdef ENABLE_AUDIO_DUMP
    // This code adds a record of buffers in a file to write calls made by AudioFlinger.
    // It replaces the current AudioHardwareInterface object by an intermediate one which
    // will record buffers in a file (after sending them to hardware) for testing purpose.
    // This feature is enabled by defining symbol ENABLE_AUDIO_DUMP.
    // The output file is set with setParameters("test_cmd_file_name=<name>"). Pause are not recorded in the file.
    LOGV("opening PCM dump interface");
    hw = new AudioDumpInterface(hw);    // replace interface
#endif
    return hw;
}

Is it possible that the system is not detecting the capabilities of my device and simply using generic mode, same as in Emulator. I read on another android (non x86) forum some users complaining that on the emulator they can only run 8Khz sampling rate for recording, while on the actual device there is no problem.

Anybody has insight about this?

Chih-Wei Huang

unread,
Dec 19, 2011, 2:33:39 AM12/19/11
to andro...@googlegroups.com
2011/12/19 Shady Rasheed <rashee...@gmail.com>:

> Yes I have tried it. Along with other applications, it appears to be a
> problem with Android / alsa.
>
> In hardware/alsa_sound/alsa_default.cpp
>
>> static alsa_handle_t _defaultsIn = {
>>     module      : 0,
>>     devices     : AudioSystem::DEVICE_IN_ALL,
>>     curDev      : 0,
>>     curMode     : 0,
>>     handle      : 0,
>>     format      : SND_PCM_FORMAT_S16_LE, // AudioSystem::PCM_16_BIT
>>     channels    : 1,
>>     sampleRate  : AudioRecord::DEFAULT_SAMPLE_RATE,
>>     latency     : 250000, // Desired Delay in usec
>>     bufferSize  : 2048, // Desired Number of samples
>>     modPrivate  : 0,
>> };
>
>
> Changing the buffersize from 2048 to 320 or 640 and managed to record using
> speech recorder in 8000 Hz, but not in 11000 Hz. After making this change,
> AudioRecorder.apk works.
>
> Even with this change voice search doesn't work.

I think it's impossible to enable voice search in android-x86.
That GMS app requires a native library libvoicesearch.so
which doesn't exist in x86 platform.


--
Chih-Wei
Android-x86 project
http://www.android-x86.org

Reply all
Reply to author
Forward
0 new messages