Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added: CanInit method to AE sinks

  • Loading branch information...
commit 615af13d765da00258481f471115fe10b464aa68 1 parent 63a254c
bobo1on1 authored
View
24 xbmc/cores/AudioEngine/Engines/PulseAE/PulseAE.cpp
@@ -28,6 +28,7 @@
#include "utils/log.h"
#include "settings/Settings.h"
#include <pulse/pulseaudio.h>
+#include <pulse/simple.h>
#include "guilib/LocalizeStrings.h"
/* Static helpers */
@@ -99,6 +100,29 @@ CPulseAE::~CPulseAE()
}
+bool CPulseAE::CanInit()
+{
+ pa_simple *s;
+ pa_sample_spec ss;
+
+ ss.format = PA_SAMPLE_S16NE;
+ ss.channels = 2;
+ ss.rate = 48000;
+
+ //create a pulse client, if this returns NULL, pulseaudio isn't running
+ s = pa_simple_new(NULL, "XBMC-test", PA_STREAM_PLAYBACK, NULL,"test", &ss, NULL, NULL, NULL);
+
+ if (s)
+ {
+ pa_simple_free(s);
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
+
bool CPulseAE::Initialize()
{
m_Volume = g_settings.m_fVolumeLevel;
View
1  xbmc/cores/AudioEngine/Engines/PulseAE/PulseAE.h
@@ -42,6 +42,7 @@ class CPulseAE : public IAE
virtual ~CPulseAE();
public:
+ virtual bool CanInit();
virtual bool Initialize ();
virtual void OnSettingsChange(std::string setting);
View
6 xbmc/cores/AudioEngine/Interfaces/AE.h
@@ -52,6 +52,12 @@ class IAE
virtual ~IAE() {}
/**
+ * Returns true when it should be possible to initialize this engine, if it returns false
+ * CAEFactory can possibly fall back to a different one
+ */
+ virtual bool CanInit() { return true; }
+
+ /**
* Initializes the AudioEngine, called by CFactory when it is time to initialize the audio engine.
* Do not call this directly, CApplication will call this when it is ready
*/
Please sign in to comment.
Something went wrong with that request. Please try again.