~ubuntu-branches/ubuntu/trusty/gnomeradio/trusty

« back to all changes in this revision

Viewing changes to debian/patches/gnomeradio-auto_device.patch

  • Committer: Package Import Robot
  • Author(s): POJAR GEORGE
  • Date: 2013-09-11 15:06:44 UTC
  • Revision ID: package-import@ubuntu.com-20130911150644-l8x3ubsyqmrvnkh8
Tags: 1.8-2ubuntu20
* Updated debian/patches/gnomeradio-station_list.patch: Prevent to parse
  malformed/incomplete/invalid XML file.
* Updated debian/patches/gnomeradio-auto_device.patch:
  - Automatically detect radio device when users type auto in settings field.
  - Updated error messages to be clear and precise.
* Updated debian/patches/gnomeradio-alsamixer.patch: Make presets list the
  default widget when open settings dialog. Presets are the most common
  settings for users than devices settings.
* Updated debian/patches/gnomeradio-about.patch: It is not safe in principle
  to write raw UTF-8 in narrow string literals, made to be multibyte
  encodings.
* debian/patches/gnomeradio-prefs.patch: Renamed to
  debian/patches/gnomeradio-about.patch.
* debian/patches/gnomeradio-preferences.patch: Make sentence capitalization in
  text and increased preferences dialog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
Index: gnomeradio-1.8/src/prefs.c
5
5
===================================================================
6
 
--- gnomeradio-1.8.orig/src/prefs.c     2013-09-10 21:07:38.591933000 +0000
7
 
+++ gnomeradio-1.8/src/prefs.c  2013-09-10 21:07:38.591933000 +0000
8
 
@@ -36,6 +36,7 @@
9
 
 extern int mom_ps;
10
 
 extern gnomeradio_settings settings;
11
 
 extern gboolean main_visible;
12
 
+extern gboolean autodetect;
13
 
 
14
 
 static GtkWidget *device_entry;
15
 
 static GtkWidget *mixer_entry;
16
 
@@ -65,7 +66,10 @@
 
6
--- gnomeradio-1.8.orig/src/prefs.c     2013-09-15 02:32:10.044914103 +0000
 
7
+++ gnomeradio-1.8/src/prefs.c  2013-09-15 02:33:03.324912519 +0000
 
8
@@ -30,6 +30,8 @@
 
9
 #include "rb_gst_media_types.h"
 
10
 #include "rb_missing_plugins.h"
 
11
 
 
12
+extern int autodetect;
 
13
+
 
14
 extern GtkWidget *preset_combo;
 
15
 extern GtkAdjustment *adj;
 
16
 
 
17
@@ -67,7 +69,10 @@
17
18
                return FALSE;
18
19
        
19
20
        /* Store general settings */
25
26
        gconf_client_set_string(client, "/apps/gnomeradio/driver", settings.driver, NULL);
26
27
        gconf_client_set_string(client, "/apps/gnomeradio/mixer", settings.mixer, NULL);
27
28
        gconf_client_set_bool(client, "/apps/gnomeradio/mute-on-exit", settings.mute_on_exit, NULL);
28
 
@@ -124,7 +128,7 @@
 
29
@@ -126,7 +131,7 @@
29
30
        /* Load general settings */
30
31
        settings.device = gconf_client_get_string(client, "/apps/gnomeradio/device" , NULL);
31
32
        if (!settings.device)
34
35
        settings.driver = gconf_client_get_string(client, "/apps/gnomeradio/driver" , NULL);
35
36
        if (!settings.driver)
36
37
                settings.driver = g_strdup("any");
37
 
@@ -211,6 +215,10 @@
38
 
                g_free(settings.device);
 
38
@@ -219,6 +224,24 @@
 
39
        return FALSE;
 
40
 }
39
41
 
40
 
        settings.device = g_strdup(text);
41
 
+
42
 
+       autodetect = FALSE;
43
 
+       if (0 == strcmp(settings.device, "auto"))
44
 
+               autodetect = TRUE;
45
 
        
46
 
        start_radio(TRUE, data);
47
 
        
48
 
@@ -1182,7 +1190,10 @@
 
42
+static void
 
