blackshard83
Posts: 91
Joined: Fri Jan 10, 2014 8:31 am

Bug in OMX audio render component?

Mon Jun 20, 2016 12:55 pm

I tried to run more than one instance of hello_audio to verify how many separate instances of audio_render components can be running in different processes at the same time.
It turns out that more than three instances cause severe problems to the whole VideoCore IV system

I launched hello_audio three times trivially this way:

Code: Select all

#./hello_audio.bin &
Then I launched vcgencmd cache_flush to clean the VC cache and the process gets stuck with this message:

Code: Select all

root@raspberrypi2:/home/pi# vcgencmd cache_flush
vc_gencmd_send returned -1
vchi_msg_dequeue -> -1(22)
Running vcdbg reloc reports heap corruption (may or may not be accurate, due to vcgencmd inability to flush cache):

Code: Select all

root@raspberrypi2:/home/pi# vcdbg reloc

Relocatable heap version 4 found at 0x2f000000
total space allocated is 236M, with 236M relocatable, 0 legacy and 0 offline
0 legacy blocks of size 2359296

free list at 0x3d8713c0
232M free memory in 2 free block(s)
largest free block is 232M bytes

0x2f000000: free 232M
[   4] 0x3d866d80: used  576 (refcount 1 lock count 0, size      512, align    4, data 0x3d866da0, d0rual) 'ILCS VC buffer pool'
[  21] 0x3d866fc0: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d866fe0, d1ruAl) 'ilin mapping buffer'
[  20] 0x3d868000: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d868020, d1ruAl) 'ilin mapping buffer'
0x3d868000: corrupt trailer (space 8320 != 4161)
[  34] 0x3d869040: used 4.1K (refcount 0 lock count 0, size     4096, align   32, data 0x3d869060, d1ruAl) 'ilin mapping buffer'
[  29] 0x3d86a080: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d86a0a0, d1ruAl) 'ilin mapping buffer'
[  28] 0x3d86b0c0: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d86b0e0, d1ruAl) 'ilin mapping buffer'
0x3d86c100: free 21K
[  31] 0x3d8713e0: used  576 (refcount 1 lock count 0, size      512, align    4, data 0x3d871400, d0rual) 'ILCS VC buffer pool'
[  36] 0x3d871620: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d871640, d1ruAl) 'ilin mapping buffer'
[  41] 0x3d872660: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d872680, d1ruAl) 'ilin mapping buffer'
[  40] 0x3d8736a0: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d8736c0, d1ruAl) 'ilin mapping buffer'
[  39] 0x3d8746e0: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d874700, d1ruAl) 'ilin mapping buffer'
[  38] 0x3d875720: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d875740, d1ruAl) 'ilin mapping buffer'
[  37] 0x3d876760: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d876780, d1ruAl) 'ilin mapping buffer'
[  32] 0x3d8777a0: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d8777c0, d1ruAl) 'ilin mapping buffer'
[  35] 0x3d8787e0: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d878800, d1ruAl) 'ilin mapping buffer'
[  34] 0x3d879820: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d879840, d1ruAl) 'ilin mapping buffer'
[  33] 0x3d87a860: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d87a880, d1ruAl) 'ilin mapping buffer'
[  42] 0x3d87b8a0: used  416 (refcount 1 lock count 0, size      340, align    4, data 0x3d87b8c0, d0rual) 'resample context'
[   5] 0x3d87ba40: used  576 (refcount 1 lock count 0, size      512, align    4, data 0x3d87ba60, d0rual) 'ILCS VC buffer pool'
[  50] 0x3d87bc80: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d87bca0, d1ruAl) 'ilin mapping buffer'
[  49] 0x3d87ccc0: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d87cce0, d1ruAl) 'ilin mapping buffer'
[   9] 0x3d87dd00: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d87dd20, d1ruAl) 'ilin mapping buffer'
[   6] 0x3d87ed40: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d87ed60, d1ruAl) 'ilin mapping buffer'
[  18] 0x3d87fd80: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d87fda0, d1ruAl) 'ilin mapping buffer'
[  17] 0x3d880dc0: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d880de0, d1ruAl) 'ilin mapping buffer'
[  16] 0x3d881e00: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d881e20, d1ruAl) 'ilin mapping buffer'
[  15] 0x3d882e40: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d882e60, d1ruAl) 'ilin mapping buffer'
[  14] 0x3d883e80: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d883ea0, d1ruAl) 'ilin mapping buffer'
[  13] 0x3d884ec0: used 4.1K (refcount 1 lock count 0, size     4096, align   32, data 0x3d884ee0, d1ruAl) 'ilin mapping buffer'
[  12] 0x3d885f00: used 1.1K (refcount 2 lock count 0, size     1024, align    4, data 0x3d885f20, d0rual) 'resample coeff table data'
[  11] 0x3d886340: used   96 (refcount 1 lock count 0, size       12, align    4, data 0x3d886360, d0rual) 'resample coeff table'
[  10] 0x3d8863a0: used  416 (refcount 1 lock count 0, size      340, align    4, data 0x3d8863c0, d0rual) 'resample context'
[  19] 0x3d886540: used  576 (refcount 1 lock count 0, size      512, align    4, data 0x3d886560, d0rual) 'ILCS VC buffer pool'
[   3] 0x3d886780: used 3.5M (refcount 1 lock count 8, size  3618816, align 4096, data 0x3d887000, d1rual) 'ARM FB'
[   2] 0x3dbfafa0: used  16K (refcount 1 lock count 0, size    16384, align   32, data 0x3dbfafc0, d0ruAl) 'audioplus_tmp_buf'
[   1] 0x3dbfefe0: used 4.0K (refcount 1 lock count 0, size        0, align 4096, data 0x3dbff000, d1rual) 'camera fast alloc arena'
heap corruption detected
small allocs not requested
Running other hello_audio instances reports this:

