/* main client write routine for sending ogg data. Each refbuf has a * single page so we only need to determine if there are new headers */ static int write_buf_to_client (client_t *client) { refbuf_t *refbuf = client->refbuf; char *buf = refbuf->data + client->pos; unsigned len = refbuf->len - client->pos; struct ogg_client *client_data = client->format_data; int ret, written = 0; do { if (client_data->headers != refbuf->associated) { ret = send_ogg_headers (client, refbuf->associated); if (ret > 0) written += ret; if (client_data->headers_sent == 0) break; } ret = client_send_bytes (client, buf, len); if (ret > 0) { client->pos += ret; client->queue_pos += ret; written += ret; client->counter += ret; } if (ret < (int)len) client->schedule_ms += 50; } while (0); return written ? written : -1; }
/* main client write routine for sending ogg data. Each refbuf has a * single page so we only need to determine if there are new headers */ static int write_buf_to_client (client_t *client) { refbuf_t *refbuf = client->refbuf; char *buf = refbuf->data + client->pos; unsigned len = refbuf->len - client->pos; struct ogg_client *client_data = client->format_data; int ret, written = 0; do { if (client_data->headers != refbuf->associated) { ret = send_ogg_headers (client, refbuf->associated); if (client_data->headers_sent == 0) break; written += ret; } ret = client_send_bytes (client, buf, len); if (ret > 0) client->pos += ret; if (ret < (int)len) break; written += ret; /* we have now written the page(s) */ ret = 0; } while (0); if (ret > 0) written += ret; return written; }