std::string Song::getDirectory(unsigned idx) const { assert(m_song); if (idx > 0 || isStream()) return ""; const char *uri = mpd_song_get_uri(m_song.get()); const char *name = strrchr(uri, '/'); if (name) return std::string(uri, name-uri); else return "/"; }
void Sound::detach() { // Ignore if we are not attached to any source if (!source) return; // Unqueue all buffers and detach source if(isStream()) unqueue(); source = nullptr; }
void NetChannel::open() { const Poco::Timespan& ts = _config.timeout(); try { if (isStream() && ts.totalMicroseconds()) socketImpl()->connect(_config.address(), ts); else socketImpl()->connect(_config.address()); } catch (Exception&) { close(); } }
void Song::guessTags() { if (isEmpty() && !isStream()) { static const QLatin1String constAlbumArtistSep(" - "); guessed=true; QStringList parts = file.split("/", QString::SkipEmptyParts); if (3==parts.length()) { title=parts.at(2); album=parts.at(1); artist=parts.at(0); } if (2==parts.length() && parts.at(0).contains(constAlbumArtistSep)) { title=parts.at(1); QStringList albumArtistParts = parts.at(0).split(constAlbumArtistSep, QString::SkipEmptyParts); if (2==albumArtistParts.length()) { album=albumArtistParts.at(1); artist=albumArtistParts.at(0); } } else if (!parts.isEmpty()) { title=parts.at(parts.length()-1); } if (!title.isEmpty()) { int dot=title.lastIndexOf('.'); if (dot>0 && dot<title.length()-2) { title=title.left(dot); } static const QSet<QChar> constSeparators=QSet<QChar>() << QLatin1Char(' ') << QLatin1Char('-') << QLatin1Char('_') << QLatin1Char('.'); int separator=0; foreach (const QChar &sep, constSeparators) { separator=title.indexOf(sep); if (1==separator || 2==separator) { break; } } if ( (1==separator && title[separator-1].isDigit()) || (2==separator && title[separator-2].isDigit() && title[separator-1].isDigit()) ) { if (0==track) { track=title.left(separator).toInt(); } title=title.mid(separator+1); while (!title.isEmpty() && constSeparators.contains(title[0])) { title=title.mid(1); } } }
std::unique_ptr<Cask::CdapOdbc::DataReader> Cask::CdapOdbc::ColumnsCommand::executeReader() { if (isStream(this->tableName)) { auto streamName = makeStreamName(this->tableName); auto queryResult = this->getConnection()->getExploreClient().getStreamFields(streamName); bool noSchema = (queryResult.getSize() == 1) && (queryResult.getRows().at(0).at(L"name").as_string() == L"body"); if (noSchema) { return std::make_unique<NoSchemaColumnsDataReader>(this->tableName, queryResult); } else { return std::make_unique<ColumnsDataReader>(this->tableName, queryResult); } } else { auto datasetName = makeDatasetName(this->tableName); auto queryResult = this->getConnection()->getExploreClient().getDatasetFields(datasetName); return std::make_unique<ColumnsDataReader>(this->tableName, queryResult); } }
void SocketChannel::init() { delete _pSocket; if (isStream()) _pSocket = new Poco::Net::StreamSocket(); else if (isDatagram()) _pSocket = new Poco::Net::DatagramSocket(); else throw IllegalStateException(); poco_check_ptr (_pSocket); open(); if (!_pSocket) throw NullPointerException(); }
Poco::Net::Socket& NetChannel::newSocket() { delete _pSocket; if (isStream()) _pSocket = new Poco::Net::StreamSocket(); else if (isDatagram()) _pSocket = new Poco::Net::DatagramSocket(); else throw InvalidArgumentException(); poco_check_ptr (_pSocket); open(); if (!_pSocket) throw NullPointerException(); return *_pSocket; }
void SocketChannel::open() { Poco::Timespan timeout(config().getTimeout() * Timespan::MILLISECONDS); SocketAddress address(config().getName()); try { if (isStream() && timeout != ChannelConfig::INFINITE_TIMEOUT) socketImpl()->connect(address, timeout); else socketImpl()->connect(address); socketImpl()->setBlocking(false); } catch (Exception&) { close(); } }
bool FFMPEGReader::connect () { if (!isStream(_options.url) && !ssi_exists(_options.url)) { ssi_err("file not found '%s'", _options.url); return false; } if (!_client) { _client = new FFMPEGReaderClient(this); } if (!(_video_provider||_audio_provider)) { ssi_wrn ("provider not set"); return false; }; FFMPEGReaderClient::SetLogLevel (ssi_log_level); if (_mode != MODE::AUDIO) { _video_buffer = new FFMPEGVideoBuffer (_options.buffer, _video_format.framesPerSecond, ssi_video_size (_video_format)); _video_buffer->reset (); } if (_mode != MODE::VIDEO) { if (_mode == MODE::AUDIOVIDEO) { _audio_buffer = new FFMPEGAudioBuffer (_options.buffer, _audio_channel.stream.sr, 1.0/_video_format.framesPerSecond); } else { _audio_buffer = new FFMPEGAudioBuffer (_options.buffer, _audio_channel.stream.sr, _options.ablock); } _audio_buffer->reset (); } _client->start(); _wait_event.block(); return true; };