aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGZNGET FOSS Team <opensource@gznianguan.com>2017-03-27 16:21:41 +0800
committerGZNGET FOSS Team <opensource@gznianguan.com>2017-03-27 16:21:41 +0800
commit95b92bae144acbcf30a0d5d61fbc0b42fcbf28a1 (patch)
treeead1f3fed67e5d1aa9a8d692bd36d7f9d82cb0a2
parentc2cd558bf051ac47cf0888d1676f2399182c4954 (diff)
downloadperl-Arctica-Services-Audio-Server-PulseAudio-95b92bae144acbcf30a0d5d61fbc0b42fcbf28a1.tar.gz
perl-Arctica-Services-Audio-Server-PulseAudio-95b92bae144acbcf30a0d5d61fbc0b42fcbf28a1.tar.bz2
perl-Arctica-Services-Audio-Server-PulseAudio-95b92bae144acbcf30a0d5d61fbc0b42fcbf28a1.zip
Moving handling of pa events back into to code of main executable
-rwxr-xr-xbin/AudioTestServer79
1 files changed, 51 insertions, 28 deletions
diff --git a/bin/AudioTestServer b/bin/AudioTestServer
index 2d98edd..1551f73 100755
--- a/bin/AudioTestServer
+++ b/bin/AudioTestServer
@@ -87,8 +87,8 @@ my $JABusServer = Arctica::Core::JABus::Socket->new($ACO,{
my $PA2GST = Arctica::Services::Audio::PulseAudio::PulseAudio2GST->new($ACO,$JABusServer);
my $PA_VDev = Arctica::Services::Audio::PulseAudio::PAVirtualDevices->new($ACO,{
-# hook_device_state => \&handle_PA_device_events,
- hook_device_state => sub {$PA2GST->handle_PA_device_events(@_)},
+ hook_device_state => \&handle_PA_device_events,
+# hook_device_state => sub {$PA2GST->handle_PA_device_events(@_)},
});
@@ -99,32 +99,55 @@ my $PA_VDev = Arctica::Services::Audio::PulseAudio::PAVirtualDevices->new($ACO,{
$ACO->{'Glib'}{'MainLoop'}->run;
-#sub handle_PA_device_events {# FIXME this has moved into PulseAudio2GST...: Clean up on line 99!
-# print "-------------------------------\n";
-# print Dumper(@_),"\n";
-# my $type = $_[0];
-# my $idnum = $_[1];
-# my $name = $_[2];
-# my $new_state = $_[3];
-# my $clientID = $PA2GST->get_active_client_id();
-# print "CID#\t$clientID\n";
-# if ($clientID) {
-# $JABusServer->server_send($clientID,"gstctl","$type:$idnum:$new_state");
-# if ($type eq "input") {
-# if ($new_state eq "R") {
-# # START LOCAL THEN CLIENTSIDE
-# } elsif($new_state eq "S") {
-# # SUSPEND CLIENTSIDE THEN LOCAL
-# }
-# } elsif ($type eq "output") {
-# if ($new_state eq "R") {
-# # START CLIENT SIDE THEN LOCAL
-# } elsif ($new_state eq "S") {
-# # SUSPEND CLIENTSIDE THEN LOCAL
-# }
-# }
-# }
-#}
+sub handle_PA_device_events {# FIXME this has moved into PulseAudio2GST...: But then it came back out here...
+ print "-------------------------------\n";
+ print Dumper(@_),"\n";
+ my $type = $_[0];
+ my $idnum = $_[1];
+ my $name = $_[2];
+ my $new_state = $_[3];
+ my $clientID = $PA2GST->get_active_client_id();
+ print "CID#\t$clientID\n";
+ if ($clientID) {
+
+ if ($type eq "input") {
+ if ($new_state eq "R") {
+ # START LOCAL THEN CLIENTSIDE
+ $PA2GST->start_input($idnum,$PA_VDev->{'pa_vdev'}{'input'}{0}{'pa_sink_name'});
+ $JABusServer->server_send($clientID,"gstctl",{
+ action => "start",
+ type => $type,
+ idnum => $idnum,
+ rate => $PA2GST->get_input_bitrate($idnum),
+ });
+ } elsif($new_state eq "S") {
+ $JABusServer->server_send($clientID,"gstctl",{
+ action => "stop",
+ type => $type,
+ idnum => $idnum,
+ });
+ $PA2GST->stop_input($idnum);
+ }
+ } elsif ($type eq "output") {
+ if ($new_state eq "R") {
+ # START CLIENT SIDE THEN LOCAL
+ $PA2GST->start_output($idnum,$PA_VDev->{'pa_vdev'}{'input'}{0}{'pa_sink_name'});
+ $JABusServer->server_send($clientID,"gstctl",{
+ action => "start",
+ type => $type,
+ idnum => $idnum,
+ });
+ } elsif ($new_state eq "S") {
+ $JABusServer->server_send($clientID,"gstctl",{
+ action => "stop",
+ type => $type,
+ idnum => $idnum,
+ });
+ $PA2GST->stop_output($idnum);
+ }
+ }
+ }
+}