diff --git a/spa/plugins/alsa/alsa-pcm-sink.c b/spa/plugins/alsa/alsa-pcm-sink.c index 639fd46d9..249d5db4a 100644 --- a/spa/plugins/alsa/alsa-pcm-sink.c +++ b/spa/plugins/alsa/alsa-pcm-sink.c @@ -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); diff --git a/spa/plugins/alsa/alsa-pcm-source.c b/spa/plugins/alsa/alsa-pcm-source.c index 59cdaae0f..2867c901a 100644 --- a/spa/plugins/alsa/alsa-pcm-source.c +++ b/spa/plugins/alsa/alsa-pcm-source.c @@ -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);