Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix: Call doAudio on timer timeout
Browse files Browse the repository at this point in the history
Fix #4904
  • Loading branch information
Diadlo committed Jan 20, 2018
1 parent 8c05399 commit 2353a66
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/audio/backend/openal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ OpenAL::OpenAL()
connect(this, &Audio::startActive, &voiceTimer, static_cast<void (QTimer::*)(int)>(&QTimer::start));
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.setSingleShot(false);
captureTimer.start();
Expand Down Expand Up @@ -301,7 +301,7 @@ bool OpenAL::initInput(const QString& deviceName, uint32_t channels)
assert(!alInDev);

// 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 uint16_t frameDuration = AUDIO_FRAME_DURATION;
const ALCsizei bufSize = (frameDuration * sampleRate * 4) / 1000 * channels;
Expand Down Expand Up @@ -555,7 +555,7 @@ void OpenAL::stopActive()
/**
* @brief Called on the captureTimer events to capture audio
*/
void OpenAL::doCapture()
void OpenAL::doAudio()
{
QMutexLocker lock(&audioLock);

Expand Down
2 changes: 1 addition & 1 deletion src/audio/backend/openal.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ class OpenAL : public Audio
bool autoInitOutput();

bool initInput(const QString& deviceName, uint32_t channels);
virtual void doAudio();

private:
virtual bool initInput(const QString& deviceName);
virtual bool initOutput(const QString& outDevDescr);
void playMono16SoundCleanup();
float getVolume(int16_t *buf);
void doCapture();

protected:
QThread* audioThread;
Expand Down
10 changes: 5 additions & 5 deletions src/audio/backend/openal2.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ class OpenAL2 : public OpenAL
public:
OpenAL2();

private:
bool initInput(const QString& deviceName);
bool initOutput(const QString& outDevDescr);
void cleanupOutput();
protected:
bool initInput(const QString& deviceName) override;
bool initOutput(const QString& outDevDescr) override;
void cleanupOutput() override;
void playMono16SoundCleanup();
void doAudio();
void doAudio() override;
void doInput();
void doOutput();
bool loadOpenALExtensions(ALCdevice* dev);
Expand Down

0 comments on commit 2353a66

Please sign in to comment.