43
+device_entry_auto_activate_cb(GtkEntry* entry, const gchar* text, gpointer data)
 
44
+{
 
45
+       GtkEditable *editable;
 
46
+
 
47
+       editable = GTK_EDITABLE (entry);
 
48
+
 
49
+       text = gtk_entry_get_text(GTK_ENTRY(device_entry));
 
50
+
 
51
+       autodetect = 0;
 
52
+       if (0 == strcmp(text, "auto")) {
 
53
+               g_signal_emit_by_name(G_OBJECT (editable), "activate");
 
54
+               autodetect = 1;
 
55
+
 
56
+               gtk_widget_grab_focus(add_button);
 
57
+       }
 
58
+}
 
59
+
 
60
 static gboolean mixer_entry_activate_cb(GtkWidget *widget, gpointer data)
 
61
 {
 
62
        const gchar *text;
 
63
@@ -1239,7 +1262,10 @@
49
64
        gtk_grid_attach (GTK_GRID (grid), label, 1, 1, 1, 1);
50
65
 
51
66
        device_entry = gtk_entry_new();
52
67
-       gtk_entry_set_text(GTK_ENTRY(device_entry), settings.device);
53
68
+       if (autodetect)
54
 
+               gtk_entry_set_text(GTK_ENTRY(device_entry), "auto");
 
69
+               gtk_entry_set_placeholder_text(GTK_ENTRY(device_entry), "auto");
55
70
+       else
56
71
+               gtk_entry_set_text(GTK_ENTRY(device_entry), settings.device);
57
72
        gtk_grid_attach(GTK_GRID(grid), device_entry, 2, 1, 1, 1);
58
73
 
59
74
        label = gtk_label_new (_("Mixer Source:"));
 
75
@@ -1257,6 +1283,7 @@
 
76
 
 
77
        g_signal_connect(G_OBJECT(device_entry), "hide", G_CALLBACK(device_entry_activate_cb), app);
 
78
        g_signal_connect(G_OBJECT(device_entry), "activate", G_CALLBACK(device_entry_activate_cb), NULL);
 
79
+       g_signal_connect(G_OBJECT(device_entry), "changed", G_CALLBACK(device_entry_auto_activate_cb), NULL);
 
80
        g_signal_connect(G_OBJECT(mixer_entry), "hide", G_CALLBACK(mixer_entry_activate_cb), app);
 
81
        g_signal_connect(G_OBJECT(mixer_entry), "activate", G_CALLBACK(mixer_entry_activate_cb), NULL);
 
82
        g_signal_connect(G_OBJECT(mute_on_exit_cb), "toggled", G_CALLBACK(mute_on_exit_toggled_cb), NULL);
60
83
Index: gnomeradio-1.8/src/gui.c
61
84
===================================================================
62
 
--- gnomeradio-1.8.orig/src/gui.c       2013-09-10 21:07:38.591933000 +0000
63
 
+++ gnomeradio-1.8/src/gui.c    2013-09-10 21:10:10.634239077 +0000
64
 
@@ -68,6 +68,7 @@
65
 
 gnomeradio_settings settings;
66
 
 
67
 
 gboolean main_visible;
68
 
+gboolean autodetect;
69
 
 
70
 
 GtkWidget *app;
71
 
 GtkWidget *preset_combo;
72
 
@@ -289,10 +290,24 @@
 
85
--- gnomeradio-1.8.orig/src/gui.c       2013-09-15 02:32:10.044914103 +0000
 
86
+++ gnomeradio-1.8/src/gui.c    2013-09-15 02:32:10.040914103 +0000
 
87
@@ -58,6 +58,8 @@
 
88
    USB radio devices benefit from a larger default latency */
 
89
 #define DEFAULT_LATENCY 500
 
90
 
 
91
+int autodetect;
 
92
+
 
93
 int alsa_loopback = 1;
 
94
 char *alsa_playback = NULL;
 
95
 char *alsa_capture = NULL;
 
96
@@ -289,10 +291,23 @@
73
97
                        driver = DRIVER_V4L2;
74
98
        }
75
99
 
76
 
+       autodetect = FALSE;
77
 
