This commit is contained in:
Chris 2017-03-28 23:20:42 +02:00
parent efee6d3ef4
commit ed5d76589f
2 changed files with 129 additions and 3 deletions

View File

@ -3,16 +3,32 @@
namespace NoccyLabs\PulseAudio;
use NoccyLabs\PulseAudio\Module\ModuleList;
use NoccyLabs\PulseAudio\Module\Loopback;
use NoccyLabs\PulseAudio\Sink\SinkList;
use NoccyLabs\PulseAudio\Sink\SinkInputList;
use NoccyLabs\PulseAudio\Sink\NullSink;
use NoccyLabs\PulseAudio\Sink\Sink;
use NoccyLabs\PulseAudio\Source\SourceList;
use NoccyLabs\PulseAudio\Source\SourceOutputList;
use NoccyLabs\PulseAudio\Source\Source;
use NoccyLabs\PulseAudio\Client\ClientList;
use NoccyLabs\PulseAudio\Card\CardList;
/**
* @class PulseAudio
*
*
*/
class PulseAudio
{
protected $server;
public function __construct($server=null)
{
$this->server = $server;
}
/**
*
*
@ -23,48 +39,139 @@ class PulseAudio
return new ModuleList($this);
}
/**
*
*
* @return SinkList
*/
public function getSinks()
{
return new SinkList($this);
}
public function createNullSink($name=null)
/**
* Create a new null sink that can be used
*
* @param Source $source The source to use as input
* @param Sink $sink The sink to use as output
* @return Loopback The created loopback module
*/
public function createNullSink($name=null, $description=null, array $properties=[])
{
return new NullSink($this, $name);
return new NullSink($this, $name, $description, $properties);
}
public function getSinkByIndex($index)
/**
* Create a new loopback, connecting a source to a sink.
*
* @param Source $source The source to use as input
* @param Sink $sink The sink to use as output
* @return Loopback The created loopback module
*/
public function createLoopback(Source $source, Sink $sink)
{
return new Loopback($this, $source, $sink);
}
/**
*
*
* @return Sink
*/
public function getDefaultSink()
{
}
/**
* Get an object representing a sink that exist on the system. Both index
* and name can be used to select the sink.
*
* @param int|string $index The index OR name of the sink to retrieve
* @return Sink|null The sink, or null if none found
*/
public function getSink($index)
{
$sinks = $this->getSinks();
return $sinks[$index];
}
/**
*
*
*
* @return SinkInputList
*/
public function getSinkInputs()
{
return new SinkInputList($this);
}
/**
*
* @return SourceList
*/
public function getSources()
{
return new SourceList($this);
}
/**
*
*
* @return Source
*/
public function getDefaultSource()
{
}
/**
*
*
* @return Source
*/
public function getSource($index)
{
}
/**
*
*
* @return SourceOutputList
*/
public function getSourceOutputs()
{
return new SourceOutputList($this);
}
/**
*
*
* @return ClientList
*/
public function getClients()
{
return new ClientList($this);
}
/**
*
*
* @return Client
*/
public function getClientByIndex($index)
{
$clients = $this->getClients();
return $clients[$index];
}
/**
*
*
* @return CardList
*/
public function getCards()
{
return new CardList($this);

View File

@ -12,6 +12,8 @@ class NullSink extends Sink
protected $destroyed = false;
protected $persistent = false;
protected $moduleIndex;
public function __construct(PulseAudio $pulse, $name=null)
@ -33,6 +35,9 @@ class NullSink extends Sink
public function __destruct()
{
if ($this->persistent) {
return;
}
if (!$this->isDestroyed()) {
$this->destroySink();
}
@ -49,5 +54,19 @@ class NullSink extends Sink
return $this->destroyed;
}
/**
* Flags the null-sink as persistent, meaning that it will not be
* automatically destroyed from the NullSink destructor. You can
* still manually destroy the sink within the object scope.
*
* The module-null-sink will have to be manually removed afterwards,
* see the documentation for more information.
*
*/
public function makePersistent()
{
$this->persistent = true;
}
}