Changeset 5221:aa6530a03260 in roaraudio for libroaryiff


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)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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; 
Note: See TracChangeset for help on using the changeset viewer.