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