Mixxx

/home/maxime/Projets/Mixxx/1.10/mixxx/src/soundmanager.h

Go to the documentation of this file.
00001 
00008 /***************************************************************************
00009  *                                                                         *
00010  *   This program is free software; you can redistribute it and/or modify  *
00011  *   it under the terms of the GNU General Public License as published by  *
00012  *   the Free Software Foundation; either version 2 of the License, or     *
00013  *   (at your option) any later version.                                   *
00014  *                                                                         *
00015  ***************************************************************************/
00016 
00017 #ifndef SOUNDMANAGER_H
00018 #define SOUNDMANAGER_H
00019 
00020 #include <QObject>
00021 #include "defs.h"
00022 #include "configobject.h"
00023 #include "soundmanagerconfig.h"
00024 #include "controlobjectthreadmain.h"
00025 
00026 class SoundDevice;
00027 class EngineMaster;
00028 class AudioOutput;
00029 class AudioInput;
00030 class AudioSource;
00031 class AudioDestination;
00032 
00033 #define MIXXX_PORTAUDIO_JACK_STRING "JACK Audio Connection Kit"
00034 #define MIXXX_PORTAUDIO_ALSA_STRING "ALSA"
00035 #define MIXXX_PORTAUDIO_OSS_STRING "OSS"
00036 #define MIXXX_PORTAUDIO_ASIO_STRING "ASIO"
00037 #define MIXXX_PORTAUDIO_DIRECTSOUND_STRING "Windows DirectSound"
00038 #define MIXXX_PORTAUDIO_COREAUDIO_STRING "Core Audio"
00039 
00040 class SoundManager : public QObject {
00041     Q_OBJECT
00042 public:
00043     SoundManager(ConfigObject<ConfigValue> *pConfig, EngineMaster *_master);
00044     ~SoundManager();
00045     const EngineMaster* getEngine() const; // this shouldn't exist
00046     QList<SoundDevice*> getDeviceList(QString filterAPI, bool bOutputDevices, bool bInputDevices);
00047     void closeDevices();
00048     void clearDeviceList();
00049     void queryDevices();
00050     int setupDevices();
00051     SoundDevice* getErrorDevice() const;
00052     QList<unsigned int> getSampleRates(QString api) const;
00053     QList<unsigned int> getSampleRates() const;
00054     QList<QString> getHostAPIList() const;
00055     SoundManagerConfig getConfig() const;
00056     int setConfig(SoundManagerConfig config);
00057     void checkConfig();
00058     QHash<AudioOutput, const CSAMPLE*> requestBuffer(
00059         QList<AudioOutput> outputs, unsigned long iFramesPerBuffer,
00060         SoundDevice *device, double streamTime = 0);
00061     void pushBuffer(QList<AudioInput> inputs, short *inputBuffer,
00062         unsigned long iFramesPerBuffer, unsigned int iFrameSize);
00063     void registerOutput(AudioOutput output, const AudioSource *src);
00064     void registerInput(AudioInput input, AudioDestination *dest);
00065     QList<AudioOutput> registeredOutputs() const;
00066     QList<AudioInput> registeredInputs() const;
00067 signals:
00068     void devicesUpdated(); // emitted when pointers to SoundDevices go stale
00069     void devicesSetup(); // emitted when the sound devices have been set up
00070     void outputRegistered(AudioOutput output, const AudioSource *src);
00071     void inputRegistered(AudioInput input, AudioDestination *dest);
00072 private:
00073     void clearOperativeVariables();
00074     void setJACKName() const;
00075 
00076     EngineMaster *m_pMaster;
00077     ConfigObject<ConfigValue> *m_pConfig;
00078     QList<SoundDevice*> m_devices;
00079     QList<unsigned int> m_samplerates;
00080     QString m_hostAPI;
00081     QHash<AudioOutput, const CSAMPLE*> m_outputBuffers;
00082     QHash<AudioInput, short*> m_inputBuffers;
00083     QHash<SoundDevice*, long> m_deviceFrameCount; // used in dead code
00084     // Clock reference, used to make sure the same device triggers buffer
00085     // refresh every $latency-ms period
00086     SoundDevice* m_pClkRefDevice;
00087     int m_outputDevicesOpened;
00088     int m_inputDevicesOpened;
00089     QMutex requestBufferMutex;
00090     SoundManagerConfig m_config;
00091     SoundDevice *m_pErrorDevice;
00092 #ifdef __PORTAUDIO__
00093     bool m_paInitialized;
00094     unsigned int m_jackSampleRate;
00095 #endif
00096     QHash<AudioOutput, const AudioSource*> m_registeredSources;
00097     QHash<AudioInput, AudioDestination*> m_registeredDestinations;
00098 
00099     ControlObjectThreadMain* m_pControlObjectLatency;
00100     ControlObjectThreadMain* m_pControlObjectSampleRate;
00101     ControlObjectThreadMain* m_pControlObjectVinylControlMode;
00102     ControlObjectThreadMain* m_pControlObjectVinylControlMode1;
00103     ControlObjectThreadMain* m_pControlObjectVinylControlMode2;
00104     ControlObjectThreadMain* m_pControlObjectVinylControlGain;
00105 };
00106 
00107 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines