Audio device is closed when frmContactEditor is closed.
// with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
#include "frmContactEditor.h"
// with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
#include "frmContactEditor.h"
-#include "frmContactEditorSound.h"
-#include "../common/base64.h"
-#include <SFML/Audio.hpp>
-#include <thread>
void frmContactEditor::AddSound( wxCommandEvent& event )
{
void frmContactEditor::AddSound( wxCommandEvent& event )
{
// Play the sound and detach.
// Play the sound and detach.
- if (!AudioStreamPlayback.openFromMemory(base64dec.c_str(), base64declen)){
+ if (!AudioStreamPlaybackPointer->openFromMemory(base64dec.c_str(), base64declen)){
// Can't load file. We must flee...
// Also show an error message too.
// Can't load file. We must flee...
// Also show an error message too.
- AudioStreamPlayback.play();
+ AudioStreamPlaybackPointer->play();
- while (AudioStreamPlayback.getStatus() == sf::SoundSource::Playing){
+ while (AudioStreamPlaybackPointer->getStatus() == sf::SoundSource::Playing){
// We poll this every 100ms in order to conserve CPU usage.
// We poll this every 100ms in order to conserve CPU usage.
long longSelected = -1;
int intSelectedData = 0;
long longSelected = -1;
int intSelectedData = 0;
+ if (AudioStreamPlaybackPointer == nullptr){
+
+ AudioStreamPlaybackPointer = new AudioStream;
+
+ }
+
// Check if sound is still being played and if it is, stop it.
// Check if sound is still being played and if it is, stop it.
- if (AudioStreamPlayback.getStatus() == sf::SoundSource::Playing){
+ if (AudioStreamPlaybackPointer->getStatus() == sf::SoundSource::Playing){
- AudioStreamPlayback.stop();
+ AudioStreamPlaybackPointer->stop();
&intSelectedData)){
return;
}
&intSelectedData)){
return;
}
+
+ btnPlay->Disable();
+
std::map<int, std::string>::iterator initier;
initier = ContactEditorData.SoundsList.find(intSelectedData);
std::map<int, std::string>::iterator initier;
initier = ContactEditorData.SoundsList.find(intSelectedData);
-
- if (AudioStreamPlayback.getStatus() == sf::SoundSource::Playing){
-
- AudioStreamPlayback.stop();
+
+ if (AudioStreamPlaybackPointer != nullptr && AudioStreamPlaybackPointer->getStatus() == sf::SoundSource::Playing){
+ AudioStreamPlaybackPointer->stop();
+
+frmContactEditor::~frmContactEditor()
+{
+
+ if (AudioStreamPlaybackPointer != nullptr)
+ {
+
+ delete AudioStreamPlaybackPointer;
+ AudioStreamPlaybackPointer = nullptr;
+
+ }
+
+}
+
void frmContactEditor::CloseContact( wxCommandEvent& event )
{
void frmContactEditor::CloseContact( wxCommandEvent& event )
{
#include "../actmgr/frmActivityMgr.h"
#include "../frmMain.h"
#include "../actmgr/frmActivityMgr.h"
#include "../frmMain.h"
+#include "frmContactEditorSound.h"
#include "cdo/ContactDataObject.h"
#include "cdo/ContactDataObject.h"
public:
/** Constructor */
frmContactEditor( wxWindow* parent );
public:
/** Constructor */
frmContactEditor( wxWindow* parent );
void SetupHeaders();
void SetupContact(wxString AccountName);
void SetupAccountData(bool UnsupportedAccount);
void SetupHeaders();
void SetupContact(wxString AccountName);
void SetupAccountData(bool UnsupportedAccount);
size_t base64declen;
std::string base64dec;
size_t base64declen;
std::string base64dec;
- sf::Music AudioPlayback;
- AudioStream AudioStreamPlayback;
- sf::SoundBuffer AudioBuffer;
+ AudioStream *AudioStreamPlaybackPointer = nullptr;
wxBitmap PictureImage;
wxBitmap LogoImage;
wxBitmap PictureImage;
wxBitmap LogoImage;