+       if (0 == strcmp(settings.device, "auto")) {
78
 
+               radio_set_device(settings.device, AUTO);
79
 
+               autodetect = TRUE;
80
 
+       }
 
100
+       autodetect = 0;
 
101
+       if (0 == strcmp(settings.device, "auto"))
 
102
+               autodetect = 1;
81
103
+
82
104
        if (!radio_init(settings.device, driver)) {
83
105
-               char *caption = g_strdup_printf(_("Could not open radio device \"%s\"!"), settings.device);
86
108
+               char *caption, *detail;
87
109
+
88
110
+               if (autodetect) {
89
 
+                       caption = g_strdup_printf (_("Could not find an radio device to connect to!"));
90
 
+                       detail = g_strdup_printf (_("Please ensure that you have a radio device connected.\n"
91
 
+                                                   "Also make sure that the device is connected properly."));
 
111
+                       caption = g_strdup_printf (_("Could not find any radio device!"));
 
112
+                       detail = g_strdup_printf (_("Please ensure that you have a radio device connected to your computer.\n"
 
113
+                                                   "You can also use the dmesg command: \"dmesg | grep radio\" to determine\n"
 
114
+                                                   "whether device is properly detected."));
92
115
+               } else {
93
116
+                       caption = g_strdup_printf (_("Could not open radio device \"%s\"!"), settings.device);
94
117
+                       detail = g_strdup_printf (_("You can auto detect radio device by typing \"auto\" in device settings."));
97
120
                show_error_message(caption, detail);
98
121
                g_free(caption);
99
122
                g_free(detail);
100
 
@@ -312,9 +327,12 @@
 
123
@@ -313,9 +328,12 @@
101
124
                mixer->close_device();
102
125
        
103
126
        if (!mixer_set_device(settings.mixer)) {
115
138
                g_free(detail);
116
139
Index: gnomeradio-1.8/src/radio.c
117
140
===================================================================
118
 
--- gnomeradio-1.8.orig/src/radio.c     2013-09-10 21:07:38.591933000 +0000
119
 
+++ gnomeradio-1.8/src/radio.c  2013-09-10 21:07:38.591933000 +0000
 
141
--- gnomeradio-1.8.orig/src/radio.c     2013-09-15 02:32:10.044914103 +0000
 
142
+++ gnomeradio-1.8/src/radio.c  2013-09-15 02:32:10.040914103 +0000
120
143
@@ -22,6 +22,7 @@
121
144
 #include <fcntl.h>
122
145
 #include <sys/ioctl.h>
125
148
 
126
149
 #include "radio.h"
127
150
 #include "v4l1.h"
128
 
@@ -40,6 +41,28 @@
 
151
@@ -29,6 +30,8 @@
 
152
 #include "alsa_stream.h"
 
153
 #include "get_media_devices.h"
 
154
 
 
155
+extern int autodetect;
 
156
+
 
157
 extern int alsa_loopback;
 
158
 extern char *alsa_playback;
 
159
 extern char *alsa_capture;
 
160
@@ -40,11 +43,37 @@
129
161
 /*
130
162
  * These functions handle the radio device
131
163
  */
132
 
+void radio_set_device(char *device, DeviceMode mode)
133
 
+{
134
 
+       switch (mode) {
135
 
+               case AUTO:
136
 
+               {
137
 
+                       void *md = discover_media_devices();
138
 
+                       const char *p = NULL;
139
 
+
140
 
+                       while (1) {
141
 
+                               p = get_associated_device(md, p, MEDIA_V4L_RADIO, NULL, NONE);
142
 
+                               if (!p)
143
 
+                                       break;
144
 
+                               snprintf(device, PATH_MAX, "/dev/%s", p);
145
 
+                       }
146
 
+
147
 
+                       free_media_devices(md);
148
 
+               }
149
 
+                       break;
150
 
+               default:
151
 
+                       break;
152
 
+       }
153
 
+}
154
 
  
 
164
155
165
 int radio_init(char *device, DriverType driver)
156
166
 {
157
 
Index: gnomeradio-1.8/src/radio.h
158
 
===================================================================
159
 
--- gnomeradio-1.8.orig/src/radio.h     2013-09-10 21:07:38.591933000 +0000
160
 
+++ gnomeradio-1.8/src/radio.h  2013-09-10 21:07:38.591933000 +0000
161
 
@@ -39,6 +39,14 @@
162
 
 
163
 
 int radio_init(char *device, DriverType type);
164
 
 
165
 
+typedef enum _DeviceMode DeviceMode;
166
 
+enum _DeviceMode
167
 
+{
168
 
+       AUTO
169
 
+};
170
 
+
171
 
+void radio_set_device(char *device, DeviceMode mode);
172
 
+
173
 
 int radio_is_init(void);
174
 
 
175
 
 void radio_stop(void);
 
167
        int rv = -1;
 
168
 
 
169
+       if (autodetect) {
 
170
+               void *md;
 
171
+               const char *p = NULL;
 
172
+               char buf[PATH_MAX];
 
173
+
 
174
+               *device = 0;
 
175
+               md = discover_media_devices();
 
176
+               if (!md) {
 
177
+                       fprintf (stderr, "open: Failed to open \"auto\" device");
 
178
+                       if (*device)
 
179
+                               fprintf (stderr, " at %s\n", device);
 
180
+                       else
 
181
+                               fprintf (stderr, "\n");
 
182
+                       goto failure;
 
183
+               }
 
184
+
 
185
+               while (1) {
 
186
+                       p = get_associated_device(md, p, MEDIA_V4L_RADIO, NULL, NONE);
 
187
+                       if (!p)
 
188
+                               break;
 
189
+                       snprintf(buf, sizeof(buf), "/dev/%s", p);
 
190
+                       device = &buf[0];
 
191
+               }
 
192
+
 
193
+               free_media_devices(md);
 
194
+       }
 
195
+
 
196
        switch (driver) {
 
197
                case DRIVER_ANY:
 
198
                case DRIVER_V4L2:
 
199
@@ -58,7 +87,7 @@
 
200
        dev = v4l1_radio_dev_new();
 
201
        rv = dev->init (dev, device);
 
202
        if (rv == 0) {
 
203
-        fprintf(stderr, "Initializing v4l1 failed\n");
 
204
+        fprintf(stderr, "v4l1: Initialization failed\n");
 
205
                dev->finalize (dev);
 
206
                dev = NULL;
 
207
                if (driver != DRIVER_ANY)
 
208
@@ -71,7 +100,7 @@
 
209
        dev = v4l2_radio_dev_new();
 
210
        rv = dev->init (dev, device);
 
211
        if (rv == 0) {
 
212
-        fprintf(stderr, "Initializing v4l2 failed\n");
 
213
+        fprintf(stderr, "v4l2: Initialization failed\n");
 
214
                dev->finalize (dev);
 
215
                dev = NULL;
 
216
                if (driver != DRIVER_ANY)
 
217
@@ -81,6 +110,12 @@
 
218
        }
 
219
 
 
220
 success:
 
221
+       if (autodetect)
 
222
+               fprintf(stderr, "open: Using radio device: %s\n", device);
 
223
+
 
224
+       if (dev == NULL)
 
225
+               alsa_loopback = 0;
 
226
+
 
227
        if (alsa_loopback) {
 
228
                if (alsa_capture == NULL) {
 
229
                        void *md = discover_media_devices();
176
230
Index: gnomeradio-1.8/data/gnomeradio.schemas.in
177
231
===================================================================
178
 
--- gnomeradio-1.8.orig/data/gnomeradio.schemas.in      2013-09-10 21:07:38.591933000 +0000
179
 
+++ gnomeradio-1.8/data/gnomeradio.schemas.in   2013-09-10 21:07:38.591933000 +0000
 
232
--- gnomeradio-1.8.orig/data/gnomeradio.schemas.in      2013-09-15 02:32:10.044914103 +0000
 
233
+++ gnomeradio-1.8/data/gnomeradio.schemas.in   2013-09-15 02:32:10.040914103 +0000
180
234
@@ -29,7 +29,7 @@
181
235
       <applyto>/apps/gnomeradio/device</applyto>
182
236
       <owner>gnomeradio</owner>