diff options
author | Asen Kirov <akirov@luxoft.com> | 2016-02-18 13:51:46 +0200 |
---|---|---|
committer | Asen Kirov <akirov@luxoft.com> | 2016-02-18 13:51:46 +0200 |
commit | 5160be5bb052c65c05b658db2bcaa80c74562324 (patch) | |
tree | 8e795bbbd6f81ced1c4f83627ffe6b9e1f87f02e /src/components/media_manager | |
parent | 081b9be9f3ccd5fa2c43931e7c9fb758f10e0994 (diff) | |
download | sdl_core-5160be5bb052c65c05b658db2bcaa80c74562324.tar.gz |
Move media pipe creation before StartStream command
Before this change, streaming pipe was not created when we start
streamning service and send pipe URI to HMI in StartStream, but only
when the streaming begins. So the HMI may try to open a non-existing
pipe when it receives pipe URI.
To fix this moved pipe creation from PipeStreamer::Connect() to
PipeStreamer::PipeStreamer() and pipe unlink from
PipeStreamer::Disconnect() to PipeStreamer::~PipeStreamer().
Thus the pipes are created when SDL starts and media manager is
initialized.
Fixes: APPLINK-20018
Diffstat (limited to 'src/components/media_manager')
-rw-r--r-- | src/components/media_manager/src/pipe_streamer_adapter.cc | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/components/media_manager/src/pipe_streamer_adapter.cc b/src/components/media_manager/src/pipe_streamer_adapter.cc index 4bf4fcc9e7..a61280f057 100644 --- a/src/components/media_manager/src/pipe_streamer_adapter.cc +++ b/src/components/media_manager/src/pipe_streamer_adapter.cc @@ -57,26 +57,33 @@ PipeStreamerAdapter::PipeStreamer::PipeStreamer( : Streamer(adapter), named_pipe_path_(named_pipe_path), pipe_fd_(0) { -} - -PipeStreamerAdapter::PipeStreamer::~PipeStreamer() { -} - -bool PipeStreamerAdapter::PipeStreamer::Connect() { - LOG4CXX_AUTO_TRACE(logger); if (!file_system::CreateDirectoryRecursively( profile::Profile::instance()->app_storage_folder())) { - LOG4CXX_ERROR(logger, "Cannot create app folder"); - return false; + LOG4CXX_ERROR(logger, "Cannot create app storage folder " + << profile::Profile::instance()->app_storage_folder() ); + return; } if ((mkfifo(named_pipe_path_.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) < 0) && (errno != EEXIST)) { - LOG4CXX_ERROR(logger, "Cannot create pipe " - << named_pipe_path_); - return false; + LOG4CXX_ERROR(logger, "Cannot create pipe " << named_pipe_path_); + } else { + LOG4CXX_INFO(logger, "Pipe " << named_pipe_path_ + << " was successfuly created"); } +} + +PipeStreamerAdapter::PipeStreamer::~PipeStreamer() { + if (0 == unlink(named_pipe_path_.c_str()) ) { + LOG4CXX_INFO(logger, "Pipe " << named_pipe_path_ << " was removed"); + } else { + LOG4CXX_ERROR(logger, "Error removing pipe " << named_pipe_path_); + } +} + +bool PipeStreamerAdapter::PipeStreamer::Connect() { + LOG4CXX_AUTO_TRACE(logger); pipe_fd_ = open(named_pipe_path_.c_str(), O_RDWR, 0); if (-1 == pipe_fd_) { @@ -86,14 +93,17 @@ bool PipeStreamerAdapter::PipeStreamer::Connect() { } LOG4CXX_INFO(logger, "Pipe " << named_pipe_path_ - << " was successfuly created"); + << " was successfuly opened for writing"); return true; } void PipeStreamerAdapter::PipeStreamer::Disconnect() { LOG4CXX_AUTO_TRACE(logger); - close(pipe_fd_); - unlink(named_pipe_path_.c_str()); + if (0 == close(pipe_fd_)) { + LOG4CXX_INFO(logger, "Pipe " << named_pipe_path_ << " was closed"); + } else { + LOG4CXX_ERROR(logger, "Error closing pipe " << named_pipe_path_); + } } bool PipeStreamerAdapter::PipeStreamer::Send( |