Permalink
Browse files

added: CanInit method to AE sinks

  • Loading branch information...
1 parent 63a254c commit 615af13d765da00258481f471115fe10b464aa68 bobo1on1 committed Oct 8, 2012
@@ -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;
@@ -42,6 +42,7 @@ class CPulseAE : public IAE
virtual ~CPulseAE();
public:
+ virtual bool CanInit();
virtual bool Initialize ();
virtual void OnSettingsChange(std::string setting);
@@ -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
*/

0 comments on commit 615af13

Please sign in to comment.