]> git.sesse.net Git - vlc/blob - src/audio_output/aout_spdif.c
85348bb2c60cf42b1a6cc035153af27ef06e0cce
[vlc] / src / audio_output / aout_spdif.c
1 /*****************************************************************************
2  * aout_spdif: ac3 passthrough output
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: aout_spdif.c,v 1.1 2001/04/29 02:55:36 stef Exp $
6  *
7  * Authors: Michel Kaempf <maxx@via.ecp.fr>
8  *          Stéphane Borel <stef@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  * 
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*****************************************************************************
26  * Preamble
27  *****************************************************************************/
28 #include "defs.h"
29
30 #include <stdio.h>                                           /* "intf_msg.h" */
31 #include <stdlib.h>                            /* calloc(), malloc(), free() */
32
33 #include "config.h"
34 #include "common.h"
35 #include "threads.h"
36 #include "mtime.h"                             /* mtime_t, mdate(), msleep() */
37
38 #include "intf_msg.h"                        /* intf_DbgMsg(), intf_ErrMsg() */
39
40 #include "audio_output.h"
41 #include "aout_common.h"
42
43 /* temporary blank until I've found how to build
44  * a real blank iec958 data frame */
45 static u8 pi_spdif_blank [] =
46 {
47     0x72, 0xf8, 0x1f, 0x4e, 0x01, 0x00, 0x00, 0x30, 
48     0x77, 0x0b, 0x07, 0x04, 0x40, 0x1c, 0xfc, 0xe1, 
49     0xcb, 0x01, 0x7d, 0x80, 0xb2, 0xfe, 0x40, 0xe8, 
50     0x06, 0x75, 0x84, 0x07, 0x14, 0x04, 0x0e, 0x14, 
51     0x84, 0x83, 0x56, 0xd5, 0xbe, 0x52, 0xad, 0x5b, 
52     0x27, 0xf4, 0x9f, 0xcf, 0xdf, 0x3f, 0x95, 0x6a, 
53     0x86, 0x3d, 0xba, 0xa6, 0xb0, 0x67, 0xbe, 0xa1, 
54     0xfd, 0x52, 0x9a, 0xd2, 0xb5, 0xcf, 0x7d, 0x5a, 
55     0xf2, 0x4d, 0x4f, 0x5a, 0xf6, 0xbd, 0xfa, 0x95, 
56     0xe9, 0x57, 0x3e, 0x95, 0xe9, 0x54, 0x77, 0x4d, 
57     0x9e, 0x4a, 0x54, 0xd7, 0x15, 0xf6, 0xb0, 0x77, 
58     0x3e, 0xdd, 0xab, 0x4c, 0xcf, 0xde, 0xc2, 0x6b, 
59     0x96, 0x86, 0xf5, 0x93, 0xa1, 0x35, 0xad, 0x56, 
60     0xeb, 0x5d, 0x4f, 0xea, 0xa6, 0x9d, 0xfa, 0x4a, 
61     0xa7, 0x13, 0x7f, 0xe8, 0xfd, 0xb8, 0xf2, 0xf3, 
62     0x9e, 0x2f, 0x73, 0xd7, 0xeb, 0x4d, 0xce, 0xf7, 
63     0xa2, 0xa9, 0x0d, 0x49, 0xe7, 0x53, 0x9e, 0xcf, 
64     0x7b, 0xd7, 0xfb, 0x5f, 0xab, 0x95, 0x54, 0x43, 
65     0xbb, 0xf6, 0xd5, 0x9a, 0x3e, 0xdf, 0x5e, 0x73, 
66     0xa7, 0x92, 0x9e, 0xca, 0x86, 0xd6, 0x33, 0xf9, 
67     0x2f, 0xa7, 0xef, 0xfe, 0x28, 0xef, 0xfc, 0x3f, 
68     0xf3, 0xf9, 0xcf, 0xe7, 0x20, 0x9f, 0xa8, 0x07, 
69     0x00, 0x63, 0xb6, 0xd6, 0x6d, 0x0d, 0xe7, 0xa0, 
70     0xd0, 0xc1, 0x1a, 0xb1, 0x35, 0xd8, 0x23, 0x47, 
71     0xa5, 0x62, 0x96, 0x41, 0xd7, 0x9c, 0xe3, 0x59, 
72     0x60, 0x9b, 0x15, 0xdb, 0xab, 0x03, 0x6a, 0x73, 
73     0xc5, 0xd6, 0x5b, 0x8d, 0xe6, 0x5a, 0xed, 0xc0, 
74     0x6c, 0x23, 0x2a, 0xb9, 0x65, 0xa7, 0xd6, 0x54, 
75     0xb6, 0xb1, 0x15, 0x6c, 0x31, 0x55, 0x6d, 0xad, 
76     0x07, 0x97, 0xb3, 0x11, 0x81, 0xb6, 0x14, 0x71, 
77     0xd4, 0xe6, 0xda, 0xb6, 0xa8, 0x35, 0x09, 0x36, 
78     0xe2, 0x85, 0x11, 0x45, 0x83, 0xad, 0x6a, 0x32, 
79     0x67, 0xe1, 0xad, 0x35, 0x1b, 0xc9, 0x5a, 0x9b, 
80     0x60, 0x06, 0x00, 0xf8, 0x05, 0x00, 0x00, 0x3c, 
81     0x26, 0x12, 0x72, 0x05, 0xad, 0x94, 0x14, 0x8e, 
82     0x07, 0x5e, 0xfb, 0x13, 0x91, 0x53, 0x83, 0x71, 
83     0xad, 0x52, 0x0a, 0x87, 0xba, 0x3a, 0xf7, 0x38, 
84     0x1a, 0xef, 0xa4, 0x65, 0x2e, 0x4b, 0x75, 0xeb, 
85     0x52, 0x32, 0xc4, 0xaa, 0xe8, 0x83, 0xf8, 0x85, 
86     0x51, 0x1d, 0x6f, 0x59, 0xea, 0xe3, 0x85, 0x07, 
87     0x19, 0xb1, 0x9f, 0x6e, 0x36, 0x6a, 0x1a, 0x71, 
88     0xa7, 0xec, 0x56, 0xed, 0xc8, 0x1b, 0xb6, 0xc3, 
89     0xfd, 0xd0, 0x98, 0xd2, 0xa3, 0xf3, 0x5a, 0xfc, 
90     0x1c, 0x5d, 0x60, 0x21, 0xc7, 0xf0, 0x08, 0x1e, 
91     0x03, 0x90, 0xb1, 0xd4, 0x31, 0x18, 0xbc, 0x27, 
92     0xb1, 0x6c, 0x8a, 0xf3, 0xe5, 0x68, 0x7a, 0x18, 
93     0x29, 0xf0, 0xeb, 0x78, 0xdf, 0xe1, 0x3f, 0xf3, 
94     0x67, 0x1b, 0xd4, 0x67, 0x20, 0x80, 0x0b, 0xb5, 
95     0x6e, 0xef, 0x45, 0xbd, 0xac, 0x48, 0xe0, 0x5e, 
96     0x3c, 0x6b, 0x3d, 0x7a, 0x7f, 0x38, 0xbd, 0xf1, 
97     0xd3, 0x8f, 0xbf, 0xa1, 0x98, 0x50, 0xa0, 0x6a, 
98     0x33, 0x5a, 0xc6, 0x2e, 0xfc, 0x8f, 0x8f, 0xcc, 
99     0x58, 0xcf, 0x57, 0x22, 0xa6, 0xf7, 0x82, 0x14, 
100     0x47, 0xea, 0x70, 0x81, 0x89, 0x86, 0x29, 0xb8, 
101     0x83, 0xae, 0xd8, 0x5a, 0x4d, 0xb7, 0x0a, 0x24, 
102     0xb5, 0xd6, 0x63, 0x4d, 0x46, 0x58, 0x79, 0xc5, 
103     0x5b, 0x66, 0x2a, 0x68, 0x5b, 0x6b, 0xb9, 0x63, 
104     0x6d, 0xad, 0x64, 0x92, 0xb1, 0xdb, 0xb3, 0xad, 
105     0x46, 0x58, 0xcd, 0xb6, 0x48, 0x73, 0x35, 0xd6, 
106     0x85, 0xc8, 0xf7, 0x68, 0xed, 0x88, 0x1a, 0x8b, 
107     0x35, 0xd6, 0x23, 0xad, 0x06, 0x9b, 0x80, 0x91, 
108     0x14, 0x23, 0x5a, 0x1c, 0xa9, 0x46, 0x4d, 0xb9, 
109     0x8e, 0x6c, 0xa3, 0xc3, 0x5a, 0x0b, 0x5d, 0xa6, 
110     0x6b, 0xad, 0xdb, 0x60, 0x26, 0x24, 0x8a, 0xb4, 
111     0x20, 0x69, 0xb0, 0xd6, 0x1b, 0x2c, 0xa2, 0x60, 
112     0x80, 0x0f, 0x00, 0x00, 0xe0, 0x53, 0xb4, 0x09, 
113     0x0a, 0x78, 0xe4, 0xff, 0x13, 0x71, 0x56, 0xfd, 
114     0x41, 0x08, 0xd7, 0x97, 0xb1, 0x43, 0x76, 0xe5, 
115     0x02, 0x29, 0x40, 0xdc, 0xb2, 0xbe, 0x24, 0x72, 
116     0x7e, 0xca, 0x30, 0x9d, 0x25, 0x92, 0x51, 0x73, 
117     0x24, 0xfc, 0x96, 0xca, 0x5a, 0xee, 0xed, 0xf8, 
118     0x65, 0x8e, 0x83, 0x94, 0xc2, 0xc2, 0x27, 0xd3, 
119     0x50, 0xb1, 0xe7, 0xca, 0xcd, 0x1f, 0xd0, 0x51, 
120     0x96, 0x34, 0xd0, 0x9d, 0x6a, 0xf5, 0x17, 0x45, 
121     0x66, 0x48, 0x51, 0xdd, 0x69, 0x53, 0xac, 0xdc, 
122     0xb1, 0xfc, 0x38, 0x79, 0x1b, 0x2a, 0xc1, 0xc8, 
123     0x66, 0x01, 0xb5, 0xa1, 0x10, 0x89, 0x83, 0x59, 
124     0xd6, 0xa6, 0x99, 0x66, 0x97, 0x60, 0xa4, 0x5e, 
125     0x90, 0xdc, 0xf3, 0xb7, 0xa0, 0xc0, 0x54, 0xc8, 
126     0xc5, 0x72, 0xf4, 0x65, 0x3c, 0xb9, 0x82, 0xa6, 
127     0xa4, 0x99, 0x4b, 0xa0, 0x3b, 0xfa, 0x3f, 0x29, 
128     0xfe, 0x00, 0x29, 0x77, 0xcc, 0xd3, 0x7a, 0x20, 
129     0xc2, 0x38, 0xbe, 0xba, 0xdf, 0x35, 0x03, 0xbc, 
130     0x01, 0xd1, 0x99, 0x5a, 0x65, 0x10, 0x2b, 0xac, 
131     0xca, 0xf9, 0x0a, 0x87, 0x6e, 0x73, 0xe2, 0x20, 
132     0x2e, 0x83, 0xe2, 0x4f, 0x32, 0x43, 0x6d, 0xb3, 
133     0xb5, 0x36, 0x6b, 0xa5, 0xd6, 0x5a, 0xaa, 0xdd, 
134     0x48, 0x6b, 0xb4, 0x76, 0x70, 0xea, 0x02, 0x63, 
135     0xb6, 0x69, 0x06, 0xdb, 0x83, 0xb8, 0x6c, 0x60, 
136     0x91, 0xa6, 0xa1, 0x47, 0x5a, 0x6b, 0x39, 0xdb, 
137     0x69, 0xad, 0xd6, 0x18, 0x4a, 0xa9, 0x6c, 0x23, 
138     0x88, 0x84, 0x36, 0xef, 0xe5, 0xda, 0xca, 0xba, 
139     0x42, 0x70, 0xb1, 0xd6, 0x69, 0x8d, 0xc8, 0xda, 
140     0x99, 0x29, 0x2e, 0xb7, 0x5c, 0x2e, 0xdd, 0xc6, 
141     0x22, 0x99, 0x28, 0x5e, 0x4a, 0x41, 0x88, 0x6a, 
142     0xa8, 0xe6, 0x7a, 0x90, 0x6a, 0x78, 0xd6, 0x9a, 
143     0x84, 0x35, 0x86, 0x83, 0x36, 0x76, 0x40, 0x04, 
144     0x00, 0xf8, 0x05, 0x00, 0x00, 0x40, 0x92, 0xee, 
145     0x7b, 0xa1, 0xc8, 0xcf, 0x0b, 0x55, 0x6b, 0x30, 
146     0xb5, 0x7b, 0x55, 0x72, 0x58, 0x74, 0x69, 0xf9, 
147     0xd6, 0x9f, 0x89, 0x21, 0x0d, 0x5b, 0x90, 0x48, 
148     0xde, 0x08, 0x65, 0xd4, 0x2b, 0x08, 0xe1, 0x22, 
149     0xd0, 0xbd, 0xe9, 0x93, 0xb1, 0x80, 0x59, 0x83, 
150     0xaa, 0xb7, 0x13, 0x57, 0x9f, 0xbf, 0xf8, 0x6c, 
151     0x6d, 0xf9, 0xe6, 0x22, 0xf5, 0xc7, 0xc0, 0xdc, 
152     0x17, 0x84, 0x63, 0xf8, 0xb3, 0x94, 0xb1, 0xd5, 
153     0xa9, 0x56, 0x87, 0xd4, 0xd8, 0x2a, 0xc8, 0x56, 
154     0x23, 0x70, 0x52, 0xb8, 0x66, 0x8b, 0x06, 0x5f, 
155     0x84, 0xd5, 0xc6, 0xa6, 0x5a, 0xb1, 0x6f, 0xef, 
156     0xcd, 0x7f, 0xe2, 0x9a, 0xb9, 0x9f, 0xff, 0x08, 
157     0xff, 0x73, 0xa7, 0x99, 0x7f, 0x57, 0xb7, 0xa8, 
158     0x19, 0xad, 0x11, 0x9c, 0xad, 0xd5, 0x97, 0xd3, 
159     0x1a, 0x2e, 0x25, 0xa9, 0x42, 0x1d, 0x9e, 0x82, 
160     0x05, 0xfa, 0xe0, 0xbf, 0x40, 0x2b, 0xce, 0xba, 
161     0xd7, 0x0d, 0x44, 0xdb, 0xa7, 0x00, 0x27, 0x7d, 
162     0x91, 0x66, 0x51, 0xfe, 0x75, 0xa0, 0xa4, 0xc4, 
163     0x33, 0x0b, 0x04, 0x2c, 0xa8, 0x07, 0x4c, 0x94, 
164     0xba, 0xf4, 0x60, 0x61, 0x41, 0x34, 0xb6, 0xc6, 
165     0x6b, 0xad, 0xc3, 0x18, 0xa4, 0x91, 0x5a, 0x6b, 
166     0xc1, 0xa6, 0x69, 0xa4, 0xda, 0x5a, 0xd7, 0xb2, 
167     0x93, 0x68, 0x36, 0xad, 0x19, 0x73, 0x4a, 0x1b, 
168     0x63, 0x6e, 0x3b, 0x4e, 0xb5, 0x66, 0x5c, 0xa9, 
169     0x36, 0x6c, 0x89, 0xb4, 0x54, 0x73, 0x36, 0xd5, 
170     0xa6, 0xc6, 0xf6, 0x31, 0x44, 0x8d, 0x5a, 0x53, 
171     0x58, 0xdb, 0x9b, 0x6a, 0xe2, 0x62, 0xcd, 0x36, 
172     0xa3, 0x22, 0x1b, 0x63, 0xc5, 0x35, 0xad, 0xb0, 
173     0x75, 0xb0, 0xa3, 0xa5, 0x5a, 0x73, 0x35, 0xa7, 
174     0x69, 0xad, 0x0b, 0x0f, 0xd5, 0xc0, 0xcd, 0x36, 
175     0x5a, 0x6b, 0x39, 0xa6, 0x2b, 0xab, 0xf4, 0x5b, 
176     0x80, 0x0f, 0x00, 0x00, 0xe0, 0x53, 0x6e, 0x14, 
177     0xd2, 0xf1, 0xc9, 0x82, 0x52, 0xf6, 0xdc, 0xc4, 
178     0x5a, 0xe1, 0x6e, 0x28, 0xfe, 0x30, 0xa3, 0xbb, 
179     0x56, 0x83, 0x82, 0x4c, 0x37, 0xf6, 0x12, 0x29, 
180     0xd7, 0x87, 0x38, 0x1f, 0xec, 0x55, 0xfa, 0x1c, 
181     0xcc, 0x1e, 0x5e, 0x30, 0x2d, 0x00, 0x4a, 0x67, 
182     0x45, 0x38, 0xe4, 0xcf, 0xeb, 0x44, 0x32, 0x78, 
183     0x34, 0xa4, 0x1b, 0x0e, 0x35, 0x34, 0x63, 0xdf, 
184     0xa6, 0xb2, 0x92, 0xba, 0xfc, 0x7d, 0x4d, 0xad, 
185     0xad, 0x53, 0xba, 0xe5, 0x30, 0x52, 0xbf, 0x31, 
186     0x39, 0x57, 0x42, 0x9f, 0xc0, 0x80, 0x89, 0x1c, 
187     0x39, 0xed, 0x7b, 0xb7, 0x1c, 0x5a, 0xfc, 0x9d, 
188     0xbe, 0xe5, 0x14, 0x7e, 0xd5, 0xad, 0xc8, 0x65, 
189     0xb7, 0x70, 0x3e, 0x83, 0x1a, 0x6c, 0x3c, 0xc4, 
190     0x35, 0x9e, 0xc8, 0x36, 0xdc, 0xa4, 0x09, 0xc9, 
191     0x07, 0x1e, 0xe3, 0x68, 0x0b, 0x88, 0x5e, 0x24, 
192     0x9e, 0x00, 0x7e, 0x09, 0xd6, 0xc5, 0x2b, 0x06, 
193     0x89, 0xb5, 0x8a, 0x48, 0x0d, 0xae, 0x81, 0x9e, 
194     0x18, 0xad, 0x36, 0xf6, 0xa1, 0xf0, 0x70, 0x7d, 
195     0x1d, 0x57, 0x53, 0x02, 0xe1, 0xbd, 0xc7, 0xf2, 
196     0x85, 0x43, 0xf1, 0xdc, 0xdf, 0x06, 0x18, 0xb3, 
197     0x2a, 0xc7, 0x2b, 0x0d, 0xd6, 0x18, 0xad, 0xbd, 
198     0x9a, 0x82, 0x35, 0x5b, 0x73, 0xad, 0xcc, 0x5a, 
199     0xb6, 0xb5, 0x1b, 0xd5, 0x70, 0xb5, 0x94, 0xb2, 
200     0xd8, 0x46, 0x15, 0xf9, 0x5a, 0x8c, 0xd9, 0xd6, 
201     0x25, 0xad, 0xf4, 0x9a, 0xad, 0xa9, 0x48, 0x6b, 
202     0xd6, 0x8b, 0xc4, 0xca, 0x02, 0xdd, 0xc4, 0x3a, 
203     0x1a, 0x81, 0x92, 0xc6, 0x1b, 0xcd, 0xe7, 0x5a, 
204     0xb6, 0x31, 0xad, 0x31, 0x32, 0xb4, 0x9d, 0xd6, 
205     0x10, 0x07, 0xa4, 0x91, 0xad, 0xd9, 0x9a, 0x62, 
206     0xb5, 0xd6, 0x82, 0xad, 0x83, 0x4d, 0x62, 0x49, 
207     0xad, 0x29, 0x9a, 0x6d, 0x29, 0xa7, 0x60, 0xbd, 
208     0x00, 0xf8, 0x05, 0x00, 0x00, 0x3a, 0xec, 0x5b, 
209     0x6c, 0xeb, 0x2f, 0x28, 0xed, 0x61, 0x82, 0x7e, 
210     0xee, 0x10, 0x49, 0x40, 0xd0, 0xda, 0xe3, 0x4a, 
211     0xf7, 0x9f, 0xac, 0x7f, 0xbf, 0x3c, 0x08, 0xbe, 
212     0x86, 0x93, 0x57, 0xe7, 0xb2, 0x84, 0xf7, 0xda, 
213     0xa1, 0xf0, 0x4a, 0x76, 0xb0, 0xb7, 0xae, 0x9e, 
214     0x40, 0xb6, 0x84, 0x2f, 0xb4, 0xd0, 0x2d, 0x08, 
215     0x6a, 0xe5, 0x06, 0x0e, 0xc0, 0xd2, 0x74, 0x1c, 
216     0x1a, 0x7b, 0xd3, 0x16, 0xd7, 0xbc, 0x83, 0xd8, 
217     0x53, 0x78, 0xe4, 0x46, 0xf2, 0x8f, 0x59, 0x3d, 
218     0x14, 0xde, 0x3e, 0x9f, 0x16, 0x49, 0xf8, 0x49, 
219     0x5d, 0xad, 0xe3, 0x1c, 0x44, 0xeb, 0x5e, 0xfd, 
220     0x2d, 0xe1, 0xcc, 0xc4, 0x79, 0x73, 0x8d, 0x58, 
221     0x87, 0x7e, 0x00, 0x94, 0xb6, 0xe4, 0x85, 0x5c, 
222     0x67, 0x84, 0x7a, 0x8d, 0xfb, 0x3f, 0x43, 0x06, 
223     0xd0, 0xf3, 0x3d, 0xac, 0x46, 0x80, 0xcb, 0x5a, 
224     0xc1, 0xc9, 0x49, 0xf5, 0x9d, 0xaa, 0x18, 0x57, 
225     0x38, 0x07, 0x9b, 0x65, 0xf8, 0xbd, 0x2f, 0xfa, 
226     0x3a, 0xad, 0x34, 0xfc, 0x5c, 0xb7, 0x0f, 0x47, 
227     0xc2, 0xba, 0x19, 0xba, 0xca, 0x99, 0xb5, 0x3a, 
228     0xd2, 0x2e, 0x26, 0x89, 0xcd, 0xb5, 0x54, 0x8b, 
229     0x35, 0x43, 0x6b, 0xca, 0x1b, 0x4e, 0x8d, 0x58, 
230     0x5b, 0x53, 0x05, 0x36, 0xb9, 0xa2, 0x69, 0x1a, 
231     0x6b, 0x4d, 0x42, 0x5c, 0xa7, 0xaa, 0x4f, 0x39, 
232     0xd7, 0x7a, 0x6a, 0x29, 0x61, 0x6b, 0x36, 0x0b, 
233     0xb3, 0x0d, 0x62, 0x5b, 0xab, 0xd9, 0x91, 0x3c, 
234     0x6d, 0x44, 0x63, 0x84, 0xc6, 0x48, 0x75, 0xb2, 
235     0x48, 0x6d, 0xd9, 0xd6, 0x64, 0xcd, 0x82, 0x1c, 
236     0xa2, 0xa8, 0xca, 0x29, 0x16, 0x4a, 0xd2, 0x8d, 
237     0x6b, 0x29, 0xc7, 0x1a, 0xcd, 0x35, 0x5a, 0x74, 
238     0x54, 0xa7, 0x29, 0x42, 0x6b, 0xb6, 0xa8, 0x9a, 
239     0xa1, 0x31, 0x03, 0x81, 0x00, 0x96, 0x2a, 0x60, 
240 };
241
242 /*****************************************************************************
243  * aout_SpdifThread: audio output thread that sends raw spdif data
244  *                   to an external decoder
245  *****************************************************************************
246  * This output thread is quite specific as it can only handle one fifo.
247  * Now fifo #0 is hardcoded, but when the output is launched by the decoder,
248  * we'll be able to associate the related fifo to this output.
249  *
250  * Note: all this is wrong: spdif can demux up to 8 ac3 streams, and can
251  * even take care of time stamps (cf ac3 spec).
252  *****************************************************************************/
253 void aout_SpdifThread( aout_thread_t * p_aout )
254 {
255     u8 *        pi_blank;
256     boolean_t   b_have_data;
257     mtime_t     date;
258
259     /* when the output is launched from the decoder,
260      * we won't have to use a hardcoded value for frame size */
261     pi_blank = malloc( 6144/*p_aout->fifo[0].l_frame_size*/ );
262     memset( pi_blank, 0, sizeof(pi_blank) );
263     memcpy( pi_blank, pi_spdif_blank, sizeof(pi_spdif_blank) );
264
265     /* the thread wait until there is some data is aout fifo */
266     vlc_mutex_lock( &p_aout->fifo[0].data_lock);
267     vlc_cond_wait( &p_aout->fifo[0].data_wait,
268                    &p_aout->fifo[0].data_lock);
269     vlc_mutex_unlock (&p_aout->fifo[0].data_lock);
270         
271     date = mdate();
272     while( !p_aout->b_die )
273     {
274         /* we leave some time for aout fifo to fill */
275         msleep( 20000 );
276
277         vlc_mutex_lock( &p_aout->fifo[0].data_lock );
278         b_have_data = !AOUT_FIFO_ISEMPTY( p_aout->fifo[0] );
279         vlc_mutex_unlock (&p_aout->fifo[0].data_lock);
280
281         if( b_have_data )
282         {
283             /* play spdif frame to the external decoder */
284             date = mdate();
285             p_aout->pf_play( p_aout,
286                              p_aout->fifo[0].buffer +
287                              p_aout->fifo[0].l_frame_size *
288                                         p_aout->fifo[0].l_start_frame,
289                              p_aout->fifo[0].l_frame_size );
290
291             vlc_mutex_lock( &p_aout->fifo[0].data_lock);
292             p_aout->fifo[0].l_start_frame = 
293                 (p_aout->fifo[0].l_start_frame + 1 ) & AOUT_FIFO_SIZE;
294             vlc_mutex_unlock (&p_aout->fifo[0].data_lock);
295         }
296         else
297         {
298             intf_WarnMsg( 2, "spdif warning: waiting (%lld)",
299                 p_aout->fifo[0].date[p_aout->fifo[0].l_start_frame-1] - date );
300
301             date = mdate();
302             /* insert blank frame for stream continuity to
303              * the external decoder */
304             p_aout->pf_play( p_aout, pi_blank, p_aout->fifo[0].l_frame_size );
305         }
306     }
307
308     return;
309 }
310