44
44
class SoundManager : public QObject {
47
47
SoundManager(ConfigObject<ConfigValue> *pConfig, EngineMaster *_master);
49
const EngineMaster* getEngine() const; // this shouldn't exist
48
virtual ~SoundManager();
50
// Returns a pointer to the EngineMaster instance used by this SoundManager.
52
// NOTE(XXX): This is only here so that preferences can find out how many
53
// channels there are.
54
const EngineMaster* getEngine() const;
56
// Returns a list of all devices we've enumerated that match the provided
57
// filterApi, and have at least one output or input channel if the
58
// bOutputDevices or bInputDevices are set, respectively.
50
59
QList<SoundDevice*> getDeviceList(QString filterAPI, bool bOutputDevices, bool bInputDevices);
61
// Closes all the open sound devices. Because multiple soundcards might be
62
// open, this method simply runs through the list of all known soundcards
63
// (from PortAudio) and attempts to close them all. Closing a soundcard that
64
// isn't open is safe.
51
65
void closeDevices();
67
// Closes all the devices and empties the list of devices we have.
52
68
void clearDeviceList();
70
// Creates a list of sound devices that PortAudio sees.
53
71
void queryDevices();
73
// Opens all the devices chosen by the user in the preferences dialog, and
74
// establishes the proper connections between them and the mixing engine.
54
75
int setupDevices();
55
77
SoundDevice* getErrorDevice() const;
79
// Returns a list of samplerates we will attempt to support for a given API.
56
80
QList<unsigned int> getSampleRates(QString api) const;
82
// Convenience overload for SoundManager::getSampleRates(QString)
57
83
QList<unsigned int> getSampleRates() const;
85
// Get a list of host APIs supported by PortAudio.
58
86
QList<QString> getHostAPIList() const;
59
87
SoundManagerConfig getConfig() const;
60
88
int setConfig(SoundManagerConfig config);
61
89
void checkConfig();
91
// Requests a buffer in the proper format, if we're prepared to give one.
62
92
QHash<AudioOutput, const CSAMPLE*> requestBuffer(
63
93
QList<AudioOutput> outputs, unsigned long iFramesPerBuffer,
64
94
SoundDevice *device, double streamTime = 0);
96
// Used by SoundDevices to "push" any audio from their inputs that they have
97
// into the mixing engine.
65
98
void pushBuffer(QList<AudioInput> inputs, short *inputBuffer,
66
unsigned long iFramesPerBuffer, unsigned int iFrameSize);
99
unsigned long iFramesPerBuffer, unsigned int iFrameSize);
67
101
void registerOutput(AudioOutput output, const AudioSource *src);
68
102
void registerInput(AudioInput input, AudioDestination *dest);
69
103
QList<AudioOutput> registeredOutputs() const;
70
104
QList<AudioInput> registeredInputs() const;
72
107
void devicesUpdated(); // emitted when pointers to SoundDevices go stale
73
108
void devicesSetup(); // emitted when the sound devices have been set up
74
109
void outputRegistered(AudioOutput output, const AudioSource *src);
75
110
void inputRegistered(AudioInput input, AudioDestination *dest);
77
void clearOperativeVariables();
78
113
void setJACKName() const;
80
115
EngineMaster *m_pMaster;
81
116
ConfigObject<ConfigValue> *m_pConfig;
118
bool m_paInitialized;
119
unsigned int m_jackSampleRate;
82
121
QList<SoundDevice*> m_devices;
83
122
QList<unsigned int> m_samplerates;
84
123
QString m_hostAPI;