* [PATCH 1/2] Arcam AV Control Plugin Updates
@ 2009-02-21 16:59 Peter Stokes
0 siblings, 0 replies; only message in thread
From: Peter Stokes @ 2009-02-21 16:59 UTC (permalink / raw)
To: alsa-devel
[-- Attachment #1: Type: text/plain, Size: 113 bytes --]
arcam_av: Remove incorrect usage of the static SHM ID variable
Signed-off-by: Peter Stokes <linux@dadeos.co.uk>
[-- Attachment #2: arcam_av_remove_static.patch --]
[-- Type: text/x-diff, Size: 2142 bytes --]
diff --git a/arcam-av/arcam_av.c b/arcam-av/arcam_av.c
index 81e72e9..0491fc6 100644
--- a/arcam-av/arcam_av.c
+++ b/arcam-av/arcam_av.c
@@ -329,39 +329,34 @@ static void arcam_av_state_query(int fd)
}
-static int arcam_av_state_shm_id = -1;
-
arcam_av_state_t* arcam_av_state_attach(const char* port)
{
arcam_av_state_t* state;
+ struct stat port_stat;
+ key_t ipc_key;
+ int shmid, shmflg;
+ struct shmid_ds shm_stat;
- if (arcam_av_state_shm_id < 0) {
- struct stat port_stat;
- key_t ipc_key;
- int shmflg;
- struct shmid_ds shm_stat;
-
- if (stat(port, &port_stat))
- return NULL;
+ if (stat(port, &port_stat))
+ return NULL;
- ipc_key = ftok(port, 'A');
- if (ipc_key < 0)
- return NULL;
+ ipc_key = ftok(port, 'A');
+ if (ipc_key < 0)
+ return NULL;
- shmflg = IPC_CREAT | (port_stat.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO));
- arcam_av_state_shm_id = shmget(ipc_key, sizeof(arcam_av_state_t), shmflg);
- if (arcam_av_state_shm_id < 0)
- return NULL;
+ shmflg = IPC_CREAT | (port_stat.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO));
+ shmid = shmget(ipc_key, sizeof(arcam_av_state_t), shmflg);
+ if (shmid < 0)
+ return NULL;
- if (shmctl(arcam_av_state_shm_id, IPC_STAT, &shm_stat))
- return NULL;
+ if (shmctl(shmid, IPC_STAT, &shm_stat))
+ return NULL;
- shm_stat.shm_perm.uid = port_stat.st_uid;
- shm_stat.shm_perm.gid = port_stat.st_gid;
- shmctl(arcam_av_state_shm_id, IPC_SET, &shm_stat);
- }
+ shm_stat.shm_perm.uid = port_stat.st_uid;
+ shm_stat.shm_perm.gid = port_stat.st_gid;
+ shmctl(shmid, IPC_SET, &shm_stat);
- state = shmat(arcam_av_state_shm_id, NULL, 0);
+ state = shmat(shmid, NULL, 0);
return (state == (void*)-1) ? NULL : state;
}
@@ -369,20 +364,7 @@ arcam_av_state_t* arcam_av_state_attach(const char* port)
int arcam_av_state_detach(arcam_av_state_t* state)
{
- struct shmid_ds shm_stat;
-
- if (shmdt(state))
- return -1;
-
- if (shmctl(arcam_av_state_shm_id, IPC_STAT, &shm_stat))
- return -1;
-
- if (!shm_stat.shm_nattch) {
- shmctl(arcam_av_state_shm_id, IPC_RMID, NULL);
- arcam_av_state_shm_id = -1;
- }
-
- return 0;
+ return shmdt(state);
}
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2009-02-21 17:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-21 16:59 [PATCH 1/2] Arcam AV Control Plugin Updates Peter Stokes
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.