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
1518
int radio_check_station(float freq);
1520
-void radio_unmute(void);
1521
+void radio_unmute(int alsa_loopback);
1523
-void radio_mute(void);
1524
+void radio_mute(int alsa_loopback);
1526
int radio_get_stereo(void);
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;
1536
+int alsa_debug = 0;
1554
1538
GtkWidget* mute_button, *preset_combo;
1555
1539
GtkAdjustment *adj;
1556
1540
GtkWidget* app;
1543
static int timeout_id, bp_timeout_id = -1, bp_timeout_steps = 0;
1545
-static DBusGProxy * connect_to_session (void);
1546
+static DBusGProxy * connect_to_session (void);
1548
static gboolean is_first_start(void)
1557
1550
@@ -115,7 +126,7 @@
1558
1551
gtk_label_set_text(GTK_LABEL(fsd->label), text);
1565
1558
fsd->stations = g_list_append(fsd->stations, f);
1566
@@ -158,11 +169,11 @@
1568
gtk_widget_show_all(data.dialog);
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));
1576
+ radio_unmute(alsa_loopback);
1578
g_source_remove(timeout_id);
1582
if (settings.mute_on_exit)
1585
+ radio_mute(alsa_loopback);
1559
@@ -250,10 +261,10 @@
1591
if (radio_check_station(gtk_adjustment_get_value(adj)/STEPS) || (start > max)) {
1594
+ radio_unmute(alsa_loopback);
1598
@@ -594,10 +605,10 @@
1600
g_source_remove(timeout_id);
1603
+ radio_unmute(alsa_loopback);
1607
+ radio_mute(alsa_loopback);
1608
timeout_id = g_timeout_add(1000/SCAN_SPEED, (GSourceFunc)scan_freq, (gpointer)1);
1611
@@ -606,10 +617,10 @@
1613
g_source_remove(timeout_id);
1616
+ radio_unmute(alsa_loopback);
1620
+ radio_mute(alsa_loopback);
1621
timeout_id = g_timeout_add(1000/SCAN_SPEED, (GSourceFunc)scan_freq, (gpointer)(-1));
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;
1573
if (!radio_init(settings.device, driver))
1624
1574
@@ -790,8 +801,19 @@
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);
1642
1592
mixer_set_volume(vol);
1643
1593
gtk_volume_button_set_value(mute_button, vol);
1644
@@ -1123,7 +1145,7 @@
1646
if (settings.mute_on_exit)
1649
+ radio_mute(alsa_loopback);
1653
@@ -1194,6 +1216,16 @@
1594
@@ -1194,6 +1216,97 @@
1600
+ ARG_ALSA_LOOPBACK,
1601
+ ARG_NO_ALSA_LOOPBACK,
1603
+ ARG_ALSA_PLAYBACK,
1609
+parse_one_option (gint opt, const gchar * arg, GError ** err)
1612
+ case ARG_ALSA_LOOPBACK:
1613
+ alsa_loopback = 1;
1615
+ case ARG_NO_ALSA_LOOPBACK:
1616
+ alsa_loopback = 0;
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);
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);
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);
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);
1636
+ case ARG_ALSA_LATENCY:
1637
+ alsa_latency = atoi (arg);
1639
+ case ARG_ALSA_DEBUG:
1643
+ g_set_error (err, G_OPTION_ERROR, G_OPTION_ERROR_UNKNOWN_OPTION,
1644
+ _("Unknown option"));
1652
+option_alsa_cb (const gchar * opt,
1653
+ const gchar * arg, gpointer data, GError ** err)
1655
+ static const struct
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}, {
1671
+ for (n = 0; options[n].opt; n++) {
1672
+ if (!strcmp (opt, options[n].opt)) {
1673
+ val = options[n].val;
1678
+ return parse_one_option (val, arg, err);
1657
1681
+G_GNUC_NORETURN static gboolean
1658
+option_version_cb (const gchar *option_name,
1659
+ const gchar *value,
1682
+option_version_cb (const gchar * opt,
1683
+ const gchar * arg, gpointer data, GError ** err)
1663
1685
+ g_print ("%s %s\n", PACKAGE, VERSION);
1667
1689
int main(int argc, char* argv[])
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 },
1740
1763
/* Connect the Session Management signals
1766
@@ -1324,7 +1454,7 @@
1768
DBusGConnection *connection;
1770
- GError *error = NULL;
1771
+ GError *error = NULL;
1773
connection = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
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)\
1860
1891
+ alsa_playback = "default";
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);
1866
+ radio_unmute(alsa_loopback);
1872
void radio_stop(void)
1875
+ radio_mute(alsa_loopback);
1877
if (dev) dev->finalize (dev);
1879
@@ -97,14 +129,19 @@
1880
if (dev) dev->set_freq (dev, frequency);
1883
-void radio_unmute(void)
1884
+void radio_unmute(int alsa_loopback)
1900
@@ -100,11 +132,16 @@
1901
void radio_unmute(void)
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);
1892
-void radio_mute(void)
1893
+void radio_mute(int alsa_loopback)
1909
void radio_mute(void)
1895
1911
if (dev) dev->mute (dev, 1);
1896
1912
+ if (alsa_loopback)