roaraudio
init
Rev | Line | |
---|
[0] | 1 | //loop.c: |
---|
| 2 | |
---|
| 3 | #include "roard.h" |
---|
| 4 | |
---|
| 5 | int main_loop (int driver, DRIVER_USERDATA_T driver_inst, struct roar_audio_info * sa) { |
---|
| 6 | void ** streams_input = NULL; |
---|
| 7 | uint32_t pos = 0; |
---|
| 8 | |
---|
| 9 | ROAR_DBG("main_loop(*) = ?"); |
---|
| 10 | alive = 1; |
---|
| 11 | |
---|
| 12 | while (alive) { |
---|
| 13 | ROAR_DBG("main_loop(*): looping..."); |
---|
| 14 | |
---|
| 15 | ROAR_DBG("main_loop(*): check for new clients..."); |
---|
| 16 | net_check_listen(); |
---|
| 17 | |
---|
| 18 | ROAR_DBG("main_loop(*): check for new data..."); |
---|
| 19 | clients_check_all(); |
---|
| 20 | |
---|
| 21 | ROAR_DBG("main_loop(*): mixing clients..."); |
---|
| 22 | if ( g_standby ) { |
---|
| 23 | // while in standby we still neet to get the buffers to free input buffer space. |
---|
| 24 | streams_get_mixbuffers(&streams_input, sa, pos); |
---|
| 25 | } else { |
---|
| 26 | if ( streams_get_mixbuffers(&streams_input, sa, pos) == 0 ) { |
---|
| 27 | mix_clients(g_output_buffer, sa->bits, streams_input, ROAR_OUTPUT_BUFFER_SAMPLES * sa->channels); |
---|
| 28 | } |
---|
| 29 | } |
---|
| 30 | |
---|
| 31 | /* |
---|
| 32 | // while in standby we still need to write out our buffer to not run in an endless loop without |
---|
| 33 | // a break |
---|
| 34 | */ |
---|
| 35 | |
---|
| 36 | if ( g_standby ) { |
---|
| 37 | usleep((1000000 * ROAR_OUTPUT_BUFFER_SAMPLES) / sa->rate); |
---|
| 38 | } else { |
---|
| 39 | clients_send_filter(sa, pos); |
---|
| 40 | output_buffer_flush(driver_inst, driver); |
---|
| 41 | clients_send_mon(sa, pos); |
---|
| 42 | } |
---|
| 43 | // output_buffer_reinit(); |
---|
| 44 | |
---|
| 45 | pos = ROAR_MATH_OVERFLOW_ADD(pos, ROAR_OUTPUT_BUFFER_SAMPLES); |
---|
| 46 | ROAR_DBG("main_loop(*): current pos: %u", pos); |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | return -1; |
---|
| 50 | } |
---|
| 51 | |
---|
| 52 | //ll |
---|
Note: See
TracBrowser
for help on using the repository browser.