Ignore:
Timestamp:
Oct 4, 2019 4:26:39 AM (5 years ago)
Author:
nanang
Message:

Fixed #2239:

  • Deinit OpenGL immediately when initialization fails, so video device start() and put_frame() will return immediately.
  • Introduced new media event PJMEDIA_EVENT_VID_DEV_ERROR, used for notifying app when video device reinit (due to format change) fails.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-videodev/android_opengl.c

    r5028 r6085  
    115115static pj_status_t andgl_stream_destroy(pjmedia_vid_dev_stream *strm); 
    116116 
     117static pj_status_t init_opengl(void * data); 
     118static pj_status_t deinit_opengl(void * data); 
     119 
    117120/* Job queue prototypes */ 
    118121static pj_status_t job_queue_create(pj_pool_t *pool, job_queue **pjq); 
     
    155158    { \ 
    156159        PJ_LOG(3, (THIS_FILE, "Unable to %s %d", str, eglGetError())); \ 
    157         return PJMEDIA_EVID_SYSERR; \ 
     160        status = PJMEDIA_EVID_SYSERR; \ 
     161        goto on_return; \ 
    158162    } 
    159163 
     
    173177    EGLint width; 
    174178    EGLint height; 
     179    pj_status_t status; 
    175180     
    176181    strm->display = eglGetDisplay(EGL_DEFAULT_DISPLAY); 
     
    220225     
    221226    /* Init GL buffers */ 
    222     return pjmedia_vid_dev_opengl_init_buffers(strm->gl_buf); 
    223 } 
     227    status = pjmedia_vid_dev_opengl_init_buffers(strm->gl_buf); 
     228     
     229on_return: 
     230    if (status != PJ_SUCCESS) 
     231        deinit_opengl(strm); 
     232 
     233    return status; 
     234} 
     235 
     236#undef EGL_ERR 
    224237 
    225238static pj_status_t render(void * data) 
     
    387400        pjmedia_format *fmt = (pjmedia_format *)pval; 
    388401        andgl_fmt_info *ifi; 
     402        pj_status_t status = PJ_SUCCESS; 
    389403         
    390404        if (!(ifi = get_andgl_format_info(fmt->id))) 
     
    407421         
    408422        if (strm->window) 
    409             job_queue_post_job(strm->jq, init_opengl, strm, 0, NULL); 
     423            job_queue_post_job(strm->jq, init_opengl, strm, 0, &status); 
    410424             
    411         PJ_LOG(4, (THIS_FILE, "Re-initializing OpenGL due to format change")); 
    412          
    413         return PJ_SUCCESS; 
     425        PJ_PERROR(4,(THIS_FILE, status, 
     426                     "Re-initializing OpenGL due to format change")); 
     427        return status; 
     428         
    414429    } else if (cap == PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW) { 
    415430        pj_status_t status = PJ_SUCCESS; 
     
    430445        } 
    431446 
    432         PJ_LOG(4, (THIS_FILE, "Re-initializing OpenGL with native window" 
    433                               " %p: %s", strm->window, 
    434                               (status == PJ_SUCCESS? "success": "failed"))); 
    435          
     447        PJ_PERROR(4,(THIS_FILE, status, 
     448                     "Re-initializing OpenGL with native window %p", 
     449                     strm->window)); 
    436450        return status; 
    437451    } 
Note: See TracChangeset for help on using the changeset viewer.