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

Shinnosuke Suzuki suzukisn at gmail.com
Fri Feb 16 09:42:05 UTC 2018


Hi,

I updated pulseaudio  to 11.1.
However, this problem was not improved.

I tried to check 2 things.
1.I collect voice data from bluetooth headset using parec as follows:
 parec -r --rate=16000 --format=s16le --channels=1 > test.raw
 parec -r --rate=8000 --format=s16le --channels=1 > test.raw
 parec -r --rate=8000 --format=u8 --channels=1 > test.raw
 parec -r --rate=8000 --format=ulaw --channels=1 > test.raw

2.I tried to listen voice to bluetooth headset with pacat using each raw
file.
 pacat -p --rate=16000 --format=s16le --channels=1 < test.raw
 pacat -p --rate=8000 --format=s16le --channels=1 < test.raw
 pacat -p --rate=8000 --format=u8 --channels=1 < test.raw
 pacat -p --rate=8000 --format=ulaw --channels=1 < test.raw

I could collect voice packet with parec and listen voice with pacat, but
CPU load is extremely high.
80% for 1. and 40% for 2.
This means that CPU load exceed 100% when I handle both streams of
bluetooth headset.

Incidentally, my board's CPU spec is 300Mhz (420MIPS) single core MIPS
architecture.
Is it enough to handle voice packet with pulseaudio?
Is there any configuration to reduce CPU load?

Best Regards,
Shinnosuke Suzuki
2018-02-14 16:29 GMT+09:00 Shinnosuke Suzuki <suzukisn at gmail.com>:

> Hi
>
> Did you test other resample methods? There are quite a few available
> and "trivial" is definitely the worst of them.
>
> Although it maybe depend on CPU, Is there any recommend setting for
> resampling-method?
> Could you tell me a character for each parameters in resampling-method?
>
>
>> 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?
>>
>
> I attached source code to control pulseaudio.Could you take a look my code?
> start function
>  usbbtf_hs_start()
> read callback
>  usbbtf_hs_stream_read_cb()
>
> I got 96bytes voice data as a parameter of usbbtf_hs_stream_read_cb().
> So I didn't have a clue to find any hint on this code.
>
> Is there any sample code for implement to control pulseaudio?
> Is it possibly code for parec and another command for pulseaudio?
> I refered to Linux Sound Programming.
>
> Best Regards,
> Shinnosuke Suzuki
> 2018-02-11 6:12 GMT+09:00 Georg Chini <georg at chini.tk>:
>
>> 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?
>>
>
>
> --
> --
> Shinnosuke Suzuki
> E-mail : suzukisn at gmail.com
>



-- 
--
Shinnosuke Suzuki
E-mail : suzukisn at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20180216/8bc631e5/attachment.html>


More information about the pulseaudio-discuss mailing list