Skip to content
Browse files

First crack at testing audio routines. From Jerry G Geiger.

  • Loading branch information...
1 parent 981c1bc commit 25cbc79b9645eeadf2883881adbe0ad6b554ed5b R. Bernstein committed Aug 9, 2011
Showing with 65 additions and 1 deletion.
  1. +1 −1 lib/Device/Cdio/Device.pm
  2. +64 −0 t/11.dev.t
View
2 lib/Device/Cdio/Device.pm
@@ -425,7 +425,7 @@ See perlcdio::driver_errmsg($drc) for return values (!= 0).
sub audio_set_volume {
my($self,@p) = @_;
- my $vol = perlcdio::audio_get_volume_levels($self->{cd});
+ my ($vol, $drc) = perlcdio::audio_get_volume_levels($self->{cd});
for(my $i =0;$i<4;$i++) {
if(defined $p[$i]) {
@$vol[$i] = $p[$i] if $p[$i] > -1;
View
64 t/11.dev.t
@@ -0,0 +1,64 @@
+#!/usr/bin/env perl
+# Test device operations
+# No assumption about the CD-ROM drives is made, so
+# we're just going to run operations and see that they
+# don't crash.
+
+use strict;
+use warnings;
+use lib '../lib';
+use blib;
+
+use Device::Cdio;
+use Device::Cdio::Device;
+use Test::More;
+
+#should be imported from Build.PL or ...
+my $device = '/dev/cdrom';
+
+note 'Test running audio device operations';
+
+my $dev = Device::Cdio::Device->new($device);
+ok ( defined $dev , 'Device::Cdio::Device->new()');
+
+#my @drives = Device::Cdio::get_devices_with_cap(
+# -capabilities => $perlcdio::FS_AUDIO,
+# -any=>0);
+my @drives = Device::Cdio::get_devices($perlcdio::DRIVER_DEVICE);
+SKIP : {
+ skip 'no devices found', 1, unless scalar @drives;
+ ok ( scalar @drives , 'Device::Cdio::get_devices');
+ diag explain @drives;
+ # $device = $drives[0]; ??
+
+ my @hwinfo = $dev->get_hwinfo;
+ ok ( $hwinfo[3] , 'Device::Cdio::Device->get_hwinfo');
+ note("Testing ", $device, ' ', $hwinfo[0],' ',$hwinfo[1]);
+
+ my ($vols,$rcv) =$dev->audio_get_volume;
+ ok ( $rcv == 0 , 'Device::Cdio::Device->audio_get_volume');
+ note('Volume was set to ',join(', ',@$vols));
+
+ $dev->audio_set_volume(-1,-1,-1,-1);
+ my ($nvols, $mvols);
+ ($nvols,$rcv) =$dev->audio_get_volume;
+ is_deeply($vols, $nvols, "audio_set_volume keep values");
+ $dev->audio_set_volume(255,255);
+ ($mvols,$rcv) =$dev->audio_get_volume;
+ @$nvols[0] = 255; @$nvols[1] = 255;
+ is_deeply($mvols, $nvols, "audio_set_volume 2 channels");
+
+ $dev->audio_set_volume(100,100,-1,255);
+ ($mvols,$rcv) =$dev->audio_get_volume;
+ @$nvols[0] = 100; @$nvols[1] = 100; @$nvols[3] = 255;
+ my $c4 = eq_array ($mvols, $nvols) || note('4 channels are not supported: ',join(', ',@$mvols));
+ $dev->audio_set_volume(@$vols[0], @$vols[1], @$vols[2], @$vols[3]);
+ ($mvols,$rcv) =$dev->audio_get_volume;
+ is_deeply($mvols, $vols, "audio_set_volume reset");
+
+ SKIP2: {
+ skip '4 volume channels are not supported', 1, unless $c4 ;
+ is_deeply($mvols, $nvols, "audio_set_volume 4 channels");
+ }
+}
+done_testing();

0 comments on commit 25cbc79

Please sign in to comment.
Something went wrong with that request. Please try again.