$OpenBSD: patch-ac3_a52_decoder_c,v 1.1 2002/03/29 14:46:01 espie Exp $
--- ac3/a52_decoder.c.orig	Fri Mar 29 15:14:16 2002
+++ ac3/a52_decoder.c	Fri Mar 29 15:19:06 2002
@@ -51,6 +51,7 @@ static int disable_dynrng = 0;
 static clocktime_t a52_decode_data(uint8_t *start, uint8_t *end);
 
 
+static a52_state_t *state;
 
 static int get_q();
 static int attach_ctrl_shm(int shmid);
@@ -216,15 +217,16 @@ int main(int argc, char *argv[])
 
   {
     uint32_t accel;
-    accel = MM_ACCEL_MLIB;
+    accel = MM_ACCEL_DJBFFT;
 
     open_output(get_speaker_flags());
 
-    samples = a52_init(accel);
-    if(samples == NULL) {
+    state = a52_init(accel);
+    if(state == NULL) {
         FATAL("A/52 init failed\n");
         exit(1);
     }
+    samples = a52_samples(state);
   }
 
   if(msgqid != -1) {
@@ -675,7 +677,6 @@ int get_q()
 }
 
 static clocktime_t a52_decode_data(uint8_t *start, uint8_t *end) {
-  static a52_state_t state;
   
   static uint8_t buf[3840];
   static uint8_t *bufptr = buf;
@@ -736,17 +737,16 @@ static clocktime_t a52_decode_data(uint8
 	
 	flags = speaker_flags;
 	flags |= A52_ADJUST_LEVEL;
-	memset(&state, 0, sizeof(a52_state_t));
 	/* flags (speaker) [in/out] level [in/out] bias [in] */
-	if(a52_frame(&state, buf, &flags, &level, bias)) {
+	if(a52_frame(state, buf, &flags, &level, bias)) {
 	  DNOTE("a52_frame() error\n");
 	  goto error;
 	}
 
 	if(disable_dynrng)
-	  a52_dynrng(&state, NULL, NULL);
+	  a52_dynrng(state, NULL, NULL);
 	for(i = 0; i < 6; i++) {
-	  if(a52_block(&state, samples)) {
+	  if(a52_block(state)) {
 	    DNOTE("a52_block() error\n");
 	    goto error;
 	  }
