alsa: avoid division by 0
After we se the format, we negotiate the buffer size and period size. When this fails, the period_size can be 0. Handle this case without causing a floating point exception.
This commit is contained in:
parent
d2cd65b6e2
commit
318d82e14f
|
@ -47,7 +47,8 @@ static void emit_node_info(struct state *this, bool full)
|
|||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_MAX_LATENCY, latency);
|
||||
snprintf(period, sizeof(period), "%lu", this->period_frames);
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT("api.alsa.period-size", period);
|
||||
snprintf(nperiods, sizeof(nperiods), "%lu", this->buffer_frames / this->period_frames);
|
||||
snprintf(nperiods, sizeof(nperiods), "%lu",
|
||||
this->period_frames != 0 ? this->buffer_frames / this->period_frames : 0);
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT("api.alsa.period-num", nperiods);
|
||||
snprintf(headroom, sizeof(headroom), "%u", this->headroom);
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT("api.alsa.headroom", headroom);
|
||||
|
|
|
@ -49,7 +49,8 @@ static void emit_node_info(struct state *this, bool full)
|
|||
items[n_items++] = SPA_DICT_ITEM_INIT(SPA_KEY_NODE_MAX_LATENCY, latency);
|
||||
snprintf(period, sizeof(period), "%lu", this->period_frames);
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT("api.alsa.period-size", period);
|
||||
snprintf(nperiods, sizeof(nperiods), "%lu", this->buffer_frames / this->period_frames);
|
||||
snprintf(nperiods, sizeof(nperiods), "%lu",
|
||||
this->period_frames != 0 ? this->buffer_frames / this->period_frames : 0);
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT("api.alsa.period-num", nperiods);
|
||||
snprintf(headroom, sizeof(headroom), "%u", this->headroom);
|
||||
items[n_items++] = SPA_DICT_ITEM_INIT("api.alsa.headroom", headroom);
|
||||
|
|
Loading…
Reference in New Issue