- SLEngineItf engineEngine;
-
- /* Allocate structure */
- p_aout->sys = calloc( 1, sizeof( aout_sys_t ) );
- if( unlikely( p_aout->sys == NULL ) )
- return VLC_ENOMEM;
-
- aout_sys_t *p_sys = p_aout->sys;
-
- //Acquiring LibOpenSLES symbols :
- p_sys->p_so_handle = dlopen( "libOpenSLES.so", RTLD_NOW );
- if( p_sys->p_so_handle == NULL )
- {
- msg_Err( p_aout, "Failed to load libOpenSLES" );
- goto error;
- }
-
- typedef SLresult (*slCreateEngine_t)(
- SLObjectItf*, SLuint32, const SLEngineOption*, SLuint32,
- const SLInterfaceID*, const SLboolean* );
- slCreateEngine_t slCreateEnginePtr = NULL;
-
- SLInterfaceID *SL_IID_ENGINE;
- SLInterfaceID *SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
- SLInterfaceID *SL_IID_VOLUME;
- SLInterfaceID *SL_IID_PLAY;
-
-#define OPENSL_DLSYM( dest, handle, name ) \
- dest = dlsym( handle, name ); \
- if( dest == NULL ) \
- { \
- msg_Err( p_aout, "Failed to load symbol %s", name ); \
- goto error; \
- }
-
- OPENSL_DLSYM( slCreateEnginePtr, p_sys->p_so_handle, "slCreateEngine" );
- OPENSL_DLSYM( SL_IID_ANDROIDSIMPLEBUFFERQUEUE, p_sys->p_so_handle,
- "SL_IID_ANDROIDSIMPLEBUFFERQUEUE" );
- OPENSL_DLSYM( SL_IID_ENGINE, p_sys->p_so_handle, "SL_IID_ENGINE" );
- OPENSL_DLSYM( SL_IID_PLAY, p_sys->p_so_handle, "SL_IID_PLAY" );
- OPENSL_DLSYM( SL_IID_VOLUME, p_sys->p_so_handle, "SL_IID_VOLUME" );
-
-
-#define CHECK_OPENSL_ERROR( msg ) \
- if( unlikely( result != SL_RESULT_SUCCESS ) ) \
- { \
- msg_Err( p_aout, msg" (%lu)", result ); \
- goto error; \
- }
-
- // create engine
- result = slCreateEnginePtr( &p_sys->engineObject, 0, NULL, 0, NULL, NULL );
- CHECK_OPENSL_ERROR( "Failed to create engine" );
-
- // realize the engine in synchronous mode
- result = Realize( p_sys->engineObject, SL_BOOLEAN_FALSE );
- CHECK_OPENSL_ERROR( "Failed to realize engine" );
-
- // get the engine interface, needed to create other objects
- result = GetInterface( p_sys->engineObject, *SL_IID_ENGINE, &engineEngine );
- CHECK_OPENSL_ERROR( "Failed to get the engine interface" );
-
- // create output mix, with environmental reverb specified as a non-required interface
- const SLInterfaceID ids1[] = { *SL_IID_VOLUME };
- const SLboolean req1[] = { SL_BOOLEAN_FALSE };
- result = CreateOutputMix( engineEngine, &p_sys->outputMixObject, 1, ids1, req1 );
- CHECK_OPENSL_ERROR( "Failed to create output mix" );
-
- // realize the output mix in synchronous mode
- result = Realize( p_sys->outputMixObject, SL_BOOLEAN_FALSE );
- CHECK_OPENSL_ERROR( "Failed to realize output mix" );