mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-11-04 13:30:08 -05:00
added ipc_gid for direct plugins
This commit is contained in:
parent
d7ef50f5ee
commit
4b7e3cff81
5 changed files with 107 additions and 8 deletions
|
|
@ -34,6 +34,7 @@
|
|||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <ctype.h>
|
||||
#include <grp.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/shm.h>
|
||||
|
|
@ -578,6 +579,7 @@ static snd_pcm_fast_ops_t snd_pcm_dshare_fast_ops = {
|
|||
* \param name Name of PCM
|
||||
* \param ipc_key IPC key for semaphore and shared memory
|
||||
* \param ipc_perm IPC permissions for semaphore and shared memory
|
||||
* \param ipc_gid IPC group ID for semaphore and shared memory
|
||||
* \param params Parameters for slave
|
||||
* \param bindings Channel bindings
|
||||
* \param slowptr Slow but more precise pointer updates
|
||||
|
|
@ -591,7 +593,7 @@ static snd_pcm_fast_ops_t snd_pcm_dshare_fast_ops = {
|
|||
* changed in future.
|
||||
*/
|
||||
int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
|
||||
key_t ipc_key, mode_t ipc_perm,
|
||||
key_t ipc_key, mode_t ipc_perm, int ipc_gid,
|
||||
struct slave_params *params,
|
||||
snd_config_t *bindings,
|
||||
int slowptr,
|
||||
|
|
@ -629,6 +631,7 @@ int snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
|
|||
|
||||
dshare->ipc_key = ipc_key;
|
||||
dshare->ipc_perm = ipc_perm;
|
||||
dshare->ipc_gid = ipc_gid;
|
||||
dshare->semid = -1;
|
||||
dshare->shmid = -1;
|
||||
|
||||
|
|
@ -851,6 +854,7 @@ int _snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
|
|||
int bsize, psize, ipc_key_add_uid = 0, slowptr = 0;
|
||||
key_t ipc_key = 0;
|
||||
mode_t ipc_perm = 0600;
|
||||
int ipc_gid = -1;
|
||||
|
||||
int err;
|
||||
snd_config_for_each(i, next, conf) {
|
||||
|
|
@ -885,6 +889,26 @@ int _snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
|
|||
ipc_perm = strtol(perm, &endp, 8);
|
||||
continue;
|
||||
}
|
||||
if (strcmp(id, "ipc_gid") == 0) {
|
||||
char *group;
|
||||
char *endp;
|
||||
err = snd_config_get_ascii(n, &group);
|
||||
if (err < 0) {
|
||||
SNDERR("The field ipc_gid must be a valid group");
|
||||
return err;
|
||||
}
|
||||
if (isdigit(*group) == 0) {
|
||||
struct group *grp = getgrnam(group);
|
||||
if (group == NULL) {
|
||||
SNDERR("The field ipc_gid must be a valid group (create group %s)", grp);
|
||||
return -EINVAL;
|
||||
}
|
||||
ipc_gid = grp->gr_gid;
|
||||
} else {
|
||||
ipc_perm = strtol(group, &endp, 10);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (strcmp(id, "ipc_key_add_uid") == 0) {
|
||||
err = snd_config_get_bool(n);
|
||||
if (err < 0) {
|
||||
|
|
@ -950,7 +974,7 @@ int _snd_pcm_dshare_open(snd_pcm_t **pcmp, const char *name,
|
|||
|
||||
params.period_size = psize;
|
||||
params.buffer_size = bsize;
|
||||
err = snd_pcm_dshare_open(pcmp, name, ipc_key, ipc_perm, ¶ms, bindings, slowptr, root, sconf, stream, mode);
|
||||
err = snd_pcm_dshare_open(pcmp, name, ipc_key, ipc_perm, ipc_gid, ¶ms, bindings, slowptr, root, sconf, stream, mode);
|
||||
if (err < 0)
|
||||
snd_config_delete(sconf);
|
||||
return err;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue