Changeset 2611
- Timestamp:
- 06/23/16 04:33:52 (8 years ago)
- Files:
-
- trunk/libffado/src/rme/rme_avdevice.cpp (modified) (2 diffs)
- trunk/libffado/src/rme/rme_shm.cpp (modified) (7 diffs)
- trunk/libffado/src/rme/rme_shm.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/rme/rme_avdevice.cpp
r2603 r2611 358 358 { 359 359 signed int i; 360 std::string id; 361 360 362 unsigned int vendorId = getConfigRom().getNodeVendorId(); 361 363 // See note in Device::probe() about why we use the unit version here. … … 389 391 } 390 392 393 id = std::string("dev0"); 394 if (!getOption("id", id)) { 395 debugWarning("Could not retrieve id parameter, defaulting to 'dev0'\n"); 396 } 397 391 398 // Set up the shared data object for configuration data 392 i = rme_shm_open( &dev_config);399 i = rme_shm_open(id, &dev_config); 393 400 if (i == RSO_OPEN_CREATED) { 394 401 debugOutput( DEBUG_LEVEL_VERBOSE, "New configuration shared data object created\n"); trunk/libffado/src/rme/rme_shm.cpp
r1629 r2611 41 41 */ 42 42 43 #define RME_SHM_NAME "/ffado:rme_shm "43 #define RME_SHM_NAME "/ffado:rme_shm-" 44 44 #define RME_SHM_SIZE sizeof(rme_shm_t) 45 45 … … 48 48 #include <unistd.h> 49 49 #include <errno.h> 50 #include <string> 51 #include <stdio.h> 50 52 #include <sys/types.h> 51 53 #include <sys/mman.h> … … 81 83 } 82 84 83 signed int rme_shm_open( rme_shm_t **shm_data) {85 signed int rme_shm_open(std::string id, rme_shm_t **shm_data) { 84 86 87 std::string shm_name; 85 88 signed int shmfd, lockfd; 86 89 rme_shm_t *data; … … 94 97 lockfd = rme_shm_lock_for_setup(); 95 98 96 shmfd = shm_open(RME_SHM_NAME, O_RDWR, 0644); 99 shm_name = std::string(RME_SHM_NAME); 100 shm_name.append(id); 101 102 shmfd = shm_open(shm_name.c_str(), O_RDWR, 0644); 97 103 if (shmfd < 0) { 98 104 if (errno == ENOENT) { 99 shmfd = shm_open( RME_SHM_NAME, O_RDWR | O_CREAT | O_EXCL, 0644);105 shmfd = shm_open(shm_name.c_str(), O_RDWR | O_CREAT | O_EXCL, 0644); 100 106 if (shmfd < 0) 101 107 return RSO_ERR_SHM; … … 116 122 if (created) { 117 123 pthread_mutex_init(&data->lock, NULL); 124 snprintf(data->shm_name, sizeof(data->shm_name), "%s", shm_name.c_str()); 118 125 } 119 126 … … 130 137 signed int rme_shm_close(rme_shm_t *shm_data) { 131 138 139 std::string shm_name = std::string(shm_data->shm_name); 132 140 signed int unlink = 0; 133 141 signed int lockfd; … … 149 157 150 158 if (unlink) 151 shm_unlink( RME_SHM_NAME);159 shm_unlink(shm_name.c_str()); 152 160 153 161 rme_shm_unlock_for_setup(lockfd); trunk/libffado/src/rme/rme_shm.h
r1671 r2611 29 29 #include "fireface_def.h" 30 30 31 #define RME_SHM_NAMELEN 64 32 31 33 /* Structure used within shared memory object */ 32 34 … … 45 47 46 48 pthread_mutex_t lock; 49 char shm_name[RME_SHM_NAMELEN]; 47 50 } rme_shm_t; 48 51 … … 62 65 void rme_shm_lock(rme_shm_t *shm_data); 63 66 void rme_shm_unlock(rme_shm_t *shm_data); 64 signed int rme_shm_open( rme_shm_t **shm_data);67 signed int rme_shm_open(std::string id, rme_shm_t **shm_data); 65 68 signed int rme_shm_close(rme_shm_t *shm_data); 66 69