Changeset 821:e2cefbe8a430 in roaraudio for libroar/cdrom.c
- Timestamp:
- 09/18/08 23:04:15 (16 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroar/cdrom.c
r820 r821 34 34 35 35 #include "libroar.h" 36 37 #define ROAR_CDROM_ERROR_NORETURN(format, args...) ROAR_ERR(format, ## args); _exit(3) 38 39 #if BYTE_ORDER == BIG_ENDIAN 40 #define ROAR_CDROM_CDPARANOIA_OUTPUTFORMAT "--output-raw-big-endian" 41 #elif BYTE_ORDER == LITTLE_ENDIA 42 #define ROAR_CDROM_CDPARANOIA_OUTPUTFORMAT "--output-raw-little-endian" 43 #endif 44 45 pid_t roar_cdrom_run_cdparanoia (int cdrom, int data, int track, char * pos) { 46 #if defined(ROAR_HAVE_BIN_CDPARANOIA) && defined(ROAR_CDROM_CDPARANOIA_OUTPUTFORMAT) 47 char my_pos[32] = {0}; 48 pid_t pid; 49 int fh[2]; 50 51 if ( cdrom == -1 || data == -1 || (track == -1 && pos == NULL) || (track != -1 && pos != NULL) ) 52 return -1; 53 54 if ( track != -1 ) { 55 pos = my_pos; 56 snprintf(pos, 32, "%i", track); 57 } 58 59 if ( (pid = fork()) == -1 ) { 60 return -1; 61 } 62 63 if ( pid ) 64 return pid; 65 66 fh[0] = dup(cdrom); 67 fh[1] = dup(data); 68 69 if ( fh[0] == -1 || fh[1] == -1 ) { 70 ROAR_CDROM_ERROR_NORETURN("Can not dup(): %s", strerror(errno)); 71 } 72 73 close(ROAR_STDIN); 74 close(ROAR_STDOUT); 75 76 // TODO: should I close some other handles? 77 78 if ( dup2(fh[0], ROAR_STDIN) == -1 || dup2(fh[1], ROAR_STDOUT) == -1 ) { 79 ROAR_CDROM_ERROR_NORETURN("Can not dup2(): %s", strerror(errno)); 80 } 81 82 execl(ROAR_HAVE_BIN_CDPARANOIA, "cdparanoia", ROAR_CDROM_CDPARANOIA_OUTPUTFORMAT, pos, "-", NULL); 83 84 ROAR_CDROM_ERROR_NORETURN("We are still alive after exec()!, very bad!, error was: %s", strerror(errno)); 85 return -1; 86 #else 87 return -1; 88 #endif 89 } 36 90 37 91 int roar_cdrom_open (struct roar_connection * con, struct roar_cdrom * cdrom, char * device) { … … 110 164 111 165 int roar_cdrom_play (struct roar_cdrom * cdrom, int track) { 166 int stream_fh; 167 struct roar_stream stream[1]; 168 112 169 if ( cdrom == NULL ) 113 170 return -1; … … 122 179 123 180 if ( cdrom->play_local ) { 124 #ifdef ROAR_HAVE_BIN_CDPARANOIA 181 182 if ( (stream_fh = roar_simple_new_stream_obj(cdrom->con, stream, ROAR_CDROM_STREAMINFO, ROAR_DIR_PLAY)) == -1 ) { 183 return -1; 184 } 185 186 close(stream_fh); 187 125 188 return -1; 126 #else127 return -1;128 #endif129 189 } else { 130 190 // no support for remote playback yet
Note: See TracChangeset
for help on using the changeset viewer.