Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Audrey and amixer code for issue #330. #619

Merged
merged 4 commits into from
Sep 26, 2016
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 20 additions & 21 deletions code/common/pa_control.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#@ Allows the rooms= speak and play parm to target specific rooms via a weeder relay or X10 controled PA system.
#@ See comment at the end of this file for example .mht entries.

=begin comment
=begin
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

File:
Expand Down Expand Up @@ -52,7 +52,7 @@

# Hooks to flag which rooms to turn on based on "rooms=" parm in speak command
if ($Reload) {
print_log("PA: Hooking into speech events");
print_log("[PA] Hooking into speech events");
&Speak_parms_add_hook( \&pa_parms_stub );
&Speak_pre_add_hook( \&pa_control_stub );
&Play_parms_add_hook( \&pa_parms_stub );
Expand All @@ -61,8 +61,7 @@
if ( said $v_pa_test) {
my $state = $v_pa_test->{state};
$v_pa_test->respond('app=pa Testing PA...');
speak
"nolog=1 rooms=all mode=unmuted volume=80 Hello. This is a PA system test.";
speak "nolog=1 rooms=all mode=unmuted volume=80 Hello. This is a PA system test.";

#speak "nolog=1 rooms=downstairs mode=unmuted volume=100 Hi!";
}
Expand All @@ -72,7 +71,7 @@
my $state = $v_pa_speakers->{state};
$v_pa_speakers->respond("app=pa Turning speakers $state...");
$state = ( $state eq 'on' ) ? ON : OFF;
print_log("PA: Turning speakers $state") if $Debug{pa};
print_log("[PA] Turning speakers $state") if $Debug{pa};
$pactrl->set( 'allspeakers', $state, 'unmuted' );
}

