Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: thekvs/radiotray-lite
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.2.15
Choose a base ref
...
head repository: thekvs/radiotray-lite
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Apr 8, 2017

  1. correctly build on Fedora 25

    Closes #7
    thekvs committed Apr 8, 2017
    Copy the full SHA
    0e8b441 View commit details
  2. increase patch version number

    thekvs committed Apr 8, 2017
    Copy the full SHA
    5825088 View commit details

Commits on May 6, 2017

  1. Copy the full SHA
    b9e329f View commit details

Commits on May 7, 2017

  1. Copy the full SHA
    e795aab View commit details

Commits on May 8, 2017

  1. clang-formatted

    thekvs committed May 8, 2017
    Copy the full SHA
    bb9682a View commit details
  2. add 2017 to copyright year(s)

    thekvs committed May 8, 2017
    Copy the full SHA
    e13087e View commit details
  3. add formatting option

    thekvs committed May 8, 2017
    Copy the full SHA
    471782b View commit details
  4. reformatted

    thekvs committed May 8, 2017
    Copy the full SHA
    c26a3d4 View commit details

Commits on May 13, 2017

  1. cleanup

    thekvs committed May 13, 2017
    Copy the full SHA
    3ad34c5 View commit details

Commits on May 14, 2017

  1. add --resume command line option

    Close #8
    thekvs committed May 14, 2017
    Copy the full SHA
    0bff416 View commit details
  2. version bump

    thekvs committed May 14, 2017
    Copy the full SHA
    43f3136 View commit details

Commits on Aug 2, 2017

  1. Copy the full SHA
    ac21d28 View commit details

Commits on Aug 3, 2017

  1. Correctly handle gstreamer's state change

    Closes #11
    thekvs committed Aug 3, 2017
    Copy the full SHA
    1576e99 View commit details
  2. version bump

    thekvs committed Aug 3, 2017
    Copy the full SHA
    a40137a View commit details
  3. Copy the full SHA
    49896d2 View commit details
  4. fix grammar

    thekvs committed Aug 3, 2017
    Copy the full SHA
    87b38ba View commit details
  5. Copy the full SHA
    fdb0902 View commit details

Commits on Aug 5, 2017

  1. Copy the full SHA
    28a6b99 View commit details

Commits on Aug 6, 2017

  1. version bump

    thekvs committed Aug 6, 2017
    Copy the full SHA
    feec552 View commit details

Commits on Oct 15, 2017

  1. logic simplified

    thekvs committed Oct 15, 2017
    Copy the full SHA
    1db32c1 View commit details
  2. code simplified

    thekvs committed Oct 15, 2017
    Copy the full SHA
    a413ea7 View commit details
  3. use nullptr instead of NULL

    thekvs committed Oct 15, 2017
    Copy the full SHA
    d0b9b8f View commit details
  4. Copy the full SHA
    7c1b7d3 View commit details
  5. remove implicit casts

    thekvs committed Oct 15, 2017
    Copy the full SHA
    d5124d5 View commit details
  6. logic simplified

    thekvs committed Oct 15, 2017
    Copy the full SHA
    739c40d View commit details
  7. logic simplified

    thekvs committed Oct 15, 2017
    Copy the full SHA
    d8ddc78 View commit details
  8. Copy the full SHA
    22d41ea View commit details
  9. Copy the full SHA
    afea46c View commit details
  10. Copy the full SHA
    487f82e View commit details
  11. simplify code readbility

    thekvs committed Oct 15, 2017
    Copy the full SHA
    f9b8a17 View commit details
  12. more auto

    thekvs committed Oct 15, 2017
    Copy the full SHA
    a9c6844 View commit details
  13. use string literals

    thekvs committed Oct 15, 2017
    Copy the full SHA
    861a981 View commit details
  14. Copy the full SHA
    94b3353 View commit details

