2007-01-15 02:05:07

by Robert Huitl

[permalink] [raw]
Subject: [Bluez-devel] a2dpd: cmdplay fails: "No such application: 'amarok player play'"

Hi again,

the cmd* functions do not work for me:
cmdplay=dcop amarok player play

When I press the play button, the following line is print (from somewhere
inside the execlp() call):
No such application: 'amarok player play'

I hacked around this problem by using system() instead of execlp():

Index: a2dpd_ipc.c
===================================================================
RCS file: /cvsroot/bluetooth-alsa/plugz/alsa-plugins/a2dpd/a2dpd_ipc.c,v
retrieving revision 1.3
diff -u -r1.3 a2dpd_ipc.c
--- a2dpd_ipc.c 12 Jan 2007 16:34:01 -0000 1.3
+++ a2dpd_ipc.c 15 Jan 2007 02:02:15 -0000
@@ -384,8 +384,10 @@
close_server_socket_on_fork();

// Replace children with new process
- i = execlp(command, command, argv[0], NULL);
- DBG("execlp failed %s=%d (errno=%d:%s)", cmd,
i, errno, strerror(errno));
+ system(cmd);
+ exit(0);
break;
case -1:
// failed


Regards,
Robert

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel


2007-01-16 03:43:01

by Brad Midgley

[permalink] [raw]
Subject: Re: [Bluez-devel] a2dpd: cmdplay fails: "No such application: 'amarok player play'"

Fr=E9d=E9ric

> I stay open to any other solutions if this limitation is a real problem

I see... you've uncovered all the issues I wouldn't have seen until
trying it.

Brad

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3DDE=
VDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-01-15 16:43:55

by Frédéric DALLEAU

[permalink] [raw]
Subject: Re: [Bluez-devel] a2dpd: cmdplay fails: "No such application: 'amarok player play'"

Brad,

I already tried system here and this led to strange interactions between =

processes. I just tried it again (in case it would be better) and it is =

still the same.

Here is the procedure to reproduce :
- xmms must not be started.
- start a2dpd.
- then from an avrcp headset press play to connect : xmms will start.
- kill a2dpd : xmms will deadlock.

Any player should behave the same. I found that the a2dpd main unix =

socket must be closed immediatly after any fork(). I suspect the socket =

remain open in the xmms process space which will try to write to an open =

socket that is no longer polled for data, thus deadlock (btw, can any =

linux guru confirm?). Any process started by system() will be forked but =

this socket won't be closed.

More over, the execution must be asynchronous, system("xmms") will wait =

until you terminate xmms before returning, system("xmms &") should work.

It is still possible to fork() then close_server_socket() then system() =

as did Robert, but a shell is spawned for that (+ 2 additionnal fork =

calls!) which is a few megabytes that could be used better...

It should be enough to rewrite the parser code just before so it handles =

more parameters.
char* argv[2];
strncpy(command, cmd, sizeof(command));
command[sizeof(command)-1]=3D '\0';
argv[0] =3D strchr(command, ' ');
if(argv[0]) { *argv[0]=3D'\0'; argv[0]++; }

I stay open to any other solutions if this limitation is a real problem, =

but as stated in amarok man page :
Options:
-r, --previous
Skip backwards in playlist
-p, --play
Start playing current playlist
-s, --stop
Stop playback
--pause
Pause playback
-f, --next
Skip forwards in playlist

Fr=E9d=E9ric


Brad Midgley a =E9crit :
> Robert
>
> this idea looks ok. The extra fork() could be removed.
>
> Brad
>
> =

>> Index: a2dpd_ipc.c
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> RCS file: /cvsroot/bluetooth-alsa/plugz/alsa-plugins/a2dpd/a2dpd_ipc.c,v
>> retrieving revision 1.3
>> diff -u -r1.3 a2dpd_ipc.c
>> --- a2dpd_ipc.c 12 Jan 2007 16:34:01 -0000 1.3
>> +++ a2dpd_ipc.c 15 Jan 2007 02:02:15 -0000
>> @@ -384,8 +384,10 @@
>> close_server_socket_on_fork();
>>
>> // Replace children with new process
>> - i =3D execlp(command, command, argv[0],=
NULL);
>> - DBG("execlp failed %s=3D%d (errno=3D%d:=
%s)", cmd, =

>> i, errno, strerror(errno));
>> + system(cmd);
>> + exit(0);
>> break;
>> case -1:
>> // failed
>> =

>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share y=
our
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D=
DEVDEV
> _______________________________________________
> Bluez-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
> =



-- =

Frederic

Without the wind, the grass does not move.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3DDE=
VDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-01-15 15:23:52

by Brad Midgley

[permalink] [raw]
Subject: Re: [Bluez-devel] a2dpd: cmdplay fails: "No such application: 'amarok player play'"

Robert

this idea looks ok. The extra fork() could be removed.

Brad

> Index: a2dpd_ipc.c
> ===================================================================
> RCS file: /cvsroot/bluetooth-alsa/plugz/alsa-plugins/a2dpd/a2dpd_ipc.c,v
> retrieving revision 1.3
> diff -u -r1.3 a2dpd_ipc.c
> --- a2dpd_ipc.c 12 Jan 2007 16:34:01 -0000 1.3
> +++ a2dpd_ipc.c 15 Jan 2007 02:02:15 -0000
> @@ -384,8 +384,10 @@
> close_server_socket_on_fork();
>
> // Replace children with new process
> - i = execlp(command, command, argv[0], NULL);
> - DBG("execlp failed %s=%d (errno=%d:%s)", cmd,
> i, errno, strerror(errno));
> + system(cmd);
> + exit(0);
> break;
> case -1:
> // failed

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

2007-01-15 10:16:03

by Frédéric DALLEAU

[permalink] [raw]
Subject: Re: [Bluez-devel] a2dpd: cmdplay fails: "No such application: 'amarok player play'"

Hi,
The command line is restricted to one program (dcop) and one parameter =

(amarok player play). You can overcome this issue by doing a shell =

script taking one parameter which will it turn execute your program =

using whatever parameters you want.

Fr=E9d=E9ric

Robert Huitl a =E9crit :
> Hi again,
>
> the cmd* functions do not work for me:
> cmdplay=3Ddcop amarok player play
>
> When I press the play button, the following line is print (from somewhere =

> inside the execlp() call):
> No such application: 'amarok player play'
>
> I hacked around this problem by using system() instead of execlp():
>
> Index: a2dpd_ipc.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> RCS file: /cvsroot/bluetooth-alsa/plugz/alsa-plugins/a2dpd/a2dpd_ipc.c,v
> retrieving revision 1.3
> diff -u -r1.3 a2dpd_ipc.c
> --- a2dpd_ipc.c 12 Jan 2007 16:34:01 -0000 1.3
> +++ a2dpd_ipc.c 15 Jan 2007 02:02:15 -0000
> @@ -384,8 +384,10 @@
> close_server_socket_on_fork();
>
> // Replace children with new process
> - i =3D execlp(command, command, argv[0], =
NULL);
> - DBG("execlp failed %s=3D%d (errno=3D%d:%=
s)", cmd, =

> i, errno, strerror(errno));
> + system(cmd);
> + exit(0);
> break;
> case -1:
> // failed
>
>
> Regards,
> Robert
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share y=
our
> opinions on IT & business topics through brief surveys - and earn cash
> http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3D=
DEVDEV
> _______________________________________________
> Bluez-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/bluez-devel
> =



-- =

Frederic

Without the wind, the grass does not move.


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3DDE=
VDEV
_______________________________________________
Bluez-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel