Tweaks
This commit is contained in:
parent
efee6d3ef4
commit
ed5d76589f
@ -3,16 +3,32 @@
|
|||||||
namespace NoccyLabs\PulseAudio;
|
namespace NoccyLabs\PulseAudio;
|
||||||
|
|
||||||
use NoccyLabs\PulseAudio\Module\ModuleList;
|
use NoccyLabs\PulseAudio\Module\ModuleList;
|
||||||
|
use NoccyLabs\PulseAudio\Module\Loopback;
|
||||||
use NoccyLabs\PulseAudio\Sink\SinkList;
|
use NoccyLabs\PulseAudio\Sink\SinkList;
|
||||||
use NoccyLabs\PulseAudio\Sink\SinkInputList;
|
use NoccyLabs\PulseAudio\Sink\SinkInputList;
|
||||||
use NoccyLabs\PulseAudio\Sink\NullSink;
|
use NoccyLabs\PulseAudio\Sink\NullSink;
|
||||||
|
use NoccyLabs\PulseAudio\Sink\Sink;
|
||||||
use NoccyLabs\PulseAudio\Source\SourceList;
|
use NoccyLabs\PulseAudio\Source\SourceList;
|
||||||
use NoccyLabs\PulseAudio\Source\SourceOutputList;
|
use NoccyLabs\PulseAudio\Source\SourceOutputList;
|
||||||
|
use NoccyLabs\PulseAudio\Source\Source;
|
||||||
use NoccyLabs\PulseAudio\Client\ClientList;
|
use NoccyLabs\PulseAudio\Client\ClientList;
|
||||||
use NoccyLabs\PulseAudio\Card\CardList;
|
use NoccyLabs\PulseAudio\Card\CardList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @class PulseAudio
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
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 new ModuleList($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return SinkList
|
||||||
|
*/
|
||||||
public function getSinks()
|
public function getSinks()
|
||||||
{
|
{
|
||||||
return new SinkList($this);
|
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();
|
$sinks = $this->getSinks();
|
||||||
return $sinks[$index];
|
return $sinks[$index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return SinkInputList
|
||||||
|
*/
|
||||||
public function getSinkInputs()
|
public function getSinkInputs()
|
||||||
{
|
{
|
||||||
return new SinkInputList($this);
|
return new SinkInputList($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return SourceList
|
||||||
|
*/
|
||||||
public function getSources()
|
public function getSources()
|
||||||
{
|
{
|
||||||
return new SourceList($this);
|
return new SourceList($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return Source
|
||||||
|
*/
|
||||||
|
public function getDefaultSource()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return Source
|
||||||
|
*/
|
||||||
|
public function getSource($index)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return SourceOutputList
|
||||||
|
*/
|
||||||
public function getSourceOutputs()
|
public function getSourceOutputs()
|
||||||
{
|
{
|
||||||
return new SourceOutputList($this);
|
return new SourceOutputList($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return ClientList
|
||||||
|
*/
|
||||||
public function getClients()
|
public function getClients()
|
||||||
{
|
{
|
||||||
return new ClientList($this);
|
return new ClientList($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return Client
|
||||||
|
*/
|
||||||
public function getClientByIndex($index)
|
public function getClientByIndex($index)
|
||||||
{
|
{
|
||||||
$clients = $this->getClients();
|
$clients = $this->getClients();
|
||||||
return $clients[$index];
|
return $clients[$index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return CardList
|
||||||
|
*/
|
||||||
public function getCards()
|
public function getCards()
|
||||||
{
|
{
|
||||||
return new CardList($this);
|
return new CardList($this);
|
||||||
|
@ -12,6 +12,8 @@ class NullSink extends Sink
|
|||||||
|
|
||||||
protected $destroyed = false;
|
protected $destroyed = false;
|
||||||
|
|
||||||
|
protected $persistent = false;
|
||||||
|
|
||||||
protected $moduleIndex;
|
protected $moduleIndex;
|
||||||
|
|
||||||
public function __construct(PulseAudio $pulse, $name=null)
|
public function __construct(PulseAudio $pulse, $name=null)
|
||||||
@ -33,6 +35,9 @@ class NullSink extends Sink
|
|||||||
|
|
||||||
public function __destruct()
|
public function __destruct()
|
||||||
{
|
{
|
||||||
|
if ($this->persistent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!$this->isDestroyed()) {
|
if (!$this->isDestroyed()) {
|
||||||
$this->destroySink();
|
$this->destroySink();
|
||||||
}
|
}
|
||||||
@ -49,5 +54,19 @@ class NullSink extends Sink
|
|||||||
return $this->destroyed;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user