Changeset 820:9e1bd17bb1f9 in roaraudio for libroar/cdrom.c


Ignore:
Timestamp:
09/18/08 20:32:00 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

done a lot more cdrom work, still need a working roar_cdrom_play()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/cdrom.c

    r813 r820  
    3636 
    3737int roar_cdrom_open (struct roar_connection * con, struct roar_cdrom * cdrom, char * device) { 
     38 int flags; 
     39 
    3840 if ( cdrom == NULL ) 
    3941  return -1; 
     
    4951 strncpy(cdrom->device, device, ROAR_CDROM_MAX_DEVLEN); 
    5052 
    51  cdrom->con    = con; // we do not care here if it is set or not as we can operate in local only mode 
     53 cdrom->con        = con; // we do not care here if it is set or not as we can operate in local only mode 
    5254 
    53  cdrom->stream = -1; 
    54  cdrom->fh     = -1; 
     55 cdrom->stream     = -1; 
     56 cdrom->play_local =  1; 
     57 
     58 if ( (cdrom->fh = open(cdrom->device, O_RDONLY, 0644)) == -1 ) 
     59  return -1; 
     60 
     61 if ( (flags = fcntl(cdrom->fh, F_GETFL, 0)) == -1 ) { 
     62  close(cdrom->fh); 
     63  cdrom->fh  = -1; 
     64  return -1; 
     65 } 
     66 
     67 flags |= FD_CLOEXEC; 
     68 
     69 if ( fcntl(cdrom->fh, F_SETFL, flags) == -1 ) { 
     70  close(cdrom->fh); 
     71  cdrom->fh = -1; 
     72  return -1; 
     73 } 
    5574 
    5675 return 0; 
     
    6988} 
    7089 
    71 int roar_cdrom_stop (struct roar_cdrom * cdrom); 
    72 int roar_cdrom_play (struct roar_cdrom * cdrom, int track); 
     90int roar_cdrom_stop (struct roar_cdrom * cdrom) { 
     91 int ret; 
     92 
     93 if ( cdrom == NULL ) 
     94  return -1; 
     95 
     96 if ( cdrom->con == NULL ) 
     97  return -1; 
     98 
     99 if ( cdrom->stream == -1 ) 
     100  return -1; 
     101 
     102 if ( (ret = roar_kick(cdrom->con, ROAR_OT_STREAM, cdrom->stream)) == -1 ) { 
     103  return -1; 
     104 } 
     105 
     106 cdrom->stream = -1; 
     107 
     108 return ret; 
     109} 
     110 
     111int roar_cdrom_play (struct roar_cdrom * cdrom, int track) { 
     112 if ( cdrom == NULL ) 
     113  return -1; 
     114 
     115 if ( cdrom->con == NULL ) 
     116  return -1; 
     117 
     118 if ( cdrom->stream != -1 ) { 
     119  if ( roar_cdrom_stop(cdrom) == -1 ) 
     120   return -1; 
     121 } 
     122 
     123 if ( cdrom->play_local ) { 
     124#ifdef ROAR_HAVE_BIN_CDPARANOIA 
     125  return -1; 
     126#else 
     127  return -1; 
     128#endif 
     129 } else { 
     130  // no support for remote playback yet 
     131  return -1; 
     132 } 
     133} 
    73134 
    74135//ll 
Note: See TracChangeset for help on using the changeset viewer.