- Timestamp:
- Mar 30, 2012 6:46:19 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia-videodev/sdl_dev.c
r3950 r3997 534 534 #endif 535 535 pj_thread_join(sf->sdl_thread); 536 pj_thread_destroy(sf->sdl_thread); 536 537 } 537 538 … … 1243 1244 if (jq->is_full && ((jq->head + 1) % jq->size == jq->tail)) { 1244 1245 unsigned i, head; 1246 pj_status_t status; 1245 1247 1246 1248 if (jq->old_sem) { … … 1254 1256 jq->size *= JOB_QUEUE_INC_FACTOR; 1255 1257 pj_sem_destroy(jq->sem); 1256 pj_sem_create(jq->pool, "thread_sem", 0, jq->size + 1, 1257 &jq->sem); 1258 status = pj_sem_create(jq->pool, "thread_sem", 0, jq->size + 1, 1259 &jq->sem); 1260 if (status != PJ_SUCCESS) { 1261 PJ_LOG(3, (THIS_FILE, "Failed growing SDL job queue size.")); 1262 return 0; 1263 } 1258 1264 jq->jobs = (job **)pj_pool_calloc(jq->pool, jq->size, 1259 1265 sizeof(job *)); … … 1261 1267 sizeof(pj_sem_t *)); 1262 1268 for (i = 0; i < jq->size; i++) { 1263 pj_sem_create(jq->pool, "job_sem", 0, 1, &jq->job_sem[i]); 1269 status = pj_sem_create(jq->pool, "job_sem", 0, 1, 1270 &jq->job_sem[i]); 1271 if (status != PJ_SUCCESS) { 1272 PJ_LOG(3, (THIS_FILE, "Failed growing SDL job " 1273 "queue size.")); 1274 return 0; 1275 } 1264 1276 } 1265 1277 jq->is_full = PJ_FALSE; … … 1282 1294 1283 1295 job_queue *jq = PJ_POOL_ZALLOC_T(pool, job_queue); 1296 jq->pool = pool; 1297 jq->size = INITIAL_MAX_JOBS; 1298 status = pj_sem_create(pool, "thread_sem", 0, jq->size + 1, &jq->sem); 1299 if (status != PJ_SUCCESS) 1300 goto on_error; 1301 jq->jobs = (job **)pj_pool_calloc(pool, jq->size, sizeof(job *)); 1302 jq->job_sem = (pj_sem_t **) pj_pool_calloc(pool, jq->size, 1303 sizeof(pj_sem_t *)); 1304 for (i = 0; i < jq->size; i++) { 1305 status = pj_sem_create(pool, "job_sem", 0, 1, &jq->job_sem[i]); 1306 if (status != PJ_SUCCESS) 1307 goto on_error; 1308 } 1309 1310 status = pj_mutex_create_recursive(pool, "job_mutex", &jq->mutex); 1311 if (status != PJ_SUCCESS) 1312 goto on_error; 1284 1313 1285 1314 #if defined(PJ_DARWINOS) && PJ_DARWINOS!=0 … … 1288 1317 status = pj_thread_create(pool, "job_th", job_thread, jq, 0, 0, 1289 1318 &jq->thread); 1290 if (status != PJ_SUCCESS) { 1291 job_queue_destroy(jq); 1292 return status; 1293 } 1319 if (status != PJ_SUCCESS) 1320 goto on_error; 1294 1321 #endif /* PJ_DARWINOS */ 1295 1322 1296 jq->pool = pool;1297 jq->size = INITIAL_MAX_JOBS;1298 pj_sem_create(pool, "thread_sem", 0, jq->size + 1, &jq->sem);1299 jq->jobs = (job **)pj_pool_calloc(pool, jq->size, sizeof(job *));1300 jq->job_sem = (pj_sem_t **) pj_pool_calloc(pool, jq->size,1301 sizeof(pj_sem_t *));1302 for (i = 0; i < jq->size; i++) {1303 pj_sem_create(pool, "job_sem", 0, 1, &jq->job_sem[i]);1304 }1305 pj_mutex_create_recursive(pool, "job_mutex", &jq->mutex);1306 1307 1323 *pjq = jq; 1308 1324 return PJ_SUCCESS; 1325 1326 on_error: 1327 job_queue_destroy(jq); 1328 return status; 1309 1329 } 1310 1330 … … 1367 1387 pj_sem_post(jq->sem); 1368 1388 pj_thread_join(jq->thread); 1389 pj_thread_destroy(jq->thread); 1369 1390 } 1370 1391 … … 1374 1395 } 1375 1396 for (i = 0; i < jq->size; i++) { 1376 pj_sem_destroy(jq->job_sem[i]); 1397 if (jq->job_sem[i]) { 1398 pj_sem_destroy(jq->job_sem[i]); 1399 jq->job_sem[i] = NULL; 1400 } 1377 1401 } 1378 1402 if (jq->old_sem) { 1379 1403 for (i = 0; i < jq->size / JOB_QUEUE_INC_FACTOR; i++) { 1380 pj_sem_destroy(jq->old_sem[i]); 1404 if (jq->old_sem[i]) { 1405 pj_sem_destroy(jq->old_sem[i]); 1406 jq->old_sem[i] = NULL; 1407 } 1381 1408 } 1382 1409 } 1383 pj_mutex_destroy(jq->mutex); 1410 if (jq->mutex) { 1411 pj_mutex_destroy(jq->mutex); 1412 jq->mutex = NULL; 1413 } 1384 1414 1385 1415 return PJ_SUCCESS;
Note: See TracChangeset
for help on using the changeset viewer.