Changeset 2611

Show
Ignore:
Timestamp:
06/23/16 04:33:52 (8 years ago)
Author:
jwoithe
Message:

rme: create separate rme shared memory segments for each RME device found. This is needed if more than one RME device is to be used at the same time. Thanks to Christopher Brown for reporting the inability to use two RME devices simultaneously.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/rme/rme_avdevice.cpp

    r2603 r2611  
    358358{ 
    359359    signed int i; 
     360    std::string id; 
     361 
    360362    unsigned int vendorId = getConfigRom().getNodeVendorId(); 
    361363    // See note in Device::probe() about why we use the unit version here. 
     
    389391    } 
    390392 
     393    id = std::string("dev0"); 
     394    if (!getOption("id", id)) { 
     395        debugWarning("Could not retrieve id parameter, defaulting to 'dev0'\n"); 
     396    } 
     397 
    391398    // Set up the shared data object for configuration data 
    392     i = rme_shm_open(&dev_config); 
     399    i = rme_shm_open(id, &dev_config); 
    393400    if (i == RSO_OPEN_CREATED) { 
    394401        debugOutput( DEBUG_LEVEL_VERBOSE, "New configuration shared data object created\n"); 
  • trunk/libffado/src/rme/rme_shm.cpp

    r1629 r2611  
    4141 */ 
    4242 
    43 #define RME_SHM_NAME  "/ffado:rme_shm
     43#define RME_SHM_NAME  "/ffado:rme_shm-
    4444#define RME_SHM_SIZE  sizeof(rme_shm_t) 
    4545 
     
    4848#include <unistd.h> 
    4949#include <errno.h> 
     50#include <string> 
     51#include <stdio.h> 
    5052#include <sys/types.h> 
    5153#include <sys/mman.h> 
     
    8183} 
    8284 
    83 signed int rme_shm_open(rme_shm_t **shm_data) { 
     85signed int rme_shm_open(std::string id, rme_shm_t **shm_data) { 
    8486 
     87    std::string shm_name; 
    8588    signed int shmfd, lockfd; 
    8689    rme_shm_t *data; 
     
    9497    lockfd = rme_shm_lock_for_setup(); 
    9598 
    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); 
    97103    if (shmfd < 0) { 
    98104        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); 
    100106            if (shmfd < 0) 
    101107                return RSO_ERR_SHM; 
     
    116122    if (created) { 
    117123        pthread_mutex_init(&data->lock, NULL); 
     124        snprintf(data->shm_name, sizeof(data->shm_name), "%s", shm_name.c_str()); 
    118125    } 
    119126 
     
    130137signed int rme_shm_close(rme_shm_t *shm_data) { 
    131138 
     139    std::string shm_name = std::string(shm_data->shm_name); 
    132140    signed int unlink = 0; 
    133141    signed int lockfd; 
     
    149157 
    150158    if (unlink) 
    151         shm_unlink(RME_SHM_NAME); 
     159        shm_unlink(shm_name.c_str()); 
    152160 
    153161    rme_shm_unlock_for_setup(lockfd); 
  • trunk/libffado/src/rme/rme_shm.h

    r1671 r2611  
    2929#include "fireface_def.h" 
    3030 
     31#define RME_SHM_NAMELEN 64 
     32 
    3133/* Structure used within shared memory object */ 
    3234 
     
    4547 
    4648    pthread_mutex_t lock; 
     49    char shm_name[RME_SHM_NAMELEN]; 
    4750} rme_shm_t; 
    4851 
     
    6265void rme_shm_lock(rme_shm_t *shm_data); 
    6366void rme_shm_unlock(rme_shm_t *shm_data); 
    64 signed int rme_shm_open(rme_shm_t **shm_data); 
     67signed int rme_shm_open(std::string id, rme_shm_t **shm_data); 
    6568signed int rme_shm_close(rme_shm_t *shm_data); 
    6669