static AuPlaybackWriter_clp AuMod_NewPlaybackWriter_m ( AuMod_cl *self, const Au_Rec *au /* IN */, const Au_FormatDescription *format, /* IN */ int64_t latency, string_t streamname, int32_t *queue_length) { Au_Rec *myau = getaurec(au); if (!checkformat(format, &myau->format)) { fprintf(stderr,"AuMod; formats incompatible!\n"); return NULL; } return AuPlaybackWriter_New(myau, latency, streamname, queue_length); }
static AuPlaybackWriter_clp AuMod_NewAsyncPlaybackWriter_m ( AuMod_cl *self, const Au_Rec *au /* IN */, const Au_FormatDescription *format /* IN */, int64_t minimum_latency /* IN */, uint32_t maximum_length /* IN */, string_t streamname /* IN */ /* RETURNS */, Thread_clp *thread ) { Au_Rec *myau = getaurec(au); if (!checkformat(format, &myau->format)) { fprintf(stderr,"AuMod; formats incompatible!\n"); return NULL; } return Async_AuPlaybackWriter_New(myau, minimum_latency, maximum_length, streamname, thread); }
/** * Initialize an EGL context for the current display. */ static int engine_init_display(struct engine* engine) { // initialize OpenGL ES and EGL static int done = 0; /* * Here specify the attributes of the desired configuration. * Below, we select an EGLConfig with at least 8 bits per color * component compatible with on-screen windows */ #if g_iColorMode == 0 // select 16 bit back buffer for performance const EGLint attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_BUFFER_SIZE, 16, EGL_DEPTH_SIZE, 16, EGL_STENCIL_SIZE, 0, EGL_CONFIG_CAVEAT, EGL_NONE, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE }; #else // select 32 bit back buffer for quality const EGLint attribs[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8, EGL_ALPHA_SIZE, 8, EGL_BUFFER_SIZE, 32, EGL_DEPTH_SIZE, 16, EGL_STENCIL_SIZE, 0, EGL_CONFIG_CAVEAT, EGL_NONE, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, EGL_NONE }; #endif EGLint w, h, dummy, format; EGLint numConfigs; EGLSurface surface; EGLContext context; EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); eglInitialize(display, 0, 0); /* Here, the application chooses the configuration it desires. In this * sample, we have a very simplified selection process, where we pick * the first EGLConfig that matches our criteria */ EGLConfig allConfigs[20]; eglChooseConfig(display, attribs, allConfigs, 20, &numConfigs); config = allConfigs[0]; if ( numConfigs == 0 ) { LOGW( "Failed to find suitable render format" ); exit(0); //return 0; } int i = 0; for ( i = 0; i < numConfigs; i++ ) { if ( i > 19 ) continue; EGLint red; EGLint green; EGLint blue; EGLint alpha; EGLint depth; EGLint stencil; EGLint window; EGLint render; eglGetConfigAttrib( display, allConfigs[i], EGL_RED_SIZE, &red ); eglGetConfigAttrib( display, allConfigs[i], EGL_GREEN_SIZE, &green ); eglGetConfigAttrib( display, allConfigs[i], EGL_BLUE_SIZE, &blue ); eglGetConfigAttrib( display, allConfigs[i], EGL_ALPHA_SIZE, &alpha ); eglGetConfigAttrib( display, allConfigs[i], EGL_DEPTH_SIZE, &depth ); eglGetConfigAttrib( display, allConfigs[i], EGL_STENCIL_SIZE, &stencil ); eglGetConfigAttrib( display, allConfigs[i], EGL_SURFACE_TYPE, &window ); eglGetConfigAttrib( display, allConfigs[i], EGL_NATIVE_VISUAL_ID, &format ); eglGetConfigAttrib( display, allConfigs[i], EGL_RENDERABLE_TYPE, &render ); LOGW( "R: %d, G: %d, B: %d, A: %d, D: %d, W: %d, F: %d, S: %d, R: %d", red, green, blue, alpha, depth, window, format, stencil, render ); } int formatIndex = 0; // check for devices that need special render formats (Wildfire S being one) if ( checkformat( engine->app->activity ) > 0 ) { LOGW( "Adjusting render format for device" ); for ( i = 0; i < numConfigs; i++ ) { if ( i > 19 ) continue; eglGetConfigAttrib( display, allConfigs[i], EGL_NATIVE_VISUAL_ID, &format ); if ( format > 0 ) { config = allConfigs[i]; formatIndex = -1; break; } } } surface = eglCreateWindowSurface(display, config, engine->app->window, NULL); while ( surface == EGL_NO_SURFACE ) { LOGW( "Failed to create EGL surface: %d, trying different format", eglGetError() ); formatIndex++; if ( formatIndex >= numConfigs || formatIndex > 19 ) { LOGW( "Failed to find compatible format" ); return -1; } config = allConfigs[ formatIndex ]; surface = eglCreateWindowSurface(display, config, engine->app->window, NULL); } /* EGL_NATIVE_VISUAL_ID is an attribute of the EGLConfig that is * guaranteed to be accepted by ANativeWindow_setBuffersGeometry(). * As soon as we picked a EGLConfig, we can safely reconfigure the * ANativeWindow buffers to match, using EGL_NATIVE_VISUAL_ID. */ eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format); int result = ANativeWindow_setBuffersGeometry(engine->app->window, 0, 0, format); LOGW( "Result: %d", result ); const EGLint contextAttribList[] = {EGL_CONTEXT_CLIENT_VERSION, 2,EGL_NONE}; context = eglCreateContext(display, config, NULL, contextAttribList); if ( context == EGL_NO_CONTEXT ) { LOGW( "Failed to create EGL context: %d", eglGetError() ); return -1; } if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) { int error = eglGetError(); LOGW("Unable to eglMakeCurrent: %d", eglGetError()); return -1; } eglQuerySurface(display, surface, EGL_WIDTH, &w); eglQuerySurface(display, surface, EGL_HEIGHT, &h); LOGW( "Width: %d Height: %d", w, h ); engine->display = display; engine->context = context; engine->surface = surface; engine->width = w; engine->height = h; engine->state.angle = 0; struct egldata data; data.display = display; data.surface = surface; data.context = context; data.activity = engine->app->activity; if ( done != 0 ) { updateptr( &data ); } else { init( &data ); } //begin(); p_AMotionEvent_getAxisValue = dlsym(RTLD_DEFAULT, "AMotionEvent_getAxisValue"); done = 1; return 0; }