[398] | 1 | //simple.c: |
---|
| 2 | |
---|
| 3 | #include <libroarpulse/libroarpulse.h> |
---|
| 4 | |
---|
[402] | 5 | /** Create a new connection to the server */ |
---|
| 6 | pa_simple* pa_simple_new( |
---|
| 7 | const char *server, /**< Server name, or NULL for default */ |
---|
| 8 | const char *name, /**< A descriptive name for this client (application name, ...) */ |
---|
| 9 | pa_stream_direction_t dir, /**< Open this stream for recording or playback? */ |
---|
| 10 | const char *dev, /**< Sink (resp. source) name, or NULL for default */ |
---|
| 11 | const char *stream_name, /**< A descriptive name for this client (application name, song title, ...) */ |
---|
| 12 | const pa_sample_spec *ss, /**< The sample type to use */ |
---|
| 13 | const pa_channel_map *map, /**< The channel map to use, or NULL for default */ |
---|
| 14 | const pa_buffer_attr *attr, /**< Buffering attributes, or NULL for default */ |
---|
| 15 | int *error /**< A pointer where the error code is stored when the routine returns NULL. It is OK to pass NULL here. */ |
---|
| 16 | ) { |
---|
| 17 | return NULL; |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | /** Close and free the connection to the server. The connection objects becomes invalid when this is called. */ |
---|
| 21 | void pa_simple_free(pa_simple *s) { |
---|
[404] | 22 | struct roarpulse_simple * ss = (struct roarpulse_simple*) s; |
---|
| 23 | if ( !s ) |
---|
| 24 | return; |
---|
| 25 | |
---|
[405] | 26 | close(ss->data_fh); |
---|
| 27 | |
---|
[404] | 28 | free(s); |
---|
[402] | 29 | } |
---|
| 30 | |
---|
| 31 | /** Write some data to the server */ |
---|
| 32 | int pa_simple_write(pa_simple *s, const void*data, size_t length, int *error) { |
---|
[404] | 33 | struct roarpulse_simple * ss = (struct roarpulse_simple*) s; |
---|
| 34 | if ( !s ) |
---|
| 35 | return -1; |
---|
| 36 | |
---|
[405] | 37 | return read(ss->data_fh, (char*) data, length); |
---|
[402] | 38 | } |
---|
| 39 | |
---|
| 40 | /** Wait until all data already written is played by the daemon */ |
---|
| 41 | int pa_simple_drain(pa_simple *s, int *error) { |
---|
[405] | 42 | // struct roarpulse_simple * ss = (struct roarpulse_simple*) s; |
---|
[404] | 43 | if ( !s ) |
---|
| 44 | return -1; |
---|
| 45 | |
---|
[405] | 46 | pa_simple_flush(s, NULL); |
---|
| 47 | |
---|
[402] | 48 | return -1; |
---|
| 49 | } |
---|
| 50 | |
---|
| 51 | /** Read some data from the server */ |
---|
| 52 | int pa_simple_read(pa_simple *s, void*data, size_t length, int *error) { |
---|
[404] | 53 | struct roarpulse_simple * ss = (struct roarpulse_simple*) s; |
---|
| 54 | if ( !s ) |
---|
| 55 | return -1; |
---|
| 56 | |
---|
[405] | 57 | return read(ss->data_fh, data, length); |
---|
[402] | 58 | } |
---|
| 59 | |
---|
| 60 | /** Return the playback latency. \since 0.5 */ |
---|
| 61 | pa_usec_t pa_simple_get_latency(pa_simple *s, int *error) { |
---|
[404] | 62 | struct roarpulse_simple * ss = (struct roarpulse_simple*) s; |
---|
| 63 | if ( !s ) |
---|
| 64 | return -1; |
---|
| 65 | |
---|
[402] | 66 | return -1; |
---|
| 67 | } |
---|
| 68 | |
---|
| 69 | /** Flush the playback buffer. \since 0.5 */ |
---|
| 70 | int pa_simple_flush(pa_simple *s, int *error) { |
---|
[404] | 71 | struct roarpulse_simple * ss = (struct roarpulse_simple*) s; |
---|
| 72 | if ( !s ) |
---|
| 73 | return -1; |
---|
| 74 | |
---|
| 75 | return fdatasync(ss->data_fh); |
---|
[402] | 76 | } |
---|
| 77 | |
---|
[398] | 78 | //ll |
---|