AESinkPULSE: Return False so that ActiveAE can open us with correct device name again
authorfritsch <peter.fruehberger@gmail.com>
Tue, 14 Jan 2014 22:15:34 +0000 (23:15 +0100)
committerfritsch <peter.fruehberger@gmail.com>
Wed, 15 Jan 2014 17:27:42 +0000 (18:27 +0100)
xbmc/cores/AudioEngine/Sinks/AESinkPULSE.cpp

index 8ac7181..d7b8288 100644 (file)
@@ -193,6 +193,7 @@ struct SinkInfoStruct
 {
   AEDeviceInfoList *list;
   bool isHWDevice;
+  bool device_not_found;
   pa_threaded_mainloop *mainloop;
 };
 
@@ -201,6 +202,8 @@ static void SinkInfoCallback(pa_context *c, const pa_sink_info *i, int eol, void
   SinkInfoStruct *sinkStruct = (SinkInfoStruct *)userdata;
   if (i && i->flags && (i->flags & PA_SINK_HARDWARE))
     sinkStruct->isHWDevice = true;
+  else if(!i)
+    sinkStruct->device_not_found = true;
   pa_threaded_mainloop_signal(sinkStruct->mainloop, 0);
 }
 
@@ -483,9 +486,19 @@ bool CAESinkPULSE::Initialize(AEAudioFormat &format, std::string &device)
   SinkInfoStruct sinkStruct;
   sinkStruct.mainloop = m_MainLoop;
   sinkStruct.isHWDevice = false;
+  sinkStruct.device_not_found = false;
+
   if (!isDefaultDevice)
     WaitForOperation(pa_context_get_sink_info_by_name(m_Context, device.c_str(),SinkInfoCallback, &sinkStruct), m_MainLoop, "Get Sink Info");
 
+  if(sinkStruct.device_not_found) // ActiveAE will open us again with a valid device name
+  {
+    CLog::Log(LOGERROR, "PulseAudio: Sink %s not found", device.c_str());
+    pa_threaded_mainloop_unlock(m_MainLoop);
+    Deinitialize();
+    return false;
+  }
+
   // 200ms max latency
   // 50ms min packet size
   if(sinkStruct.isHWDevice || isDefaultDevice)