4 #include <devices/ahi.h>
6 #include <proto/exec.h>
15 static const char version
[] = "$VER: Test-7.1 " VERS
"\n\r";
17 struct Library
* AHIBase
= NULL
;
19 static int Test71( ULONG
);
22 main( int argc
, char* argv
[] ) {
26 fprintf( stderr
, "Usage: %s <audio mode id>\n", argv
[ 0 ] );
30 struct MsgPort
* mp
= CreateMsgPort();
33 struct AHIRequest
* io
= (struct AHIRequest
*)
34 CreateIORequest( mp
, sizeof( struct AHIRequest
) );
37 // We use 32 bit, 8 channel samples, so we need version 6.
40 if( OpenDevice( AHINAME
, AHI_NO_UNIT
, (struct IORequest
*) io
, 0 )
42 AHIBase
= (struct Library
*) io
->ahir_Std
.io_Device
;
44 rc
= Test71( strtol( argv
[ 1 ], NULL
, 0 ) );
46 CloseDevice( (struct IORequest
*) io
);
49 fprintf( stderr
, "Unable to open '" AHINAME
"' version 6.\n" );
53 DeleteIORequest( (struct IORequest
*) io
);
56 fprintf( stderr
, "Unable to create IO request.\n" );
63 fprintf( stderr
, "Unable to create message port.\n" );
75 Test71( ULONG mode_id
) {
80 sample
= malloc( sizeof(LONG
) * 8 * (LENGTH
+1) );
82 if( sample
!= NULL
) {
83 struct AHIAudioCtrl
* actrl
;
86 for( i
= 0; i
< (LENGTH
+1); ++i
) {
87 sample
[ i
* 8 + 0 ] = 0;
88 sample
[ i
* 8 + 1 ] = 0;
89 sample
[ i
* 8 + 2 ] = 0;
90 sample
[ i
* 8 + 3 ] = 0;
91 sample
[ i
* 8 + 4 ] = 0;
92 sample
[ i
* 8 + 5 ] = 0;
93 sample
[ i
* 8 + 6 ] = 0;
95 sample
[ i
* 8 + 7 ] = 0x7fffffff*sin(2*M_PI
*i
/LENGTH
);
97 sample
[ i
* 8 + 7 ] = i
< (LENGTH
/2) ? 0x7fffffff : 0x80000000;
103 AHI_GetAudioAttrs( mode_id
, NULL
,
104 AHIDB_Name
, (ULONG
) &name
,
108 printf( "Testing mode 0x%08lx (%s)\n", mode_id
, name
);
110 actrl
= AHI_AllocAudio( AHIA_AudioID
, mode_id
,
116 if( actrl
!= NULL
) {
117 struct AHISampleInfo sample_fl
= { AHIST_L7_1
, sample
+ 7, LENGTH
};
118 struct AHISampleInfo sample_fr
= { AHIST_L7_1
, sample
+ 6, LENGTH
};
119 struct AHISampleInfo sample_rl
= { AHIST_L7_1
, sample
+ 5, LENGTH
};
120 struct AHISampleInfo sample_rr
= { AHIST_L7_1
, sample
+ 4, LENGTH
};
121 struct AHISampleInfo sample_sl
= { AHIST_L7_1
, sample
+ 3, LENGTH
};
122 struct AHISampleInfo sample_sr
= { AHIST_L7_1
, sample
+ 2, LENGTH
};
123 struct AHISampleInfo sample_c
= { AHIST_L7_1
, sample
+ 1, LENGTH
};
124 struct AHISampleInfo sample_lfe
= { AHIST_L7_1
, sample
+ 0, LENGTH
};
126 if( AHI_LoadSound( 0, AHIST_SAMPLE
, &sample_fl
, actrl
) == AHIE_OK
&&
127 AHI_LoadSound( 1, AHIST_SAMPLE
, &sample_fr
, actrl
) == AHIE_OK
&&
128 AHI_LoadSound( 2, AHIST_SAMPLE
, &sample_rl
, actrl
) == AHIE_OK
&&
129 AHI_LoadSound( 3, AHIST_SAMPLE
, &sample_rr
, actrl
) == AHIE_OK
&&
130 AHI_LoadSound( 4, AHIST_SAMPLE
, &sample_sl
, actrl
) == AHIE_OK
&&
131 AHI_LoadSound( 5, AHIST_SAMPLE
, &sample_sr
, actrl
) == AHIE_OK
&&
132 AHI_LoadSound( 6, AHIST_SAMPLE
, &sample_c
, actrl
) == AHIE_OK
&&
133 AHI_LoadSound( 7, AHIST_SAMPLE
, &sample_lfe
, actrl
) == AHIE_OK
) {
135 if( AHI_ControlAudio( actrl
,
137 TAG_DONE
) == AHIE_OK
) {
139 AHIP_BeginChannel
, 0,
146 printf( "Front Left.\n" );
149 AHI_SetSound( 0, 1, 0, 0, actrl
, AHISF_IMM
);
150 printf( "Front Right.\n" );
153 AHI_SetSound( 0, 2, 0, 0, actrl
, AHISF_IMM
);
154 printf( "Rear Left.\n" );
157 AHI_SetSound( 0, 3, 0, 0, actrl
, AHISF_IMM
);
158 printf( "Rear Right.\n" );
161 AHI_SetSound( 0, 4, 0, 0, actrl
, AHISF_IMM
);
162 printf( "Surround Left.\n" );
165 AHI_SetSound( 0, 5, 0, 0, actrl
, AHISF_IMM
);
166 printf( "Surround Right.\n" );
169 AHI_SetSound( 0, 6, 0, 0, actrl
, AHISF_IMM
);
170 printf( "Center.\n" );
173 AHI_SetSound( 0, 7, 0, 0, actrl
, AHISF_IMM
);
177 AHI_ControlAudio( actrl
,
182 fprintf( stderr
, "Unable start playback.\n" );
186 // AHI_FreeAudio() will unload the sounds
189 fprintf( stderr
, "Unable load sounds.\n" );
193 AHI_FreeAudio( actrl
);
196 fprintf( stderr
, "Unable to allocate audio.\n" );
202 fprintf( stderr
, "Unable to allocate memory for sample.\n" );