Code: Select all

tvservice-client: Failed to connect to TV service: -1
hello_dispmanx and hello_triangle also fail to start:

Code: Select all

root@raspberrypi2:/opt/vc/src/hello_pi/hello_dispmanx# ./hello_dispmanx.bin 
tvservice-client: Failed to connect to TV service: -1
Open display[0]...
hello_dispmanx.bin: dispmanx.c:100: main: Assertion `ret == 0' failed.
Aborted

root@raspberrypi2:/opt/vc/src/hello_pi/hello_triangle# ./hello_triangle.bin 
tvservice-client: Failed to connect to TV service: -1
hello_triangle.bin: triangle.c:149: init_ogl: Assertion `success >= 0' failed.
Aborted
This happens on kernel 4.1.18-v7+ (it's a rpi2) with firmware revision cae1bdb3f430414aa563ff0255b0efaf71bb84be
I don't think this is an expected behavior. It would be nice to know if there is a way to handle more than one audio stream in separate processes without using ALSA or jack daemons.

blackshard83
Posts: 91
Joined: Fri Jan 10, 2014 8:31 am

Re: Bug in OMX audio render component?

Mon Jun 20, 2016 2:31 pm

All my fault: the problem seems to disappear upgrading to latest kernel and firmware; multiple audio_render instances seems to work fine now, even when in use with omxplayer.
I'll stress a bit the system though to be sure it satisfies my needs.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7026
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Bug in OMX audio render component?

Mon Jun 20, 2016 3:13 pm

You'll be calling bcm_host_init for each application instance, and also for vcgencmd. There are only a certain number of service slots - it was 4, now 8 IIRC.
Use up all the slots and subsequent applications will fail.

I can't remember when exactly it changed - February/March seems to ring a bell.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

blackshard83
Posts: 91
Joined: Fri Jan 10, 2014 8:31 am

Re: Bug in OMX audio render component?

Tue Jun 21, 2016 6:53 am

Thanks, got it. I tried with more instances and found that the limit has been raised.
I wonder the bcm2805 ALSA driver do use a slot or not...

Return to “OpenMAX”