Commit a2109377 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* Don't upmix the channels if we only have Stereo or Mono audio. Let the...

* Don't upmix the channels if we only have Stereo or Mono audio. Let the device setup take care of that.
parent 3f9d14bb
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
*****************************************************************************/ *****************************************************************************/
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/aout.h> #include <vlc/aout.h>
...@@ -56,6 +57,13 @@ ...@@ -56,6 +57,13 @@
#define BUFSIZE 0xffffff #define BUFSIZE 0xffffff
#define AOUT_VAR_SPDIF_FLAG 0xf00000 #define AOUT_VAR_SPDIF_FLAG 0xf00000
/*
* TODO:
* - clean up the debug info
* - clean up C99'isms
* - be better at changing stream setup or devices setup changes while playing.
*/
/***************************************************************************** /*****************************************************************************
* aout_sys_t: private audio output method descriptor * aout_sys_t: private audio output method descriptor
***************************************************************************** *****************************************************************************
...@@ -354,6 +362,22 @@ static int OpenAnalog( aout_instance_t *p_aout ) ...@@ -354,6 +362,22 @@ static int OpenAnalog( aout_instance_t *p_aout )
msg_Dbg( p_aout, "Layout of AUHAL has %d channels" , (int)layout->mNumberChannelDescriptions ); msg_Dbg( p_aout, "Layout of AUHAL has %d channels" , (int)layout->mNumberChannelDescriptions );
p_aout->output.output.i_physical_channels = 0; p_aout->output.output.i_physical_channels = 0;
int i_original = p_aout->output.output.i_original_channels & AOUT_CHAN_PHYSMASK;
if( i_original == AOUT_CHAN_CENTER || layout->mNumberChannelDescriptions < 2 )
{
// We only need Mono or cannot output more
p_aout->output.output.i_physical_channels |= AOUT_CHAN_CENTER;
}
else if( i_original == (AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT) || layout->mNumberChannelDescriptions < 3 )
{
// We only need Stereo or cannot output more
p_aout->output.output.i_physical_channels |= AOUT_CHAN_RIGHT;
p_aout->output.output.i_physical_channels |= AOUT_CHAN_LEFT;
}
else
{
// We want more then stereo and we can do that
for( i = 0; i < layout->mNumberChannelDescriptions; i++ ) for( i = 0; i < layout->mNumberChannelDescriptions; i++ )
{ {
msg_Dbg( p_aout, "This is channel: %d", (int)layout->mChannelDescriptions[i].mChannelLabel ); msg_Dbg( p_aout, "This is channel: %d", (int)layout->mChannelDescriptions[i].mChannelLabel );
...@@ -411,13 +435,14 @@ static int OpenAnalog( aout_instance_t *p_aout ) ...@@ -411,13 +435,14 @@ static int OpenAnalog( aout_instance_t *p_aout )
case 7: case 7:
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
AOUT_CHAN_CENTER | AOUT_CHAN_LFE | AOUT_CHAN_CENTER | AOUT_CHAN_LFE |
AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_REARCENTER; AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT |
AOUT_CHAN_REARCENTER;
break; break;
case 8: case 8:
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
AOUT_CHAN_CENTER | AOUT_CHAN_LFE | AOUT_CHAN_CENTER | AOUT_CHAN_LFE |
AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT |
AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT;
break; break;
case 2: case 2:
default: default:
...@@ -427,9 +452,11 @@ static int OpenAnalog( aout_instance_t *p_aout ) ...@@ -427,9 +452,11 @@ static int OpenAnalog( aout_instance_t *p_aout )
break; break;
} }
} }
free( layout ); }
if( layout ) free( layout );
msg_Dbg( p_aout, "defined %d physical channels for vlc core", aout_FormatNbChannels( &p_aout->output.output ) ); msg_Dbg( p_aout, "we want to output these channels: %#x", p_aout->output.output.i_original_channels);
msg_Dbg( p_aout, "selected %d physical channels for device output", aout_FormatNbChannels( &p_aout->output.output ) );
msg_Dbg( p_aout, "%s", aout_FormatPrintChannels( &p_aout->output.output )); msg_Dbg( p_aout, "%s", aout_FormatPrintChannels( &p_aout->output.output ));
AudioChannelLayout new_layout; AudioChannelLayout new_layout;
...@@ -1050,7 +1077,7 @@ static void Probe( aout_instance_t * p_aout ) ...@@ -1050,7 +1077,7 @@ static void Probe( aout_instance_t * p_aout )
&i_param_size, psz_name); &i_param_size, psz_name);
if( err ) goto error; if( err ) goto error;
msg_Dbg( p_aout, "DevID: %lu DevName: %s", p_devices[i], psz_name ); msg_Dbg( p_aout, "DevID: %#lx DevName: %s", p_devices[i], psz_name );
if( !AudioDeviceHasOutput( p_devices[i]) ) if( !AudioDeviceHasOutput( p_devices[i]) )
{ {
...@@ -1216,7 +1243,7 @@ static int AudioStreamSupportsDigital( aout_instance_t *p_aout, AudioStreamID i_ ...@@ -1216,7 +1243,7 @@ static int AudioStreamSupportsDigital( aout_instance_t *p_aout, AudioStreamID i_
for( i = 0; i < i_formats; i++ ) for( i = 0; i < i_formats; i++ )
{ {
msg_Dbg( p_aout, STREAM_FORMAT_MSG( "supported format", p_format_list[i] ) ); msg_Dbg( p_aout, STREAM_FORMAT_MSG( "supported format: ", p_format_list[i] ) );
if( p_format_list[i].mFormatID == 'IAC3' || if( p_format_list[i].mFormatID == 'IAC3' ||
p_format_list[i].mFormatID == kAudioFormat60958AC3 ) p_format_list[i].mFormatID == kAudioFormat60958AC3 )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment