2013-09-30 2 views
1

J'ai écrit une application de l'enregistreur de base en utilisant l'Android NDK et OpenSL ES. Il compile et se lie bien, mais lorsque je tente de l'exécuter sur un appareil Nexus Galaxy je reçois l'erreur suivante:Demande SL_IID_ANDROIDSIMPLEBUFFERQUEUE d'interface sur objet retourne enregistreur OpenSL ES SL_RESULT_FEATURE_UNSUPPORTED

W/libOpenSLES(10708): Leaving Object::GetInterface (SL_RESULT_FEATURE_UNSUPPORTED)

Cela se produit sur la ligne:

res = (*recorderObj)->GetInterface(recorderObj, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &recorderBufferQueueItf);

Est-ce signifie que l'enregistrement en utilisant OpenSL ES sur un appareil Galaxy Nexus n'est pas supporté, ou ai-je simplement fait une erreur? Ci-dessous le code correspondant:

static SLObjectItf recorderObj; 
    static SLEngineItf EngineItf; 
    static SLRecordItf recordItf; 
    static SLAndroidSimpleBufferQueueItf recorderBufferQueueItf; 
    static SLDataSink recDest; 
    static SLDataLocator_AndroidSimpleBufferQueue recBuffQueue; 
    static SLDataFormat_PCM pcm; 

    /* Setup the data source structure */ 
    locator_mic.locatorType = SL_DATALOCATOR_IODEVICE; 
    locator_mic.deviceType = SL_IODEVICE_AUDIOINPUT; 
    locator_mic.deviceID = SL_DEFAULTDEVICEID_AUDIOINPUT; 
    locator_mic.device = NULL; 
    audioSource.pLocator = (void *) &locator_mic; 
    audioSource.pFormat = NULL; 

    /* Setup the data sink structure */ 
    recBuffQueue.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE; 
    recBuffQueue.numBuffers = NB_BUFFERS_IN_QUEUE; 

    /* set up the format of the data in the buffer queue */ 
    pcm.formatType = SL_DATAFORMAT_PCM; 
    pcm.numChannels = 1; 
    pcm.samplesPerSec = SL_SAMPLINGRATE_44_1; 
    pcm.bitsPerSample = SL_PCMSAMPLEFORMAT_FIXED_16; 
    pcm.containerSize = SL_PCMSAMPLEFORMAT_FIXED_16; 
    pcm.channelMask = SL_SPEAKER_FRONT_CENTER; 
    pcm.endianness = SL_BYTEORDER_LITTLEENDIAN; 

    recDest.pLocator = (void *) &recBuffQueue; 
    recDest.pFormat = (void *) &pcm; 

    /* Create audio recorder */ 
    res = (*EngineItf)->CreateAudioRecorder(EngineItf, &recorderObj, &audioSource, &recDest, 0, iidArray, required); 
    CheckErr(res); 

    /* Realizing the recorder in synchronous mode. */ 
    res = (*recorderObj)->Realize(recorderObj, SL_BOOLEAN_FALSE); 
    CheckErr(res); 

    /* Get the RECORD interface - it is an implicit interface */ 
    LOGI("GetInterface: Recorder"); 
    res = (*recorderObj)->GetInterface(recorderObj, SL_IID_RECORD, &recordItf); 
    CheckErr(res); 

    /* Get the buffer queue interface which was explicitly requested */ 
    LOGI("GetInterface: Buffer Queue"); 
    res = (*recorderObj)->GetInterface(recorderObj, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &recorderBufferQueueItf); 
    CheckErr(res); 

Toute aide à cette question serait la bienvenue :)

+0

pouvez-vous s'il vous plaît fournir des documents appropriés pour les méthodes GetInterface. plzz –

Répondre

2

Lorsque vous créez l'enregistreur audio, vous spécifiez « 0 » comme le troisième avant-dernier argument, est le nombre d'interfaces non implicites à supporter. La file d'attente de tampon n'est pas une interface implicite pour un enregistreur.

Essayez de changer

res = (*EngineItf)->CreateAudioRecorder(EngineItf, &recorderObj, &audioSource, &recDest, 0, iidArray, required); 

à

res = (*EngineItf)->CreateAudioRecorder(EngineItf, &recorderObj, &audioSource, &recDest, 1, iidArray, required); 
+0

Merci, c'était tout le problème apparemment :) J'ai initialement copié cette ligne de l'échantillon d'enregistrement de la documentation OpenSL ES 1.0.1. Cela fonctionne finalement après ce changement mineur. Craie celui-ci jusqu'à apprendre encore OpenSL. – MayaPosch

+0

@HerrLip pouvez-vous s'il vous plaît fournir des documents appropriés pour les méthodes getInterface. plzz –

+0

Vérifiez la spécification et ces liens: http://www.khronos.org/registry/sles/specs/OpenSL_ES_Specification_1.0.1.pdf http://mobilepearls.com/labs/native-android-api/ndk/docs /opensles/index.html http://audioprograming.wordpress.com/ – HerrLip

Questions connexes