Commits on Oct 16, 2017

  1. Copy the full SHA
    9cdd9d9 View commit details
  2. use nullptr instead of NULL

    thekvs committed Oct 16, 2017
    Copy the full SHA
    f81954b View commit details
  3. avoid implicit casts

    thekvs committed Oct 16, 2017
    Copy the full SHA
    e4f4809 View commit details
  4. Copy the full SHA
    ddaa725 View commit details
  5. Copy the full SHA
    5bedd37 View commit details
  6. Copy the full SHA
    b3a2c42 View commit details
  7. minor optimizations

    thekvs committed Oct 16, 2017
    Copy the full SHA
    38e2d40 View commit details
  8. use emplace_back()

    thekvs committed Oct 16, 2017
    Copy the full SHA
    52b6d35 View commit details

Commits on Oct 17, 2017

  1. Copy the full SHA
    5699dec View commit details

Commits on Nov 27, 2017

  1. handle unplayable streams

    thekvs committed Nov 27, 2017
    Copy the full SHA
    9b74541 View commit details

Commits on Dec 4, 2017

  1. Copy the full SHA
    b0899a0 View commit details

Commits on Dec 7, 2017

  1. Correctly adjust bookmarks' menu levels.

    Closes #17
    thekvs committed Dec 7, 2017
    Copy the full SHA
    f188d6f View commit details

Commits on Jul 16, 2018

  1. ignore .vscode/ folder

    thekvs committed Jul 16, 2018
    Copy the full SHA
    8972c9c View commit details
  2. correct buffering

    thekvs committed Jul 16, 2018
    Copy the full SHA
    6f13bd4 View commit details

Commits on Jul 19, 2018

  1. Copy the full SHA
    561eb82 View commit details

Commits on Jul 23, 2018

  1. Copy the full SHA
    6619112 View commit details

Commits on Jul 31, 2018

  1. ignore build/ folder

    thekvs committed Jul 31, 2018
    Copy the full SHA
    8974e0b View commit details
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
@@ -7,6 +7,6 @@ Standard: Cpp11
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AlwaysBreakTemplateDeclarations: true
AlwaysBreakAfterDefinitionReturnType: true
AlwaysBreakAfterReturnType: TopLevelDefinitions
BinPackParameters: false
SortIncludes: false
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -3,4 +3,5 @@
tags
.ycm_extra_conf.*
*.swp
.Rhistory
.vscode/
build/
18 changes: 10 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -28,8 +28,10 @@ message(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
add_compile_options(-Wall)
add_compile_options(-Wextra)

set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DELPP_NO_DEFAULT_LOG_FILE -s")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DELPP_NO_DEFAULT_LOG_FILE -s")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DELPP_NO_DEFAULT_LOG_FILE")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DELPP_NO_DEFAULT_LOG_FILE")

set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -s")

find_package(LibMagic REQUIRED)
if (NOT LIBMAGIC_FOUND)
@@ -43,22 +45,22 @@ pkg_check_modules(LIBXML2 REQUIRED libxml-2.0)
pkg_check_modules(GLIB2 REQUIRED glib-2.0)
pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
pkg_check_modules(GTKMM REQUIRED gtkmm-3.0)
pkg_check_modules(APPINDICATOR REQUIRED appindicator3-0.1>=12.10)
pkg_check_modules(APPINDICATOR REQUIRED appindicator3-0.1)
pkg_check_modules(CURL REQUIRED libcurl)

pkg_check_modules(GSTREAMER QUIET gstreamer-0.10)
pkg_check_modules(GSTREAMER QUIET gstreamer-1.0)
if (NOT GSTREAMER_FOUND)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-0.10)
endif()

pkg_check_modules(GSTREAMERMM QUIET gstreamermm-0.10)
pkg_check_modules(GSTREAMERMM QUIET gstreamermm-1.0)
if (NOT GSTREAMERMM_FOUND)
pkg_check_modules(GSTREAMERMM REQUIRED gstreamermm-1.0)
pkg_check_modules(GSTREAMERMM REQUIRED gstreamermm-0.10)
endif()

set(TARGET_VERSION_MAJOR 0)
set(TARGET_VERSION_MINOR 2)
set(TARGET_VERSION_PATCH 15)
set(TARGET_VERSION_PATCH 19)
set(APP_VERSION "${TARGET_VERSION_MAJOR}.${TARGET_VERSION_MINOR}.${TARGET_VERSION_PATCH}")

add_subdirectory(src)
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2016 Konstantin Sorokin <kvs@sigterm.ru>
Copyright © 2016-2017 Konstantin Sorokin <kvs@sigterm.ru>

