the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 117 lines 3.4 kB view raw
1#include "..\stdafx.h" 2#include <sysutil/sysutil_sysparam.h> 3#include <cell/sysmodule.h> 4#include <sys/spu_initialize.h> 5#include <fcntl.h> 6#include <unistd.h> 7#include <cell/audio.h> 8#include "..\..\Common\Audio\SoundEngine.h" 9#include "..\..\Common\Consoles_App.h" 10#include "..\..\PS3\Miles\include\mss.h" 11 12// This file has the platform specific functions required for PS3 audio 13 14// 15// this function configures the audio hardware. 16// you specify the minimum number of channels that you need, and it 17// returns the number of output channels that will be used (which will 18// be at least your minimum count, but possibly more). it will return 0 19// for any failure cases. 20 21int SoundEngine::initAudioHardware( int minimum_chans ) 22{ 23 int ret; 24 int ch_pcm; 25 int ch_bit; 26 CellAudioOutConfiguration a_config; 27 28 memset( &a_config, 0, sizeof( CellAudioOutConfiguration ) ); 29 30 // first lets see how many pcm output channels we have 31 ch_pcm = cellAudioOutGetSoundAvailability( CELL_AUDIO_OUT_PRIMARY, 32 CELL_AUDIO_OUT_CODING_TYPE_LPCM, 33 CELL_AUDIO_OUT_FS_48KHZ, 0 ); 34 35 if ( ch_pcm >= minimum_chans ) 36 { 37 a_config.channel = ch_pcm; 38 a_config.encoder = CELL_AUDIO_OUT_CODING_TYPE_LPCM; 39 a_config.downMixer = CELL_AUDIO_OUT_DOWNMIXER_NONE; /* No downmixer is used */ 40 cellAudioOutConfigure( CELL_AUDIO_OUT_PRIMARY, &a_config, NULL, 0 ); 41 42 ret = ch_pcm; 43 } 44 else 45 { 46 switch ( ch_pcm ) 47 { 48 case 6: 49 // this means we asked for 8 channels, but only 6 are available 50 // so, we'll turn on the 7.1 to 5.1 downmixer. 51 a_config.channel = 6; 52 a_config.encoder = CELL_AUDIO_OUT_CODING_TYPE_LPCM; 53 a_config.downMixer = CELL_AUDIO_OUT_DOWNMIXER_TYPE_B; 54 if ( cellAudioOutConfigure( CELL_AUDIO_OUT_PRIMARY, &a_config, NULL, 0 ) != CELL_OK ) 55 { 56 return 0; // error - the downmixer didn't init 57 } 58 59 ret = 8; 60 break; 61 62 case 2: 63 // ok, this means they asked for multi-channel out, but only stereo 64 // is supported. we'll try dolby digital first and then the downmixer 65 66 ch_bit = cellAudioOutGetSoundAvailability( CELL_AUDIO_OUT_PRIMARY, 67 CELL_AUDIO_OUT_CODING_TYPE_AC3, 68 CELL_AUDIO_OUT_FS_48KHZ, 0 ); 69 if ( ch_bit > 0 ) 70 { 71 a_config.channel = ch_bit; 72 a_config.encoder = CELL_AUDIO_OUT_CODING_TYPE_AC3; 73 if ( ch_bit >= minimum_chans ) 74 { 75 // we have enough channels to support their minimum 76 a_config.downMixer = CELL_AUDIO_OUT_DOWNMIXER_NONE; 77 ret = ch_bit; 78 } 79 else 80 { 81 // we don't have enough channels to support their minimum, so use the downmixer 82 a_config.downMixer = CELL_AUDIO_OUT_DOWNMIXER_TYPE_B; 83 ret = 8; 84 } 85 86 if ( cellAudioOutConfigure( CELL_AUDIO_OUT_PRIMARY, &a_config, NULL, 0 ) == CELL_OK ) 87 { 88 break; 89 } 90 91 // if we got here the dolby encoder, didn't init, so fall through to downmixing to stereo 92 } 93 94 a_config.channel = 2; 95 a_config.encoder = CELL_AUDIO_OUT_CODING_TYPE_LPCM; 96 a_config.downMixer = CELL_AUDIO_OUT_DOWNMIXER_TYPE_A; 97 if ( cellAudioOutConfigure( CELL_AUDIO_OUT_PRIMARY, &a_config, NULL, 0 ) != CELL_OK ) 98 { 99 return 0; // error - downmixer didn't work 100 } 101 102 ret = 2; // downmixer does 7.0 to 2.0 downmixing... 103 break; 104 105 default: 106 // some other weird case that we don't understand 107 return 0; 108 } 109 } 110 111 // turn off copy protection stupidness 112 cellAudioOutSetCopyControl( CELL_AUDIO_OUT_PRIMARY, 113 CELL_AUDIO_OUT_COPY_CONTROL_COPY_FREE ); 114 115 return( ret ); 116} 117