Changeset 82:395b9657ca85 in roaraudio for libroar/simple.c


Ignore:
Timestamp:
07/12/08 18:49:34 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added roar_simple_new_stream()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/simple.c

    r54 r82  
    5858} 
    5959 
     60int roar_simple_new_stream (struct roar_connection * con, int rate, int channels, int bits, int codec, int dir) { 
     61 struct roar_stream     s; 
     62 struct roar_message    mes; 
     63 char file[80]; 
     64 int fh = -1, listen; 
     65 static int count = 0; 
     66 
     67 sprintf(file, "/tmp/.libroar-simple-stream.%i-%i", getpid(), count++); 
     68 
     69 if ( (listen = roar_socket_listen(ROAR_SOCKET_TYPE_UNIX, file, 0)) == -1 ) { 
     70  return -1; 
     71 } 
     72 
     73 if ( roar_stream_new(&s, rate, channels, bits, codec) == -1 ) { 
     74  return -1; 
     75 } 
     76 
     77 if ( roar_stream_connect(con, &s, dir) == -1 ) { 
     78  return -1; 
     79 } 
     80 
     81 if ( roar_stream_connect_to_ask(con, &s, ROAR_SOCKET_TYPE_UNIX, file, 0) != -1 ) { 
     82 
     83  if ( (fh = accept(listen, NULL, NULL)) != -1 ) { 
     84   if ( dir == ROAR_DIR_PLAY ) { 
     85    shutdown(fh, SHUT_RD); 
     86   } else if ( dir == ROAR_DIR_MONITOR || dir == ROAR_DIR_RECORD ) { 
     87    shutdown(fh, SHUT_WR); 
     88   } 
     89  } 
     90   if ( roar_recv_message(con, &mes, NULL) == -1 ) { 
     91    close(fh); 
     92    fh = -1; 
     93   } else if ( mes.cmd != ROAR_CMD_OK ) { 
     94    close(fh); 
     95    fh = -1; 
     96   } 
     97 } 
     98 
     99 close(listen); 
     100 unlink(file); 
     101 
     102 return fh; 
     103} 
     104 
    60105int roar_simple_play(int rate, int channels, int bits, int codec, char * server, char * name) { 
    61106 return roar_simple_stream(rate, channels, bits, codec, server, ROAR_DIR_PLAY, name); 
Note: See TracChangeset for help on using the changeset viewer.