Copyright © 2009 WooThemes

24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -26,9 +26,31 @@ To compile program run following (with obvious amendments) commands from build d

Package will be created in the `packages` folder of the build directory.

### Configs
### Configuration
#### Bookmarks
Copy your existing `bookmarks.xml` from [Radio Tray](http://radiotray.sourceforge.net/) (which is usually located at
`$HOME/.local/share/radiotray/bookmarks.xml`) into `$HOME/.config/radiotray-lite/` directory.

#### Options
Configuration file is located in the same directory as bookmarks file. It has simple XML format and following options are supported:
* `last_station` -- name of the last played station. Automatically updated, you don't need to change it.
* `buffer_size` -- size of the internal gstreamer's buffer.
* `buffer_duration` -- number of seconds to buffer.
* `url_timeout` -- timeout in seconds for fetching playlist.
* `notifications` -- if set to `false` disables desktop notification messages. Default is `true`.

Example:

```
<?xml version="1.0"?>
<config>
<option name="last_station" value="Rock 181" />
<option name="buffer_size" value="102400" />
<option name="buffer_duration" value="2" />
<option name="url_timeout" value="5" />
<option name="notifications" value="false" />
</config>
```

### Licensing
See [LICENSE.md](LICENSE.md) file for license information.
2 changes: 1 addition & 1 deletion cmake/CPackConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ set(CPACK_DEBIAN_PACKAGE_SECTION "sound")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Konstantin Sorokin <kvs@sigterm.ru>")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE @CPACK_DEBIAN_PACKAGE_ARCHITECTURE@)
set(CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}_${APP_VERSION}_@CPACK_DEBIAN_PACKAGE_ARCHITECTURE@)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libgtkmm-3.0-1 | libgtkmm-3.0-1v5 (>= 3.10.1), libgstreamermm-0.10-2 (>= 0.10.11) | libgstreamermm-1.0-0v5 (>= 1.4.3), gstreamer0.10-plugins-base (>= 0.10.36) | gstreamer1.0-plugins-base (>= 1.2.4), gstreamer0.10-plugins-good (>= 0.10.31) | gstreamer1.0-plugins-good (>= 1.2.4), gstreamer0.10-plugins-bad (>= 0.10.23) | gstreamer1.0-plugins-bad (>= 1.2.4), libcurl3 (>= 7.35.0), libnotify4 (>= 0.7.6), libappindicator3-1, libmagic1")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6, libgtkmm-3.0-1 | libgtkmm-3.0-1v5 (>= 3.10.1), libgstreamermm-0.10-2 (>= 0.10.11) | libgstreamermm-1.0-0v5 (>= 1.4.3) | libgstreamermm-1.0-1 (>= 1.10.0), gstreamer0.10-plugins-base (>= 0.10.36) | gstreamer1.0-plugins-base (>= 1.2.4), gstreamer0.10-plugins-good (>= 0.10.31) | gstreamer1.0-plugins-good (>= 1.2.4), gstreamer0.10-plugins-bad (>= 0.10.23) | gstreamer1.0-plugins-bad (>= 1.2.4), libcurl3 (>= 7.35.0) | libcurl4 (>= 7.58.0), libnotify4 (>= 0.7.6), libappindicator3-1, libmagic1")

set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/share/applications;/usr/share/pixmaps")
set(CPACK_RPM_PACKAGE_URL "https://github.com/thekvs/radiotray-lite/")
27 changes: 16 additions & 11 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
include_directories(${GLIB2_INCLUDE_DIRS})
include_directories(${LIBXML2_INCLUDE_DIRS})
include_directories(${APPINDICATOR_INCLUDE_DIRS})
include_directories(${GTK3_INCLUDE_DIRS})
include_directories(${GTKMM_INCLUDE_DIRS})
include_directories(${GSTREAMER_INCLUDE_DIRS})
include_directories(${GSTREAMERMM_INCLUDE_DIRS})
include_directories(${CURL_INCLUDE_DIRS})
include_directories(${LIBNOTIFY_INCLUDE_DIRS})
include_directories(${LIBMAGIC_INCLUDE_DIRS})
include_directories(third_party)
include_directories(SYSTEM ${GLIB2_INCLUDE_DIRS})
include_directories(SYSTEM ${LIBXML2_INCLUDE_DIRS})
include_directories(SYSTEM ${APPINDICATOR_INCLUDE_DIRS})
include_directories(SYSTEM ${GTK3_INCLUDE_DIRS})
include_directories(SYSTEM ${GTKMM_INCLUDE_DIRS})
include_directories(SYSTEM ${GSTREAMER_INCLUDE_DIRS})
include_directories(SYSTEM ${GSTREAMERMM_INCLUDE_DIRS})
include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
include_directories(SYSTEM ${LIBNOTIFY_INCLUDE_DIRS})
include_directories(SYSTEM ${LIBMAGIC_INCLUDE_DIRS})

