diff options
author | AGaliuzov <AGaliuzov@luxoft.com> | 2016-02-22 19:13:16 +0200 |
---|---|---|
committer | AGaliuzov <AGaliuzov@luxoft.com> | 2016-02-22 19:13:16 +0200 |
commit | 303571bd6026b6a7ee3a1f0fa1c69846483314c7 (patch) | |
tree | 84401b2ad1270c64160404df8ec77b3fe2b604b2 /src/components/media_manager | |
parent | 91270a24c4c6c593e60b6069faba24df19b9a2db (diff) | |
parent | 5160be5bb052c65c05b658db2bcaa80c74562324 (diff) | |
download | sdl_core-303571bd6026b6a7ee3a1f0fa1c69846483314c7.tar.gz |
Merge pull request #396 from LuxoftSDL/hotfix/Move_media_pipe_creation_before_StartStream_command
Move media pipe creation before StartStream command
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( |