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,84 +362,103 @@ static int OpenAnalog( aout_instance_t *p_aout ) ...@@ -354,84 +362,103 @@ 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;
for( i = 0; i < layout->mNumberChannelDescriptions; i++ ) int i_original = p_aout->output.output.i_original_channels & AOUT_CHAN_PHYSMASK;
if( i_original == AOUT_CHAN_CENTER || layout->mNumberChannelDescriptions < 2 )
{ {
msg_Dbg( p_aout, "This is channel: %d", (int)layout->mChannelDescriptions[i].mChannelLabel ); // We only need Mono or cannot output more
p_aout->output.output.i_physical_channels |= AOUT_CHAN_CENTER;
switch( layout->mChannelDescriptions[i].mChannelLabel ) }
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++ )
{ {
case kAudioChannelLabel_Left: msg_Dbg( p_aout, "This is channel: %d", (int)layout->mChannelDescriptions[i].mChannelLabel );
p_aout->output.output.i_physical_channels |= AOUT_CHAN_LEFT;
continue; switch( layout->mChannelDescriptions[i].mChannelLabel )
case kAudioChannelLabel_Right: {
p_aout->output.output.i_physical_channels |= AOUT_CHAN_RIGHT; case kAudioChannelLabel_Left:
continue; p_aout->output.output.i_physical_channels |= AOUT_CHAN_LEFT;
case kAudioChannelLabel_Center: continue;
p_aout->output.output.i_physical_channels |= AOUT_CHAN_CENTER; case kAudioChannelLabel_Right:
continue; p_aout->output.output.i_physical_channels |= AOUT_CHAN_RIGHT;
case kAudioChannelLabel_LFEScreen: continue;
p_aout->output.output.i_physical_channels |= AOUT_CHAN_LFE; case kAudioChannelLabel_Center:
continue; p_aout->output.output.i_physical_channels |= AOUT_CHAN_CENTER;
case kAudioChannelLabel_LeftSurround: continue;
p_aout->output.output.i_physical_channels |= AOUT_CHAN_REARLEFT; case kAudioChannelLabel_LFEScreen:
continue; p_aout->output.output.i_physical_channels |= AOUT_CHAN_LFE;
case kAudioChannelLabel_RightSurround: continue;
p_aout->output.output.i_physical_channels |= AOUT_CHAN_REARRIGHT; case kAudioChannelLabel_LeftSurround:
continue; p_aout->output.output.i_physical_channels |= AOUT_CHAN_REARLEFT;
case kAudioChannelLabel_RearSurroundLeft: continue;
p_aout->output.output.i_physical_channels |= AOUT_CHAN_MIDDLELEFT; case kAudioChannelLabel_RightSurround:
continue; p_aout->output.output.i_physical_channels |= AOUT_CHAN_REARRIGHT;
case kAudioChannelLabel_RearSurroundRight: continue;
p_aout->output.output.i_physical_channels |= AOUT_CHAN_MIDDLERIGHT; case kAudioChannelLabel_RearSurroundLeft:
continue; p_aout->output.output.i_physical_channels |= AOUT_CHAN_MIDDLELEFT;
case kAudioChannelLabel_CenterSurround: continue;
p_aout->output.output.i_physical_channels |= AOUT_CHAN_REARCENTER; case kAudioChannelLabel_RearSurroundRight:
continue; p_aout->output.output.i_physical_channels |= AOUT_CHAN_MIDDLERIGHT;
default: continue;
msg_Warn( p_aout, "Unrecognized channel form provided by driver: %d", (int)layout->mChannelDescriptions[i].mChannelLabel ); case kAudioChannelLabel_CenterSurround:
if( i == 0 ) p_aout->output.output.i_physical_channels |= AOUT_CHAN_REARCENTER;
{ continue;
msg_Warn( p_aout, "Probably no channellayout is set. force based on channelcount" ); default:
switch( layout->mNumberChannelDescriptions ) msg_Warn( p_aout, "Unrecognized channel form provided by driver: %d", (int)layout->mChannelDescriptions[i].mChannelLabel );
if( i == 0 )
{ {
/* We make assumptions based on number of channels here. msg_Warn( p_aout, "Probably no channellayout is set. force based on channelcount" );
* Unfortunatly Apple has provided no 100% method to retrieve the speaker configuration */ switch( layout->mNumberChannelDescriptions )
case 1: {
p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER; /* We make assumptions based on number of channels here.
break; * Unfortunatly Apple has provided no 100% method to retrieve the speaker configuration */
case 4: case 1:
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | p_aout->output.output.i_physical_channels = AOUT_CHAN_CENTER;
AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; break;
break; case 4:
case 6: 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_REARLEFT | AOUT_CHAN_REARRIGHT;
AOUT_CHAN_CENTER | AOUT_CHAN_LFE | break;
AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; case 6:
break; p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
case 7: AOUT_CHAN_CENTER | AOUT_CHAN_LFE |
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT;
AOUT_CHAN_CENTER | AOUT_CHAN_LFE | break;
AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | AOUT_CHAN_REARCENTER; case 7:
break; p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
case 8: AOUT_CHAN_CENTER | AOUT_CHAN_LFE |
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT | AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT |
AOUT_CHAN_CENTER | AOUT_CHAN_LFE | AOUT_CHAN_REARCENTER;
AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT | break;
AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT; case 8:
break; p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
case 2: AOUT_CHAN_CENTER | AOUT_CHAN_LFE |
default: AOUT_CHAN_REARLEFT | AOUT_CHAN_REARRIGHT |
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT; AOUT_CHAN_MIDDLELEFT | AOUT_CHAN_MIDDLERIGHT;
break;
case 2:
default:
p_aout->output.output.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT;
}
} }
} 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;
memset (&new_layout, 0, sizeof(new_layout)); memset (&new_layout, 0, sizeof(new_layout));
switch( aout_FormatNbChannels( &p_aout->output.output ) ) switch( aout_FormatNbChannels( &p_aout->output.output ) )
...@@ -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