static size_t httpd_output_play(void *data, const void *chunk, size_t size, GError **error) { struct httpd_output *httpd = data; bool has_clients; g_mutex_lock(httpd->mutex); has_clients = httpd->clients != NULL; g_mutex_unlock(httpd->mutex); if (has_clients) { bool success; success = httpd_output_encode_and_play(httpd, chunk, size, error); if (!success) return 0; } if (!httpd->timer->started) timer_start(httpd->timer); else timer_sync(httpd->timer); timer_add(httpd->timer, size); return size; }
static size_t httpd_output_play(struct audio_output *ao, const void *chunk, size_t size, GError **error_r) { struct httpd_output *httpd = (struct httpd_output *)ao; if (httpd_output_lock_has_clients(httpd)) { if (!httpd_output_encode_and_play(httpd, chunk, size, error_r)) return 0; } if (!httpd->timer->started) timer_start(httpd->timer); timer_add(httpd->timer, size); return size; }