This makes it so period sizes are a power of 2, which in turns makes it
so the value set by `snd_pcm_sw_params_set_avail_min()` is also a power
of 2. This is inline with a suggestion by the ALSA documentation, and
seems to have an actual positive impact in practice with my testing as
well.
In order to get detailed information about a device, that is supported
formats, channels and sample rates, the PCM needs to be opened. This
can fail sometimes, in which case enumeration would previously just not
enumerate the device.
This is OK, but it creates issues. The first is that the enumerated
devices will not be consistent with what's reported by `aplay`. The
other is that when a hardware device is opened, iteration will not
include that device because it'll be opened in exclusive mode. This
creates a practical issue when trying to get the name of an already
opened device.
This commit makes it so that these devices will still be enumerated,
only they'll be missing detailed format, channels and rate information.
* A start threshold is no longer used meaning an explicit call to
snd_pcm_start() is required, which was happening already anyway.
* The stop threshold is no longer used.
* Stopping the playback side of device now drains it.
* Starting a device will now pre-fill the playback side with silence
before starting it which should hopefully avoid an immediate xrun.
This is intended to address the following issues:
- Stepping the device now correctly polls both the capture and
playback side in one call in duplex mode. Prior to this commit it
would wait separately for each side which was totally incorrect.
- The initialization process has been simplified and made more robust
when trying to initialize the default device.
More work still to be done.
This removes the dependency on querying the required input frame count
from the resampler. This should in turn enable future work to support
custom resamplers.
Public issue https://github.com/mackron/miniaudio/issues/965
This commit fixes a bug relating to nodes with a scheduled start/stop
time. Whether or not the node is considered started or stopped is being
incorrectly reported by `ma_node_get_state_by_time_range()`.
Another issue is fixed in `ma_node_read_pcm_frames()`, which is related
to the fix above, where the frame count can underflow thereby resulting
in a crash.
Public issue https://github.com/mackron/miniaudio/issues/969