Merge lp:~cjcurran/indicator-sound/fix-playlist-null-pointer into lp:indicator-sound/fifth

Proposed by Conor Curran
Status: Merged
Approved by: Ted Gould
Approved revision: 301
Merged at revision: 299
Proposed branch: lp:~cjcurran/indicator-sound/fix-playlist-null-pointer
Merge into: lp:indicator-sound/fifth
Diff against target: 221 lines (+97/-38)
3 files modified
src/mpris2-controller.vala (+1/-2)
src/mpris2-interfaces.vala (+6/-6)
src/pulseaudio-mgr.c (+90/-30)
To merge this branch: bzr merge lp:~cjcurran/indicator-sound/fix-playlist-null-pointer
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+95395@code.launchpad.net

Description of the change

Fixes bugs attached.

To post a comment you must log in.
Ted Gould (ted) wrote :

Makes sense to me. Not sure I can recreate those bugs, but this should make things safer no matter.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/mpris2-controller.vala'
2--- src/mpris2-controller.vala 2011-10-21 19:03:54 +0000
3+++ src/mpris2-controller.vala 2012-03-01 16:02:32 +0000
4@@ -248,8 +248,7 @@
5 private bool fetch_active_playlist()
6 {
7 if (this.playlists.ActivePlaylist.valid == false){
8- // TODO
9- // What happens here ?
10+ return false;
11 }
12 PlaylistsMenuitem playlists_item = this.owner.custom_items[PlayerController.widget_order.PLAYLISTS] as PlaylistsMenuitem;
13 playlists_item.active_playlist_update ( this.playlists.ActivePlaylist.details );
14
15=== modified file 'src/mpris2-interfaces.vala'
16--- src/mpris2-interfaces.vala 2011-03-08 21:43:50 +0000
17+++ src/mpris2-interfaces.vala 2012-03-01 16:02:32 +0000
18@@ -49,15 +49,15 @@
19
20 // Playlist container
21 public struct PlaylistDetails{
22- public ObjectPath path;
23- public string name;
24- public string icon_path;
25+ public ObjectPath? path;
26+ public string? name;
27+ public string? icon_path;
28 }
29
30 // Active playlist property container
31 public struct ActivePlaylistContainer{
32 public bool valid;
33- public PlaylistDetails details;
34+ public PlaylistDetails? details;
35 }
36
37 [DBus (name = "org.mpris.MediaPlayer2.Playlists")]
38@@ -69,11 +69,11 @@
39
40 //methods
41 public abstract async void ActivatePlaylist(ObjectPath playlist_id) throws IOError;
42- public abstract async PlaylistDetails[] GetPlaylists ( uint32 index,
43+ public abstract async PlaylistDetails[]? GetPlaylists ( int32 index,
44 uint32 max_count,
45 string order,
46 bool reverse_order ) throws IOError;
47 //signals
48 public signal void PlaylistChanged (PlaylistDetails details);
49
50-}
51\ No newline at end of file
52+}
53
54=== modified file 'src/pulseaudio-mgr.c'
55--- src/pulseaudio-mgr.c 2012-02-22 16:40:59 +0000
56+++ src/pulseaudio-mgr.c 2012-03-01 16:02:32 +0000
57@@ -121,7 +121,6 @@
58 reconnect_to_pulse (gpointer user_data)
59 {
60 g_debug("Attempt a pulse connection");
61- // reset
62 g_return_val_if_fail (IS_DEVICE (user_data), FALSE);
63
64 connection_attempts += 1;
65@@ -175,50 +174,107 @@
66 pm_update_volume (gint sink_index, pa_cvolume new_volume)
67 {
68 if (sink_index < 0 || pulse_context == NULL){
69- return;
70- }
71- pa_operation_unref (pa_context_set_sink_volume_by_index (pulse_context,
72- sink_index,
73- &new_volume,
74- NULL,
75- NULL) );
76+ g_warning ("pm_update_volume sink index is negative or the context is null");
77+ return;
78+ }
79+
80+ if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){
81+ g_warning ("pm_update_volume context is not in a ready state");
82+ return;
83+ }
84+
85+ pa_operation *operation = NULL;
86+
87+ operation = pa_context_set_sink_volume_by_index (pulse_context,
88+ sink_index,
89+ &new_volume,
90+ NULL,
91+ NULL);
92+ if (!operation){
93+ g_warning ("pm_update_volume operation failed for some reason");
94+ return;
95+ }
96+ pa_operation_unref (operation);
97 }
98
99 void
100 pm_update_mute (gboolean update)
101 {
102- pa_operation_unref (pa_context_get_sink_info_list (pulse_context,
103- pm_toggle_mute_for_every_sink_callback,
104- GINT_TO_POINTER (update)));
105+ if (pulse_context == NULL){
106+ g_warning ("pm_update_mute - the context is null");
107+ return;
108+ }
109+
110+ if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){
111+ g_warning ("pm_update_mute context is not in a ready state");
112+ return;
113+ }
114+
115+ pa_operation *operation = NULL;
116+
117+ operation = pa_context_get_sink_info_list (pulse_context,
118+ pm_toggle_mute_for_every_sink_callback,
119+ GINT_TO_POINTER (update));
120+ if (!operation){
121+ g_warning ("pm_update_mute operation failed for some reason");
122+ return;
123+ }
124+ pa_operation_unref (operation);
125 }
126
127 void
128 pm_update_mic_gain (gint source_index, pa_cvolume new_gain)
129 {
130- // LP: #850662
131 if (source_index < 0 || pulse_context == NULL){
132- return;
133- }
134- pa_operation_unref (pa_context_set_source_volume_by_index (pulse_context,
135- source_index,
136- &new_gain,
137- NULL,
138- NULL) );
139+ g_warning ("pm_update_mic_gain source index is negative or the context is null");
140+ return;
141+ }
142+
143+ if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){
144+ g_warning ("pm_update_mic_gain context is not in a ready state");
145+ return;
146+ }
147+
148+ pa_operation *operation = NULL;
149+
150+ operation = pa_context_set_source_volume_by_index (pulse_context,
151+ source_index,
152+ &new_gain,
153+ NULL,
154+ NULL);
155+ if (!operation){
156+ g_warning ("pm_update_mic_gain operation failed for some reason");
157+ return;
158+ }
159+ pa_operation_unref (operation);
160 }
161
162 void
163 pm_update_mic_mute (gint source_index, gint mute_update)
164 {
165- // LP: #850662
166- if (source_index < 0){
167- return;
168- }
169- pa_operation_unref (pa_context_set_source_mute_by_index (pulse_context,
170- source_index,
171- mute_update,
172- NULL,
173- NULL));
174+ if (source_index < 0){
175+ return;
176+ }
177+
178+ if (pa_context_get_state (pulse_context) != PA_CONTEXT_READY ){
179+ g_warning ("pm_update_mic_mute context is not in a ready state");
180+ return;
181+ }
182+
183+ pa_operation *operation = NULL;
184+
185+ operation = pa_context_set_source_mute_by_index (pulse_context,
186+ source_index,
187+ mute_update,
188+ NULL,
189+ NULL);
190+ if (!operation){
191+ g_warning ("pm_update_mic_mute operation failed for some reason");
192+ return;
193+ }
194+ pa_operation_unref (operation);
195 }
196+
197 /**********************************************************************************************************************/
198 // Pulse-Audio asychronous call-backs
199 /**********************************************************************************************************************/
200@@ -308,8 +364,6 @@
201 }
202 }
203
204-
205-
206 static void
207 pm_context_state_callback (pa_context *c, void *userdata)
208 {
209@@ -337,6 +391,12 @@
210 break;
211 case PA_CONTEXT_TERMINATED:
212 g_debug ("Terminated");
213+ device_sink_deactivated (DEVICE (userdata));
214+
215+ if (reconnect_idle_id != 0){
216+ g_source_remove (reconnect_idle_id);
217+ reconnect_idle_id = 0;
218+ }
219 break;
220 case PA_CONTEXT_READY:
221 connection_attempts = 0;

Subscribers

People subscribed via source and target branches