Skip to content

Commit

Permalink
player: added '--buffer-seconds' configuration option to tweak buffer…
Browse files Browse the repository at this point in the history
…ing in gmusic, scloud, dirble, youtube and plex (#547)
  • Loading branch information
juanrubio committed Mar 12, 2019
1 parent 98279f7 commit 1dde005
Show file tree
Hide file tree
Showing 22 changed files with 267 additions and 79 deletions.
2 changes: 1 addition & 1 deletion player/src/httpserv/tizhttpservconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace tiz
const std::string &station_name,
const std::string &station_genre,
const bool &icy_metadata_enabled)
: config (playlist), host_ (host), addr_ (ip_address), port_ (port),
: config (playlist, 0), host_ (host), addr_ (ip_address), port_ (port),
sampling_rate_list_ (sampling_rate_list), bitrate_mode_list_ (bitrate_mode_list),
station_name_ (station_name), station_genre_ (station_genre),
icy_metadata_enabled_ (icy_metadata_enabled)
Expand Down
2 changes: 1 addition & 1 deletion player/src/services/chromecast/tizchromecastconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace tiz
chromecastconfig (const std::string &cc_name_or_ip,
const tizgraphconfig_ptr_t &service_config,
const service_config_type_t service_config_type)
: config (service_config->get_playlist ()),
: config (service_config->get_playlist (), 0),
name_or_ip_ (cc_name_or_ip),
service_config_ (service_config),
service_config_type_(service_config_type)
Expand Down
5 changes: 3 additions & 2 deletions player/src/services/dirble/tizdirbleconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ namespace tiz
{

public:
dirbleconfig (const tizplaylist_ptr_t &playlist, const std::string &api_key,
dirbleconfig (const tizplaylist_ptr_t &playlist, uint32_t buffer_seconds,
const std::string &api_key,
const OMX_TIZONIA_AUDIO_DIRBLEPLAYLISTTYPE &playlist_type)
: config (playlist),
: config (playlist, buffer_seconds),
api_key_ (api_key),
playlist_type_ (playlist_type)
{
Expand Down
6 changes: 6 additions & 0 deletions player/src/services/dirble/tizdirblegraphops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ void graph::dirbleops::do_configure_comp (const int comp_id)
handles_[0], playlist_->get_current_uri (),
dirble_config->get_playlist_type (), playlist_->shuffle ()),
"Unable to set OMX_TizoniaIndexParamAudioDirblePlaylist");

const OMX_U32 port_id = 0;
G_OPS_BAIL_IF_ERROR (
tiz::graph::util::set_streaming_buffer_params (
handles_[0], port_id, config_->get_buffer_seconds (), 0, 100),
"Unable to set OMX_TizoniaIndexParamStreamingBuffer");
}
}

Expand Down
9 changes: 5 additions & 4 deletions player/src/services/googlemusic/tizgmusicconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,18 @@ namespace tiz
{

public:
gmusicconfig (const tizplaylist_ptr_t &playlist, const std::string &user,
const std::string &pass, const std::string &device_id,
gmusicconfig (const tizplaylist_ptr_t &playlist, uint32_t buffer_seconds,
const std::string &user, const std::string &pass,
const std::string &device_id,
const OMX_TIZONIA_AUDIO_GMUSICPLAYLISTTYPE playlist_type,
const std::string &additional_keywords,
const bool is_unlimited_search = false)
: config (playlist),
: config (playlist, buffer_seconds),
user_ (user),
pass_ (pass),
device_id_ (device_id),
playlist_type_ (playlist_type),
additional_keywords_(additional_keywords),
additional_keywords_ (additional_keywords),
is_unlimited_search_ (is_unlimited_search)
{
}
Expand Down
6 changes: 6 additions & 0 deletions player/src/services/googlemusic/tizgmusicgraphops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ void graph::gmusicops::do_configure_comp (const int comp_id)
gmusic_config->get_additional_keywords (),
gmusic_config->is_unlimited_search (), playlist_->shuffle ()),
"Unable to set OMX_TizoniaIndexParamAudioGmusicPlaylist");

