Changeset 4492:150839188b8a in roaraudio


Ignore:
Timestamp:
10/12/10 04:42:11 (8 years ago)
Author:
phi
Branch:
default
Tags:
driver_example
Message:

implemented some jack stuff

Location:
roard
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • roard/driver_jack.c

    r4491 r4492  
    3232                           int fh, 
    3333                           struct roar_stream_server * sstream) { 
     34 struct driver_jack * self; 
    3435 
    3536 // we are not FH Safe, return error if fh != -1: 
     
    3738  return -1; 
    3839 
     40 // set up VIO: 
     41 memset(inst, 0, sizeof(struct roar_vio_calls)); 
     42 
     43 inst->read     = driver_jack_read; 
     44 inst->write    = driver_jack_write; 
     45 inst->lseek    = NULL; // no seeking on this device 
     46 inst->nonblock = driver_jack_nonblock; 
     47 inst->sync     = driver_jack_sync; 
     48 inst->ctl      = driver_jack_ctl; 
     49 inst->close    = driver_jack_close; 
     50 
     51 // set up internal struct: 
     52 if ( (self = roar_mm_malloc(sizeof(struct driver_jack))) == NULL ) 
     53  return -1; 
     54 
     55 memset(self, 0, sizeof(struct driver_jack)); 
     56 
     57 inst->inst     = self; 
     58 
     59 // return -1 on error or 0 on no error. 
    3960 return -1; 
    4061} 
     62 
     63ssize_t driver_jack_read    (struct roar_vio_calls * vio, void *buf, size_t count) { 
     64 struct driver_jack * self = vio->inst; 
     65 // read up to count bytes into buf. 
     66 // return the number of bits read. 
     67 return -1; 
     68} 
     69 
     70ssize_t driver_jack_write   (struct roar_vio_calls * vio, void *buf, size_t count) { 
     71 struct driver_jack * self = vio->inst; 
     72 // write up to count bytes from buf. 
     73 // return the number of written bytes. 
     74 return -1; 
     75} 
     76 
     77int     driver_jack_nonblock(struct roar_vio_calls * vio, int state) { 
     78 struct driver_jack * self = vio->inst; 
     79 // control if read and write calls should block untill all data is read or written. 
     80 // state could be: 
     81 //  ROAR_SOCKET_BLOCK    - Block untill the data is read or written 
     82 //  ROAR_SOCKET_NONBLOCK - Return as soon as possible 
     83 return -1; 
     84} 
     85 
     86int     driver_jack_sync    (struct roar_vio_calls * vio) { 
     87 struct driver_jack * self = vio->inst; 
     88 // init to sync data to device. 
     89 // sync does not need to be complet when this function returns. 
     90 return 0; 
     91} 
     92 
     93int     driver_jack_ctl     (struct roar_vio_calls * vio, int cmd, void * data) { 
     94 struct driver_jack * self = vio->inst; 
     95 // function for a lot control features. 
     96 
     97 switch (cmd) { 
     98  case ROAR_VIO_CTL_GET_NAME: 
     99    if ( data == NULL ) 
     100     return -1; 
     101 
     102    *(char**)data = "driver_jack"; 
     103    return 0; 
     104   break; 
     105  case ROAR_VIO_CTL_GET_FH: 
     106  case ROAR_VIO_CTL_GET_READ_FH: 
     107  case ROAR_VIO_CTL_GET_WRITE_FH: 
     108  case ROAR_VIO_CTL_GET_SELECT_FH: 
     109  case ROAR_VIO_CTL_GET_SELECT_READ_FH: 
     110  case ROAR_VIO_CTL_GET_SELECT_WRITE_FH: 
     111/* Return FH if possible: 
     112    *(int*)data = FH...; 
     113*/ 
     114    return -1; 
     115   break; 
     116  case ROAR_VIO_CTL_SET_NOSYNC: 
     117    vio->sync = NULL; 
     118    return 0; 
     119   break; 
     120   case ROAR_VIO_CTL_GET_AUINFO: 
     121   case ROAR_VIO_CTL_SET_AUINFO: 
     122    // get or set audio info, data is a struct roar_audio_info*. 
     123    return -1; 
     124   break; 
     125   case ROAR_VIO_CTL_GET_DBLKSIZE: 
     126   case ROAR_VIO_CTL_SET_DBLKSIZE: 
     127     // get or set block size used, data is uint_least32_t*, number of bytes. 
     128    return -1; 
     129   break; 
     130   case ROAR_VIO_CTL_GET_DBLOCKS: 
     131   case ROAR_VIO_CTL_SET_DBLOCKS: 
     132     // get or set number of blocks used, data is uint_least32_t*. 
     133    return -1; 
     134   break; 
     135   case ROAR_VIO_CTL_SET_SSTREAM: 
     136    // set server stream object for this stream, data is struct roar_stream_server* 
     137    return -1; 
     138   break; 
     139   case ROAR_VIO_CTL_SET_SSTREAMID: 
     140    // set stream ID for this stream, data is int* 
     141    return -1; 
     142   break; 
     143   case ROAR_VIO_CTL_SET_VOLUME: 
     144    // set volume for this device, data is struct roar_mixer_settings* 
     145    return -1; 
     146   break; 
     147   case ROAR_VIO_CTL_GET_DELAY: 
     148    // get delay of this stream, data is uint_least32_t*, in bytes 
     149    // there is more about delay. please ask. 
     150    return -1; 
     151   break; 
     152  default: 
     153    return -1; 
     154   break; 
     155 } 
     156} 
     157 
     158int     driver_jack_close   (struct roar_vio_calls * vio) { 
     159 struct driver_jack * self = vio->inst; 
     160 // close and free everything in here... 
     161 
     162 roar_mm_free(self); 
     163 
     164 return 0; 
     165} 
     166 
    41167#endif 
    42168 
  • roard/include/driver_jack.h

    r4490 r4492  
    2727#define _DRIVER_JACK_H_ 
    2828 
     29struct driver_jack { 
     30 jack_client_t * client; 
     31}; 
     32 
    2933int driver_jack_open_vio  (struct roar_vio_calls * inst, char * device, struct roar_audio_info * info, int fh, struct roar_stream_server * sstream); 
     34 
     35ssize_t driver_jack_read    (struct roar_vio_calls * vio, void *buf, size_t count); 
     36ssize_t driver_jack_write   (struct roar_vio_calls * vio, void *buf, size_t count); 
     37int     driver_jack_nonblock(struct roar_vio_calls * vio, int state); 
     38int     driver_jack_sync    (struct roar_vio_calls * vio); 
     39int     driver_jack_ctl     (struct roar_vio_calls * vio, int cmd, void * data); 
     40int     driver_jack_close   (struct roar_vio_calls * vio); 
    3041 
    3142#endif 
Note: See TracChangeset for help on using the changeset viewer.