Changeset ab02583b3e in mythtv
- Timestamp:
- Dec 28, 2011, 6:54:11 PM (13 years ago)
- Branches:
- devel/2020-player, devel/ffmpeg-resync, devel/gpu-commflag, fixes/0.25, fixes/0.26, fixes/0.27, fixes/0.28, fixes/29, fixes/30, fixes/31, github-templates, master
- Children:
- 124d820e6
- Parents:
- c5aca5cf4f
- git-author:
- Argus <pthorn-mythd@…> (12/28/11 18:54:11)
- git-committer:
- Paul Harrison <pharrison@…> (12/28/11 18:55:14)
- Location:
- mythplugins/mythzoneminder/mythzmserver
- Files:
-
- 2 edited
-
zmserver.cpp (modified) (4 diffs)
-
zmserver.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
mythplugins/mythzoneminder/mythzmserver/zmserver.cpp
rc5aca5cf4f rab02583b3e 26 26 #include <sys/shm.h> 27 27 28 #if _POSIX_MAPPED_FILES > 0L 29 #include <sys/mman.h> 30 #endif 31 28 32 #ifdef linux 29 33 # include <sys/vfs.h> … … 217 221 snprintf(buf, sizeof(buf), "0x%x", (unsigned int)m_shmKey); 218 222 cout << "Shared memory key is: " << buf << endl; 223 } 224 225 // get the MMAP path 226 m_mmapPath = getZMSetting("ZM_PATH_MAP"); 227 if (m_debug) 228 { 229 cout << "Memory path directory is: " << m_mmapPath << endl; 219 230 } 220 231 … … 1302 1313 void ZMServer::initMonitor(MONITOR *monitor) 1303 1314 { 1304 void *shm_ptr ;1315 void *shm_ptr = NULL; 1305 1316 1306 1317 monitor->shared_data = NULL; … … 1325 1336 ((monitor->image_buffer_count) * monitor->frame_size); 1326 1337 1327 int shmid; 1328 1329 if ((shmid = shmget((m_shmKey & 0xffffff00) | monitor->mon_id, 1330 shared_data_size, SHM_R)) == -1) 1331 { 1332 cout << "Failed to shmget for monitor: " << monitor->mon_id << endl; 1333 monitor->status = "Error"; 1334 switch(errno) 1335 { 1336 case EACCES: cout << "EACCES - no rights to access segment\n"; break; 1337 case EEXIST: cout << "EEXIST - segment already exists\n"; break; 1338 case EINVAL: cout << "EINVAL - size < SHMMIN or size > SHMMAX\n"; break; 1339 case ENFILE: cout << "ENFILE - limit on open files has been reached\n"; break; 1340 case ENOENT: cout << "ENOENT - no segment exists for the given key\n"; break; 1341 case ENOMEM: cout << "ENOMEM - couldn't reserve memory for segment\n"; break; 1342 case ENOSPC: cout << "ENOSPC - shmmni or shmall limit reached\n"; break; 1343 } 1344 1345 return; 1346 } 1347 1348 shm_ptr = shmat(shmid, 0, SHM_RDONLY); 1349 1338 1339 #if _POSIX_MAPPED_FILES > 0L 1340 /* 1341 * Try to open the mmap file first if the architecture supports it. 1342 * Otherwise, legacy shared memory will be used below. 1343 */ 1344 stringstream mmap_filename; 1345 mmap_filename << m_mmapPath << "/zm.mmap." << monitor->mon_id; 1346 1347 int mapFile = open(mmap_filename.str().c_str(), O_RDONLY, 0x0); 1348 if (mapFile >= 0) 1349 { 1350 if (m_debug) 1351 cout << "Opened mmap file: " << mmap_filename << endl; 1352 1353 shm_ptr = mmap(NULL, shared_data_size, PROT_READ, 1354 MAP_SHARED, mapFile, 0x0); 1355 if (shm_ptr == NULL) 1356 { 1357 cout << "Failed to map shared memory from file [" << 1358 mmap_filename << "] " << 1359 "for monitor: " << 1360 monitor->mon_id << 1361 endl; 1362 monitor->status = "Error"; 1363 return; 1364 } 1365 } 1366 #endif 1350 1367 1351 1368 if (shm_ptr == NULL) 1352 1369 { 1353 cout << "Failed to shmat for monitor: " << monitor->mon_id << endl; 1354 monitor->status = "Error"; 1355 return; 1370 // fail back to shmget() functionality if mapping memory above failed. 1371 int shmid; 1372 1373 if ((shmid = shmget((m_shmKey & 0xffffff00) | monitor->mon_id, 1374 shared_data_size, SHM_R)) == -1) 1375 { 1376 cout << "Failed to shmget for monitor: " << monitor->mon_id << endl; 1377 monitor->status = "Error"; 1378 switch(errno) 1379 { 1380 case EACCES: cout << "EACCES - no rights to access segment\n"; break; 1381 case EEXIST: cout << "EEXIST - segment already exists\n"; break; 1382 case EINVAL: cout << "EINVAL - size < SHMMIN or size > SHMMAX\n"; break; 1383 case ENFILE: cout << "ENFILE - limit on open files has been reached\n"; break; 1384 case ENOENT: cout << "ENOENT - no segment exists for the given key\n"; break; 1385 case ENOMEM: cout << "ENOMEM - couldn't reserve memory for segment\n"; break; 1386 case ENOSPC: cout << "ENOSPC - shmmni or shmall limit reached\n"; break; 1387 } 1388 1389 return; 1390 } 1391 1392 shm_ptr = shmat(shmid, 0, SHM_RDONLY); 1393 1394 1395 if (shm_ptr == NULL) 1396 { 1397 cout << "Failed to shmat for monitor: " << monitor->mon_id << endl; 1398 monitor->status = "Error"; 1399 return; 1400 } 1356 1401 } 1357 1402 -
mythplugins/mythzoneminder/mythzmserver/zmserver.h
rc5aca5cf4f rab02583b3e 193 193 string m_analyseFileFormat; 194 194 key_t m_shmKey; 195 string m_mmapPath; 195 196 }; 196 197
Note: See TracChangeset
for help on using the changeset viewer.
