Changeset 5296:b7fd2c45243e in roaraudio


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

Updated connection object. (Closes: #188)

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5295 r5296  
    11v. 1.0beta0 - ? 
    2         * Updated API (SONAME change) (Closes: #184, #185, #128, #135, #134, #133, #129) 
     2        * Updated API (SONAME change) (Closes: #184, #185, #128, #135, #134, #133, #129, #188) 
    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) 
  • doc/man3/roar_disconnect.3

    r5032 r5296  
    11.\" roar_simple_play.3: 
    22 
    3 .TH "roar_disconnect" "3" "May 2011" "RoarAudio" "System Manager's Manual: RoarAudio" 
     3.TH "roar_connectionref" "3" "May 2011" "RoarAudio" "System Manager's Manual: RoarAudio" 
    44 
    55.SH NAME 
    6 roar_disconnect \- disconnect from RoarAudio's sound server 
     6roar_connectionref, roar_connectionunref \- change reference counter for RoarAudio connections 
    77 
    88.SH SYNOPSIS 
     
    1010#include <roaraudio.h> 
    1111 
    12 int roar_disconnect(struct roar_connection * con); 
     12int roar_connectionref(struct roar_connection * con); 
     13 
     14int roar_connectionunref(struct roar_connection * con); 
     15 
     16#define roar_disconnect(x) roar_connectionunref((x)) 
    1317 
    1418.SH "DESCRIPTION" 
    15 Closes es connection previously opend via \fBBroar_simple_connect\fR(3) or \fBBroar_simple_connect2\fR(3). 
    16  
     19Those functions change the reference counter for connection objects 
     20previously opend via \fBroar_connect\fR(3), \fBroar_connect_fh\fR(3) or \fBroar_simple_connect\fR(3). 
     21If the reference counter hints zero the connection is closed and the object is destroyed. 
     22.PP 
     23The \fBroar_disconnect\fR(3) macro is provided to be source compatible (recompile needed) 
     24with RoarAudio 0.4 or older. 
    1725 
    1826.SH "PARAMETERS" 
    1927.TP 
    2028\fBcon\fR 
    21 The connection to be closed. 
     29The connection to be altered. 
    2230 
    2331.SH "RETURN VALUE" 
  • doc/symlinks.src

    r5083 r5296  
    2929roar_vs_latency                 3       roar_vs_position        3 
    3030roar_vs_latency2                3       roar_vs_position        3 
     31roar_connectionref              3       roar_disconnect         3 
     32roar_connectionunref            3       roar_disconnect         3 
  • include/libroar/basic.h

    r5270 r5296  
    4747#endif 
    4848 
    49 #define ROAR_CON_FLAGS_NONE        0x00 
    50 #define ROAR_CON_FLAGS_FH          0x01 /* obsoleted */ 
    51 #define ROAR_CON_FLAGS_VIO         0x02 /* mandatory */ 
    52 #define ROAR_CON_FLAGS_ISCLIENT    0x04 
    53 #define ROAR_CON_FLAGS_SUPPORT_V2  0x08 /* mandatory if con.version == 2 */ 
    54 #define ROAR_CON_FLAGS_SUPPORT_EF  0x10 /* Both peers support error frames */ 
     49#define ROAR_CON_FLAGS_NONE        0x00000000UL 
     50#define ROAR_CON_FLAGS_FH          0x00000001UL /* obsoleted */ 
     51#define ROAR_CON_FLAGS_VIO         0x00000002UL /* mandatory */ 
     52#define ROAR_CON_FLAGS_ISCLIENT    0x00000004UL 
     53#define ROAR_CON_FLAGS_SUPPORT_V2  0x00000008UL /* mandatory if con.version == 2 */ 
     54#define ROAR_CON_FLAGS_SUPPORT_EF  0x00000010UL /* Both peers support error frames */ 
     55#define ROAR_CON_FLAGS_FREESELF    0x00000020UL /* Free the connection object */ 
    5556 
    5657struct roar_message { 
     
    6768}; 
    6869 
     70struct roar_stds; // "caps.h" will be included later. 
     71 
    6972struct roar_connection { 
    7073 size_t refc; 
    7174 uint32_t flags; 
    7275 int version; 
    73  struct roar_vio_calls viocon; 
     76 struct roar_vio_calls * viocon; 
     77 struct roar_vio_calls   viocon_store; 
    7478 struct roar_error_frame errorframe; 
    7579 void * cb_userdata; 
    7680 void (*cb)(struct roar_connection * con, struct roar_message * mes, void * data, void * userdata); 
     81 struct roar_stds * server_stds; 
     82 char * server_name; 
    7783}; 
    7884 
     
    8490int roar_get_connection_fh  (struct roar_connection * con); 
    8591struct roar_vio_calls * roar_get_connection_vio2 (struct roar_connection * con); 
    86 int roar_disconnect   (struct roar_connection * con); 
     92const char * roar_get_connection_server(struct roar_connection * con); 
     93int roar_connectionref(struct roar_connection * con); 
     94int roar_connectionunref(struct roar_connection * con); 
     95#define roar_disconnect(x) roar_connectionunref((x)) 
    8796 
    8897int roar_set_connection_callback(struct roar_connection * con, 
  • libroar/basic.c

    r5267 r5296  
    262262int roar_connect     (struct roar_connection * con, const char * server, int flags, uint_least32_t timeout) { 
    263263 int fh; 
     264 int err; 
    264265 
    265266 if ( con == NULL ) { 
     
    274275  return -1; 
    275276 
    276  return roar_connect_fh(con, fh); 
     277 if ( roar_connect_fh(con, fh) == -1 ) { 
     278  err = roar_error; 
     279#ifdef ROAR_TARGET_WIN32 
     280  closesocket(fh); 
     281#else 
     282  close(fh); 
     283#endif 
     284  roar_error = err; 
     285  return -1; 
     286 } 
     287 
     288 if ( server != NULL ) { 
     289  con->server_name = roar_mm_strdup(server); 
     290 } 
     291 
     292 return 0; 
    277293} 
    278294 
     
    289305 
    290306 memset(con, 0, sizeof(struct roar_connection)); 
    291  con->refc        = 0; 
     307 con->refc        = 1; 
    292308 con->flags       = ROAR_CON_FLAGS_NONE; 
    293309 con->version     = 0; 
    294310 con->cb_userdata = NULL; 
    295311 con->cb          = NULL; 
     312 con->server_stds = NULL; 
     313 con->server_name = NULL; 
    296314 
    297315 roar_err_init(&(con->errorframe)); 
    298316 
    299  if ( roar_vio_open_fh_socket(&(con->viocon), fh) != -1 ) { 
     317 con->viocon = &(con->viocon_store); 
     318 
     319 if ( roar_vio_open_fh_socket(con->viocon, fh) != -1 ) { 
    300320  con->flags |= ROAR_CON_FLAGS_VIO; 
    301321 } 
     
    317337 ROAR_DBG("roar_get_connection_fh(con=%p) = ?", con); 
    318338 
    319  if ( roar_vio_ctl(&(con->viocon), ROAR_VIO_CTL_GET_FH, &fh) == -1 ) 
     339 if ( roar_vio_ctl(con->viocon, ROAR_VIO_CTL_GET_FH, &fh) == -1 ) 
    320340  return -1; 
    321341 
     
    330350 
    331351 if ( con->flags & ROAR_CON_FLAGS_VIO ) 
    332   return &(con->viocon); 
     352  return con->viocon; 
    333353 
    334354// TODO: try to open the VIO. 
     
    337357} 
    338358 
    339 int roar_disconnect (struct roar_connection * con) { 
     359const char * roar_get_connection_server(struct roar_connection * con) { 
     360 if ( con == NULL ) { 
     361  roar_err_set(ROAR_ERROR_FAULT); 
     362  return NULL; 
     363 } 
     364 
     365 return con->server_name; 
     366} 
     367 
     368int roar_connectionref(struct roar_connection * con) { 
     369 if ( con == NULL ) { 
     370  roar_err_set(ROAR_ERROR_FAULT); 
     371  return -1; 
     372 } 
     373 
     374 con->refc++; 
     375 
     376 return 0; 
     377} 
     378 
     379int roar_connectionunref(struct roar_connection * con) { 
    340380 struct roar_vio_calls * vio; 
    341381 struct roar_message m; 
     382 
     383 if ( con == NULL ) { 
     384  roar_err_set(ROAR_ERROR_FAULT); 
     385  return -1; 
     386 } 
     387 
     388 con->refc--; 
     389 
     390 if ( con->refc ) 
     391  return 0; 
    342392 
    343393 memset(&m, 0, sizeof(m)); 
     
    354404 } 
    355405 
    356  roar_connect_fh(con, -2); 
    357  
    358  roar_err_set(ROAR_ERROR_NONE); 
     406 if ( con->server_stds != NULL ) { 
     407  roar_stds_free(con->server_stds); 
     408  con->server_stds = NULL; 
     409 } 
     410 
     411 if ( con->server_name != NULL ) { 
     412  roar_mm_free(con->server_name); 
     413  con->server_name = NULL; 
     414 } 
     415 
     416 if ( con->flags & ROAR_CON_FLAGS_FREESELF ) { 
     417  roar_mm_free(con); 
     418 } else { 
     419  roar_connect_fh(con, -2); 
     420 } 
    359421 
    360422 return 0; 
  • libroar/simple.c

    r5289 r5296  
    120120 int fh; 
    121121 
    122  if ( (fh = roar_simple_stream_obj(s, rate, channels, bits, codec, NULL /* server, we hope this is ok here... */, 
     122 if ( (fh = roar_simple_stream_obj(s, rate, channels, bits, codec, roar_get_connection_server(con), 
    123123                                   dir, "libroar temp stream", mixer)) == -1 ) 
    124124  return -1; 
Note: See TracChangeset for help on using the changeset viewer.