Changeset 5221:aa6530a03260 in roaraudio


Ignore:
Timestamp:
11/12/11 12:25:21 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Removed old functions from API (Closes: #186)

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5219 r5221  
    33        * Do not set errno to zero in ogg_vorbis codec filter (Closes: #191) 
    44        * Updated data types for struct roar_audio_info (Closes: #189) 
     5        * Removed old functions from API (Closes: #186) 
    56 
    67v. 0.4 - Fri Nov 11 2011 20:12 CET 
  • doc/man1/roarcatplay.1

    r3088 r5221  
    2626 
    2727.TP 
    28 \fB--passive\fR 
    29 Use passiv playback (experimental, works only localy) 
    30  
    31 .TP 
    32 \fB--background\fR 
    33 Use background playback, impleys passive mode 
    34  
    35 .TP 
    3628\fB--verbose\fR 
    3729Use verbose output 
     
    4032\fB--help\fR 
    4133Show this help 
     34 
     35.SH "REMOVED OPTIONS" 
     36The following options has been removed: 
     37\fB--passive\fR, 
     38\fB--background\fR 
    4239 
    4340.SH "SEE ALSO" 
  • include/libroar/file.h

    r5109 r5221  
    4545int     roar_file_codecdetect(char * buf, int len); 
    4646ssize_t roar_file_send_raw   (int out, int in) _LIBROAR_ATTR_DEPRECATED; 
    47 ssize_t roar_file_play       (struct roar_connection * con, char * file, int exec) _LIBROAR_ATTR_DEPRECATED; 
    48 ssize_t roar_file_play_full  (struct roar_connection * con, char * file, int exec, int passfh, struct roar_stream * s) _LIBROAR_ATTR_DEPRECATED; 
    4947 
    5048ssize_t roar_file_map        (char * filename, int flags, mode_t mode, size_t len, void ** mem) _LIBROAR_ATTR_DEPRECATED; 
  • libroar/file.c

    r5148 r5221  
    198198 
    199199 
    200 ssize_t roar_file_play (struct roar_connection * con, char * file, int exec) { 
    201  return roar_file_play_full(con, file, exec, 0, NULL); 
    202 } 
    203  
    204 ssize_t roar_file_play_full  (struct roar_connection * con, char * file, int exec, int passfh, struct roar_stream * s) { 
    205 #ifdef _CAN_OPERATE 
    206  int codec = -1; 
    207  int in, out = -1; 
    208  ssize_t r = 0; 
    209  int seek; 
    210  int len; 
    211  char buf[BUFFERSIZE]; 
    212  int rate = ROAR_RATE_DEFAULT, channels = ROAR_CHANNELS_DEFAULT, bits = ROAR_BITS_DEFAULT; 
    213  struct roar_stream localstream[1]; 
    214  
    215  // FIXME: check error cases 
    216  
    217  ROAR_DBG("roar_file_play_full(*) = ?"); 
    218  
    219  if ( s == NULL ) 
    220   s = localstream; 
    221  
    222  if ( con == NULL ) { 
    223   roar_err_set(ROAR_ERROR_FAULT); 
    224   return -1; 
    225  } 
    226  
    227  if ( file == NULL ) { 
    228   roar_err_set(ROAR_ERROR_FAULT); 
    229   return -1; 
    230  } 
    231  
    232  if ( exec && passfh ) { 
    233   roar_err_set(ROAR_ERROR_INVAL); 
    234   return -1; 
    235  } 
    236  
    237 #ifdef ROAR_TARGET_WIN32 
    238  if ( (in = open(file, O_RDONLY|O_BINARY, 0644)) == -1 ) { 
    239 #else 
    240  if ( (in = open(file, O_RDONLY, 0644)) == -1 ) { 
    241 #endif 
    242   roar_err_from_errno(); 
    243   return -1; 
    244  } 
    245  
    246  if ((len = read(in, buf, BUFFERSIZE)) < 1) { 
    247   roar_err_from_errno(); 
    248   close(in); 
    249   return -1; 
    250  } 
    251  
    252  codec = roar_file_codecdetect(buf, len); 
    253  
    254  ROAR_DBG("roar_file_play_full(*): codec=%i(%s)", codec, roar_codec2str(codec)); 
    255  
    256  seek = lseek(in, 0, SEEK_SET) == (off_t) -1 ? 0 : 1; 
    257  
    258  if ( codec == -1 ) { 
    259   ROAR_WARN("roar_file_play_full(*): Unknown codec of file: %s", file); 
    260   close(in); 
    261   roar_err_set(ROAR_ERROR_BADMAGIC); 
    262   return -1; 
    263  } 
    264  
    265  if ( passfh && !seek ) { 
    266   ROAR_WARN("roar_file_play_full(*): passfh on non seekable file: this may produce incorrect playback"); 
    267  } 
    268  
    269  if ( exec ) { 
    270   if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) { 
    271    ROAR_DBG("roar_file_play_full(*): Can not create new stream. This is realy BAD!"); 
    272    close(in); 
    273    return -1; 
    274   } 
    275  
    276   if ( roar_stream_connect2(con, s, ROAR_DIR_PLAY, -1) == -1 ) { 
    277    ROAR_DBG("roar_file_play_full(*): Can not connect new stream to server."); 
    278    close(in); 
    279    return -1; 
    280   } 
    281  
    282   if ( roar_stream_exec(con, s) == -1 ) { 
    283    ROAR_DBG("roar_file_play_full(*): Can not exec new stream on server."); 
    284    close(in); 
    285    return -1; 
    286   } 
    287  
    288   roar_libroar_nowarn(); 
    289   if ( (out = roar_get_connection_fh(con)) == -1 ) { 
    290    ROAR_DBG("roar_file_play_full(*): Can not get socket of server connection for exec data transmition."); 
    291    close(in); 
    292    roar_libroar_warn(); 
    293    return -1; 
    294   } 
    295   roar_libroar_warn(); 
    296  
    297   ROAR_SHUTDOWN(out, SHUT_RD); 
    298  } else { 
    299   if ( !(passfh && seek) ) { 
    300    if ( (out = roar_simple_new_stream_obj(con, s, rate, channels, bits, codec, ROAR_DIR_PLAY)) == -1 ) { 
    301     close(in); 
    302     return -1; 
    303    } 
    304   } else { 
    305    if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) { 
    306     close(in); 
    307     return -1; 
    308    } 
    309  
    310    if ( roar_stream_connect2(con, s, ROAR_DIR_PLAY, -1) == -1 ) { 
    311     close(in); 
    312     return -1; 
    313    } 
    314   } 
    315  } 
    316  
    317  if ( !seek ) 
    318   ROAR_NETWORK_WRITE(out, buf, len); 
    319  
    320  if ( !passfh ) { 
    321 #ifndef ROAR_TARGET_WIN32 
    322   r = roar_file_send_raw(out, in); 
    323  
    324   close(out); 
    325 #else 
    326  while ((len = read(in, buf, BUFFERSIZE)) > 0) 
    327   if ( send(out, buf, len, 0) != len ) 
    328    break; 
    329  
    330  closesocket(out); 
    331 #endif 
    332  
    333   if ( exec ) { 
    334    // TODO: FIXME: this ma cause a memory leak in future 
    335    // OLD: con->fh = -1; 
    336    roar_connect_fh(con, -2); 
    337   } 
    338  
    339   close(in); 
    340  } else { 
    341   if ( roar_stream_passfh(con, s, in) == -1 ) { 
    342    return -1; 
    343   } 
    344   close(out); 
    345   close(in); 
    346   return 0; 
    347  } 
    348  
    349  return r; 
    350 #else 
    351  roar_err_set(ROAR_ERROR_NOSYS); 
    352  return -1; 
    353 #endif 
    354 } 
    355  
    356200char  * roar_cdromdevice     (void) { 
    357201 char * k; 
  • libroaryiff/playback.c

    r4708 r5221  
    3636#include <libroaryiff.h> 
    3737 
     38#define BUFFERSIZE  8192 
     39 
     40#ifdef ROAR_HAVE_IO_POSIX 
     41#define _CAN_OPERATE 
     42#endif 
     43 
    3844YID YStartPlaySoundObjectSimple (YConnection *con, const char *path) { 
    3945 return YStartPlaySoundObject(con, path, NULL); 
     46} 
     47 
     48static inline ssize_t _file_play  (struct roar_connection * con, const char * file, struct roar_stream * s) { 
     49#ifdef _CAN_OPERATE 
     50 int codec = -1; 
     51 int in, out = -1; 
     52 ssize_t r = 0; 
     53 int seek; 
     54 int len; 
     55 char buf[BUFFERSIZE]; 
     56 int rate = ROAR_RATE_DEFAULT, channels = ROAR_CHANNELS_DEFAULT, bits = ROAR_BITS_DEFAULT; 
     57 
     58 // FIXME: check error cases 
     59 
     60 ROAR_DBG("roar_file_play_full(*) = ?"); 
     61 
     62#ifdef ROAR_TARGET_WIN32 
     63 if ( (in = open(file, O_RDONLY|O_BINARY, 0644)) == -1 ) { 
     64#else 
     65 if ( (in = open(file, O_RDONLY, 0644)) == -1 ) { 
     66#endif 
     67  roar_err_from_errno(); 
     68  return -1; 
     69 } 
     70 
     71 if ((len = read(in, buf, BUFFERSIZE)) < 1) { 
     72  roar_err_from_errno(); 
     73  close(in); 
     74  return -1; 
     75 } 
     76 
     77 codec = roar_file_codecdetect(buf, len); 
     78 
     79 ROAR_DBG("roar_file_play_full(*): codec=%i(%s)", codec, roar_codec2str(codec)); 
     80 
     81 seek = lseek(in, 0, SEEK_SET) == (off_t) -1 ? 0 : 1; 
     82 
     83 if ( codec == -1 ) { 
     84  ROAR_WARN("roar_file_play_full(*): Unknown codec of file: %s", file); 
     85  close(in); 
     86  roar_err_set(ROAR_ERROR_BADMAGIC); 
     87  return -1; 
     88 } 
     89 
     90 if ( !seek ) { 
     91  ROAR_WARN("roar_file_play_full(*): passfh on non seekable file: this may produce incorrect playback"); 
     92  close(in); 
     93  roar_err_set(ROAR_ERROR_NOSEEK); 
     94  return -1; 
     95 } 
     96 
     97 if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) { 
     98  close(in); 
     99  return -1; 
     100 } 
     101 
     102 if ( roar_stream_connect2(con, s, ROAR_DIR_PLAY, -1) == -1 ) { 
     103  close(in); 
     104  return -1; 
     105 } 
     106 
     107 if ( roar_stream_passfh(con, s, in) == -1 ) { 
     108  close(in); 
     109  roar_kick(con, ROAR_OT_STREAM, roar_stream_get_id(s)); 
     110  return -1; 
     111 } 
     112 
     113 close(out); 
     114 close(in); 
     115 return 0; 
     116 
     117 return r; 
     118#else 
     119 roar_err_set(ROAR_ERROR_NOSYS); 
     120 return -1; 
     121#endif 
    40122} 
    41123 
     
    44126 struct roar_stream     stream[1]; 
    45127 
    46  if ( !con ) 
     128 if ( con == NULL ) 
    47129  return YIDNULL; 
    48130 
    49  if ( !path ) 
     131 if ( path == NULL ) 
    50132  return YIDNULL; 
    51133 
     
    56138 // in background 
    57139 
    58  if ( roar_file_play_full(&rcon, (char*)path, 0, 1, stream) == -1 ) { 
     140 if ( _file_play(&rcon, path, stream) == -1 ) { 
    59141  ROAR_ERR("Can not start playback"); 
    60142  return YIDNULL; 
  • roarclients/roarcatplay.c

    r5109 r5221  
    3535 printf("  --server SERVER    - Set server hostname\n" 
    3636        "  --simple           - Use the simple interface (default)\n" 
    37         "  --passive          - Use passiv playback (experimental, works only localy)\n" 
    38         "  --background       - Use background playback, impleys passive mode\n" 
    3937        "  --verbose          - Use verbose output\n" 
    4038        "  --help             - Show this help\n" 
     
    4341} 
    4442 
    45 #define MODE_SIMPLE  1 
    46 #define MODE_PASSIVE 2 
    47  
    4843int main (int argc, char * argv[]) { 
    4944 char * server   = NULL; 
     
    5146 int    i; 
    5247 char * file    = NULL; 
    53  int    mode    = MODE_SIMPLE; 
    54  int    bg      = 0; 
    5548 int    verbose = 0; 
    5649 roar_vs_t * vss; 
    5750 int err; 
    58 #ifdef ROAR_HAVE_UNIX 
    59  struct roar_connection con[1]; 
    60  struct roar_stream     stream[1]; 
    61 #endif 
    6251 
    6352 for (i = 1; i < argc; i++) { 
     
    6756   server = argv[++i]; 
    6857  } else if ( strcmp(k, "--simple") == 0 ) { 
    69    mode = MODE_SIMPLE; 
    70   } else if ( strcmp(k, "--passive") == 0 ) { 
    71    mode = MODE_PASSIVE; 
    72   } else if ( strcmp(k, "--background") == 0 ) { 
    73    bg = 1; 
     58   /* no op */ 
    7459  } else if ( strcmp(k, "--verbose") == 0 || strcmp(k, "-v") == 0 ) { 
    7560   verbose++; 
     
    8671 } 
    8772 
    88  if ( bg ) 
    89   mode = MODE_PASSIVE; 
    90  
    91 #ifndef ROAR_HAVE_UNIX 
    92  if ( mode == MODE_PASSIVE ) { 
    93   fprintf(stderr, "Error: passive mode is not supported on this system.\n"); 
    94   return 1; 
    95  } 
    96 #endif 
    97  
    98  if ( mode == MODE_PASSIVE ) { 
    99   fprintf(stderr, "Warning: passive mode is obsoleted and will be removed soon.\n"); 
    100  } 
    101  
    10273 if ( file == NULL ) 
    10374  file = "/dev/stdin"; 
    10475 
    105 #ifdef ROAR_HAVE_UNIX 
    106  if ( mode == MODE_PASSIVE ) { 
    107   if ( roar_simple_connect(con, server, "roarcatplay") == -1 ) { 
    108    ROAR_ERR("Can not connect to server"); 
    109    return 0; 
    110   } 
    111  
    112   if ( roar_file_play_full(con, file, 0, 1, stream) == -1 ) { 
    113    ROAR_ERR("Can not start playback"); 
    114    return 1; 
    115   } 
    116  
    117   if ( bg ) { 
    118    if ( roar_stream_attach_simple(con, stream, 0) == -1 ) { 
    119     ROAR_ERR("Can not attach stream to server"); 
    120    } 
    121   } else { 
    122    roar_sleep(10); 
    123   } 
    124  
    125   roar_disconnect(con); 
    126  
    127  } else { // MODE_SIMPLE 
    128 #endif 
    129   if ( (vss = roar_vs_new_from_file(server, "roarcatplay", file, &err)) == NULL ) { 
    130    ROAR_ERR("Can not start playback: %s", roar_error2str(err)); 
    131    return 1; 
    132   } 
    133   roar_vs_run(vss, NULL); 
    134   roar_vs_sync(vss, ROAR_VS_WAIT, NULL); 
    135   roar_vs_close(vss, ROAR_VS_FALSE, NULL); 
    136 #ifdef ROAR_HAVE_UNIX 
     76 if ( (vss = roar_vs_new_from_file(server, "roarcatplay", file, &err)) == NULL ) { 
     77  ROAR_ERR("Can not start playback: %s", roar_error2str(err)); 
     78  return 1; 
    13779 } 
    138 #endif 
     80 roar_vs_run(vss, NULL); 
     81 roar_vs_sync(vss, ROAR_VS_WAIT, NULL); 
     82 roar_vs_close(vss, ROAR_VS_FALSE, NULL); 
    13983 
    14084 return 0; 
Note: See TracChangeset for help on using the changeset viewer.