Skip to content
Snippets Groups Projects
Commit 0613ef38 authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

audio(win32): fix crash when changing audio devices during call

Change-Id: I09393d058dfd89f124998fe0873ffe45244bfb75
Gitlab: #170
parent 09161495
Branches
No related tags found
No related merge requests found
......@@ -88,6 +88,11 @@ PortAudioLayer::PortAudioLayer(const AudioPreference& pref)
, pimpl_ {new PortAudioLayerImpl(*this, pref)}
{}
PortAudioLayer::~PortAudioLayer()
{
stopStream();
}
std::vector<std::string>
PortAudioLayer::getCaptureDeviceList() const
{
......@@ -281,6 +286,8 @@ PortAudioLayer::PortAudioLayerImpl::init(PortAudioLayer& parent)
parent.audioFormat_.nb_channels = outputDeviceInfo->maxOutputChannels;
parent.audioFormat_.sample_rate = outputDeviceInfo->defaultSampleRate;
parent.hardwareFormatAvailable(parent.audioFormat_);
JAMI_DBG() << "PortAudioLayer initialized output using: "
<< outputDeviceInfo->name;
} else {
indexOut_ = paNoDevice;
}
......@@ -291,6 +298,8 @@ PortAudioLayer::PortAudioLayerImpl::init(PortAudioLayer& parent)
parent.audioInputFormat_.nb_channels = inputDeviceInfo->maxInputChannels;
parent.audioInputFormat_.sample_rate = inputDeviceInfo->defaultSampleRate;
parent.hardwareInputFormatAvailable(parent.audioInputFormat_);
JAMI_DBG() << "PortAudioLayer initialized input using: "
<< inputDeviceInfo->name;
} else {
indexIn_ = paNoDevice;
}
......
......@@ -33,29 +33,29 @@ class PortAudioLayer : public AudioLayer {
public:
PortAudioLayer(const AudioPreference& pref);
virtual ~PortAudioLayer() = default;
~PortAudioLayer();
virtual std::vector<std::string> getCaptureDeviceList() const;
virtual std::vector<std::string> getPlaybackDeviceList() const;
virtual int getAudioDeviceIndex(const std::string& name, DeviceType type) const;
virtual std::string getAudioDeviceName(int index, DeviceType type) const;
virtual int getIndexCapture() const;
virtual int getIndexPlayback() const;
virtual int getIndexRingtone() const;
std::vector<std::string> getCaptureDeviceList() const override;
std::vector<std::string> getPlaybackDeviceList() const override;
int getAudioDeviceIndex(const std::string& name, DeviceType type) const override;
std::string getAudioDeviceName(int index, DeviceType type) const override;
int getIndexCapture() const override;
int getIndexPlayback() const override;
int getIndexRingtone() const override;
/**
* Start the capture stream and prepare the playback stream.
* The playback starts accordingly to its threshold
*/
virtual void startStream();
void startStream() override;
/**
* Stop the playback and capture streams.
* Drops the pending frames and put the capture and playback handles to PREPARED state
*/
virtual void stopStream();
void stopStream() override;
virtual void updatePreference(AudioPreference& pref, int index, DeviceType type);
void updatePreference(AudioPreference& pref, int index, DeviceType type) override;
private:
NON_COPYABLE(PortAudioLayer);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment