mirror of
https://github.com/badaix/snapcast.git
synced 2025-04-28 17:57:05 +02:00
Remove metadata pipe on behalf of shairport sync
This commit is contained in:
parent
ad538d5178
commit
296a2f4dea
4 changed files with 28 additions and 8 deletions
|
@ -37,8 +37,15 @@ namespace file
|
|||
|
||||
static bool exists(const std::string& filename)
|
||||
{
|
||||
std::ifstream infile(filename.c_str());
|
||||
return infile.good();
|
||||
if (filename.empty())
|
||||
return false;
|
||||
#ifdef WINDOWS
|
||||
DWORD dwAttrib = GetFileAttributes(filename.c_str());
|
||||
return (dwAttrib != INVALID_FILE_ATTRIBUTES);
|
||||
#else
|
||||
struct stat buffer;
|
||||
return (stat(filename.c_str(), &buffer) == 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef WINDOWS
|
||||
|
|
|
@ -186,11 +186,14 @@ It might be neccessary to set the PulseAudio latency environment variable to 60
|
|||
|
||||
### AirPlay
|
||||
|
||||
Snapserver supports [shairport-sync](https://github.com/mikebrady/shairport-sync) with the `stdout` backend.
|
||||
Snapserver supports [shairport-sync](https://github.com/mikebrady/shairport-sync) with the `stdout` backend and metadata support.
|
||||
|
||||
1. Build shairport-sync (version 3.3 or later) with `stdout` backend: `./configure --with-stdout --with-avahi --with-ssl=openssl --with-metadata`
|
||||
2. Copy the `shairport-sync` binary somewhere to your `PATH`, e.g. `/usr/local/bin/`
|
||||
3. Configure snapserver with `stream = airplay:///shairport-sync?name=Airplay[&devicename=Snapcast][&port=5000]`
|
||||
1. Install dependencies. For debian derivates: `apt-get install autoconf libpopt-dev libconfig-dev libssl-dev`
|
||||
2. Build shairport-sync (version 3.3 or later) with `stdout` backend:
|
||||
- `autoreconf -i -f`
|
||||
- `./configure --with-stdout --with-avahi --with-ssl=openssl --with-metadata`
|
||||
3. Copy the `shairport-sync` binary somewhere to your `PATH`, e.g. `/usr/local/bin/`
|
||||
4. Configure snapserver with `stream = airplay:///shairport-sync?name=Airplay[&devicename=Snapcast][&port=5000]`
|
||||
|
||||
### Spotify
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "common/aixlog.hpp"
|
||||
#include "common/snap_exception.hpp"
|
||||
#include "common/utils.hpp"
|
||||
#include "common/utils/file_utils.hpp"
|
||||
#include "common/utils/string_utils.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
@ -209,6 +210,15 @@ void AirplayStream::do_connect()
|
|||
}
|
||||
|
||||
|
||||
void AirplayStream::do_disconnect()
|
||||
{
|
||||
ProcessStream::do_disconnect();
|
||||
// Shairpot-sync created but does not remove the pipe
|
||||
if (utils::file::exists(pipePath_) && (remove(pipePath_.c_str()) != 0))
|
||||
LOG(INFO, LOG_TAG) << "Failed to remove metadata pipe \"" << pipePath_ << "\": " << errno << "\n";
|
||||
}
|
||||
|
||||
|
||||
void AirplayStream::pipeReadLine()
|
||||
{
|
||||
if (!pipe_fd_ || !pipe_fd_->is_open())
|
||||
|
@ -236,8 +246,7 @@ void AirplayStream::pipeReadLine()
|
|||
{
|
||||
// For some reason, EOF is returned until the first metadata is written to the pipe.
|
||||
// If shairport-sync has not finished setting up the pipe, bad file descriptor is returned.
|
||||
LOG(INFO, LOG_TAG) << "Waiting for metadata, retrying in 2500ms"
|
||||
<< "\n";
|
||||
LOG(INFO, LOG_TAG) << "Waiting for metadata, retrying in 2500ms\n";
|
||||
wait(pipe_open_timer_, 2500ms, [this] { pipeReadLine(); });
|
||||
}
|
||||
else
|
||||
|
|
|
@ -83,6 +83,7 @@ protected:
|
|||
void setParamsAndPipePathFromPort();
|
||||
|
||||
void do_connect() override;
|
||||
void do_disconnect() override;
|
||||
void onStderrMsg(const std::string& line) override;
|
||||
void initExeAndPath(const std::string& filename) override;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue