Re: [Alsa-user] USB Synchronization w/ALSA via g_audio
Rob wrote: > I am capturing data from my microphone, and transmitting it via > pcm_write() to the USB gadget card, and arecording on the USB host. > If I query the buffer, I begin to see a creeping fill on the device > side buffers, such that after a few hours of constant streaming, the > buffer is filled, and my pcm_write is returning "we only wrote SOME > of your data". The ALSA API was designed for 'normal' sound cards where only the hardware itself can control the sample clock. This means that the USB audio gadget does not give you control over its clock, and that samples are moved synchronously with the USB bus clock. You'd have to measure the clock difference, and dynamically resample the stream. (Zita-ajbridge does something like this.) Alternatively, it might be possible to extend the audio gadget driver to add a mechanism to slightly adjust the sample rate, relative to the bus clock. Regards, Clemens -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot ___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
Re: [Alsa-user] USB Synchronization w/ALSA via g_audio
Hi Chris, My goal is a low latency USB microphone that's always on; similar to an intercom system. I am capturing data from my microphone, and transmitting it via pcm_write() to the USB gadget card, and arecording on the USB host. If I query the buffer, I begin to see a creeping fill on the device side buffers, such that after a few hours of constant streaming, the buffer is filled, and my pcm_write is returning "we only wrote SOME of your data". As this happens, I start to notice more and more latency between my device's capture and the host's playback, as I eventually have a whole buffer's worth of "old" audio I'm queuing "now's audio" data behind. If I modify the UAC driver to provide a larger buffer size, my pcm_write of "not a full buffer" takes longer to happen, but when it does, my latency has gone from unnoticeable to several seconds. I figured (and may very well be wrong), that this was due to my device clocks sending buffers at a rate *slightly* faster than the USB is able to sink it to the host. Could this be something else? Thanks, Rob On Thu, Jul 12, 2018 at 8:13 PM, chris hermansen wrote: > Rob and list, > > On Thu, Jul 12, 2018, 19:27 Rob wrote: > >> Hi all, >> >> I'm reading about the feedback mechanism for USB audio. I'm trying to see >> if I can implement asynchronous mode. >> > > What makes you think asynchronous mode isn't already implemented? > > Chris Hermansen > -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user
Re: [Alsa-user] USB Synchronization w/ALSA via g_audio
Rob and list, On Thu, Jul 12, 2018, 19:27 Rob wrote: > Hi all, > > I'm reading about the feedback mechanism for USB audio. I'm trying to see > if I can implement asynchronous mode. > What makes you think asynchronous mode isn't already implemented? Chris Hermansen -- Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot___ Alsa-user mailing list Alsa-user@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/alsa-user