Expand All @@ -94,23 +93,22 @@ sub pa_parms_stub {
my $results = $pactrl->prep_parms($parms);
my %pa_zones = $pactrl->get_pa_zones();

if ( defined $pa_zones{audrey} && $pa_zones{audrey} ne '' ) {
print_log( "PA: audrey zone detected, hooking via web_hook. ("
. $pa_zones{audrey}
if ( defined $pa_zones{all}{audrey} && $pa_zones{all}{audrey} ne '' ) {
print_log( "[PA] audrey zone detected, hooking via web_hook. ("
. $pa_zones{all}{audrey}
. ")" )
if $Debug{pa};
push( @{ $parms->{web_hook} }, \&pa_web_hook );
}

print_log("PA: parms_stub set results: $results") if $Debug{pa} >= 2;
print_log("[PA] parms_stub set results: $results") if $Debug{pa} >= 2;

}
else {
#MH is already speaking, and other PA zones are already active. Delay speech.
#MH is already speaking, and other PA zones are already active. Delay speech.
if ( $main::Debug{voice} ) {
$parms->{clash_retry} = 0 unless $parms->{clash_retry};
&print_log(
"PA SPEECH CLASH($parms->{clash_retry}): Delaying speech call for "
&print_log("[PA] SPEECH CLASH($parms->{clash_retry}): Delaying speech call for "
. $parms->{text}
. "\n" )
unless $parms->{clash_retry} lt 1;
Expand All @@ -124,15 +122,15 @@ sub pa_parms_stub {
$parmstxt .= ', ' if $parmstxt;
$parmstxt .= "$pkey => q($pval)";
}
&print_log("PA SPEECH CLASH Parameters: $parmstxt")
&print_log("[PA] SPEECH CLASH Parameters: $parmstxt")
if $main::Debug{voice} && $parms->{clash_retry} eq 0;
&run_after_delay( $pa_clash_delay, "speak($parmstxt)" );

$parms->{no_speak} = 1; #To stop MH from speaking this time around
return;
}
if ( $parms->{clash_retry} ) {
&print_log("PA SPEECH CLASH: Resolved, continuing speech.");
&print_log("[PA] SPEECH CLASH: Resolved, continuing speech.");
}
}

Expand All @@ -142,10 +140,10 @@ sub pa_control_stub {
my $mode = $parms{pa_mode};
return if $mode eq 'mute' or $mode eq 'offline';

my $rooms = $parms{rooms};
print_log("PA: control_stub: rooms=$rooms, mode=$mode") if $Debug{pa};
print_log("[PA] control_stub: rooms=$parms{pa_zones}, mode=$mode")
if $Debug{pa};
my $results = $pactrl->audio_hook( ON, \%parms );
print_log("PA: control_stub set results: $results") if $Debug{pa} >= 2;
print_log("[PA] control_stub set results: $results") if $Debug{pa} >= 2;
set $pa_speaker_timer $pa_timer if $results;
return $results;
}
Expand All @@ -158,7 +156,7 @@ sub pa_web_hook {
#Turn off speakers when MH says it's done speaking/playing
if ( state_now $mh_speakers eq OFF ) {
unset $pa_speaker_timer;
print_log("PA: Turning speakers off") if $Debug{pa};
print_log("[PA] Turning speakers off") if $Debug{pa};
$pactrl->audio_hook( OFF, 'normal' );
$pactrl->active(0);
}
Expand All @@ -167,7 +165,7 @@ sub pa_web_hook {
$pa_speaker_timer = new Timer;
set $pa_speaker_timer 60 if state_now $mh_speakers eq ON;
if ( expired $pa_speaker_timer) {
print_log("PA: Timer expired. Forcing PA speakers off.") if $Debug{pa};
print_log("[PA] Timer expired. Forcing PA speakers off.") if $Debug{pa};
set $mh_speakers OFF;
}

Expand Down Expand Up @@ -222,9 +220,10 @@ sub pa_web_hook {
used.

Serial: The name of the serial port that you use for communcating to the IO device.
The default is "weeder". Note that this can be changed with an INI parm.
Leave this blank unless the "Type" of the PA control line is wdio, wdio_old or
aviosys. The default is "weeder". Note that this can be changed with an INI parm.

Other: Optional. Sets the type of PA control. Defaults to 'wdio'. Available options are:
Type: Optional. Sets the type of PA control. Defaults to 'wdio'. Available options are:
wdio,wdio_old,X10,xpl,xap,audrey,amixer,object

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Expand Down
33 changes: 20 additions & 13 deletions lib/PAobj.pm
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,21 @@ sub prep_parms {
for my $room (@speakers) {
my $ref = &::get_object_by_name("pa_$room");
my $type = $ref->get_type();
&::print_log("PAobj: speakers_$type: Adding $room")
if $main::Debug{pa} >= 3;
$pa_zone_types{$type}++ unless $pa_zone_types{$type};
push( @{ $speakertype{$type} }, $room );
&::print_log("PAobj: speakers_$type: Adding $room") if $main::Debug{pa} >=3;
# $pa_zone_types{$type}++ unless $pa_zone_types{$type};
push(@{$speakertype{$type}}, $room);
}

foreach my $type (keys(%pa_zone_types)) {
undef $pa_zones{active}{$type};
}

foreach my $type ( keys(%speakertype) ) {
my @thespeakers = @{ $speakertype{$type} };
&::print_log( "PAobj: speakers_$type: "
. ( $#thespeakers + 1 ) . ": "
. join( ',', @thespeakers ) )
if $main::Debug{pa};
$pa_zones{active}{$type} = join( ',', @thespeakers );
if ( $#thespeakers > -1 ) {
$parms->{web_file} = "web_file" if $type eq 'audrey';
foreach my $type (keys(%speakertype)) {
my @thespeakers = @{$speakertype{$type}};
&::print_log("PAobj: speakers_$type: ".($#thespeakers+1).": " . join(',',@thespeakers)) if $main::Debug{pa};
$pa_zones{active}{$type}=join(',',@thespeakers);
if ($#thespeakers > -1) {
$parms->{web_file}="web_file" if $type eq 'audrey';
}
}

Expand Down Expand Up @@ -727,9 +727,16 @@ sub new {
if ( lc $paz_type eq 'amixer' ) {

#Headphone:0:L
<<<<<<< HEAD
Copy link
Owner

@hollie hollie Sep 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There seems to be a remaining merge conflict here. Can you please review it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching that. Fixed..

my ($mixer,$mixernum,$channel) = split(':',$self->{address});
&::print_log("$mixer / $mixernum / $channel");
$self->{mixer} = "$mixer";
$self->{mixer} .= ",$mixernum" if $mixernum;
=======
my ( $mixer, $mixernum, $channel ) = split( ':', $self->{address} );
&main::print_log("$mixer / $mixernum / $channel");
$self->{mixer} = "$mixer,$mixernum";
>>>>>>> hollie/master
$self->{mixerchan} = lc $channel if $channel;
}

Expand Down