From fe24ad2d395ffecfafc39e24db00eb3253e13ed7 Mon Sep 17 00:00:00 2001
From: raefaldhia <raefaldhiamartya@gmail.com>
Date: Sat, 17 Dec 2016 12:18:33 +0700
Subject: Add compatibility to build on haiku


diff --git a/mpg321.c b/mpg321.c
index 19282bb..e728d7e 100644
--- a/mpg321.c
+++ b/mpg321.c
@@ -47,7 +47,6 @@
 #include <sys/mman.h>
 #include <sys/ipc.h>
 #include <sys/sem.h>
-#include <sys/shm.h>
 
 #include <getopt.h> /* GNU getopt is needed, so I included it */
 #include "mpg321.h"
@@ -614,56 +613,7 @@ int main(int argc, char *argv[])
 		    goto out;
 		    //exit(EXIT_FAILURE);
 	    }
-
-	    /* Shared Memory */
-	    mem_key = ftok(argv[0],1);
-	    shm_id = shmget(mem_key,buffer_size * sizeof(output_frame), IPC_CREAT | S_IREAD | S_IWRITE);
-	    if(shm_id == -1)
-	    {
-		    perror("Cannot initialize shared buffer");
-		    goto out;
-		    //exit(EXIT_FAILURE);
-	    }
-	    Output_Queue = shmat(shm_id,NULL,0);
-	    if(*(int *)Output_Queue == -1)
-	    {
-		    perror("Error while attaching shared buffer to mad_decoder");
-		    if(shmctl(shm_id,IPC_RMID,NULL))
-			    perror("Cannot destroy shared buffer");
-		    goto out;
-		    //exit(EXIT_FAILURE);
-	    }
-	    static int n;
-	    for(n=0;n<buffer_size;n++)
-	    {
-		    memset((Output_Queue+n)->data,'\0',4608);
-		    memset((Output_Queue+n)->time,'\0',80);
-		    (Output_Queue+n)->length = 0;
-		    (Output_Queue+n)->seconds = 0;
-		    (Output_Queue+n)->num_frames = 0;
-	    }
 	    
-	    frames_key = ftok(argv[0],2);
-	    frames_id = shmget(frames_key,buffer_size * sizeof(decoded_frames), IPC_CREAT | S_IREAD | S_IWRITE);
-	    if(frames_id == -1)
-	    {
-		    perror("Cannot initialize shared frames counter");
-		    goto out;
-		    //exit(EXIT_FAILURE);
-	    }
-	    Decoded_Frames = shmat(frames_id,NULL,0);
-	    if(*(int *)Decoded_Frames == -1)
-	    {
-		    perror("Error while attaching shared frames counter to mad_decoder");
-		    if(shmctl(frames_id,IPC_RMID,NULL))
-			    perror("Cannot destroy shared frames counter");
-		    goto out;
-		    //exit(EXIT_FAILURE);
-	    }
-	    	
-	    Decoded_Frames->is_http = 0;
-	    Decoded_Frames->is_file = 0;
-
     }
     else {
 	    ao_initialize();
@@ -1187,12 +1137,6 @@ out:
 		    perror("Error while waiting for output process to exit");
 	    if(semctl(semarray,0,IPC_RMID) == -1)
 		    perror("Error while destroying semaphores");
-	    if(shmdt(Output_Queue) == -1)
-		    perror("Error while detaching shared buffer");
-	    if(shmctl(shm_id,IPC_RMID,NULL))
-		    perror("Cannot destroy shared buffer");
-	    if(shmctl(frames_id,IPC_RMID,NULL))
-		    perror("Cannot destroy shared buffer");
     }
     return(0);
 }
diff --git a/options.c b/options.c
index dae001e..3ba0f91 100644
--- a/options.c
+++ b/options.c
@@ -312,7 +312,6 @@ void parse_options(int argc, char *argv[], playlist *pl)
             case 'I':
                 /* We only try to get high priority. If it fails (just as
                    mpg123 does when run as a user), that's fine */
-                setpriority(PRIO_PROCESS, getpid(), -20);
                 break;
 
             case 'T':
-- 
2.7.0

