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