On Tue, Sep 03, 2019 at 02:03:52PM -0300, Martin Pieuchot wrote: > On 18/08/19(Sun) 08:02, Alexandre Ratchov wrote: > > Currently the block size calculations are broken by design: the driver > > provides a round_blocksize() function which must retrun a valid block > > size in *bytes*. Unfortunately, since the driver doesn't know if it's > > called for the play or for the record block size, it's mathematically > > impossible to calculate the block size in all cases if play and record > > number of channels are different. As a consequence, there are > > half-working and weired hacks to find a usable block sizes. > > > > The diff below addresses this by adding two new driver functions, > > which are very simple to use: > > > > set_blksz() - calculate and set the block size in *frames*, it's > > necessarily common to play and recording directions no matter > > the number of channels, > > > > set_nblks() - calculate the number of blocks per buffer for the given > > direction. > > > > the diff below shows how to properly calculate the block size in > > azalia and uaudio. The plan is to convert all drivers from > > round_blocksize() to the new functions and to delete > > round_blocksize(). > > > > Why is this important? besides for removing ugly (and risky) hacks, we > > want all our drivers to support common block sizes in the 5ms-50ms > > range. This would allow to implement switching between audio devices: > > for instance, start playback on a USB device, unplug the cable and > > continue on azalia. > > While the cleanup in itself makes sense to me. I'm unsure if continuing > to play on a secondary audio device is what we want. Nowadays phones > seems to stop music players if an audio device is disconnected. > > Let's assume I'm in a hackathon hearing music via a USB device, if I > unplug it, accidentally or not, I'd find more logical that the player > stop instead of forcing the whole room to listen my music.
I totally agree, making this the default would be a mistake as it's against the "least surprise" principle. It seems practical in few specific cases though: for instance I use it to temporarilly connect a usb headset in order to answer a phone call in firefox without the need to restart sndiod and firefox and then call back the other person. > > OK? > > Diff is ok with me, if you think it makes sense to do this change anyway > :) > Sure, the change is very useful.