const OMX_U32 port_id = 0;
G_OPS_BAIL_IF_ERROR (
tiz::graph::util::set_streaming_buffer_params (
handles_[0], port_id, config_->get_buffer_seconds (), 0, 100),
"Unable to set OMX_TizoniaIndexParamStreamingBuffer");
}
}

Expand Down
6 changes: 3 additions & 3 deletions player/src/services/plex/tizplexconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ namespace tiz
{

public:
plexconfig (const tizplaylist_ptr_t &playlist, const std::string &base_url,
const std::string &token,
plexconfig (const tizplaylist_ptr_t &playlist, uint32_t buffer_seconds,
const std::string &base_url, const std::string &token,
const OMX_TIZONIA_AUDIO_PLEXPLAYLISTTYPE &playlist_type)
: config (playlist),
: config (playlist, buffer_seconds),
base_url_ (base_url),
token_ (token),
playlist_type_ (playlist_type)
Expand Down
6 changes: 6 additions & 0 deletions player/src/services/plex/tizplexgraphops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ void graph::plexops::do_configure_comp (const int comp_id)
handles_[0], playlist_->get_current_uri (),
plex_config->get_playlist_type (), playlist_->shuffle ()),
"Unable to set OMX_TizoniaIndexParamAudioPlexPlaylist");

const OMX_U32 port_id = 0;
G_OPS_BAIL_IF_ERROR (
tiz::graph::util::set_streaming_buffer_params (
handles_[0], port_id, config_->get_buffer_seconds (), 0, 100),
"Unable to set OMX_TizoniaIndexParamStreamingBuffer");
}
}

Expand Down
8 changes: 5 additions & 3 deletions player/src/services/soundcloud/tizscloudconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ namespace tiz
{

public:
scloudconfig (const tizplaylist_ptr_t &playlist, const std::string &oauth_token,
const OMX_TIZONIA_AUDIO_SOUNDCLOUDPLAYLISTTYPE &playlist_type)
: config (playlist),
scloudconfig (
const tizplaylist_ptr_t &playlist, uint32_t buffer_seconds,
const std::string &oauth_token,
const OMX_TIZONIA_AUDIO_SOUNDCLOUDPLAYLISTTYPE &playlist_type)
: config (playlist, buffer_seconds),
oauth_token_ (oauth_token),
playlist_type_ (playlist_type)
{
Expand Down
6 changes: 6 additions & 0 deletions player/src/services/soundcloud/tizscloudgraphops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ void graph::scloudops::do_configure_comp (const int comp_id)
handles_[0], playlist_->get_current_uri (),
scloud_config->get_playlist_type (), playlist_->shuffle ()),
"Unable to set OMX_TizoniaIndexParamAudioSoundCloudPlaylist");

const OMX_U32 port_id = 0;
G_OPS_BAIL_IF_ERROR (
tiz::graph::util::set_streaming_buffer_params (
handles_[0], port_id, config_->get_buffer_seconds (), 0, 100),
"Unable to set OMX_TizoniaIndexParamStreamingBuffer");
}
}

Expand Down
2 changes: 1 addition & 1 deletion player/src/services/spotify/tizspotifyconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace tiz
const std::string &owner,
const bool recover_lost_token,
const bool allow_explicit_tracks)
: config (playlist),
: config (playlist, 0),
user_ (user),
pass_ (pass),
playlist_type_ (playlist_type),
Expand Down
4 changes: 2 additions & 2 deletions player/src/services/youtube/tizyoutubeconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ namespace tiz
{

public:
youtubeconfig (const tizplaylist_ptr_t &playlist,
youtubeconfig (const tizplaylist_ptr_t &playlist, uint32_t buffer_seconds,
const OMX_TIZONIA_AUDIO_YOUTUBEPLAYLISTTYPE &playlist_type)
: config (playlist), playlist_type_ (playlist_type)
: config (playlist, buffer_seconds), playlist_type_ (playlist_type)
{
}

Expand Down
6 changes: 6 additions & 0 deletions player/src/services/youtube/tizyoutubegraphops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ void graph::youtubeops::do_configure_comp (const int comp_id)
handles_[0], playlist_->get_current_uri (),
youtube_config->get_playlist_type (), playlist_->shuffle ()),
"Unable to set OMX_TizoniaIndexParamAudioYoutubePlaylist");

