~ubuntu-branches/ubuntu/saucy/gnomeradio/saucy

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): POJAR GEORGE
  • Date: 2013-07-05 15:14:16 UTC
  • Revision ID: package-import@ubuntu.com-20130705151416-pebdtz831ugsabv3
Tags: 1.8-2ubuntu15
* Modified debian/patches/gnomeradio-alsa.patch: Added command line option to
  disable loopback digital audio from radio device.
* Modified debian/patches/gnomeradio-media_types.patch: Use
  g_return_val_if_fail().
* debian/gnomeradio.sgml: Updated man page.
* Refresh patches:
  - debian/patches/gnomeradio-alsamixer.patch
  - debian/patches/gnomeradio-media_types.patch
  - debian/patches/gnomeradio-save_the_world.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
Index: gnomeradio-1.8/src/alsa_stream.c
5
5
===================================================================
6
6
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
7
 
+++ gnomeradio-1.8/src/alsa_stream.c    2013-06-13 02:59:30.447406767 +0000
 
7
+++ gnomeradio-1.8/src/alsa_stream.c    2013-07-05 09:04:47.332932682 +0000
8
8
@@ -0,0 +1,640 @@
9
9
+/*
10
10
+ *  ALSA streaming support
649
649
Index: gnomeradio-1.8/src/alsa_stream.h
650
650
===================================================================
651
651
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
652
 
+++ gnomeradio-1.8/src/alsa_stream.h    2013-06-13 02:56:45.297964000 +0000
 
652
+++ gnomeradio-1.8/src/alsa_stream.h    2013-07-05 09:04:47.332932682 +0000
653
653
@@ -0,0 +1,34 @@
654
654
+
655
655
+/*
688
688
Index: gnomeradio-1.8/src/get_media_devices.c
689
689
===================================================================
690
690
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
691
 
+++ gnomeradio-1.8/src/get_media_devices.c      2013-06-13 03:02:09.747402032 +0000
 
691
+++ gnomeradio-1.8/src/get_media_devices.c      2013-07-05 09:20:15.000000000 +0000
692
692
@@ -0,0 +1,595 @@
693
693
+/*
694
694
+   Copyright © 2011 by Mauro Carvalho Chehab <mchehab@redhat.com>
1288
1288
Index: gnomeradio-1.8/src/get_media_devices.h
1289
1289
===================================================================
1290
1290
--- /dev/null   1970-01-01 00:00:00.000000000 +0000
1291
 
+++ gnomeradio-1.8/src/get_media_devices.h      2013-06-13 02:56:45.297964000 +0000
 
1291
+++ gnomeradio-1.8/src/get_media_devices.h      2013-07-05 09:04:47.336932682 +0000
1292
1292
@@ -0,0 +1,168 @@
1293
1293
+/*
1294
1294
+   Copyright © 2011 by Mauro Carvalho Chehab <mchehab@redhat.com>
1460
1460
+                                     const enum device_type not_desired_type);
1461
1461
Index: gnomeradio-1.8/configure.in
1462
1462
===================================================================
1463
 
--- gnomeradio-1.8.orig/configure.in    2013-06-13 02:56:45.297964000 +0000
1464
 
+++ gnomeradio-1.8/configure.in 2013-06-13 02:57:49.000000000 +0000
 
1463
--- gnomeradio-1.8.orig/configure.in    2013-07-05 09:04:47.340932682 +0000
 
1464
+++ gnomeradio-1.8/configure.in 2013-07-05 09:20:18.000000000 +0000
1465
1465
@@ -5,7 +5,7 @@
1466
1466
 AM_INIT_AUTOMAKE(AC_PACKAGE_NAME, AC_PACKAGE_VERSION)
1467
1467
 
1509
1509
 ])
1510
1510
+
1511
1511
+AC_OUTPUT
1512
 
Index: gnomeradio-1.8/src/radio.h
1513
 
===================================================================
1514
 
--- gnomeradio-1.8.orig/src/radio.h     2013-06-13 02:56:45.297964000 +0000
1515
 
+++ gnomeradio-1.8/src/radio.h  2013-06-13 02:56:45.297964000 +0000
1516
 
@@ -47,9 +47,9 @@
1517
 
 
1518
 
 int radio_check_station(float freq);
1519
 
 
1520
 
-void radio_unmute(void);
1521
 
+void radio_unmute(int alsa_loopback);
1522
 
 
1523
 
-void radio_mute(void);
1524
 
+void radio_mute(int alsa_loopback);
1525
 
 
1526
 
 int radio_get_stereo(void);
1527
 
 
1528
1512
Index: gnomeradio-1.8/src/gui.c
1529
1513
===================================================================
1530
 
--- gnomeradio-1.8.orig/src/gui.c       2013-06-13 02:56:45.297964000 +0000
1531
 
+++ gnomeradio-1.8/src/gui.c    2013-06-13 02:57:50.000000000 +0000
 
1514
--- gnomeradio-1.8.orig/src/gui.c       2013-07-05 09:04:47.340932682 +0000
 
1515
+++ gnomeradio-1.8/src/gui.c    2013-07-05 09:20:33.968904542 +0000
1532
1516
@@ -36,6 +36,7 @@
1533
1517
 #include "lirc.h"
1534
1518
 #include "prefs.h"
1549
1533
+char *alsa_playback = NULL;
1550
1534
+char *alsa_capture = NULL;
1551
1535
+int alsa_latency = DEFAULT_LATENCY;
1552
 
+int debug = 0;
 
1536
+int alsa_debug = 0;
1553
1537
+
1554
1538
 GtkWidget* mute_button, *preset_combo;
1555
1539
 GtkAdjustment *adj;
1556
1540
 GtkWidget* app;
 
1541
@@ -68,7 +79,7 @@
 
1542
 
 
1543
 static int timeout_id, bp_timeout_id = -1, bp_timeout_steps = 0;
 
1544
 
 
1545
-static DBusGProxy      * connect_to_session               (void);
 
1546
+static DBusGProxy      * connect_to_session           (void);
 
1547
 
 
1548
 static gboolean is_first_start(void)
 
1549
 {
1557
1550
@@ -115,7 +126,7 @@
1558
1551
                gtk_label_set_text(GTK_LABEL(fsd->label), text);
1559
1552
                g_free(text);
1563
1556
                
1564
1557
                *f = freq;
1565
1558
                fsd->stations = g_list_append(fsd->stations, f);
1566
 
@@ -158,11 +169,11 @@
1567
 
        
1568
 
        gtk_widget_show_all(data.dialog);
1569
 
        
1570
 
-       radio_mute();
1571
 
+       radio_mute(alsa_loopback);
1572
 
        timeout_id = g_timeout_add(1000/SCAN_SPEED, (GSourceFunc)initial_frequency_scan_cb, (gpointer)&data);   
1573
 
        gtk_dialog_run(GTK_DIALOG(data.dialog));
1574
 
 
1575
 
-       radio_unmute();
1576
 
+       radio_unmute(alsa_loopback);
1577
 
        if (timeout_id) {
1578
 
                g_source_remove(timeout_id);
1579
 
                timeout_id = 0;
1580
 
@@ -419,7 +430,7 @@
1581
 
 {
1582
 
        if (settings.mute_on_exit)
1583
 
        {
1584
 
-               radio_mute();
1585
 
+               radio_mute(alsa_loopback);
 
1559
@@ -250,10 +261,10 @@
1586
1560
                radio_stop();
1587
 
        }
1588
 
        mixer_close();
1589
 
@@ -569,7 +580,7 @@
1590
 
                
1591
 
        if (radio_check_station(gtk_adjustment_get_value(adj)/STEPS) || (start > max))  {
1592
 
                start = mom = 0;
1593
 
-               radio_unmute();
1594
 
+               radio_unmute(alsa_loopback);
1595
 
                timeout_id = 0;
1596
 
                return FALSE;
1597
 
        }
1598
 
@@ -594,10 +605,10 @@
1599
 
        if (timeout_id) {
1600
 
                g_source_remove(timeout_id);
1601
 
                timeout_id = 0;
1602
 
-               radio_unmute();
1603
 
+               radio_unmute(alsa_loopback);
1604
 
                return;
1605
 
        }
1606
 
-       radio_mute();
1607
 
+       radio_mute(alsa_loopback);
1608
 
        timeout_id = g_timeout_add(1000/SCAN_SPEED, (GSourceFunc)scan_freq, (gpointer)1);       
1609
 
 }
1610
 
 
1611
 
@@ -606,10 +617,10 @@
1612
 
        if (timeout_id) {
1613
 
                g_source_remove(timeout_id);
1614
 
                timeout_id = 0;
1615
 
-               radio_unmute();
1616
 
+               radio_unmute(alsa_loopback);
1617
 
                return;
1618
 
        }
1619
 
-       radio_mute();
1620
 
+       radio_mute(alsa_loopback);
1621
 
        timeout_id = g_timeout_add(1000/SCAN_SPEED, (GSourceFunc)scan_freq, (gpointer)(-1));    
1622
 
 }
1623
 
 
 
1561
        
 
1562
     if (settings.driver) {
 
1563
-        if (0 == strcmp(settings.driver, "v4l1"))
 
1564
-            driver = DRIVER_V4L1;
 
1565
-        if (0 == strcmp(settings.driver, "v4l2"))
 
1566
-            driver = DRIVER_V4L2;
 
1567
+       if (0 == strcmp(settings.driver, "v4l1"))
 
1568
+           driver = DRIVER_V4L1;
 
1569
+       if (0 == strcmp(settings.driver, "v4l2"))
 
1570
+           driver = DRIVER_V4L2;
 
1571
     }
 
1572
 
 
1573
        if (!radio_init(settings.device, driver))
1624
1574
@@ -790,8 +801,19 @@
1625
1575
        if (vol) {
1626
1576
                old_vol = vol;
1637
1587
                vol = old_vol;
1638
1588
+               if (alsa_loopback)
1639
1589
+                       alsa_thread_startup(alsa_playback, alsa_capture,
1640
 
+                                           alsa_latency, stderr, debug);
 
1590
+                                           alsa_latency, stderr, alsa_debug);
1641
1591
        }       
1642
1592
        mixer_set_volume(vol);
1643
1593
        gtk_volume_button_set_value(mute_button, vol);
1644
 
@@ -1123,7 +1145,7 @@
1645
 
 {
1646
 
        if (settings.mute_on_exit)
1647
 
        {
1648
 
-               radio_mute();
1649
 
+               radio_mute(alsa_loopback);
1650
 
                radio_stop();
1651
 
        }
1652
 
        mixer_close();
1653
 
@@ -1194,6 +1216,16 @@
 
1594
@@ -1194,6 +1216,97 @@
1654
1595
        return FALSE;
1655
1596
 }
1656
1597
 
 
1598
+enum
 
1599
+{
 
1600
+       ARG_ALSA_LOOPBACK,
 
1601
+       ARG_NO_ALSA_LOOPBACK,
 
1602
+       ARG_ALSA_CAPTURE,
 
1603
+       ARG_ALSA_PLAYBACK,
 
1604
+       ARG_ALSA_LATENCY,
 
1605
+       ARG_ALSA_DEBUG
 
1606
+};
 
1607
+
 
1608
+static gboolean
 
1609
+parse_one_option (gint opt, const gchar * arg, GError ** err)
 
1610
+{
 
1611
+       switch (opt) {
 
1612
+               case ARG_ALSA_LOOPBACK:
 
1613
+                       alsa_loopback = 1;
 
1614
+                       break;
 
1615
+               case ARG_NO_ALSA_LOOPBACK:
 
1616
+                       alsa_loopback = 0;
 
1617
+                       break;
 
1618
+               case ARG_ALSA_CAPTURE:
 
1619
+                       if (!strncmp(arg, "hw:", 3) && isdigit(arg[3]) && arg[4] == ',' && isdigit(arg[5])) {
 
1620
+                               alsa_capture = g_strdup (arg);
 
1621
+                               break;
 
1622
+                       } else {
 
1623
+                               g_set_error(err, G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
 
1624
+                                           _("invalid argument name '%s', must be e.g. 'hw:1,0'"), arg);
 
1625
+                               return FALSE;
 
1626
+                       }
 
1627
+               case ARG_ALSA_PLAYBACK:
 
1628
+                       if (!strncmp(arg, "hw:", 3) && isdigit(arg[3]) && arg[4] == ',' && isdigit(arg[5])) {
 
1629
+                               alsa_capture = g_strdup (arg);
 
1630
+                               break;
 
1631
+                       } else {
 
1632
+                               g_set_error(err, G_OPTION_ERROR, G_OPTION_ERROR_FAILED,
 
1633
+                                           _("invalid argument name '%s', must be e.g. 'hw:0,0'"), arg);
 
1634
+                               return FALSE;
 
1635
+                       }
 
1636
+               case ARG_ALSA_LATENCY:
 
1637
+                       alsa_latency = atoi (arg);
 
1638
+                       break;
 
1639
+               case ARG_ALSA_DEBUG:
 
1640
+                       alsa_debug = 1;
 
1641
+                       break;
 
1642
+               default:
 
1643
+                       g_set_error (err, G_OPTION_ERROR, G_OPTION_ERROR_UNKNOWN_OPTION,
 
1644
+                                       _("Unknown option"));
 
1645
+                       return FALSE;
 
1646
+       }
 
1647
+
 
1648
+       return TRUE;
 
1649
+}
 
1650
+
 
1651
+static gboolean
 
1652
+option_alsa_cb (const gchar * opt,
 
1653
+                  const gchar * arg, gpointer data, GError ** err)
 
1654
+{
 
1655
+       static const struct
 
1656
+       {
 
1657
+               const gchar *opt;
 
1658
+               int val;
 
1659
+       } options[] = {
 
1660
+               {
 
1661
+               "--alsa-loopback", ARG_ALSA_LOOPBACK}, {
 
1662
+               "--no-alsa-loopback", ARG_NO_ALSA_LOOPBACK}, {
 
1663
+               "--alsa-capture", ARG_ALSA_CAPTURE}, {
 
1664
+               "--alsa-playback", ARG_ALSA_PLAYBACK}, {
 
1665
+               "--alsa-latency", ARG_ALSA_LATENCY}, {
 
1666
+               "--alsa-debug", ARG_ALSA_DEBUG}, {
 
1667
+               NULL}
 
1668
+       };
 
1669
+       gint val = 0, n;
 
1670
+
 
1671
+       for (n = 0; options[n].opt; n++) {
 
1672
+               if (!strcmp (opt, options[n].opt)) {
 
1673
+                       val = options[n].val;
 
1674
+                       break;
 
1675
+               }
 
1676
+       }
 
1677
+
 
1678
+       return parse_one_option (val, arg, err);
 
1679
+}
 
1680
+
1657
1681
+G_GNUC_NORETURN static gboolean
1658
 
+option_version_cb (const gchar *option_name,
1659
 
+                  const gchar *value,
1660
 
+                  gpointer     data,
1661
 
+                  GError     **error)
 
1682
+option_version_cb (const gchar * opt,
 
1683
+                  const gchar * arg, gpointer data, GError ** err)
1662
1684
+{
1663
1685
+       g_print ("%s %s\n", PACKAGE, VERSION);
1664
1686
+       exit (0);
1667
1689
 int main(int argc, char* argv[])
1668
1690
 {
1669
1691
        GList *ptr;
1670
 
@@ -1202,23 +1234,38 @@
 
1692
@@ -1202,23 +1315,39 @@
1671
1693
        gboolean do_scan = FALSE;
1672
1694
        GOptionContext *ctx;
1673
1695
        const GOptionEntry entries[] = {
1674
1696
-               { "scan", 0, 0, G_OPTION_ARG_NONE, &do_scan, N_("Scan for stations"), NULL },
1675
 
+               { "alsa-loopback", '\0', 0, G_OPTION_ARG_INT, &alsa_loopback, N_("Loopback digital audio from radio device  [default: enable]"), N_("0|1") },
1676
 
+               { "alsa-capture", '\0', 0, G_OPTION_ARG_STRING, &alsa_capture, N_("Capture device for loopback (e.g. hw:1,0)  [default: auto]"), N_("DEVICE") },
1677
 
+               { "alsa-playback", '\0', 0, G_OPTION_ARG_STRING, &alsa_playback, N_("Playback device for loopback (e.g. hw:0,0)  [default: default]"), N_("DEVICE") },
1678
 
+               { "alsa-latency", '\0', 0, G_OPTION_ARG_INT, &alsa_latency, N_("Latency for loopback in ms  [default: 500]"), N_("VALUE") },
 
1697
+               { "alsa-loopback", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) option_alsa_cb, N_("Enable loopback digital audio from radio device (default: enable)"), NULL },
 
1698
+               { "no-alsa-loopback", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) option_alsa_cb, N_("Disable loopback digital audio from radio device"), NULL },
 
1699
+               { "alsa-capture", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) option_alsa_cb, N_("Set capture device for loopback digital audio (default: auto)"), N_("DEVICE") },
 
1700
+               { "alsa-playback", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) option_alsa_cb, N_("Set playback device for loopback digital audio (default: default)"), N_("DEVICE") },
 
1701
+               { "alsa-latency", 0, 0, G_OPTION_ARG_CALLBACK, (gpointer) option_alsa_cb, N_("Set latency for loopback digital audio in ms (default: 500)"), N_("TIME") },
 
1702
+               { "alsa-debug", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, (gpointer) option_alsa_cb, N_("Enable debug output for loopback digital audio"), NULL },
1679
1703
+               { "scan", '\0', 0, G_OPTION_ARG_NONE, &do_scan, N_("Scan for stations"), NULL },
1680
 
+               { "verbose", '\0', 0, G_OPTION_ARG_NONE, &debug, N_("Enable verbose output"), NULL },
1681
1704
+               { "version", 0, G_OPTION_FLAG_NO_ARG | G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_CALLBACK, option_version_cb, NULL, NULL },
1682
1705
                { NULL }
1683
1706
        };
1711
1734
        /* Main app */
