~mkas/mixxx/mysql

« back to all changes in this revision

Viewing changes to mixxx/src/soundmanager.h

  • Committer: MKas
  • Date: 2012-11-03 12:55:54 UTC
  • Revision ID: mkas@tux.lt-20121103125554-ez5ajqyk7bwehrp2
merge with trunk + sql fixes

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
 
44
44
class SoundManager : public QObject {
45
45
    Q_OBJECT
46
 
public:
 
46
  public:
47
47
    SoundManager(ConfigObject<ConfigValue> *pConfig, EngineMaster *_master);
48
 
    ~SoundManager();
49
 
    const EngineMaster* getEngine() const; // this shouldn't exist
 
48
    virtual ~SoundManager();
 
49
 
 
50
    // Returns a pointer to the EngineMaster instance used by this SoundManager.
 
51
    //
 
52
    // NOTE(XXX): This is only here so that preferences can find out how many
 
53
    // channels there are.
 
54
    const EngineMaster* getEngine() const;
 
55
 
 
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);
 
60
 
 
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();
 
66
 
 
67
    // Closes all the devices and empties the list of devices we have.
52
68
    void clearDeviceList();
 
69
 
 
70
    // Creates a list of sound devices that PortAudio sees.
53
71
    void queryDevices();
 
72
 
 
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();
 
76
 
55
77
    SoundDevice* getErrorDevice() const;
 
78
 
 
79
    // Returns a list of samplerates we will attempt to support for a given API.
56
80
    QList<unsigned int> getSampleRates(QString api) const;
 
81
 
 
82
    // Convenience overload for SoundManager::getSampleRates(QString)
57
83
    QList<unsigned int> getSampleRates() const;
 
84
 
 
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();
 
90
 
 
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);
 
95
 
 
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);
 
100
 
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;
71
 
signals:
 
105
 
 
106
  signals:
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);
76
 
private:
77
 
    void clearOperativeVariables();
 
111
 
 
112
  private:
78
113
    void setJACKName() const;
79
114
 
80
115
    EngineMaster *m_pMaster;
81
116
    ConfigObject<ConfigValue> *m_pConfig;
 
117
#ifdef __PORTAUDIO__
 
118
    bool m_paInitialized;
 
119
    unsigned int m_jackSampleRate;
 
120
#endif
82
121
    QList<SoundDevice*> m_devices;
83
122
    QList<unsigned int> m_samplerates;
84
123
    QString m_hostAPI;
92
131
    int m_inputDevicesOpened;
93
132
    QMutex requestBufferMutex;
94
133
    SoundManagerConfig m_config;
95
 
    SoundDevice *m_pErrorDevice;
96
 
#ifdef __PORTAUDIO__
97
 
    bool m_paInitialized;
98
 
    unsigned int m_jackSampleRate;
99
 
#endif
 
134
    SoundDevice* m_pErrorDevice;
100
135
    QHash<AudioOutput, const AudioSource*> m_registeredSources;
101
136
    QHash<AudioInput, AudioDestination*> m_registeredDestinations;
102
137