From ba183a09135c03763a4790cdafac2e43d8dbccd0 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Thu, 11 Feb 2016 19:50:55 +0100 Subject: Add default value for rpcTlsPort Passing NULL to printf and the result to curl may or may not work. YMMV. Fixes #574. # Conflicts: # src/ui.c --- src/settings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/settings.c') diff --git a/src/settings.c b/src/settings.c index 0765bc8..6ba2e91 100644 --- a/src/settings.c +++ b/src/settings.c @@ -180,7 +180,7 @@ void BarSettingsRead (BarSettings_t *settings) { settings->titleFormat = strdup (TITLE " - \"%t\" by \"%a\" on \"%l\"%r%@%s"); settings->player = NULL; settings->rpcHost = strdup (PIANO_RPC_HOST); - settings->rpcTlsPort = NULL; + settings->rpcTlsPort = strdup ("443"); settings->partnerUser = strdup ("android"); settings->partnerPassword = strdup ("AC7IBG09A3DTSYM4R41UJWL07VLN8JI7"); settings->device = strdup ("android-generic"); -- cgit v1.2.3 From 06192d9c879cf70171139597b8f722a41fb88a37 Mon Sep 17 00:00:00 2001 From: blmpl Date: Sat, 15 Oct 2016 10:10:52 +0200 Subject: Support binding to a specific network interface Closes #597. # Conflicts: # src/ui.c --- contrib/config-example | 1 + contrib/pianobar.1 | 11 +++++++++++ src/settings.c | 3 +++ src/settings.h | 1 + 4 files changed, 16 insertions(+) (limited to 'src/settings.c') diff --git a/contrib/config-example b/contrib/config-example index 899ee39..070314b 100644 --- a/contrib/config-example +++ b/contrib/config-example @@ -10,6 +10,7 @@ # Proxy (for those who are not living in the USA) #control_proxy = http://127.0.0.1:9090/ +#bind_to = if!tun0 # Keybindings #act_help = ? diff --git a/contrib/pianobar.1 b/contrib/pianobar.1 index ee09c41..910af9a 100644 --- a/contrib/pianobar.1 +++ b/contrib/pianobar.1 @@ -209,6 +209,17 @@ required to validate Pandora’s SSL certificate. Non-american users need a proxy to use pandora.com. Only the xmlrpc interface will use this proxy. The music is streamed directly. +.TP +.B bind_to = {if!tunX,host!x.x.x.x,..} +This sets the interface name to use as outgoing network interface. The name can +be an interface name, an IP address, or a host name. (from CURLOPT_INTERFACE) + +It can be used as a replacement for +.B control_proxy +in conjunction with OpenVPN's +option +.B route-nopull. + .TP .B decrypt_password = R=U!LH$O2B# diff --git a/src/settings.c b/src/settings.c index 6ba2e91..36245de 100644 --- a/src/settings.c +++ b/src/settings.c @@ -119,6 +119,7 @@ void BarSettingsInit (BarSettings_t *settings) { void BarSettingsDestroy (BarSettings_t *settings) { free (settings->controlProxy); free (settings->proxy); + free (settings->bindTo); free (settings->username); free (settings->password); free (settings->passwordCmd); @@ -236,6 +237,8 @@ void BarSettingsRead (BarSettings_t *settings) { settings->controlProxy = strdup (val); } else if (streq ("proxy", key)) { settings->proxy = strdup (val); + } else if (streq ("bind_to", key)) { + settings->bindTo = strdup (val); } else if (streq ("user", key)) { settings->username = strdup (val); } else if (streq ("password", key)) { diff --git a/src/settings.h b/src/settings.h index 78d0e45..e6067f3 100644 --- a/src/settings.h +++ b/src/settings.h @@ -93,6 +93,7 @@ typedef struct { char *password, *passwordCmd; char *controlProxy; /* non-american listeners need this */ char *proxy; + char *bindTo; char *autostartStation; char *eventCmd; char *loveIcon; -- cgit v1.2.3 From 926764b76434c0919759ecd5b26cc4d3bc92712b Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sat, 29 Oct 2016 15:57:20 +0200 Subject: Replace getline() with fgets() Mac OS X 10.6 compatibility, fixes #572. # Conflicts: # src/settings.c --- src/settings.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 6 deletions(-) (limited to 'src/settings.c') diff --git a/src/settings.c b/src/settings.c index 36245de..b15053d 100644 --- a/src/settings.c +++ b/src/settings.c @@ -27,11 +27,13 @@ THE SOFTWARE. #include "settings.h" #include "config.h" +#include "ui.h" #include "ui_dispatch.h" #include #include #include #include +#include #define PACKAGE_CONFIG PACKAGE ".cfg" #define PACKAGE_STATE PACKAGE ".state" @@ -214,8 +216,9 @@ void BarSettingsRead (BarSettings_t *settings) { /* read config files */ for (size_t j = 0; j < sizeof (configfiles) / sizeof (*configfiles); j++) { static const char *formatMsgPrefix = "format_msg_"; - char key[256], val[256]; FILE *configfd; + char line[512]; + size_t lineNum = 0; char * const path = BarGetXdgConfigDir (configfiles[j]); assert (path != NULL); @@ -225,14 +228,64 @@ void BarSettingsRead (BarSettings_t *settings) { } while (1) { - char lwhite, rwhite; - int scanRet = fscanf (configfd, "%255s%c=%c%255[^\n]", key, &lwhite, &rwhite, val); - if (scanRet == EOF) { + ++lineNum; + char * const ret = fgets (line, sizeof (line), configfd); + if (ret == NULL) { + /* EOF or error */ break; - } else if (scanRet != 4 || lwhite != ' ' || rwhite != ' ') { - /* invalid config line */ + } + if (strchr (line, '\n') == NULL && !feof (configfd)) { + BarUiMsg (settings, MSG_INFO, "Line %s:%zu too long, " + "ignoring\n", path, lineNum); + continue; + } + /* parse lines that match "^\s*(.*?)\s?=\s?(.*)$". Windows and Unix + * line terminators are supported. */ + char *key = line; + + /* skip leading spaces */ + while (isspace ((unsigned char) key[0])) { + ++key; + } + + /* skip comments */ + if (key[0] == '#') { continue; } + + /* search for delimiter and split key-value pair */ + char *val = strchr (line, '='); + if (val == NULL) { + /* no warning for empty lines */ + if (key[0] != '\0') { + BarUiMsg (settings, MSG_INFO, + "Invalid line at %s:%zu\n", path, lineNum); + } + /* invalid line */ + continue; + } + *val = '\0'; + ++val; + + /* drop spaces at the end */ + char *keyend = &key[strlen (key)-1]; + while (keyend >= key && isspace ((unsigned char) *keyend)) { + *keyend = '\0'; + --keyend; + } + + /* strip at most one space, legacy cruft, required for values with + * leading spaces like love_icon */ + if (isspace ((unsigned char) val[0])) { + ++val; + } + /* drop trailing cr/lf */ + char *valend = &val[strlen (val)-1]; + while (valend >= val && (*valend == '\r' || *valend == '\n')) { + *valend = '\0'; + --valend; + } + if (streq ("control_proxy", key)) { settings->controlProxy = strdup (val); } else if (streq ("proxy", key)) { -- cgit v1.2.3 From c934c373e16acc7b7db6a374b1047649a0875dc3 Mon Sep 17 00:00:00 2001 From: Sean Greenslade Date: Tue, 14 Mar 2017 19:36:24 -0700 Subject: Added gain_mul setting to soften effect of replaygain. --- contrib/pianobar.1 | 6 ++++++ src/main.c | 3 ++- src/settings.c | 3 +++ src/settings.h | 1 + 4 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/settings.c') diff --git a/contrib/pianobar.1 b/contrib/pianobar.1 index 910af9a..0619735 100644 --- a/contrib/pianobar.1 +++ b/contrib/pianobar.1 @@ -366,6 +366,12 @@ Your pandora.com username. .B volume = 0 Initial volume correction in dB. Usually between -30 and +5. +.TP +.B gain_mul = 1.0 +Pandora sends a ReplayGain value with every song. This sets a multiplier so that the gain adjustment can be +reduced. 0.0 means no gain adjustment, 1.0 means full gain adjustment, values inbetween reduce the magnitude +of gain adjustment. + .SH REMOTE CONTROL .B pianobar can be controlled through a fifo. You have to create it yourself by executing diff --git a/src/main.c b/src/main.c index 3e6e85f..4f4214a 100644 --- a/src/main.c +++ b/src/main.c @@ -31,6 +31,7 @@ THE SOFTWARE. #include "ui.h" #include "ui_dispatch.h" #include "ui_readline.h" +#include "settings.h" /* authenticate user */ @@ -238,7 +239,7 @@ static void BarMainStartPlayback(BarApp_t *app) } else { - BarPlayer2SetGain(app->player, curSong->fileGain); + BarPlayer2SetGain(app->player, curSong->fileGain * app->settings.gainMul); BarPlayer2Open(app->player, curSong->audioUrl); /* throw event */ diff --git a/src/settings.c b/src/settings.c index b15053d..4f0ef8c 100644 --- a/src/settings.c +++ b/src/settings.c @@ -172,6 +172,7 @@ void BarSettingsRead (BarSettings_t *settings) { settings->autoselect = true; settings->history = 5; settings->volume = 0; + settings->gainMul = 1.0; settings->maxPlayerErrors = 5; settings->sortOrder = BAR_SORT_NAME_AZ; settings->loveIcon = strdup (" <3"); @@ -378,6 +379,8 @@ void BarSettingsRead (BarSettings_t *settings) { settings->atIcon = strdup (val); } else if (streq ("volume", key)) { settings->volume = atoi (val); + } else if (streq ("gain_mul", key)) { + settings->gainMul = (float)atof (val); } else if (streq ("format_nowplaying_song", key)) { free (settings->npSongFormat); settings->npSongFormat = strdup (val); diff --git a/src/settings.h b/src/settings.h index e6067f3..f8225ce 100644 --- a/src/settings.h +++ b/src/settings.h @@ -87,6 +87,7 @@ typedef struct { bool autoselect; unsigned int history, maxPlayerErrors; int volume; + float gainMul; BarStationSorting_t sortOrder; PianoAudioQuality_t audioQuality; char *username; -- cgit v1.2.3