Chris@0
|
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 A waveform viewer and audio annotation editor.
|
Chris@0
|
5 Chris Cannam, Queen Mary University of London, 2005
|
Chris@0
|
6
|
Chris@0
|
7 This is experimental software. Not for distribution.
|
Chris@0
|
8 */
|
Chris@0
|
9
|
Chris@0
|
10 #include "AudioTargetFactory.h"
|
Chris@0
|
11
|
Chris@0
|
12 #include "AudioJACKTarget.h"
|
Chris@0
|
13 #include "AudioCoreAudioTarget.h"
|
Chris@0
|
14 #include "AudioPortAudioTarget.h"
|
Chris@0
|
15
|
Chris@0
|
16 #include <iostream>
|
Chris@0
|
17
|
Chris@0
|
18 AudioCallbackPlayTarget *
|
Chris@0
|
19 AudioTargetFactory::createCallbackTarget(AudioCallbackPlaySource *source)
|
Chris@0
|
20 {
|
Chris@0
|
21 AudioCallbackPlayTarget *target = 0;
|
Chris@0
|
22
|
Chris@0
|
23 #ifdef HAVE_JACK
|
Chris@0
|
24 target = new AudioJACKTarget(source);
|
Chris@0
|
25 if (target->isOK()) return target;
|
Chris@0
|
26 else {
|
Chris@0
|
27 std::cerr << "WARNING: AudioTargetFactory::createCallbackTarget: Failed to open JACK target" << std::endl;
|
Chris@0
|
28 delete target;
|
Chris@0
|
29 }
|
Chris@0
|
30 #endif
|
Chris@0
|
31
|
Chris@0
|
32 #ifdef HAVE_COREAUDIO
|
Chris@0
|
33 target = new AudioCoreAudioTarget(source);
|
Chris@0
|
34 if (target->isOK()) return target;
|
Chris@0
|
35 else {
|
Chris@0
|
36 std::cerr << "WARNING: AudioTargetFactory::createCallbackTarget: Failed to open CoreAudio target" << std::endl;
|
Chris@0
|
37 delete target;
|
Chris@0
|
38 }
|
Chris@0
|
39 #endif
|
Chris@0
|
40
|
Chris@0
|
41 #ifdef HAVE_DIRECTSOUND
|
Chris@0
|
42 target = new AudioDirectSoundTarget(source);
|
Chris@0
|
43 if (target->isOK()) return target;
|
Chris@0
|
44 else {
|
Chris@0
|
45 std::cerr << "WARNING: AudioTargetFactory::createCallbackTarget: Failed to open DirectSound target" << std::endl;
|
Chris@0
|
46 delete target;
|
Chris@0
|
47 }
|
Chris@0
|
48 #endif
|
Chris@0
|
49
|
Chris@0
|
50 #ifdef HAVE_PORTAUDIO
|
Chris@0
|
51 target = new AudioPortAudioTarget(source);
|
Chris@0
|
52 if (target->isOK()) return target;
|
Chris@0
|
53 else {
|
Chris@0
|
54 std::cerr << "WARNING: AudioTargetFactory::createCallbackTarget: Failed to open PortAudio target" << std::endl;
|
Chris@0
|
55 delete target;
|
Chris@0
|
56 }
|
Chris@0
|
57 #endif
|
Chris@0
|
58
|
Chris@0
|
59 std::cerr << "WARNING: AudioTargetFactory::createCallbackTarget: No suitable targets available" << std::endl;
|
Chris@0
|
60 return 0;
|
Chris@0
|
61 }
|
Chris@0
|
62
|
Chris@0
|
63
|