include_directories(SYSTEM third_party)

add_definitions(-Wno-deprecated-declarations)

@@ -35,6 +36,8 @@ add_executable(
playlist.cpp
notification.cpp
config.cpp
options.cpp
event_manager.cpp
${PLAYLIST_DECODERS}
${THIRD_PARTY}
)
@@ -66,6 +69,8 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
player.cpp
playlist.cpp
config.cpp
options.cpp
event_manager.cpp
${PLAYLIST_DECODERS}
${THIRD_PARTY}
)
2 changes: 1 addition & 1 deletion src/asx_playlist_decoder.cpp
Original file line number Diff line number Diff line change
@@ -58,7 +58,7 @@ ASXPlaylistDecoder::extract_media_streams(const std::string& data)
}

auto nodes = xpath_obj->nodesetval;
auto size = (nodes) ? nodes->nodeNr : 0;
auto size = (nodes != nullptr) ? nodes->nodeNr : 0;

for (decltype(size) i = 0; i < size; ++i) {
auto cur = nodes->nodeTab[i];
129 changes: 90 additions & 39 deletions src/config.cpp
Original file line number Diff line number Diff line change
@@ -4,44 +4,7 @@ namespace radiotray
{
Config::~Config()
{
if (last_station.empty() or filename.empty()) {
return;
}

if (config.first_child().empty()) { // create new config
auto root = config.append_child("config");

{
auto option = root.append_child("option");
option.append_attribute("name").set_value("last_station");
option.append_attribute("value").set_value(last_station.c_str());
}

{
auto option = root.append_child("option");
option.append_attribute("name").set_value("buffer_size");
option.append_attribute("value").set_value(buffer_size);
}

{
auto option = root.append_child("option");
option.append_attribute("name").set_value("url_timeout");
option.append_attribute("value").set_value(static_cast<float>(url_timeout_ms) / 1000.f);
}
} else {
try {
pugi::xpath_node node = config.select_node("/config/option[@name='last_station']");
if (not node.node().empty()) {
// replace attribute's value
node.node().attribute("value").set_value(last_station.c_str());
}
} catch (pugi::xpath_exception& exc) {
LOG(ERROR) << "XPath expression failed: " << exc.what();
return;
}
}

config.save_file(filename.c_str(), " ");
save_config();
}

void
@@ -71,10 +34,20 @@ Config::load_config()
buffer_size = node.node().attribute("value").as_int();
}

node = config.select_node("/config/option[@name='buffer_duration']");
if (not node.node().empty()) {
buffer_duration = node.node().attribute("value").as_int();
}

node = config.select_node("/config/option[@name='url_timeout']");
if (not node.node().empty()) {
url_timeout_ms = node.node().attribute("value").as_float() * 1000; /* 'url_timeout' is in seconds */
}

node = config.select_node("/config/option[@name='notifications']");
if (not node.node().empty()) {
notifications = node.node().attribute("value").as_bool();
}
} catch (pugi::xpath_exception& exc) {
LOG(ERROR) << "XPath query error: " << exc.what() << " File: " << filename;
}
@@ -86,7 +59,85 @@ Config::load_config()
bool
Config::has_last_station()
{
return (last_station.empty() == false);
return (!last_station.empty());
}

bool
Config::has_notifications() const
{
return notifications;
}

void
Config::set_last_played_station(const Glib::ustring& station)
{
last_station = station;
save_config();
}

