Skip to content
This repository
Browse code

[WIN32][AE] fixed: release audio stream when XBMC is idle. Changed ha…

…rd coded value to a existing define.
  • Loading branch information...
commit c468689eb8b954b57af84226931c0d9f1dbb666e 1 parent 92787f3
wsoltys authored February 17, 2013
14  xbmc/cores/AudioEngine/Sinks/AESinkDirectSound.cpp
@@ -603,7 +603,7 @@ void CAESinkDirectSound::EnumerateDevicesEx(AEDeviceInfoList &deviceInfoList, bo
603 603
     if (SUCCEEDED(hr) && varName.blob.cbSize > 0)
604 604
     {
605 605
       WAVEFORMATEX* smpwfxex = (WAVEFORMATEX*)varName.blob.pBlobData;
606  
-      deviceInfo.m_channels = layoutsByChCount[std::max(std::min(smpwfxex->nChannels, (WORD) 8), (WORD) 2)];
  606
+      deviceInfo.m_channels = layoutsByChCount[std::max(std::min(smpwfxex->nChannels, (WORD) DS_SPEAKER_COUNT), (WORD) 2)];
607 607
       deviceInfo.m_dataFormats.push_back(AEDataFormat(AE_FMT_FLOAT));
608 608
       deviceInfo.m_dataFormats.push_back(AEDataFormat(AE_FMT_AC3));
609 609
       deviceInfo.m_sampleRates.push_back(std::min(smpwfxex->nSamplesPerSec, (DWORD) 192000));
@@ -896,3 +896,15 @@ std::string CAESinkDirectSound::GetDefaultDevice()
896 896
 
897 897
   return strDevName;
898 898
 }
  899
+
  900
+bool CAESinkDirectSound::SoftSuspend()
  901
+{
  902
+  Deinitialize();
  903
+  return true;
  904
+}
  905
+
  906
+bool CAESinkDirectSound::SoftResume()
  907
+{
  908
+  /* Return false to force re-init by engine */
  909
+  return false;
  910
+}
2  xbmc/cores/AudioEngine/Sinks/AESinkDirectSound.h
@@ -43,6 +43,8 @@ class CAESinkDirectSound : public IAESink
43 43
   virtual double       GetCacheTime       ();
44 44
   virtual double       GetCacheTotal      ();
45 45
   virtual unsigned int AddPackets         (uint8_t *data, unsigned int frames, bool hasAudio);
  46
+  virtual bool         SoftSuspend        ();
  47
+  virtual bool         SoftResume         ();
46 48
   static  std::string  GetDefaultDevice   ();
47 49
   static  void         EnumerateDevicesEx (AEDeviceInfoList &deviceInfoList, bool force = false);
48 50
 private:

0 notes on commit c468689

Peter Frühberger

Don't you have to resume the device here? Aka initialize it with the last format used? Think of someone pressing pause within a song and it goes idling?

wsoltys

Thats what the engine does for us (according to the comment in AEsinkWASAPI.cpp :). And it seems to work here. SoftAE.cpp l1095 does it in this case.

Peter Frühberger

I hope it works (TM). Btw. did you have problems lately on windows after I changed the explicit blocking behaviour when opening a sink?

wsoltys

Not that I'm aware of but I use XBMC on Windows only for developing so you might want to have a look at the forums.

Peter Frühberger

On linux it is a bit different now since SoftSuspend was made working. snd_pcm is freed, so we must take special care in order to reinit the hardware again. Perhaps I could stop calling Initialize in the Resume method, as I set m_reOpen = true; so InternalSink should do this for us. But it takes special if "keeping old sink" code path is triggered. Methods with 500 lines of codes are not easy to understand :-)

Btw. as you both are also doing Audio, could we talk on IRC some time, to plan some things on howto go on in the future?

Damian Huckle

Fixing the ALSA re-init issue was excellent. Like WiSo I am Windows-only. I believe ALSA has seperate requirements for hardware init and software init which Windows doesn't, so if at all possible that's best handled in it's sink as it's platform-dependent.

Adding an bIsInitialized member variable to the device enum vector might be the way to go for tracking the device's state - especially when "hot-plug" logic is added. At present the closest to device-lost handling is in calls to AddPackets() where a return of INT_MAX triggers a reOpen but there's no device prioritization for graceful fallbacks. This is oft-asked-for but requires user settings which are widely hated.

Please sign in to comment.
Something went wrong with that request. Please try again.