[player/pipe] Only pass path to pipe_setup

This commit is contained in:
chme 2016-10-26 19:40:15 +02:00
parent 2db3318ce7
commit 477088a36c
3 changed files with 10 additions and 11 deletions

View File

@ -41,36 +41,36 @@ static int g_fd = -1;
static uint16_t *g_buf = NULL;
int
pipe_setup(struct media_file_info *mfi)
pipe_setup(const char *path)
{
struct stat sb;
if (!mfi->path)
if (!path)
{
DPRINTF(E_LOG, L_PLAYER, "Path to pipe is NULL\n");
return -1;
}
DPRINTF(E_DBG, L_PLAYER, "Setting up pipe: %s\n", mfi->path);
DPRINTF(E_DBG, L_PLAYER, "Setting up pipe: %s\n", path);
if (lstat(mfi->path, &sb) < 0)
if (lstat(path, &sb) < 0)
{
DPRINTF(E_LOG, L_PLAYER, "Could not lstat() '%s': %s\n", mfi->path, strerror(errno));
DPRINTF(E_LOG, L_PLAYER, "Could not lstat() '%s': %s\n", path, strerror(errno));
return -1;
}
if (!S_ISFIFO(sb.st_mode))
{
DPRINTF(E_LOG, L_PLAYER, "Source type is pipe, but path is not a fifo: %s\n", mfi->path);
DPRINTF(E_LOG, L_PLAYER, "Source type is pipe, but path is not a fifo: %s\n", path);
return -1;
}
pipe_cleanup();
g_fd = open(mfi->path, O_RDONLY | O_NONBLOCK);
g_fd = open(path, O_RDONLY | O_NONBLOCK);
if (g_fd < 0)
{
DPRINTF(E_LOG, L_PLAYER, "Could not open pipe for reading '%s': %s\n", mfi->path, strerror(errno));
DPRINTF(E_LOG, L_PLAYER, "Could not open pipe for reading '%s': %s\n", path, strerror(errno));
return -1;
}

View File

@ -3,10 +3,9 @@
#define __PIPE_H__
#include <event2/buffer.h>
#include "db.h"
int
pipe_setup(struct media_file_info *mfi);
pipe_setup(const char *path);
void
pipe_cleanup(void);

View File

@ -693,7 +693,7 @@ stream_setup(struct player_source *ps, struct media_file_info *mfi)
break;
case DATA_KIND_PIPE:
ret = pipe_setup(mfi);
ret = pipe_setup(mfi->path);
break;
default: