Merge ~alfonsosanchezbeato/snappy-hwe-snaps/+git/pulseaudio:example-snap into ~snappy-hwe-team/snappy-hwe-snaps/+git/pulseaudio:master
- Git
- lp:~alfonsosanchezbeato/snappy-hwe-snaps/+git/pulseaudio
- example-snap
- Merge into master
Status: | Merged |
---|---|
Approved by: | Simon Fels |
Approved revision: | 7bee74f71ea30ab0bada4974cd84b83b0042c4bd |
Merged at revision: | 43b5d389a7be81406f1d15fc66cf6f2b090f9405 |
Proposed branch: | ~alfonsosanchezbeato/snappy-hwe-snaps/+git/pulseaudio:example-snap |
Merge into: | ~snappy-hwe-team/snappy-hwe-snaps/+git/pulseaudio:master |
Diff against target: |
232 lines (+119/-30) 5 files modified
docs/access-from-other-snaps.md (+51/-20) docs/index.md (+8/-0) docs/install-pulseaudio.md (+13/-10) docs/metadata.yaml (+2/-0) docs/using-pulseaudio.md (+45/-0) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Simon Fels | Approve | ||
System Enablement Bot | continuous-integration | Approve | |
Jim Hodapp (community) | Approve | ||
Konrad Zapałowicz (community) | code | Approve | |
Review via email: mp+319454@code.launchpad.net |
Commit message
Some cleanup and link to example snap
Cleanup and comment on example snap that uses PA snap in Core.
Description of the change
Some cleanup and link to example snap
Cleanup and comment on example snap that uses PA snap in Core.
Simon Fels (morphis) : | # |
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
Konrad Zapałowicz (kzapalowicz) wrote : | # |
ack
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
Review comments addressed
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:8145ff719c7
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
Simon Fels (morphis) wrote : | # |
A few more comments inline.
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
Comments addressed and section added
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:be6c0fe6f80
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:c3cc1348365
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:64a5b1bf1d6
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
SUCCESS: https:/
Click here to trigger a rebuild:
https:/
Jim Hodapp (jhodapp) wrote : | # |
Looks great, several changes needed inline below.
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
Comments addressed
System Enablement Bot (system-enablement-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:7bee74f71ea
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | diff --git a/docs/access-from-other-snaps.md b/docs/access-from-other-snaps.md |
2 | index 3e778d7..7e4cb7d 100644 |
3 | --- a/docs/access-from-other-snaps.md |
4 | +++ b/docs/access-from-other-snaps.md |
5 | @@ -5,22 +5,22 @@ table_of_contents: True |
6 | |
7 | # Access PulseAudio From Other Snaps |
8 | |
9 | -To allow other snaps to play or record audio by using the PulseAudio service |
10 | -the *pulseaudio* interface exists which can be used to get access to features |
11 | -PulseAudio offers. Apart from using the *pulseaudio* interface a few other things |
12 | -need to be considered in order to get playback or recording working. These are |
13 | +To allow other snaps to play or record audio, or to use other PulseAudio |
14 | +features, the *pulseaudio* interface must be used. Apart from using this |
15 | +interface, a few other things need to be considered in order to get playback or |
16 | +recording to work. These are |
17 | |
18 | - 1. Define a pulseaudio interface plug for your application in the applications |
19 | + 1. Define a pulseaudio interface plug for your application in the application's |
20 | snapcraft.yaml. |
21 | 2. Set necessary environment variables for each application which communicates |
22 | with PulseAudio. |
23 | |
24 | ## Define Pulseaudio Interface Plug |
25 | |
26 | -To use the *pulseaudio* interface you simply need to define a plug with it |
27 | -in your *snapcraft.yaml* for all relevant applications: |
28 | +To use the *pulseaudio* interface you need to first define a plug with it in |
29 | +your *snapcraft.yaml* for all relevant applications: |
30 | |
31 | -``` |
32 | +```text |
33 | name: my-audio-snap |
34 | [...] |
35 | apps: |
36 | @@ -42,24 +42,55 @@ Now the interface connection between your client snap and the service is establi |
37 | |
38 | ## Set Necessary Environment Variables |
39 | |
40 | -In order to talk with the PulseAudio service you need to set one environment variable |
41 | -to ensure that libpulse finds the socket and other files it requires to talk to |
42 | -the service. The environment variable you need to set is the following: |
43 | +In order to talk with the PulseAudio service you need to set two environment |
44 | +variables to ensure that libpulse finds the socket and other files that it |
45 | +requires to talk to the service. The environment variables are the following: |
46 | |
47 | -``` |
48 | +```text |
49 | PULSE_RUNTIME_PATH=/var/run/pulse |
50 | +PULSE_SYSTEM=1 |
51 | + |
52 | ``` |
53 | |
54 | -This can be included in the snapcraft.yaml or in shell scripts you use as wrappers |
55 | -around your programs. In our example we will directly include it in the *snapcraft.yaml* file: |
56 | +This can be included in the snapcraft.yaml or in shell scripts you can use as |
57 | +wrappers around your programs. |
58 | |
59 | -``` |
60 | -name: my-audio-snap |
61 | -[...] |
62 | +## Example Program |
63 | + |
64 | +To illustrate these concepts, it is worth looking at this [small |
65 | +example](https://github.com/canonical-system-enablement/pulseaudio-example) that |
66 | +uses [libpulse](https://freedesktop.org/software/pulseaudio/doxygen/) and |
67 | +integrates properly with Ubuntu Core. |
68 | + |
69 | +You can compile and install following the instructions in the following |
70 | +[README file](https://github.com/canonical-system-enablement/pulseaudio-example/blob/master/README.md). |
71 | + |
72 | +The example is quite straightforward, although we can emphasize a couple of aspects. |
73 | + |
74 | +First, note the |
75 | +[snapcraft.yaml](https://github.com/canonical-system-enablement/pulseaudio-example/blob/master/snapcraft.yaml) |
76 | +file contains the following information: |
77 | + |
78 | +```text |
79 | apps: |
80 | - player: |
81 | - command: PULSE_RUNTIME_PATH=/var/run/pulse bin/player |
82 | + pulseaudio-example: |
83 | + command: bin/client-wrapper usr/bin/pulseaudio-example |
84 | plugs: |
85 | - pulseaudio |
86 | -[...] |
87 | + - home |
88 | ``` |
89 | + |
90 | +Which shows that we are using the pulseaudio plug and a wrapper. |
91 | +[The wrapper](https://github.com/canonical-system-enablement/pulseaudio-example/blob/master/overlay/bin/client-wrapper) |
92 | +sets the expected variables: |
93 | + |
94 | +```text |
95 | +export PULSE_RUNTIME_PATH=/var/run/pulse |
96 | +export PULSE_SYSTEM=1 |
97 | +``` |
98 | + |
99 | +Second, as explained in the [previous section](using-pulseaudio.md), for using |
100 | +PulseAudio, we need root permissions in Ubuntu Core, so we have to put the audio |
101 | +files in some place which belongs to root and that can be accessed by the snap, |
102 | +for instance $SNAP_COMMON, which would be /var/snap/pacat-simple/common in the |
103 | +example snap. |
104 | diff --git a/docs/index.md b/docs/index.md |
105 | index ea4f41e..591fcad 100644 |
106 | --- a/docs/index.md |
107 | +++ b/docs/index.md |
108 | @@ -11,6 +11,14 @@ as it passes between your application and your hardware. Things like transferrin |
109 | the audio to a different machine, changing the sample format or channel count and |
110 | mixing several sounds into one are easily achieved using a sound server. |
111 | |
112 | +PulseAudio works as a proxy to |
113 | +[ALSA](http://www.alsa-project.org/main/index.php/Main_Page) so if your kernel |
114 | +supports ALSA and the needed sound card drivers for your device, the snap should |
115 | +work out of the box. More information on the kernel configuration needed for |
116 | +audio can be found |
117 | +[here](https://www.kernel.org/doc/html/latest/sound/alsa-configuration.html). |
118 | +Of course, Ubuntu Kernel comes with all this already enabled. |
119 | + |
120 | PulseAudio is an integral part of all relevant modern Linux distributions and used |
121 | in various mobile devices by multiple vendors. |
122 | |
123 | diff --git a/docs/install-pulseaudio.md b/docs/install-pulseaudio.md |
124 | index 02d633f..16da8e9 100644 |
125 | --- a/docs/install-pulseaudio.md |
126 | +++ b/docs/install-pulseaudio.md |
127 | @@ -16,9 +16,10 @@ You can install the snap with the following command: |
128 | pulseaudio 8.0-3 from 'canonical' installed |
129 | ``` |
130 | |
131 | -Although the pulseaudio snap is available from other channels (candidate, beta, edge), |
132 | -only the stable version should be used for production devices. Their meaning is internal |
133 | -to the development team of the pulseaudio snap. |
134 | +Although the pulseaudio snap is available from other channels (candidate, beta, |
135 | +edge), only the stable version should be used for production devices. The |
136 | +purpose of the other channels is for internal use for the development team of |
137 | +the pulseaudio snap. |
138 | |
139 | All necessary plugs and slots will be automatically connected within the |
140 | installation process. You can verify this with: |
141 | @@ -32,13 +33,14 @@ pulseaudio:service pulseaudio:client |
142 | |
143 | ``` |
144 | |
145 | -As may noted, we do not connect the home plug of the PulseAudio snap by default. |
146 | -This is because normally you will use another snap to play audio through PulseAudio |
147 | -and then PulseAudio itself does not need any access to something outside of its |
148 | -snap as the playing snap will submits its audio data over network or memory based |
149 | -transport. If you want to use the included parec or paplay utilities you have to |
150 | -connect the home plug as otherwise both can only read/write data within the |
151 | -PulseAudio snap and nowhere else. You can connect it via: |
152 | +Please note that we do not connect the home plug of the PulseAudio snap by |
153 | +default. This is because normally you will use another snap to play audio |
154 | +through PulseAudio and then PulseAudio itself does not need any access to |
155 | +something outside of its snap as the playing snap will submits its audio data |
156 | +over network or memory based transport. If you want to use the included parec or |
157 | +paplay utilities you have to connect the home plug as otherwise both can only |
158 | +read/write data within the PulseAudio snap and nowhere else. You can connect it |
159 | +via: |
160 | |
161 | ``` |
162 | $ snap connect pulseaudio:home core |
163 | @@ -48,4 +50,5 @@ Now you have PulseAudio successfully installed. |
164 | |
165 | ## Next Steps |
166 | |
167 | + * [Using PulseAudio](using-pulseaudio.md) |
168 | * [Access from other snaps](access-from-other-snaps.md) |
169 | diff --git a/docs/metadata.yaml b/docs/metadata.yaml |
170 | index 321e111..5932a8a 100644 |
171 | --- a/docs/metadata.yaml |
172 | +++ b/docs/metadata.yaml |
173 | @@ -9,6 +9,8 @@ navigation: |
174 | children: |
175 | - title: Install PulseAudio |
176 | location: install-pulseaudio.md |
177 | + - title: Using PulseAudio |
178 | + location: using-pulseaudio.md |
179 | - title: Access from other snaps |
180 | location: access-from-other-snaps.md |
181 | - title: Reference |
182 | diff --git a/docs/using-pulseaudio.md b/docs/using-pulseaudio.md |
183 | new file mode 100644 |
184 | index 0000000..ac7d7ad |
185 | --- /dev/null |
186 | +++ b/docs/using-pulseaudio.md |
187 | @@ -0,0 +1,45 @@ |
188 | +--- |
189 | +title: "Using PulseAudio" |
190 | +table_of_contents: True |
191 | +--- |
192 | + |
193 | +# Using PulseAudio |
194 | + |
195 | +## PulseAudio Daemon |
196 | + |
197 | +After install of pulseaudio snap, the pulseaudio daemon should be up and |
198 | +running. We can check its status with systemctl, and something similar to |
199 | + |
200 | +```text |
201 | +$ systemctl status snap.pulseaudio.pulseaudio.service | cat |
202 | +● snap.pulseaudio.pulseaudio.service - Service for snap application pulseaudio.pulseaudio |
203 | + Loaded: loaded (/etc/systemd/system/snap.pulseaudio.pulseaudio.service; enabled; vendor preset: enabled) |
204 | + Active: active (running) since Fri 2017-03-10 08:09:05 UTC; 2min 10s ago |
205 | + Main PID: 1242 (pulseaudio) |
206 | + CGroup: /system.slice/snap.pulseaudio.pulseaudio.service |
207 | + ├─1242 /bin/sh /snap/pulseaudio/9/bin/pulseaudio |
208 | + └─1276 /snap/pulseaudio/9/usr/bin/pulseaudio --exit-idle-time=-1 --disallow-exit=yes --disallow-module-loading --system -F /snap/pulseaudio/9/etc/pulse/default.pa -p /snap/pulseaudio/9/usr/lib/pulse-8.0/modules -n |
209 | +``` |
210 | + |
211 | +should be displayed. |
212 | + |
213 | +## PulseAudio Utils |
214 | + |
215 | +The snap also includes some core pulseaudio utilities: |
216 | +[pactl](http://manpages.ubuntu.com/manpages/zesty/en/man1/pactl.1.html), |
217 | +[paplay](http://manpages.ubuntu.com/manpages/zesty/en/man1/paplay.1.html) and |
218 | +[parec](http://manpages.ubuntu.com/manpages/zesty/en/man1/parec.1.html). Usage |
219 | +is as normally expected (check the linked man pages), but we need to take into |
220 | +account that we are running PA in system mode and we need root permissions when |
221 | +accessing it. This also implies that files need to be in some place which |
222 | +belongs to root and that can be accessed by the snap, like |
223 | +[$SNAP_COMMON](https://snapcraft.io/docs/reference/env). For instance, if we |
224 | +want to play an audio file that we have in our home folder with paplay, the |
225 | +command would be similar to |
226 | + |
227 | +```text |
228 | +$ sudo cp <audio-file> /var/snap/pacat-simple/common/ |
229 | +$ sudo paplay /var/snap/pacat-simple/common/<audio-file> |
230 | +``` |
231 | + |
232 | +The same appplies to the rest of the commands. |
PASSED: Continuous integration, rev:78f6b134efd 19a82da1d45a4ee b3adc4f11cc212 /jenkins. canonical. com/system- enablement/ job/generic- build-snap/ 1267/ /jenkins. canonical. com/system- enablement/ job/generic- build-snap- worker/ 336 /jenkins. canonical. com/system- enablement/ job/generic- update- snap-mp/ 1175/console /jenkins. canonical. com/system- enablement/ job/generic- test-snap/ 993 /jenkins. canonical. com/system- enablement/ job/generic- cleanup- snap/9/ console
https:/
Executed test runs:
SUCCESS: https:/
None: https:/
SUCCESS: https:/
None: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/system- enablement/ job/generic- build-snap/ 1267/rebuild
https:/