const OMX_U32 port_id = 0;
G_OPS_BAIL_IF_ERROR (
tiz::graph::util::set_streaming_buffer_params (
handles_[0], port_id, config_->get_buffer_seconds (), 0, 100),
"Unable to set OMX_TizoniaIndexParamStreamingBuffer");
}
else if (comp_id == 2)
{
Expand Down
12 changes: 10 additions & 2 deletions player/src/tizgraphconfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#ifndef TIZGRAPHCONFIG_HPP
#define TIZGRAPHCONFIG_HPP

#include <stdint.h>

#include <boost/shared_ptr.hpp>

#include "tizgraphtypes.hpp"
Expand All @@ -42,8 +44,8 @@ namespace tiz
{

public:
explicit config (const tizplaylist_ptr_t &playlist)
: playlist_ (playlist)
explicit config (const tizplaylist_ptr_t &playlist, const uint32_t buffer_seconds)
: playlist_ (playlist), buffer_seconds_ (buffer_seconds)
{
}

Expand All @@ -56,8 +58,14 @@ namespace tiz
return playlist_;
}

uint32_t get_buffer_seconds () const
{
return buffer_seconds_;
}

protected:
tizplaylist_ptr_t playlist_;
uint32_t buffer_seconds_;
};

} // namespace graph
Expand Down
5 changes: 4 additions & 1 deletion player/src/tizgraphmgrops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,15 @@ void graphmgr::ops::do_load ()

void graphmgr::ops::do_execute ()
{
const uint32_t unused_buffer_seconds = 0; // this is not used here

assert (playlist_);
assert (next_playlist_);

next_playlist_->set_loop_playback (playlist_->single_format ());
graph_config_.reset ();
graph_config_ = boost::make_shared< tiz::graph::config >(next_playlist_);
graph_config_ = boost::make_shared< tiz::graph::config > (
next_playlist_, unused_buffer_seconds);

if (graph_config_)
{
Expand Down
25 changes: 25 additions & 0 deletions player/src/tizgraphutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,31 @@ graph::util::set_plex_playlist (
&playlisttype);
}

OMX_ERRORTYPE
graph::util::set_streaming_buffer_params (const OMX_HANDLETYPE handle,
const OMX_U32 port_id,
const uint32_t capacity_seconds,
const uint32_t low_watermark,
const uint32_t high_watermark)
{
// Set the streaming buffer parameters
OMX_TIZONIA_STREAMINGBUFFERTYPE buffertype;
TIZ_INIT_OMX_PORT_STRUCT (buffertype, port_id);
tiz_check_omx (OMX_GetParameter (
handle,
static_cast< OMX_INDEXTYPE > (OMX_TizoniaIndexParamStreamingBuffer),
&buffertype));

buffertype.nCapacity = capacity_seconds;
buffertype.nLowWaterMark = low_watermark;
buffertype.nHighWaterMark = high_watermark;

return OMX_SetParameter (
handle,
static_cast< OMX_INDEXTYPE > (OMX_TizoniaIndexParamStreamingBuffer),
&buffertype);
}

OMX_ERRORTYPE
graph::util::enable_port_format_auto_detection (const OMX_HANDLETYPE handle,
const OMX_U32 port_id,
Expand Down
5 changes: 5 additions & 0 deletions player/src/tizgraphutil.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ namespace tiz
const OMX_TIZONIA_AUDIO_PLEXPLAYLISTTYPE playlist_type,
const bool shuffle);

static OMX_ERRORTYPE set_streaming_buffer_params (
const OMX_HANDLETYPE handle, const OMX_U32 port_id,
const uint32_t capacity_seconds, const uint32_t low_watermark,
const uint32_t high_watermark);

static OMX_ERRORTYPE enable_port_format_auto_detection (
const OMX_HANDLETYPE handle, const OMX_U32 port_id,
const OMX_PORTDOMAINTYPE domain);
Expand Down
Loading

0 comments on commit 1dde005

Please sign in to comment.