1 /*****************************************************************************
2 * waveout.c : Windows waveOut plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: waveout.c,v 1.14 2003/01/26 16:37:20 gbazin Exp $
7 * Authors: Gildas Bazin <gbazin@netcourrier.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <string.h> /* strerror() */
28 #include <stdlib.h> /* calloc(), malloc(), free() */
32 #include "aout_internal.h"
37 #define FRAME_SIZE 1024 /* The size is in samples, not in bytes */
40 /*****************************************************************************
42 *****************************************************************************/
44 # define DWORD_PTR DWORD
47 #ifndef WAVE_FORMAT_IEEE_FLOAT
48 # define WAVE_FORMAT_IEEE_FLOAT 0x0003
51 #ifndef WAVE_FORMAT_DOLBY_AC3_SPDIF
52 # define WAVE_FORMAT_DOLBY_AC3_SPDIF 0x0092
55 #ifndef WAVE_FORMAT_EXTENSIBLE
56 #define WAVE_FORMAT_EXTENSIBLE 0xFFFE
59 #ifndef SPEAKER_FRONT_LEFT
60 # define SPEAKER_FRONT_LEFT 0x1
61 # define SPEAKER_FRONT_RIGHT 0x2
62 # define SPEAKER_FRONT_CENTER 0x4
63 # define SPEAKER_LOW_FREQUENCY 0x8
64 # define SPEAKER_BACK_LEFT 0x10
65 # define SPEAKER_BACK_RIGHT 0x20
66 # define SPEAKER_FRONT_LEFT_OF_CENTER 0x40
67 # define SPEAKER_FRONT_RIGHT_OF_CENTER 0x80
68 # define SPEAKER_BACK_CENTER 0x100
69 # define SPEAKER_SIDE_LEFT 0x200
70 # define SPEAKER_SIDE_RIGHT 0x400
71 # define SPEAKER_TOP_CENTER 0x800
72 # define SPEAKER_TOP_FRONT_LEFT 0x1000
73 # define SPEAKER_TOP_FRONT_CENTER 0x2000
74 # define SPEAKER_TOP_FRONT_RIGHT 0x4000
75 # define SPEAKER_TOP_BACK_LEFT 0x8000
76 # define SPEAKER_TOP_BACK_CENTER 0x10000
77 # define SPEAKER_TOP_BACK_RIGHT 0x20000
78 # define SPEAKER_RESERVED 0x80000000
81 #ifndef _WAVEFORMATEXTENSIBLE_
85 WORD wValidBitsPerSample; /* bits of precision */
86 WORD wSamplesPerBlock; /* valid if wBitsPerSample==0 */
87 WORD wReserved; /* If neither applies, set to zero. */
89 DWORD dwChannelMask; /* which channels are */
90 /* present in stream */
92 } WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;
96 #ifndef KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
97 DEFINE_GUID( KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, WAVE_FORMAT_IEEE_FLOAT, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 );
99 #ifndef KSDATAFORMAT_SUBTYPE_PCM
100 DEFINE_GUID( KSDATAFORMAT_SUBTYPE_PCM, WAVE_FORMAT_PCM, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 );
102 #ifndef KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF
103 DEFINE_GUID( KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF, WAVE_FORMAT_DOLBY_AC3_SPDIF, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71 );
106 /*****************************************************************************
108 *****************************************************************************/
109 static int Open ( vlc_object_t * );
110 static void Close ( vlc_object_t * );
111 static void Play ( aout_instance_t * );
113 /* local functions */
114 static void Probe ( aout_instance_t * );
115 static int OpenWaveOut ( aout_instance_t *, int, int, int, int, vlc_bool_t );
116 static int OpenWaveOutPCM( aout_instance_t *, int*, int, int, int, vlc_bool_t );
117 static void CheckReordering( aout_instance_t *, int );
118 static int PlayWaveOut ( aout_instance_t *, HWAVEOUT, WAVEHDR *,
121 static void CALLBACK WaveOutCallback ( HWAVEOUT, UINT, DWORD, DWORD, DWORD );
123 static void InterleaveFloat32( float *, int *, int );
124 static void InterleaveS16( int16_t *, int *, int );
126 /*****************************************************************************
128 *****************************************************************************/
130 set_description( _("Win32 waveOut extension module") );
131 set_capability( "audio output", 50 );
132 set_callbacks( Open, Close );
135 /*****************************************************************************
136 * aout_sys_t: waveOut audio output method descriptor
137 *****************************************************************************
138 * This structure is part of the audio output thread descriptor.
139 * It describes the waveOut specific properties of an audio device.
140 *****************************************************************************/
143 HWAVEOUT h_waveout; /* handle to waveout instance */
145 WAVEFORMATEXTENSIBLE waveformat; /* audio format */
147 WAVEHDR waveheader[FRAMES_NUM];
151 byte_t *p_silence_buffer; /* buffer we use to play silence */
153 vlc_bool_t b_chan_reorder; /* do we need channel reordering */
157 static const uint32_t pi_channels_in[] =
158 { AOUT_CHAN_LEFT, AOUT_CHAN_RIGHT,
159 AOUT_CHAN_REARLEFT, AOUT_CHAN_REARRIGHT,
160 AOUT_CHAN_CENTER, AOUT_CHAN_LFE };
161 static const uint32_t pi_channels_out[] =
162 { SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT,
163 SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT,
164 SPEAKER_FRONT_CENTER, SPEAKER_LOW_FREQUENCY };
165 static const uint32_t pi_channels_ordered[] =
166 { SPEAKER_FRONT_LEFT, SPEAKER_FRONT_RIGHT, SPEAKER_FRONT_CENTER,
167 SPEAKER_LOW_FREQUENCY,
168 SPEAKER_BACK_LEFT, SPEAKER_BACK_RIGHT };
170 /*****************************************************************************
171 * Open: open the audio device
172 *****************************************************************************
173 * This function opens and setups Win32 waveOut
174 *****************************************************************************/
175 static int Open( vlc_object_t *p_this )
177 aout_instance_t *p_aout = (aout_instance_t *)p_this;
181 /* Allocate structure */
182 p_aout->output.p_sys = malloc( sizeof( aout_sys_t ) );
184 if( p_aout->output.p_sys == NULL )
186 msg_Err( p_aout, "out of memory" );
190 p_aout->output.pf_play = Play;
191 aout_VolumeSoftInit( p_aout );
192 p_aout->output.p_sys->pi_chan_table = NULL;
193 p_aout->b_die = VLC_FALSE;
195 if( var_Type( p_aout, "audio-device" ) == 0 )
200 if( var_Get( p_aout, "audio-device", &val ) < 0 )
202 /* Probe() has failed. */
203 free( p_aout->output.p_sys );
207 /* Open the device */
208 if( !strcmp( val.psz_string, N_("A/52 over S/PDIF") ) )
210 p_aout->output.output.i_format = VLC_FOURCC('s','p','d','i');
211 free( val.psz_string );
213 if( OpenWaveOut( p_aout, VLC_FOURCC('s','p','d','i'),
214 p_aout->output.output.i_physical_channels,
215 aout_FormatNbChannels( &p_aout->output.output ),
216 p_aout->output.output.i_rate, VLC_FALSE )
219 msg_Err( p_aout, "cannot open waveout audio device" );
220 free( p_aout->output.p_sys );
226 if( !strcmp( val.psz_string, N_("5.1") ) )
228 p_aout->output.output.i_physical_channels
229 = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_CENTER
230 | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT
233 else if( !strcmp( val.psz_string, N_("2 Front 2 Rear") ) )
235 p_aout->output.output.i_physical_channels
236 = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT
237 | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
239 else if( !strcmp( val.psz_string, "Mono" ) )
241 p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER;
245 p_aout->output.output.i_physical_channels
246 = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
248 free( val.psz_string );
250 if( OpenWaveOutPCM( p_aout, &p_aout->output.output.i_format,
251 p_aout->output.output.i_physical_channels,
252 aout_FormatNbChannels( &p_aout->output.output ),
253 p_aout->output.output.i_rate, VLC_FALSE )
256 msg_Err( p_aout, "cannot open waveout audio device" );
257 free( p_aout->output.p_sys );
263 waveOutReset( p_aout->output.p_sys->h_waveout );
265 /* Calculate the frame size in bytes */
266 p_aout->output.i_nb_samples = FRAME_SIZE;
267 aout_FormatPrepare( &p_aout->output.output );
268 p_aout->output.p_sys->i_buffer_size = FRAME_SIZE *
269 p_aout->output.output.i_bytes_per_frame;
270 /* Allocate silence buffer */
271 p_aout->output.p_sys->p_silence_buffer =
272 malloc( p_aout->output.p_sys->i_buffer_size );
273 if( p_aout->output.p_sys->p_silence_buffer == NULL )
275 free( p_aout->output.p_sys );
276 msg_Err( p_aout, "out of memory" );
280 /* Zero the buffer. WinCE doesn't have calloc(). */
281 memset( p_aout->output.p_sys->p_silence_buffer, 0,
282 p_aout->output.p_sys->i_buffer_size );
284 /* We need to kick off the playback in order to have the callback properly
286 for( i = 0; i < FRAMES_NUM; i++ )
288 PlayWaveOut( p_aout, p_aout->output.p_sys->h_waveout,
289 &p_aout->output.p_sys->waveheader[i], NULL );
294 /*****************************************************************************
295 * Probe: probe the audio device for available formats and channels
296 *****************************************************************************/
297 static void Probe( aout_instance_t * p_aout )
301 unsigned int i_physical_channels;
303 var_Create( p_aout, "audio-device", VLC_VAR_STRING | VLC_VAR_HASCHOICE );
305 /* Test for SPDIF support */
306 if ( AOUT_FMT_NON_LINEAR( &p_aout->output.output ) )
308 if( OpenWaveOut( p_aout, VLC_FOURCC('s','p','d','i'),
309 p_aout->output.output.i_physical_channels,
310 aout_FormatNbChannels( &p_aout->output.output ),
311 p_aout->output.output.i_rate, VLC_TRUE )
314 msg_Dbg( p_aout, "device supports A/52 over S/PDIF" );
315 val.psz_string = N_("A/52 over S/PDIF");
316 var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
320 /* Test for 5.1 support */
321 i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
322 AOUT_CHAN_CENTER | AOUT_CHAN_REARLEFT |
323 AOUT_CHAN_REARRIGHT | AOUT_CHAN_LFE;
324 if( p_aout->output.output.i_physical_channels == i_physical_channels )
326 if( OpenWaveOutPCM( p_aout, &i_format,
327 i_physical_channels, 6,
328 p_aout->output.output.i_rate, VLC_TRUE )
331 val.psz_string = N_("5.1");
332 var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
335 msg_Dbg( p_aout, "device supports 5.1 channels" );
338 /* Test for 2 Front 2 Rear support */
339 i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
340 AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
341 if( p_aout->output.output.i_physical_channels & i_physical_channels )
343 if( OpenWaveOutPCM( p_aout, &i_format,
344 i_physical_channels, 4,
345 p_aout->output.output.i_rate, VLC_TRUE )
348 val.psz_string = N_("2 Front 2 Rear");
349 var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
352 msg_Dbg( p_aout, "device supports 4 channels" );
355 /* Test for stereo support */
356 i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
357 if( OpenWaveOutPCM( p_aout, &i_format,
358 i_physical_channels, 2,
359 p_aout->output.output.i_rate, VLC_TRUE )
362 val.psz_string = N_("Stereo");
363 var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
364 var_Set( p_aout, "audio-device", val );
367 msg_Dbg( p_aout, "device supports 2 channels" );
369 /* Test for mono support */
370 i_physical_channels = AOUT_CHAN_CENTER;
371 if( OpenWaveOutPCM( p_aout, &i_format,
372 i_physical_channels, 1,
373 p_aout->output.output.i_rate, VLC_TRUE )
376 val.psz_string = N_("Mono");
377 var_Change( p_aout, "audio-device", VLC_VAR_ADDCHOICE, &val );
380 msg_Dbg( p_aout, "device supports 1 channel" );
382 var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL );
384 val.b_bool = VLC_TRUE;
385 var_Set( p_aout, "intf-change", val );
388 /*****************************************************************************
389 * Play: play a sound buffer
390 *****************************************************************************
391 * This doesn't actually play the buffer. This just stores the buffer so it
392 * can be played by the callback thread.
393 *****************************************************************************/
394 static void Play( aout_instance_t *p_aout )
398 /*****************************************************************************
399 * Close: close the audio device
400 *****************************************************************************/
401 static void Close( vlc_object_t *p_this )
403 aout_instance_t *p_aout = (aout_instance_t *)p_this;
405 /* Before calling waveOutClose we must reset the device */
406 p_aout->b_die = VLC_TRUE;
408 /* Wait for the waveout buffers to be freed */
412 vlc_bool_t b_not_done = VLC_FALSE;
414 for( i = 0; i < FRAMES_NUM; i++ )
416 if( !(p_aout->output.p_sys->waveheader[i].dwFlags & WHDR_DONE) )
417 b_not_done = VLC_TRUE;
426 waveOutReset( p_aout->output.p_sys->h_waveout );
428 /* Close the device */
429 if( waveOutClose( p_aout->output.p_sys->h_waveout ) != MMSYSERR_NOERROR )
431 msg_Err( p_aout, "waveOutClose failed" );
434 free( p_aout->output.p_sys->p_silence_buffer );
435 if( p_aout->output.p_sys->pi_chan_table )
436 free( p_aout->output.p_sys->pi_chan_table );
437 free( p_aout->output.p_sys );
440 /*****************************************************************************
441 * OpenWaveOut: open the waveout sound device
442 ****************************************************************************/
443 static int OpenWaveOut( aout_instance_t *p_aout, int i_format,
444 int i_channels, int i_nb_channels, int i_rate,
450 /* Set sound format */
452 #define waveformat p_aout->output.p_sys->waveformat
454 waveformat.dwChannelMask = 0;
455 for( i = 0; i < sizeof(pi_channels_in)/sizeof(uint32_t); i++ )
457 if( i_channels & pi_channels_in[i] )
458 waveformat.dwChannelMask |= pi_channels_out[i];
463 case VLC_FOURCC('s','p','d','i'):
465 waveformat.Format.wBitsPerSample = 16;
466 waveformat.Samples.wValidBitsPerSample =
467 waveformat.Format.wBitsPerSample;
468 waveformat.Format.wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;
469 waveformat.SubFormat = KSDATAFORMAT_SUBTYPE_DOLBY_AC3_SPDIF;
472 case VLC_FOURCC('f','l','3','2'):
473 waveformat.Format.wBitsPerSample = sizeof(float) * 8;
474 waveformat.Samples.wValidBitsPerSample =
475 waveformat.Format.wBitsPerSample;
476 waveformat.Format.wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
477 waveformat.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
480 case VLC_FOURCC('s','1','6','l'):
481 waveformat.Format.wBitsPerSample = 16;
482 waveformat.Samples.wValidBitsPerSample =
483 waveformat.Format.wBitsPerSample;
484 waveformat.Format.wFormatTag = WAVE_FORMAT_PCM;
485 waveformat.SubFormat = KSDATAFORMAT_SUBTYPE_PCM;
489 waveformat.Format.nChannels = i_nb_channels;
490 waveformat.Format.nSamplesPerSec = i_rate;
491 waveformat.Format.nBlockAlign =
492 waveformat.Format.wBitsPerSample / 8 * i_nb_channels;
493 waveformat.Format.nAvgBytesPerSec =
494 waveformat.Format.nSamplesPerSec * waveformat.Format.nBlockAlign;
496 /* Only use the new WAVE_FORMAT_EXTENSIBLE format for multichannel audio */
497 if( i_nb_channels <= 2 )
499 waveformat.Format.cbSize = 0;
503 waveformat.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
504 waveformat.Format.cbSize =
505 sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX);
508 /* Open the device */
509 result = waveOutOpen( &p_aout->output.p_sys->h_waveout, WAVE_MAPPER,
510 (WAVEFORMATEX *)&waveformat,
511 (DWORD_PTR)WaveOutCallback, (DWORD_PTR)p_aout,
512 CALLBACK_FUNCTION | (b_probe?WAVE_FORMAT_QUERY:0) );
513 if( result == WAVERR_BADFORMAT )
515 msg_Warn( p_aout, "waveOutOpen failed WAVERR_BADFORMAT" );
518 if( result == MMSYSERR_ALLOCATED )
520 msg_Warn( p_aout, "waveOutOpen failed WAVERR_ALLOCATED" );
523 if( result != MMSYSERR_NOERROR )
525 msg_Warn( p_aout, "waveOutOpen failed" );
529 CheckReordering( p_aout, i_nb_channels );
537 /*****************************************************************************
538 * OpenWaveOutPCM: open a PCM waveout sound device
539 ****************************************************************************/
540 static int OpenWaveOutPCM( aout_instance_t *p_aout, int *i_format,
541 int i_channels, int i_nb_channels, int i_rate,
544 if( OpenWaveOut( p_aout, VLC_FOURCC('f','l','3','2'),
545 i_channels, i_nb_channels, i_rate, b_probe )
548 if ( OpenWaveOut( p_aout, VLC_FOURCC('s','1','6','l'),
549 i_channels, i_nb_channels, i_rate, b_probe )
556 *i_format = VLC_FOURCC('s','1','6','l');
562 *i_format = VLC_FOURCC('f','l','3','2');
567 /*****************************************************************************
568 * CheckReordering: Check if we need to do some channel re-ordering (the ac3
569 * channel order is different from the one chosen by
571 *****************************************************************************/
572 static void CheckReordering( aout_instance_t *p_aout, int i_nb_channels )
576 #define waveformat p_aout->output.p_sys->waveformat
577 #define pi_chan_table p_aout->output.p_sys->pi_chan_table
579 p_aout->output.p_sys->b_chan_reorder = VLC_FALSE;
581 pi_chan_table = malloc( i_nb_channels * sizeof(int) );
588 i < (int)(sizeof(pi_channels_out)/sizeof(uint32_t)); i++ )
590 if( waveformat.dwChannelMask & pi_channels_out[i] )
593 pi_channels_out[i] != pi_channels_ordered[k]; k++ )
595 if( waveformat.dwChannelMask & pi_channels_ordered[k] )
601 pi_chan_table[j] = l;
607 for( i = 0; i < i_nb_channels; i++ )
609 if( pi_chan_table[i] != i )
611 p_aout->output.p_sys->b_chan_reorder = VLC_TRUE;
615 if( p_aout->output.p_sys->b_chan_reorder )
617 msg_Dbg( p_aout, "channel reordering needed" );
624 /*****************************************************************************
625 * PlayWaveOut: play a buffer through the WaveOut device
626 *****************************************************************************/
627 static int PlayWaveOut( aout_instance_t *p_aout, HWAVEOUT h_waveout,
628 WAVEHDR *p_waveheader, aout_buffer_t *p_buffer )
632 /* Prepare the buffer */
633 if( p_buffer != NULL )
634 p_waveheader->lpData = p_buffer->p_buffer;
636 /* Use silence buffer instead */
637 p_waveheader->lpData = p_aout->output.p_sys->p_silence_buffer;
639 p_waveheader->dwUser = (DWORD_PTR)p_buffer;
640 p_waveheader->dwBufferLength = p_aout->output.p_sys->i_buffer_size;
641 p_waveheader->dwFlags = 0;
643 result = waveOutPrepareHeader( h_waveout, p_waveheader, sizeof(WAVEHDR) );
644 if( result != MMSYSERR_NOERROR )
646 msg_Err( p_aout, "waveOutPrepareHeader failed" );
650 /* Send the buffer to the waveOut queue */
651 result = waveOutWrite( h_waveout, p_waveheader, sizeof(WAVEHDR) );
652 if( result != MMSYSERR_NOERROR )
654 msg_Err( p_aout, "waveOutWrite failed" );
661 /*****************************************************************************
662 * WaveOutCallback: what to do once WaveOut has played its sound samples
663 *****************************************************************************/
664 static void CALLBACK WaveOutCallback( HWAVEOUT h_waveout, UINT uMsg,
666 DWORD dwParam1, DWORD dwParam2 )
668 aout_instance_t *p_aout = (aout_instance_t *)_p_aout;
669 WAVEHDR *p_waveheader = (WAVEHDR *)dwParam1;
670 aout_buffer_t *p_buffer;
672 if( uMsg != WOM_DONE ) return;
674 /* Unprepare and free the buffer which has just been played */
675 waveOutUnprepareHeader( h_waveout, p_waveheader, sizeof(WAVEHDR) );
676 if( p_waveheader->dwUser )
677 aout_BufferFree( (aout_buffer_t *)p_waveheader->dwUser );
679 if( p_aout->b_die ) return;
681 /* Take into account the latency ( 1 FRAME ) */
682 p_buffer = aout_OutputNextBuffer( p_aout,
683 mdate() + 1000000 / p_aout->output.output.i_rate * FRAME_SIZE,
686 /* Do the channel reordering here */
687 if( p_buffer && p_aout->output.p_sys->b_chan_reorder )
689 if( p_aout->output.output.i_format == VLC_FOURCC('s','1','6','l') )
690 InterleaveS16( (int16_t *)p_buffer->p_buffer,
691 p_aout->output.p_sys->pi_chan_table,
692 aout_FormatNbChannels( &p_aout->output.output ) );
694 InterleaveFloat32( (float *)p_buffer->p_buffer,
695 p_aout->output.p_sys->pi_chan_table,
696 aout_FormatNbChannels( &p_aout->output.output ) );
699 PlayWaveOut( p_aout, h_waveout, p_waveheader, p_buffer );
702 static void InterleaveFloat32( float *p_buf, int *pi_chan_table,
708 for( i = 0; i < FRAME_SIZE; i++ )
710 for( j = 0; j < i_nb_channels; j++ )
712 p_tmp[pi_chan_table[j]] = p_buf[i*i_nb_channels + j];
715 memcpy( &p_buf[i*i_nb_channels], p_tmp,
716 i_nb_channels * sizeof(float) );
720 static void InterleaveS16( int16_t *p_buf, int *pi_chan_table,
726 for( i = 0; i < FRAME_SIZE; i++ )
728 for( j = 0; j < i_nb_channels; j++ )
730 p_tmp[pi_chan_table[j]] = p_buf[i*i_nb_channels + j];
733 memcpy( &p_buf[i*i_nb_channels], p_tmp,
734 i_nb_channels * sizeof(int16_t) );