Glib::ustring
Config::get_last_played_station() const
{
return last_station;
}

void
Config::create_new_config()
{
auto root = config.append_child("config");

{
auto option = root.append_child("option");
option.append_attribute("name").set_value("last_station");
option.append_attribute("value").set_value(last_station.c_str());
}

{
auto option = root.append_child("option");
option.append_attribute("name").set_value("buffer_size");
option.append_attribute("value").set_value(buffer_size);
}

{
auto option = root.append_child("option");
option.append_attribute("name").set_value("buffer_duration");
option.append_attribute("value").set_value(buffer_duration);
}

{
auto option = root.append_child("option");
option.append_attribute("name").set_value("url_timeout");
option.append_attribute("value").set_value(static_cast<float>(url_timeout_ms) / 1000.f);
}

{
auto option = root.append_child("option");
option.append_attribute("name").set_value("notifications");
option.append_attribute("value").set_value(notifications);
}
}

void
Config::save_config()
{
if (not config.first_child().empty()) {
try {
pugi::xpath_node node = config.select_node("/config/option[@name='last_station']");
if (not node.node().empty()) {
// replace attribute's value
node.node().attribute("value").set_value(last_station.c_str());
}
} catch (pugi::xpath_exception& exc) {
LOG(ERROR) << "XPath expression failed: " << exc.what();
return;
}
} else { // create new config
create_new_config();
}

if (not filename.empty()) {
config.save_file(filename.c_str(), " ");
}
}

} // namespace radiotray
10 changes: 9 additions & 1 deletion src/config.hpp
Original file line number Diff line number Diff line change
@@ -22,14 +22,22 @@ class Config
void set_config_file(const std::string& name);
void load_config();
bool has_last_station();
void set_last_played_station(const Glib::ustring& station);
Glib::ustring get_last_played_station() const;
bool has_notifications() const;

Glib::ustring last_station;
long url_timeout_ms = kDefaultHTTPRequestTimeout;
int buffer_size = kDefaultGStreamerBufferSize;
int64_t buffer_duration = kDefaultBufferDuration;

private:
std::string filename;
pugi::xml_document config;
Glib::ustring last_station;
bool notifications = true;

void create_new_config();
void save_config();
};

} // namespace radiotray
6 changes: 4 additions & 2 deletions src/constants.hpp
Original file line number Diff line number Diff line change
@@ -2,11 +2,13 @@
#define __CONSTANTS_HPP_INCLUDED__

#include <string>
#include <cstdint>

namespace radiotray
{
const long kDefaultHTTPRequestTimeout = 5 * 1000;
const int kDefaultGStreamerBufferSize = 1024 * 100;
const int kDefaultGStreamerBufferSize = 320000;
const int64_t kDefaultBufferDuration = 2;

const char* const kRadioTrayAppDirName = "radiotray";
const char* const kAppDirName = "radiotray-lite";
@@ -30,7 +32,7 @@ const char* const kAppVersion = APP_VERSION;
const char* const kAppName = "Radio Tray Lite";
const char* const kWebSite = "https://github.com/thekvs/radiotray-lite/";
const char* const kAuthor = "Konstantin Sorokin <kvs@sigterm.ru>";
const char* const kCopyrightYear = "2016";
const char* const kCopyrightYear = "2016-2017";
const char* const kCopyrightTmpl = "%s - Copyright (c) %s\n %s";

} // namespace radiotray
23 changes: 23 additions & 0 deletions src/event_manager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include "event_manager.hpp"

namespace radiotray
{

std::string
get_station_state_desc(StationState state)
{
switch (state) {
case StationState::CONNECTING:
return "CONNECTING";
case StationState::IDLE:
return "IDLE";
case StationState::PLAYING:
return "PLAYING";
case StationState::UNKNOWN:
return "UNKNOWN";
default:
return "OOPS";
}
}

} // namespace radiotray
2 changes: 2 additions & 0 deletions src/event_manager.hpp
Original file line number Diff line number Diff line change
@@ -36,6 +36,8 @@ class EventManager
StateChangedSignal state_changed;
};

std::string get_station_state_desc(StationState state);

} // namespace radiotray

#endif
Loading