Skip to content

Commit

Permalink
Merge pull request #45 from martinellimarco/master
Browse files Browse the repository at this point in the history
No need to open IVSHMEM in write mode
  • Loading branch information
martinellimarco committed May 13, 2019
2 parents 1c628e9 + a86a973 commit 9f973f4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions Receivers/alsa-ivshmem/scream-ivshmem-alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,19 +131,19 @@ static int write_frames(snd_pcm_t *snd, unsigned char *buf, int total_frames, in
static void * open_mmap(const char *shmfile) {
struct stat st;
if (stat(shmfile, &st) < 0) {
fprintf(stderr, "Failed to stat the shared memory file: %s", shmfile);
fprintf(stderr, "Failed to stat the shared memory file: %s\n", shmfile);
exit(2);
}

int shmFD = open(shmfile, O_RDWR, (mode_t)0600);
int shmFD = open(shmfile, O_RDONLY);
if (shmFD < 0) {
fprintf(stderr, "Failed to open the shared memory file: %s", shmfile);
fprintf(stderr, "Failed to open the shared memory file: %s\n", shmfile);
exit(3);
}

void * map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, shmFD, 0);
if (map == MAP_FAILED) {
fprintf(stderr, "Failed to map the shared memory file: %s", shmfile);
fprintf(stderr, "Failed to map the shared memory file: %s\n", shmfile);
close(shmFD);
exit(4);
}
Expand Down
8 changes: 4 additions & 4 deletions Receivers/pulseaudio-ivshmem/scream-ivshmem-pulse.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@ static void show_usage(const char *arg0)
static void * open_mmap(const char *shmfile) {
struct stat st;
if (stat(shmfile, &st) < 0) {
fprintf(stderr, "Failed to stat the shared memory file: %s", shmfile);
fprintf(stderr, "Failed to stat the shared memory file: %s\n", shmfile);
exit(2);
}

int shmFD = open(shmfile, O_RDWR, (mode_t)0600);
int shmFD = open(shmfile, O_RDONLY);
if (shmFD < 0) {
fprintf(stderr, "Failed to open the shared memory file: %s", shmfile);
fprintf(stderr, "Failed to open the shared memory file: %s\n", shmfile);
exit(3);
}

void * map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, shmFD, 0);
if (map == MAP_FAILED) {
fprintf(stderr, "Failed to map the shared memory file: %s", shmfile);
fprintf(stderr, "Failed to map the shared memory file: %s\n", shmfile);
close(shmFD);
exit(4);
}
Expand Down
8 changes: 4 additions & 4 deletions Receivers/raw-ivshmem/scream-ivshmem-raw.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ static void show_usage(const char *arg0)
static void * open_mmap(const char *shmfile) {
struct stat st;
if (stat(shmfile, &st) < 0) {
fprintf(stderr, "Failed to stat the shared memory file: %s", shmfile);
fprintf(stderr, "Failed to stat the shared memory file: %s\n", shmfile);
exit(2);
}

int shmFD = open(shmfile, O_RDWR, (mode_t)0600);
int shmFD = open(shmfile, O_RDONLY);
if (shmFD < 0) {
fprintf(stderr, "Failed to open the shared memory file: %s", shmfile);
fprintf(stderr, "Failed to open the shared memory file: %s\n", shmfile);
exit(3);
}

void * map = mmap(0, st.st_size, PROT_READ, MAP_SHARED, shmFD, 0);
if (map == MAP_FAILED) {
fprintf(stderr, "Failed to map the shared memory file: %s", shmfile);
fprintf(stderr, "Failed to map the shared memory file: %s\n", shmfile);
close(shmFD);
exit(4);
}
Expand Down

0 comments on commit 9f973f4

Please sign in to comment.