FreeCalypso > hg > themwi-rtp-lib
diff src/twjit.c @ 15:355de6301404
twjit: simplify create API, factor out clock & quantum config
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 06 Jul 2024 21:31:16 +0000 |
parents | 95f6c8ce33b0 |
children | 58e9719d1a84 |
line wrap: on
line diff
--- a/src/twjit.c Sat Jul 06 17:32:26 2024 +0000 +++ b/src/twjit.c Sat Jul 06 21:31:16 2024 +0000 @@ -25,8 +25,7 @@ /* create and destroy functions */ struct twrtp_jibuf_inst * -twrtp_jibuf_create(void *ctx, uint16_t quantum_ms, uint16_t clock_khz, - struct twrtp_jibuf_config *config) +twrtp_jibuf_create(void *ctx, struct twrtp_jibuf_config *config) { struct twrtp_jibuf_inst *twjit; @@ -35,14 +34,11 @@ return NULL; twjit->ext_config = config; - twjit->ts_quantum = (uint32_t)quantum_ms * clock_khz; - twjit->quanta_per_sec = 1000 / quantum_ms; - twjit->ts_units_per_ms = clock_khz; - twjit->ts_units_per_sec = (uint32_t) clock_khz * 1000; - twjit->ns_to_ts_units = 1000000 / clock_khz; twjit->state = TWJIT_STATE_EMPTY; INIT_LLIST_HEAD(&twjit->sb[0].queue); INIT_LLIST_HEAD(&twjit->sb[1].queue); + /* default of 8 kHz clock, 20 ms quantum */ + twrtp_jibuf_set_ts_quant(twjit, 8, 20); return twjit; } @@ -53,3 +49,15 @@ msgb_queue_free(&twjit->sb[1].queue); talloc_free(twjit); } + +/* basic housekeeping */ + +void twrtp_jibuf_set_ts_quant(struct twrtp_jibuf_inst *twjit, + uint16_t clock_khz, uint16_t quantum_ms) +{ + twjit->ts_quantum = (uint32_t) quantum_ms * clock_khz; + twjit->quanta_per_sec = 1000 / quantum_ms; + twjit->ts_units_per_ms = clock_khz; + twjit->ts_units_per_sec = (uint32_t) clock_khz * 1000; + twjit->ns_to_ts_units = 1000000 / clock_khz; +}