00001 #include <qstring.h>
00002 #include <cstdio>
00003 #include <cstdlib>
00004
00005 using namespace std;
00006
00007 #include "config.h"
00008 #include "audiooutput.h"
00009 #include "compat.h"
00010
00011 #include "audiooutputnull.h"
00012 #ifdef USING_DIRECTX
00013 #include "audiooutputdx.h"
00014 #endif
00015 #ifdef USING_WINAUDIO
00016 #include "audiooutputwin.h"
00017 #endif
00018 #ifdef USING_OSS
00019 #include "audiooutputoss.h"
00020 #endif
00021 #ifdef USE_ALSA
00022 #include "audiooutputalsa.h"
00023 #endif
00024 #ifdef USE_ARTS
00025 #include "audiooutputarts.h"
00026 #endif
00027 #ifdef CONFIG_DARWIN
00028 #include "audiooutputca.h"
00029 #endif
00030 #ifdef USE_JACK
00031 #include "audiooutputjack.h"
00032 #endif
00033
00034 AudioOutput *AudioOutput::OpenAudio(QString main_device,
00035 QString passthru_device,
00036 int audio_bits,
00037 int audio_channels, int audio_samplerate,
00038 AudioOutputSource source,
00039 bool set_initial_vol, bool audio_passthru)
00040 {
00041 if (passthru_device.isEmpty() || passthru_device.lower() == "default")
00042 passthru_device = main_device;
00043
00044 if (main_device.startsWith("ALSA:"))
00045 {
00046 #ifdef USE_ALSA
00047 return new AudioOutputALSA(main_device.remove(0, 5),
00048 passthru_device.remove(0, 5), audio_bits,
00049 audio_channels, audio_samplerate, source,
00050 set_initial_vol, audio_passthru);
00051 #else
00052 VERBOSE(VB_IMPORTANT, "Audio output device is set to an ALSA device "
00053 "but ALSA support is not compiled in!");
00054 return NULL;
00055 #endif
00056 }
00057 else if (main_device.startsWith("NULL"))
00058 {
00059 return new AudioOutputNULL(main_device, passthru_device, audio_bits,
00060 audio_channels, audio_samplerate, source,
00061 set_initial_vol, audio_passthru);
00062 }
00063 else if (main_device.startsWith("ARTS:"))
00064 {
00065 #ifdef USE_ARTS
00066 return new AudioOutputARTS(main_device.remove(0, 5),
00067 passthru_device.remove(0, 5), audio_bits,
00068 audio_channels, audio_samplerate, source,
00069 set_initial_vol, audio_passthru);
00070 #else
00071 VERBOSE(VB_IMPORTANT, "Audio output device is set to an ARTS device "
00072 "but ARTS support is not compiled in!");
00073 return NULL;
00074 #endif
00075 }
00076 else if (main_device.startsWith("JACK:"))
00077 {
00078 #ifdef USE_JACK
00079 return new AudioOutputJACK(main_device.remove(0, 5),
00080 passthru_device.remove(0, 5), audio_bits,
00081 audio_channels, audio_samplerate, source,
00082 set_initial_vol, audio_passthru);
00083 #else
00084 VERBOSE(VB_IMPORTANT, "Audio output device is set to a JACK device "
00085 "but JACK support is not compiled in!");
00086 return NULL;
00087 #endif
00088 }
00089 else if (main_device.startsWith("DirectX:"))
00090 {
00091 #ifdef USING_DIRECTX
00092 return new AudioOutputDX(main_device, passthru_device, audio_bits,
00093 audio_channels, audio_samplerate, source,
00094 set_initial_vol, audio_passthru);
00095 #else
00096 VERBOSE(VB_IMPORTANT, "Audio output device is set to DirectX device "
00097 "but DirectX support is not compiled in!");
00098 return NULL;
00099 #endif
00100 }
00101 else if (main_device.startsWith("Windows:"))
00102 {
00103 #ifdef USING_WINAUDIO
00104 return new AudioOutputWin(main_device, passthru_device, audio_bits,
00105 audio_channels, audio_samplerate, source,
00106 set_initial_vol, audio_passthru);
00107 #else
00108 VERBOSE(VB_IMPORTANT, "Audio output device is set to a Windows device "
00109 "but Windows support is not compiled in!");
00110 return NULL;
00111 #endif
00112 }
00113 #if defined(USING_OSS)
00114 else
00115 return new AudioOutputOSS(main_device, passthru_device, audio_bits,
00116 audio_channels, audio_samplerate, source,
00117 set_initial_vol, audio_passthru);
00118 #elif defined(CONFIG_DARWIN)
00119 else
00120 return new AudioOutputCA(main_device, passthru_device, audio_bits,
00121 audio_channels, audio_samplerate, source,
00122 set_initial_vol, audio_passthru);
00123 #endif
00124
00125 VERBOSE(VB_IMPORTANT, "No useable audio output driver found.");
00126 VERBOSE(VB_IMPORTANT, "Don't disable OSS support unless you're "
00127 "not running on Linux.");
00128
00129 return NULL;
00130 }
00131
00132 void AudioOutput::SetStretchFactor(float )
00133 {
00134 }
00135
00136