mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
parent
8c05399e41
commit
2353a66fde
|
@ -62,7 +62,7 @@ OpenAL::OpenAL()
|
||||||
connect(this, &Audio::startActive, &voiceTimer, static_cast<void (QTimer::*)(int)>(&QTimer::start));
|
connect(this, &Audio::startActive, &voiceTimer, static_cast<void (QTimer::*)(int)>(&QTimer::start));
|
||||||
connect(&voiceTimer, &QTimer::timeout, this, &Audio::stopActive);
|
connect(&voiceTimer, &QTimer::timeout, this, &Audio::stopActive);
|
||||||
|
|
||||||
connect(&captureTimer, &QTimer::timeout, this, &OpenAL::doCapture);
|
connect(&captureTimer, &QTimer::timeout, this, &OpenAL::doAudio);
|
||||||
captureTimer.setInterval(AUDIO_FRAME_DURATION / 2);
|
captureTimer.setInterval(AUDIO_FRAME_DURATION / 2);
|
||||||
captureTimer.setSingleShot(false);
|
captureTimer.setSingleShot(false);
|
||||||
captureTimer.start();
|
captureTimer.start();
|
||||||
|
@ -301,7 +301,7 @@ bool OpenAL::initInput(const QString& deviceName, uint32_t channels)
|
||||||
assert(!alInDev);
|
assert(!alInDev);
|
||||||
|
|
||||||
// TODO: Try to actually detect if our audio source is stereo
|
// TODO: Try to actually detect if our audio source is stereo
|
||||||
int stereoFlag = AUDIO_CHANNELS == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
|
int stereoFlag = channels == 1 ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;
|
||||||
const uint32_t sampleRate = AUDIO_SAMPLE_RATE;
|
const uint32_t sampleRate = AUDIO_SAMPLE_RATE;
|
||||||
const uint16_t frameDuration = AUDIO_FRAME_DURATION;
|
const uint16_t frameDuration = AUDIO_FRAME_DURATION;
|
||||||
const ALCsizei bufSize = (frameDuration * sampleRate * 4) / 1000 * channels;
|
const ALCsizei bufSize = (frameDuration * sampleRate * 4) / 1000 * channels;
|
||||||
|
@ -555,7 +555,7 @@ void OpenAL::stopActive()
|
||||||
/**
|
/**
|
||||||
* @brief Called on the captureTimer events to capture audio
|
* @brief Called on the captureTimer events to capture audio
|
||||||
*/
|
*/
|
||||||
void OpenAL::doCapture()
|
void OpenAL::doAudio()
|
||||||
{
|
{
|
||||||
QMutexLocker lock(&audioLock);
|
QMutexLocker lock(&audioLock);
|
||||||
|
|
||||||
|
|
|
@ -104,13 +104,13 @@ protected:
|
||||||
bool autoInitOutput();
|
bool autoInitOutput();
|
||||||
|
|
||||||
bool initInput(const QString& deviceName, uint32_t channels);
|
bool initInput(const QString& deviceName, uint32_t channels);
|
||||||
|
virtual void doAudio();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual bool initInput(const QString& deviceName);
|
virtual bool initInput(const QString& deviceName);
|
||||||
virtual bool initOutput(const QString& outDevDescr);
|
virtual bool initOutput(const QString& outDevDescr);
|
||||||
void playMono16SoundCleanup();
|
void playMono16SoundCleanup();
|
||||||
float getVolume(int16_t *buf);
|
float getVolume(int16_t *buf);
|
||||||
void doCapture();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QThread* audioThread;
|
QThread* audioThread;
|
||||||
|
|
|
@ -55,12 +55,12 @@ class OpenAL2 : public OpenAL
|
||||||
public:
|
public:
|
||||||
OpenAL2();
|
OpenAL2();
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
bool initInput(const QString& deviceName);
|
bool initInput(const QString& deviceName) override;
|
||||||
bool initOutput(const QString& outDevDescr);
|
bool initOutput(const QString& outDevDescr) override;
|
||||||
void cleanupOutput();
|
void cleanupOutput() override;
|
||||||
void playMono16SoundCleanup();
|
void playMono16SoundCleanup();
|
||||||
void doAudio();
|
void doAudio() override;
|
||||||
void doInput();
|
void doInput();
|
||||||
void doOutput();
|
void doOutput();
|
||||||
bool loadOpenALExtensions(ALCdevice* dev);
|
bool loadOpenALExtensions(ALCdevice* dev);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user