Did you test this in handset? This is really sensitive change. 

And I'm not sure how often the logic of board detection is used .If it's in 
critical path, g_spawn way is for sure unacceptable from performance and power 
saving point. 

Peter

> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Zheng Huan
> Sent: Sunday, March 06, 2011 11:03 PM
> To: [email protected]
> Subject: [meego-commits] 14544: Changes to
> Trunk:Testing/pulseaudio-policy-enforcement
> 
> Hi,
> I have made the following changes to pulseaudio-policy-enforcement in project
> Trunk:Testing. Please review and accept ASAP.
> 
> Thank You,
> Zheng Huan
> 
> [This message was auto-generated]
> 
> ---
> 
> Request #14544:
> 
>   submit:   home:zbt/pulseaudio-policy-enforcement(r4) ->
> Trunk:Testing/pulseaudio-policy-enforcement
> 
> 
> Message:
>     Support multiple audio output for HDMI and WiDi, FEA#3053, platform
> detection is used, thus will not affect normal platform
> 
> State:   new          2011-03-06T23:01:57 zbt
> Comment: None
> 
> 
> 
> changes files:
> --------------
> --- pulseaudio-policy-enforcement.changes
> +++ pulseaudio-policy-enforcement.changes
> @@ -0,0 +1,3 @@
> +* Mon Mar 7 2011 Huan Zheng <[email protected]> - 1.1.10
> +- Support multiple audio output for HDMI and WiDi, FEA#3053, platform
> detection is used, thus will not affect normal platform
> +
> @@ -3 +6 @@
> -- FEA#6701
> \ No newline at end of file
> +- FEA#6701
> 
> new:
> ----
>   support_multiple_audio_output.patch
> 
> spec files:
> -----------
> --- pulseaudio-policy-enforcement.spec
> +++ pulseaudio-policy-enforcement.spec
> @@ -14,6 +14,7 @@
>  URL:
> http://meego.gitorious.org/maemo-multimedia/pulseaudio-policy-enforcement
>  Source0:    %{name}-%{version}.tar.gz
>  Source100:  pulseaudio-policy-enforcement.yaml
> +Patch0:     support_multiple_audio_output.patch
>  BuildRequires:  pkgconfig(pulsecore)
>  BuildRequires:  pkgconfig(libpulse)
>  BuildRequires:  pkgconfig(dbus-1)
> @@ -30,7 +31,8 @@
> 
>  %prep
>  %setup -q -n %{name}-%{version}
> -
> +# support_multiple_audio_output.patch
> +%patch0 -p1
>  # >> setup
>  # << setup
> 
> 
> other changes:
> --------------
> 
> ++++++ support_multiple_audio_output.patch (new)
> --- support_multiple_audio_output.patch
> +++ support_multiple_audio_output.patch
> +diff -urN pulseaudio-policy-enforcement-1.1.10/configure.ac
> pulseaudio-policy-enforcement-1.1.11/configure.ac
> +--- pulseaudio-policy-enforcement-1.1.10/configure.ac        2010-12-02
> 15:18:39.000000000 +0800
> ++++ pulseaudio-policy-enforcement-1.1.11/configure.ac        2011-03-07
> 13:43:52.000000000 +0800
> +@@ -72,6 +72,10 @@
> + AC_SUBST(DBUS_CFLAGS)
> + AC_SUBST(DBUS_LIBS)
> +
> ++PKG_CHECK_MODULES(GLIB, [glib-2.0])
> ++AC_SUBST(GLIB_CFLAGS)
> ++AC_SUBST(GLIB_LIBS)
> ++
> +
> + AC_ARG_WITH(
> +         [module-dir],
> +@@ -110,5 +114,7 @@
> +     PULSEAUDIO_HAS_PORTS: ${PULSEAUDIO_HAS_PORTS}
> +     DBUS_CFLAGS:          ${DBUS_CFLAGS}
> +     DBUS_LIBS:            ${DBUS_LIBS}
> ++    GLIB_CFLAGS:          ${GLIB_CFLAGS}
> ++    GLIB_LIBS:            ${GLIB_LIBS}
> +     PD_SUPPORT:           ${PD_SUPPORT}
> + "
> +diff -urN pulseaudio-policy-enforcement-1.1.10/src/config-file.c
> pulseaudio-policy-enforcement-1.1.11/src/config-file.c
> +--- pulseaudio-policy-enforcement-1.1.10/src/config-file.c   2010-12-02
> 15:18:39.000000000 +0800
> ++++ pulseaudio-policy-enforcement-1.1.11/src/config-file.c   2011-03-07
> 13:42:57.000000000 +0800
> +@@ -21,6 +21,7 @@
> +
> + #include <pulsecore/core-util.h>
> + #include <pulsecore/log.h>
> ++#include <glib.h>
> +
> + #include "config-file.h"
> + #include "policy-group.h"
> +@@ -28,6 +29,7 @@
> + #include "context.h"
> +
> + #define DEFAULT_CONFIG_FILE        "policy.conf"
> ++#define DEFAULT_CONFIG_FILE1        "policyikb.conf"
> + #define DEFAULT_CONFIG_DIRECTORY   "/etc/pulse/xpolicy.conf.d"
> +
> + enum section_type {
> +@@ -182,8 +184,23 @@
> +
> +     pa_assert(u);
> +
> +-    if (!cfgfile)
> +-        cfgfile = DEFAULT_CONFIG_FILE;
> ++    if (!cfgfile) {
> ++        if (u->boardname == NULL)
> ++            cfgfile = DEFAULT_CONFIG_FILE;
> ++        else {
> ++            if (!strcmp(u->boardname, IKB)) { /* Detected board */
> ++                char cfgpath1[PATH_MAX]; /* Check whether IKB config
> file exist or not */
> ++                pa_policy_file_path(DEFAULT_CONFIG_FILE1, cfgpath1,
> PATH_MAX);
> ++                if (g_file_test(cfgpath1, G_FILE_TEST_EXISTS)) {
> ++                    cfgfile = DEFAULT_CONFIG_FILE1;
> ++                } else {
> ++                    cfgfile = DEFAULT_CONFIG_FILE;
> ++                }
> ++            } else {
> ++                cfgfile = DEFAULT_CONFIG_FILE;
> ++            }
> ++        }
> ++    }
> +
> +     pa_policy_file_path(cfgfile, cfgpath, PATH_MAX);
> +     pa_log_info("parsing config file '%s'", cfgpath);
> +diff -urN pulseaudio-policy-enforcement-1.1.10/src/Makefile.am
> pulseaudio-policy-enforcement-1.1.11/src/Makefile.am
> +--- pulseaudio-policy-enforcement-1.1.10/src/Makefile.am     2010-12-02
> 15:18:39.000000000 +0800
> ++++ pulseaudio-policy-enforcement-1.1.11/src/Makefile.am     2011-03-07
> 13:42:45.000000000 +0800
> +@@ -15,5 +15,5 @@
> +                     context.c \
> +                     dbusif.c
> + module_policy_enforcement_la_LDFLAGS = -module -avoid-version
> +-module_policy_enforcement_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS)
> $(LIBPULSECORE_LIBS) $(LIBPULSE_LIBS)
> +-module_policy_enforcement_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
> $(LIBPULSE_CFLAGS) $(LIBPULSECORE_CFLAGS)
> -DPULSEAUDIO_HAS_PORTS=$(PULSEAUDIO_HAS_PORTS)
> ++module_policy_enforcement_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS)
> $(GLIB_LIBS) $(LIBPULSECORE_LIBS) $(LIBPULSE_LIBS)
> ++module_policy_enforcement_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
> $(GLIB_CFLAGS) $(LIBPULSE_CFLAGS) $(LIBPULSECORE_CFLAGS)
> -DPULSEAUDIO_HAS_PORTS=$(PULSEAUDIO_HAS_PORTS)
> +diff -urN
> pulseaudio-policy-enforcement-1.1.10/src/module-policy-enforcement.c
> pulseaudio-policy-enforcement-1.1.11/src/module-policy-enforcement.c
> +--- pulseaudio-policy-enforcement-1.1.10/src/module-policy-enforcement.c
>       2010-12-02 15:18:39.000000000 +0800
> ++++ pulseaudio-policy-enforcement-1.1.11/src/module-policy-enforcement.c
>       2011-03-07 13:43:09.000000000 +0800
> +@@ -24,6 +24,7 @@
> + #include <pulsecore/core-error.h>
> + #include <pulsecore/modargs.h>
> + #include <pulsecore/log.h>
> ++#include <glib.h>
> +
> + #include "module-policy-enforcement-symdef.h"
> + #include "userdata.h"
> +@@ -116,6 +117,7 @@
> +     u->classify = pa_classify_new(u);
> +     u->context  = pa_policy_context_new(u);
> +     u->dbusif   = pa_policy_dbusif_init(u, ifnam, mypath, pdpath, pdnam);
> ++    u->boardname = NULL;
> +
> +     if (u->scl == NULL      || u->ssnk == NULL     || u->ssrc == NULL ||
> +         u->ssi == NULL      || u->sso == NULL      || u->scrd == NULL
> ||
> +@@ -123,6 +125,17 @@
> +         u->classify == NULL || u->context == NULL  || u->dbusif == NULL)
> +         goto fail;
> +
> ++    const gchar *cmdline = "boardname";
> ++    gchar *output = NULL;
> ++    GError *error = NULL;
> ++    int exit_status = 0;
> ++    if (g_spawn_command_line_sync(cmdline, &output, NULL,
> &exit_status, &error)) {
> ++        u->boardname = output;
> ++        g_strstrip(u->boardname);
> ++        pa_log_info("Board %s Detected\n", u->boardname);
> ++    } else
> ++        pa_log_error("No Board Info Detected\n");
> ++
> +     pa_policy_groupset_update_default_sink(u, PA_IDXSET_INVALID);
> +     pa_policy_groupset_create_default_group(u, preempt);
> +
> +diff -urN pulseaudio-policy-enforcement-1.1.10/src/policy-group.c
> pulseaudio-policy-enforcement-1.1.11/src/policy-group.c
> +--- pulseaudio-policy-enforcement-1.1.10/src/policy-group.c  2010-12-02
> 15:18:39.000000000 +0800
> ++++ pulseaudio-policy-enforcement-1.1.11/src/policy-group.c  2011-03-07
> 13:43:27.000000000 +0800
> +@@ -308,6 +308,7 @@
> +     group->srcname  = srcname  ? pa_xstrdup(srcname) : NULL;
> +     group->source   = srcname  ? NULL : defsource;
> +     group->srcidx   = srcname  ? PA_IDXSET_INVALID : defsrcidx;
> ++    group->prfed_sinkname = pa_xstrdup(group->sinkname);
> +
> +     gset->hash_tbl[idx] = group;
> +
> +@@ -392,6 +393,7 @@
> +                 pa_xfree(group->name);
> +                 pa_xfree(group->sinkname);
> +                 pa_xfree(group->srcname);
> ++                pa_xfree(group->prfed_sinkname);
> +
> +                 prev->next = group->next;
> +
> +@@ -674,7 +676,13 @@
> +     int                       target_is_sink;
> +     int                       ret = -1;
> +
> ++    void            *state = NULL;
> ++    pa_idxset       *idxset;
> ++    struct pa_sink  *sink;
> ++
> +     pa_assert(u);
> ++    pa_assert(u->core);
> ++    pa_assert_se((idxset = u->core->sinks));
> +
> +     target.class = class;
> +     target.mode  = mode ? mode : "";
> +@@ -710,10 +718,41 @@
> +         else {                  /* move all groups */
> +             ret = 0;
> +
> +-            for (curs = NULL; (grp = pa_policy_group_scan(u->groups,
> &curs));){
> +-                if ((grp->flags &
> PA_POLICY_GROUP_FLAG_ROUTE_AUDIO)) {
> +-                    if (move_group(grp, &target) < 0)
> +-                        ret = -1;
> ++            if (u->boardname && !strcmp(IKB, u->boardname)) { /* IKB
> logic*/
> ++                for (curs = NULL; (grp = pa_policy_group_scan(u->groups,
> &curs));){
> ++                    if (target.class == pa_policy_route_to_sink &&
> (!strcmp(grp->name, "HDMI") || !strcmp(grp->name, "WIDI"))) {
> ++                        /* do not move HDMI and WIDI group */
> ++                        pa_log_error("Into the logic of HDMI and
> WIDI");
> ++
> ++                        struct pa_sink *target_sink = NULL;
> ++                        while ((sink = pa_idxset_iterate(idxset, &state,
> NULL)) != NULL) {
> ++                            if (!strcmp(sink->name,
> grp->prfed_sinkname)) {
> ++                                target_sink = sink;
> ++                                break;
> ++                            }
> ++                        }
> ++
> ++                        if (!target_sink) {
> ++                            target.sink = target_sink;
> ++                            if ((grp->flags &
> PA_POLICY_GROUP_FLAG_ROUTE_AUDIO)) {
> ++                                if (move_group(grp, &target) < 0)
> ++                                    ret = -1;
> ++                            }
> ++                        }
> ++                    }
> ++                    else {
> ++                        if ((grp->flags &
> PA_POLICY_GROUP_FLAG_ROUTE_AUDIO)) {
> ++                            if (move_group(grp, &target) < 0)
> ++                                ret = -1;
> ++                        }
> ++                    }
> ++                }
> ++            } else { /* Original logic*/
> ++                for (curs = NULL; (grp = pa_policy_group_scan(u->groups,
> &curs));){
> ++                    if ((grp->flags &
> PA_POLICY_GROUP_FLAG_ROUTE_AUDIO)) {
> ++                        if (move_group(grp, &target) < 0)
> ++                            ret = -1;
> ++                    }
> +                 }
> +             }
> +         }
> +diff -urN pulseaudio-policy-enforcement-1.1.10/src/policy-group.h
> pulseaudio-policy-enforcement-1.1.11/src/policy-group.h
> +--- pulseaudio-policy-enforcement-1.1.10/src/policy-group.h  2010-12-02
> 15:18:39.000000000 +0800
> ++++ pulseaudio-policy-enforcement-1.1.11/src/policy-group.h  2011-03-07
> 13:43:33.000000000 +0800
> +@@ -55,6 +55,7 @@
> (27 more lines skipped)
> 
> _______________________________________________
> MeeGo-commits mailing list
> [email protected]
> http://lists.meego.com/listinfo/meego-commits
_______________________________________________
MeeGo-packaging mailing list
[email protected]
http://lists.meego.com/listinfo/meego-packaging

Reply via email to