Re: [pulseaudio-discuss] I want to know about how to communication one module with another module

2012-08-02 Thread Zhen Fu
Hi rong,

It is very useful message for me. I am doing a audio server, so I refer the 
pulseaudio system.

--
Best Regards,
Zhen Fu

-Original Message-
From: rong deng [mailto:dzro...@gmail.com] 
Sent: Wednesday, July 25, 2012 11:21 PM
To: General PulseAudio Discussion
Cc: Zhen Fu
Subject: Re: [pulseaudio-discuss] I want to know about how to communication one 
module with another module

Hi Zhen,

2012/7/24 Zhen Fu f...@marvell.com:
 Hi all developer,



 I want to know about how to communication one module with another module. Is
 it use asyncmg? Thank you!

I'm not the expert here, but here's my two cents. :)

In theory, two modules should not communicate directly with each
other. For a module, the only thing it should care about is the core,
and it should communicate with the core, handling the messages from
the core etc. As you might know already, pulseaudio takes the thread
model, for most of the modules, they would reside in a separate
thread, e.g. ALSA. Communicating directly with two methods could be a
mess, and even worse, one module is totally unaware when the another
module is loaded or not.

So the current way, in my humble opinion, is to use the core as a
bridge to direct the communication between two modules.

That said, the intrinsic question is why you should do this at your
first place? :) Maybe there's a chance to skip this ugliness in your
design.

Thanks!
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] I want to know about how to communication one module with another module

2012-08-02 Thread Flavio Ceolin
Zhen Fu f...@marvell.com writes:

Hi guys,

 Hi rong,

 It is very useful message for me. I am doing a audio server, so I refer the 
 pulseaudio system.

 --
 Best Regards,
 Zhen Fu

 -Original Message-
 From: rong deng [mailto:dzro...@gmail.com] 
 Sent: Wednesday, July 25, 2012 11:21 PM
 To: General PulseAudio Discussion
 Cc: Zhen Fu
 Subject: Re: [pulseaudio-discuss] I want to know about how to communication 
 one module with another module

 Hi Zhen,

 2012/7/24 Zhen Fu f...@marvell.com:
 Hi all developer,



 I want to know about how to communication one module with another module. Is
 it use asyncmg? Thank you!

 I'm not the expert here, but here's my two cents. :)

 In theory, two modules should not communicate directly with each
 other. For a module, the only thing it should care about is the core,
 and it should communicate with the core, handling the messages from
 the core etc. As you might know already, pulseaudio takes the thread
 model, for most of the modules, they would reside in a separate
 thread, e.g. ALSA. Communicating directly with two methods could be a
 mess, and even worse, one module is totally unaware when the another
 module is loaded or not.

 So the current way, in my humble opinion, is to use the core as a
 bridge to direct the communication between two modules.

 That said, the intrinsic question is why you should do this at your
 first place? :) Maybe there's a chance to skip this ugliness in your
 design.

 Thanks!
 ___
 pulseaudio-discuss mailing list
 pulseaudio-discuss@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss

Taking the opportunity, how pa handle two different conflicting modules
? For example, module-role-cork can be used to cork others streams when
a stream with the expected role appears, what happens if we've another
module that increases the volume when a stream with the same role appears
?

Is it responsability of pa or of the user ?

Regards,
Flavio Ceolin
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


[pulseaudio-discuss] I want to know about how to communication one module with another module

2012-07-25 Thread Zhen Fu
Hi all developer,

I want to know about how to communication one module with another module. Is it 
use asyncmg? Thank you!

--
Best Regards,
Zhen Fu

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] I want to know about how to communication one module with another module

2012-07-25 Thread rong deng
Hi Zhen,

2012/7/24 Zhen Fu f...@marvell.com:
 Hi all developer,



 I want to know about how to communication one module with another module. Is
 it use asyncmg? Thank you!

I'm not the expert here, but here's my two cents. :)

In theory, two modules should not communicate directly with each
other. For a module, the only thing it should care about is the core,
and it should communicate with the core, handling the messages from
the core etc. As you might know already, pulseaudio takes the thread
model, for most of the modules, they would reside in a separate
thread, e.g. ALSA. Communicating directly with two methods could be a
mess, and even worse, one module is totally unaware when the another
module is loaded or not.

So the current way, in my humble opinion, is to use the core as a
bridge to direct the communication between two modules.

That said, the intrinsic question is why you should do this at your
first place? :) Maybe there's a chance to skip this ugliness in your
design.

Thanks!
___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss


Re: [pulseaudio-discuss] I want to know about how to communication one module with another module

2012-07-25 Thread Tanu Kaskinen
On Wed, 2012-07-25 at 23:21 +0800, rong deng wrote:
 Hi Zhen,
 
 2012/7/24 Zhen Fu f...@marvell.com:
  Hi all developer,
 
 
 
  I want to know about how to communication one module with another module. Is
  it use asyncmg? Thank you!

No, the asyncmsgq stuff is not a generic inter-module communication
method. It's a method for communicating between threads (which may be
handled by different modules, though).

There's no messaging system specifically for communication between
modules. There are different ways to do the communication, depending on
what you're doing.

 I'm not the expert here, but here's my two cents. :)
 
 In theory, two modules should not communicate directly with each
 other.

I don't think it's that strict. You're right in asking for the reason
for wanting to communicate between modules, though. If it can be avoided
in a nice way, then it should be avoided, but there are valid cases
where a set of modules need to collaborate using custom interfaces (I'll
give some examples later).

 For a module, the only thing it should care about is the core,
 and it should communicate with the core, handling the messages from
 the core etc. As you might know already, pulseaudio takes the thread
 model, for most of the modules, they would reside in a separate
 thread, e.g. ALSA. Communicating directly with two methods could be a
 mess, and even worse, one module is totally unaware when the another
 module is loaded or not.

Threading is created mostly (perhaps even only) in modules that
implement sinks and sources. Threads are used there, because the main
thread of pulseaudio isn't suitable for real-time audio processing. In
other modules (that I believe are actually the majority) the code runs
in the main thread. Life is much simpler that way.

 So the current way, in my humble opinion, is to use the core as a
 bridge to direct the communication between two modules.

That's one way to do it. For example, the native protocol and the D-Bus
protocol modules both have a component in pulsecore
(src/pulsecore/protocol-native.c and src/pulsecore/protocol-dbus.c) that
implement the interfaces for communicating between modules that want to
use those protocols and the modules that implement the protocol.

The model in this case is to create a reference counted singleton object
(pa_native_protocol and pa_dbus_protocol) when any module wants to use
that functionality. The singleton object will then exist as long as
there are users for it, and it's freed when the last module using it is
unloaded.

That's a bit ugly in my opinion, because it bloats libpulsecore with
non-core things.

A similar model is used in the bluetooth modules, for doing interaction
between the modules, but there the singleton object
(pa_bluetooth_discovery) is not implemented in libpulsecore, but in
libbluetooth-util instead.

There has been some plans for creating a bit of infrastructure for
helping with inter-module communication:
http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/9315/focus=9474

I think Frédéric Dalleau planned to start working on this some time ago,
but I'm not sure if he had time for it after all. Frédéric, could you
clarify the status of this?

-- 
Tanu

___
pulseaudio-discuss mailing list
pulseaudio-discuss@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/pulseaudio-discuss