Re: 4a-play on M3

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 8 Nov 2018 07:53:39 +0100
Thierry Bultel <thierry.bultel@xxxxxxx> wrote:

> ChenWei,
> AFAIK, the message you can see from the kernel log is more related to 
> your "scp" upload than to the softmixer.

Hi ChenWei, Hi Thierry, Hi all,

Thierry, it is true that ssh/scp raise an audit message due to key
management in the kernel and how smack handles it. There are iprogress
on that topic and it will be solve very soon.

However the audit message, here, reflect a true issue in the way how
NAVI accesses HAL4A features.

The audit message tells that a process "afb-client-demo" forked by NAVI
and so running its security context "User::App::navigation" tries to
access the binder application's socket of "agl-service-audio-4a".

This is not possible. That socket is only accessible by applications
of "agl-service-audio-4a". The fact that 4a-tools access it successfully
is a consequence of running it in a console that brings the security
context "System". Trying to run 4a-tools (or some of its algorithm) in
the context of NAVI may lead to this issue.

There is a distinction to do between the "application common
connection" and the "api connection", both exported by the binder but
serving different purposes. (see page 13 of [1])

I suppose that your need is to open/close a role using API "ahl-4a".

To achieve it most application use a binder that connect the application
to the system. This is the case when your application has one of the
following type: "text/html", "application/vnd.agl.service" (see [2]).
In that case, your application receive at start the port and the
initial token of it binder. Using this values in your command
"afb-client-demo" will solve the issue. This is the preferred way.

An other option, that is not recommended, consists to use the direct
mode of afb-client-demo to connect to the API "ahl-4a". It would imply
hi-level scripting skill to ensure the connection of afb-client-demo
during all the duration of the play.

Hope it helps.
Feel free to ask details more if you need.

Best regards
José

[1]
http://www.iot.bzh/download/public/2018/amm-dresden/AGL-app-design.pdf
[2]
http://docs.automotivelinux.org/docs/apis_services/en/dev/reference/af-main/2.2-config.xml.html#known-content-types

> You can see the softmixer output this way:
> 
> systemctl | grep 4a
> -> identify the name of the 4a service (for example   
> afm-service-agl-service-audio-4a--1.0-14cc9c6--main.service)
> 
> journalctl -f -u <4a service>
> 
> At the present time I do not now where that 0.5s delay comes from, I 
> have to try on my side.
> 
> Regards
> 
> On 11/08/2018 06:09 AM, I37546_CHIN@xxxxxxxxxxxxxx wrote:
> >
> > Hi Thierry
> >
> > I tried changing 2 to 0.02 and rebuilding “alsa-softmixer.ctlso”.
> >
> > And find the delay is shortened a lot but still takes about 0.5
> > second.
> >
> > Meanwhile I got some message[1] during running the 4a-play that may
> > be some clue to the delay.
> >
> > [1]these message also appeared before changing the
> > “alsa-softmixer.ctlso”
> >
> > ------------------------
> >
> > Oct 30 10:20:05 m3ulcb kernel: audit: type=1400 
> > audit(1540894805.793:13): lsm=SMACK fn=smack_socket_sock_rcv_skb 
> > action=denied subject="User::App::navigation" 
> > object="User::App::agl-service-audio-4a" requested=w pid=7 
> > comm="ksoftirqd/0" saddr=127.0.0.1 src=47494 daddr=127.0.0.1
> > dest=1026 netif=lo
> >
> > Oct 30 10:20:05 m3ulcb kernel: audit: type=1300 
> > audit(1540894804.769:12): arch=c00000b7 syscall=203 success=no 
> > exit=-113 a0=6 a1=aaaaf92c1670 a2=10 a3=ffffaa352000 items=0
> > ppid=4284 pid=4325 auid=4294967295 uid=0 gid=0 euid=0 suid=0
> > fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295
> > comm="afb-client-demo" exe="/usr/bin/afb-client-demo"
> > subj=User::App::navigation key=(null)
> >
> > Oct 30 10:20:05 m3ulcb kernel: audit: type=1327 
> > audit(1540894804.769:12): 
> > proctitle=6166622D636C69656E742D64656D6F002D48006C6F63616C686F73743A313032362F6170693F746F6B656E3D48454C4C4F26757569643D6D616769630061686C2D3461006E617669676174696F6E007B2022616374696F6E223A2022636C6F736522207D
> >
> > Oct 30 10:20:04 m3ulcb audit: PROCTITLE 
> > proctitle=6166622D636C69656E742D64656D6F002D48006C6F63616C686F73743A313032362F6170693F746F6B656E3D48454C4C4F26757569643D6D616769630061686C2D3461006E617669676174696F6E007B2022616374696F6E223A2022636C6F736522207D
> >
> > Thanks/BR
> >
> > ChenWei
> >
> > *From:*Thierry Bultel [mailto:thierry.bultel@xxxxxxx]
> > *Sent:* Thursday, November 8, 2018 11:30 AM
> > *To:* I37546 Chin I
> > *Cc:* automotive-discussions; I25461 Momiyama Yoshito
> > *Subject:* RE:  4a-play on M3
> >
> >
> > Le 8 nov. 2018 3:06 AM, I37546_CHIN@xxxxxxxxxxxxxx a écrit :  
> > >
> > > Hi Thierry
> > >
> > >
> > >
> > > Thanks a lot for the support.
> > >
> > > I’d like to have try but please give me some time.
> > >
> > >
> > >
> > > And need to confirm something
> > >  
> > > > snd_pcm_uframes_t nbFrames = 2 * opts->rate; // Exactly 2
> > > > second   
> > of buffer  
> > >
> > >
> > >
> > > Does “2” stand for the delay time ?
> > >
> > > Usually we want the delay to be as short as possible, but
> > >
> > > as this configuration may affect the buffer that could be
> > > necessary   
> > for playback,  
> > >
> > > I’d like to know the possible value for the softmixer
> > >
> > >  
> >
> > As i said in my previous mail, the value should be as small as
> > possible. I think that i will make it configurable per stream,
> > because having some delay for music is acceptable, but not for
> > voice (where small clipping is not an issue either)
> >  
> > >
> > > Do you have any suggestion or it should be confirmed just by test?
> > >  
> > Yes, start with 0.02 (20 ms) for instance, and increase it, if it
> > is not enough
> > Regards  
> > >
> > >
> > > Thanks/BR
> > >
> > > ChenWei
> > >
> > > From: automotive-discussions-bounces@xxxxxxxxxxxxxxxxxxxxxxxxx   
> > [mailto:automotive-discussions-bounces@xxxxxxxxxxxxxxxxxxxxxxxxx]
> > On Behalf Of Thierry Bultel  
> > > Sent: Wednesday, November 7, 2018 6:45 PM
> > > To: automotive-discussions@xxxxxxxxxxxxxxxxxxxxxxxxx
> > > Subject: Re:  4a-play on M3
> > >
> > >
> > >
> > > Hi ChenWei,
> > >
> > > The current delay is exactly of 2 seconds. This is a lot, indeed,
> > > and has remain as such from an early test phase with
> > > experimental   
> > versions.  
> > > This delay is not acceptable for everything that is not music
> > > (phone   
> > voice, navigation ...)  
> > > and should be decreased to another order of magnitude (20 to 200
> > > ms   
> > for instance)  
> > >
> > > It is currently hardcoded at that place:   
> > 4a-softmixer/plugins/alsa/alsa-core-pcm.c line 705  
> > >
> > >     snd_pcm_uframes_t nbFrames = 2 * opts->rate; // Exactly 2
> > > second   
> > of buffer  
> > >
> > > You can change it for your tests, if recompiling the softmixer
> > > is   
> > possible for you.  
> > > I will change that as a configurable option asap.
> > >
> > > Please give us your feedback about it.
> > > Best regards
> > > Thierry
> > >
> > > On 11/05/2018 08:04 AM, I37546_CHIN@xxxxxxxxxxxxxx wrote:  
> > >>
> > >> Hi Loic
> > >>
> > >>
> > >>
> > >> Sorry for another question.
> > >>
> > >> After I tried both softmixer and USB by using 4a-play to
> > >> playback a   
> > sound file,  
> > >>
> > >> I found some delay of softmixer (about 1 second or more)
> > >> compared   
> > with USB.  
> > >>
> > >>
> > >>
> > >> Does this delay come from softmixer/4a-framework or just depend
> > >> on   
> > some configuration (I mean it’s configurable)?  
> > >>
> > >>
> > >>
> > >> We’d like to use 4a-play to playback the navigation guidance
> > >> and   
> > are expecting short delay within it.  
> > >>
> > >>
> > >>
> > >> Thanks/BR
> > >>
> > >> ChenWei
> > >>
> > >> From: I37546 Chin I
> > >> Sent: Friday, November 2, 2018 6:19 PM
> > >> To: Loïc
> > >> Cc: automotive-discussions@xxxxxxxxxxxxxxxxxxxxxxxxx; I25461   
> > Momiyama Yoshito  
> > >> Subject: RE:  4a-play on M3
> > >>
> > >>
> > >>
> > >> Hi Loic
> > >>
> > >>
> > >>
> > >> Thank you very much for the explanation.
> > >>
> > >> Now I can see that is exactly what happened to me.
> > >>
> > >>
> > >>
> > >> After switching to card 0 (loopback), I got some json-liked
> > >> message   
> > (not the device busy message)and I think that could come from 
> > afb-bindings,  
> > >>
> > >> which means it is the softmixer.
> > >>
> > >>
> > >>
> > >> So finally we have 2 choices of PCM (softmixer/USB) for our   
> > application and that is very helpful.  
> > >>
> > >> Thanks again.
> > >>
> > >>
> > >>
> > >> Thanks/BR
> > >>
> > >> ChenWei
> > >>
> > >> From: Loïc [mailto:loic.collignon@xxxxxxx]
> > >> Sent: Friday, November 2, 2018 5:37 PM
> > >> To: I37546 Chin I
> > >> Cc: automotive-discussions@xxxxxxxxxxxxxxxxxxxxxxxxx; I25461   
> > Momiyama Yoshito  
> > >> Subject: Re:  4a-play on M3
> > >>
> > >>
> > >>
> > >> Hello,
> > >>
> > >> You have only one more card when you plug the usb device, so
> > >> it's   
> > not created by the softmixer, it's created by the usb-audio
> > kernel's driver. It's the raw PCM from your usb device.  
> > >>
> > >> Here is what can happen:
> > >>
> > >> 1) You have two enabled HALs (the M3 and the USB)
> > >>
> > >>     1.1) the usb device is unplugged at boot
> > >>
> > >>             The softmixer will not find the usb hardware   
> > (obviously), so it does not bind streams. It will however find the
> > PCM from the M3, and use it. So roles are bound to the M3 streams.  
> > >>
> > >>     1.2) the usb device is plugged at boot
> > >>
> > >>             The softmixer will it, but there is now two cards   
> > providing the sames streams, so the softmixer will create only one 
> > multimedia stream, and the multimedia role will be bound to this
> > stream.  
> > >>             As the M3' audio hardware is called "ak4613" while
> > >> the   
> > usb one is called 'Device', the M3 one will probably be the first 
> > processed by the hal-manager and the softmixer. So the usb device
> > is ignored by 4a.  
> > >>
> > >> 2) You have only one HAL enabled
> > >>
> > >>     Then the corresponding hardware is used by the softmixer (so
> > >> it   
> > cannot be used by someone else). The softmixer ignore hardware with 
> > disabled HAL, so that you can still use it normally, without 4a.  
> > >>
> > >>
> > >>
> > >> In all of these situation, you end up with the same audio card
> > >> list   
> > as you shown: 3 cards, one for the softmixer (Loopback), one for
> > the M3's hardware (ak4613), and one for the usb hardware.  
> > >>
> > >> ---
> > >>
> > >> Regards,
> > >> Loïc Collignon [IoT.bzh]
> > >>
> > >>
> > >>
> > >> On 2018-11-01 03:43, I37546_CHIN@xxxxxxxxxxxxxx wrote:  
> > >>>
> > >>> Hi Loic
> > >>>
> > >>>
> > >>>
> > >>> Thank you very much for the details.
> > >>>
> > >>> I think I've understood the usage of 4a-stream/softmixer.
> > >>>
> > >>> As softmixer is designed to control/arbitrate the audio of
> > >>> APPs,   
> > we'd like to use its PCMs instead of raw ones.  
> > >>>
> > >>>
> > >>>
> > >>> Sorry to say I still have a question but it could be another
> > >>> issue.
> > >>>
> > >>> Before I plug-in the USB Audio, I can find
> > >>>
> > >>>
> > >>>
> > >>> card 0: Loopback
> > >>>
> > >>> card 1: ak4613
> > >>>
> > >>>
> > >>>
> > >>> and after plug-in, I got
> > >>>
> > >>>
> > >>>
> > >>> card 0: Loopback
> > >>>
> > >>> card 1: ak4613
> > >>>
> > >>> card 2: Device
> > >>>
> > >>>
> > >>>
> > >>> so it seems softmixer created card 2 after plug-in and I can   
> > understand this point.  
> > >>>
> > >>> But it also means USB Audio is also necessary if I want to
> > >>> use   
> > softmixer. which I still couldn't understand.  
> > >>>
> > >>>
> > >>>
> > >>>
> > >>>
> > >>> Thanks/BR
> > >>>
> > >>> ChenWei
> > >>>
> > >>> From: Loïc [mailto:loic.collignon@xxxxxxx]
> > >>> Sent: Wednesday, October 31, 2018 7:45 PM
> > >>> To: I37546 Chin I
> > >>> Cc: automotive-discussions@xxxxxxxxxxxxxxxxxxxxxxxxx; I25461   
> > Momiyama Yoshito  
> > >>> Subject: Re:  4a-play on M3
> > >>>
> > >>>
> > >>>
> > >>> To clarify the relationship of HALs and device:
> > >>>
> > >>> A HAL is a configuration that is provided to the softmixer,
> > >>> so   
> > that it can create the virtual PCM with the correct bindings
> > between the real hardware and the 4a-streams.  
> > >>> For example, we want a 'multimedia' and a 'navigation'
> > >>> stream,   
> > both with a 'Playback Volume' control, but the real hardware
> > provides only one PCM with a control named 'Master Playback
> > Volume".  
> > >>> So we wrote a HAL that tells the softmixer that we want two
> > >>> PCM   
> > ('multimedia', 'navigation'), with a 'Playback Volume' control, and 
> > bind both streams to the single PCM exposed by the hardware.  
> > >>>
> > >>> Because of that, we end up with 2 audio cards, 3 PCMs, and 3   
> > controls (one per PCM).  
> > >>> The real audio card should be the first, so let's assume it's
> > >>> URI   
> > are in this form: hw:1,X,X.  
> > >>> The softmixer use snd-aloop to build a virtual audio card,
> > >>> let's   
> > assume it use: hw:2,X,X.  
> > >>> And finally, because softmixer is actually routing and mixing   
> > audio from the virtual card to the real one, it means that it have
> > to open the destination PCM.  
> > >>> This is why you can't play anything on hw:1,X,X: the softmixer
> > >>> is   
> > using it, this is why you have 'busy resource'.  
> > >>>
> > >>> So, in conclusion, you can play audio on PCMs exposed by the   
> > softmixer, but you can play audio only on PCMs not used by the
> > softmixer.  
> > >>> Meaning that the corresponding HAL should be disabled, to
> > >>> prevent   
> > the softmixer from using it.  
> > >>>
> > >>> ---
> > >>>
> > >>> Regards,
> > >>> Loïc Collignon [IoT.bzh]
> > >>>
> > >>>
> > >>>
> > >>> On 2018-10-31 10:08, I37546_CHIN@xxxxxxxxxxxxxx wrote:  
> > >>>>
> > >>>> Hi Loic
> > >>>>
> > >>>>
> > >>>>
> > >>>> Thank you for the reply.
> > >>>>
> > >>>>
> > >>>>
> > >>>> In fact I've also read the HAL's docs, but still not very
> > >>>> clearly   
> > about the relationship of HAL's and device.  
> > >>>>
> > >>>> Maybe I missed something and if you could give some more
> > >>>> advice   
> > it could be very helpful.  
> > >>>>
> > >>>>
> > >>>>
> > >>>> I can see hal-4a-rcar-m3 is currently applied on my M3(SK)
> > >>>> board   
> > and the roles of radio/multimedia/emergency/navigation are
> > available  
> > >>>>
> > >>>> through the 4a-api commands.
> > >>>>
> > >>>>
> > >>>>
> > >>>> But I still don't understand why only the pair of USB Audio
> > >>>> +   
> > hw:2,0,0 works well.  
> > >>>>
> > >>>>
> > >>>>
> > >>>> I can find a card 1 for ak4613 (card 0 is for loopback) and
> > >>>> an   
> > on-board earphone output,  
> > >>>>
> > >>>> but hw:1,0,0 always returns a device busy.
> > >>>>
> > >>>> (and hw:2,0,1 also returns a device busy, no matter which role
> > >>>> is   
> > used)  
> > >>>>
> > >>>>
> > >>>>
> > >>>> Thanks
> > >>>>
> > >>>> ChenWei
> > >>>>
> > >>>> From: Loïc [mailto:loic.collignon@xxxxxxx]
> > >>>> Sent: Wednesday, October 31, 2018 5:22 PM
> > >>>> To: I37546 Chin I
> > >>>> Cc: automotive-discussions@xxxxxxxxxxxxxxxxxxxxxxxxx
> > >>>> Subject: Re:  4a-play on M3
> > >>>>
> > >>>>
> > >>>>
> > >>>> Hello!
> > >>>>
> > >>>> I agree that the note on 4a-play isn't clear enough. What it   
> > means is that the command does not check if you specify the right
> > role according to the right device.  
> > >>>> So if you play something on a PCM (i.e. hw:2,0,0) but specify
> > >>>> the   
> > wrong role (i.e. navigation which is supposed to be on hw:2,0,1),
> > it means that the wrong role will be opened, preventing others to
> > open the same role.  
> > >>>> But you will still play on the specified PCM (hw:2,0,0 in this
> > >>>> case).
> > >>>>
> > >>>> So nothing to do with USB or not.
> > >>>>
> > >>>> The PCM exposed by 4a are streams, handled by the softmixer.
> > >>>> Their ID are hw:X,0,Y, where X is the card number and Y is
> > >>>> the   
> > stream id.  
> > >>>> Usually X=2 because it's the second audio card. But it can
> > >>>> depend   
> > on the hardware.  
> > >>>> 4a binds roles to streams, so everything depends on the
> > >>>> selected   
> > HAL: http://docs.iot.bzh/docs/apis_services/en/dev/reference/audio/high-level-api/TipsAndTricks/HALs.html  
> > >>>>
> > >>>> ---
> > >>>>
> > >>>> Regards,
> > >>>> Loïc Collignon [IoT.bzh]
> > >>>>
> > >>>>
> > >>>>
> > >>>> On 2018-10-31 06:31, I37546_CHIN@xxxxxxxxxxxxxx wrote:  
> > >>>>>
> > >>>>> Hi,
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>> I'm using 4a-play to playback WAV files on M3 with ff 6.0.1.
> > >>>>>
> > >>>>> By referring the web documents, I can get sound from a USB   
> > headphone,  
> > >>>>>
> > >>>>> but nothing from the on-board earphone jack.
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>> The Docs say, usually device "hw:2,0,0" matches
> > >>>>> "multimedia",   
> > while I find it also works with "navigation".  
> > >>>>>
> > >>>>> Does that mean, "hw:2,0,0" stands for a USB Audio?
> > >>>>>
> > >>>>> And is USB Audio the only device supported currently?
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>> Any suggestion appreciated.
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>> Thanks
> > >>>>>
> > >>>>> ChenWei
> > >>>>>
> > >>>>>
> > >>>>>
> > >>>>> _______________________________________________
> > >>>>> automotive-discussions mailing list
> > >>>>> automotive-discussions@xxxxxxxxxxxxxxxxxxxxxxxxx
> > >>>>>   
> > https://lists.linuxfoundation.org/mailman/listinfo/automotive-discussions  
> > >>
> > >>
> > >>
> > >>
> > >> _______________________________________________
> > >>
> > >> automotive-discussions mailing list
> > >>
> > >> automotive-discussions@xxxxxxxxxxxxxxxxxxxxxxxxx
> > >>
> > >>   
> > https://lists.linuxfoundation.org/mailman/listinfo/automotive-discussions  
> > >
> > >  
> >  
> 

_______________________________________________
automotive-discussions mailing list
automotive-discussions@xxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/automotive-discussions




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux