[pulseaudio-discuss] Sample format spec with Linear 16bit 16kHz

Georg Chini georg at chini.tk
Sat Feb 10 21:12:47 UTC 2018


On 10.02.2018 02:11, Shinnosuke Suzuki wrote:
> Hi
>
>> PA 11.1 should work fine with your kernel and bluez version.
>
> Thank you, I’ll try that.
>
>>>> When you record from the BT headset, the BT headset is set to HSP/HFP.
>>>> This means that recording and playback stream are at 8kHz, not 16kHz.
>
> I want to handle voice packet as Linear 16bit little endian 16000Hz,
> I configure stream as follows.
>   static pa_sample_spec samplespec = {
>       .format = PA_SAMPLE_S16LE, /* Linear 16bit */
>       .rate = 16000, /* 16000Hz */
>       .channels = 1 /* mono */
>   }
> Does it means .rate should be 8000?

It should work if you specify 16kHz because PA will do the resampling.
But I would try with 8kHz, just to see if something changes.
Did you try another source? Does parecord work with your headset?

>
>> You should not expect to get a fixed number of bytes in a fixed time
>> interval. This is only true on average but not for a single callback. Are
>> the 96 bytes an average value?
>> If your application needs constant size data packets, you may have to
>> buffer some data.
>> Did you take a look at the pacat code to see how reading data from
>> a stream is done correctly?
>
> I don’t expect fixed number of bytes. So, I implemented to  buffer 
> voice packets in read callback.
> However I got voice packet on my callback at 96 bytes per 10ms constantly.
> It means I couldn’t get sufficient voice packet because voice packet 
> needs
> at least 320bytes per 10ms in case of Linear 16bit little endian 16000Hz.
>
> I read pacat how to handle voice packet in read callback.
> I implemented like pacat except silence hole using pa_silence_memory().

Sorry, currently I have no idea what goes wrong. The number of 96 bytes 
/ 10ms
sounds weird and does not match any of the involved sample rates / formats.
Is your code available somewhere so that I can take a look?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20180210/84b09c4a/attachment-0001.html>


More information about the pulseaudio-discuss mailing list