1712
1735
        main_visible = FALSE;
1713
1736
        app = gnome_radio_gui();
1714
 
@@ -1241,11 +1288,12 @@
 
1737
@@ -1241,11 +1370,12 @@
1715
1738
        }
1716
1739
 
1717
1740
        load_settings();
1725
1748
                } else {
1726
1749
                        initial_frequency_scan(app);
1727
1750
                        set_first_time_flag();
1728
 
@@ -1278,12 +1326,12 @@
 
1751
@@ -1278,12 +1408,12 @@
1729
1752
                gtk_dialog_run (GTK_DIALOG (dialog));
1730
1753
                gtk_widget_destroy (dialog);
1731
1754
 */
1740
1763
 /* Connect the Session Management signals
1741
1764
  */
1742
1765
 
 
1766
@@ -1324,7 +1454,7 @@
 
1767
 {
 
1768
        DBusGConnection *connection;
 
1769
        DBusGProxy      *proxy;
 
1770
-       GError          *error = NULL;
 
1771
+       GError    *error = NULL;
 
1772
 
 
1773
        connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
 
1774
 
1743
1775
Index: gnomeradio-1.8/src/Makefile.am
1744
1776
===================================================================
1745
 
--- gnomeradio-1.8.orig/src/Makefile.am 2013-06-13 02:56:45.297964000 +0000
1746
 
+++ gnomeradio-1.8/src/Makefile.am      2013-06-13 02:57:50.000000000 +0000
 
1777
--- gnomeradio-1.8.orig/src/Makefile.am 2013-07-05 09:04:47.340932682 +0000
 
1778
+++ gnomeradio-1.8/src/Makefile.am      2013-07-05 09:20:19.000000000 +0000
1747
1779
@@ -1,35 +1,39 @@
1748
1780
-INCLUDES = -I$(top_srcdir) -I$(includedir) \
1749
1781
-           $(GNOME_CFLAGS) $(GSTREAMER_CFLAGS) $(XML_CFLAGS)\
1817
1849
+gnomeradio_LDADD = $(ALSA_LIBS) $(GNOME_LIBS) $(GSTREAMER_LIBS) $(XML_LIBS) $(LIRC)
1818
1850
Index: gnomeradio-1.8/src/radio.c
1819
1851
===================================================================
1820
 
--- gnomeradio-1.8.orig/src/radio.c     2013-06-13 02:56:45.297964000 +0000
1821
 
+++ gnomeradio-1.8/src/radio.c  2013-06-13 02:56:45.297964000 +0000
 
1852
--- gnomeradio-1.8.orig/src/radio.c     2013-07-05 09:04:47.340932682 +0000
 
1853
+++ gnomeradio-1.8/src/radio.c  2013-07-05 09:04:47.336932682 +0000
1822
1854
@@ -26,6 +26,14 @@
1823
1855
 #include "radio.h"
1824
1856
 #include "v4l1.h"
1830
1862
+extern char *alsa_playback;
1831
1863
+extern char *alsa_capture;
1832
1864
+extern int alsa_latency;
1833
 
+extern int debug;
 
1865
+extern int alsa_debug;
1834
1866
 
1835
1867
 static RadioDev *dev;
1836
1868
 
1837
 
@@ -73,7 +81,31 @@
 
1869
@@ -73,6 +81,30 @@
1838
1870
        }
1839
1871
 
1840
1872
 success:
1841
 
-       radio_unmute();
1842
1873
+       if (alsa_loopback && alsa_capture == NULL) {
1843
1874
+               void *md = discover_media_devices();
1844
1875
+               const char *p = strrchr(device, '/');
1860
1891
+               alsa_playback = "default";
1861
1892
+
1862
1893
+       if (alsa_loopback)
1863
 
+               fprintf(stderr, "Using alsa loopback: capture: %s (%s), output: %s\n",
 
1894
+               fprintf(stderr, "alsa: Using loopback device: capture: %s (%s), output: %s\n",
1864
1895
+                       alsa_capture, device, alsa_playback);
1865
1896
+
1866
 
+       radio_unmute(alsa_loopback);
 
1897
        radio_unmute();
1867
1898
 failure:
1868
1899
 
1869
 
        return rv;
1870
 
@@ -87,7 +119,7 @@
1871
 
 
1872
 
 void radio_stop(void)
1873
 
 {
1874
 
-       radio_mute();
1875
 
+       radio_mute(alsa_loopback);
1876
 
        
1877
 
        if (dev) dev->finalize (dev);
1878
 
 }
1879
 
@@ -97,14 +129,19 @@
1880
 
        if (dev) dev->set_freq (dev, frequency);
1881
 
 }
1882
 
 
1883
 
-void radio_unmute(void)
1884
 
+void radio_unmute(int alsa_loopback)
 
1900
@@ -100,11 +132,16 @@
 
1901
 void radio_unmute(void)
1885
1902
 {
1886
1903
        if (dev) dev->mute (dev, 0);
1887
1904
+       if (alsa_loopback)
1888
1905
+               alsa_thread_startup(alsa_playback, alsa_capture,
1889
 
+                                   alsa_latency, stderr, debug);
 
1906
+                                   alsa_latency, stderr, alsa_debug);
1890
1907
 }
1891
1908
 
1892
 
-void radio_mute(void)
1893
 
+void radio_mute(int alsa_loopback)
 
1909
 void radio_mute(void)
1894
1910
 {
1895
1911
        if (dev) dev->mute (dev, 1);
1896
1912
+       if (alsa_loopback)