Skip to content
Browse files

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

…rd coded value to a existing define.
  • Loading branch information...
1 parent 92787f3 commit c468689eb8b954b57af84226931c0d9f1dbb666e wsoltys committed
14 xbmc/cores/AudioEngine/Sinks/AESinkDirectSound.cpp
@@ -603,7 +603,7 @@ void CAESinkDirectSound::EnumerateDevicesEx(AEDeviceInfoList &deviceInfoList, bo
if (SUCCEEDED(hr) && varName.blob.cbSize > 0)
WAVEFORMATEX* smpwfxex = (WAVEFORMATEX*)varName.blob.pBlobData;
- deviceInfo.m_channels = layoutsByChCount[std::max(std::min(smpwfxex->nChannels, (WORD) 8), (WORD) 2)];
+ deviceInfo.m_channels = layoutsByChCount[std::max(std::min(smpwfxex->nChannels, (WORD) DS_SPEAKER_COUNT), (WORD) 2)];
deviceInfo.m_sampleRates.push_back(std::min(smpwfxex->nSamplesPerSec, (DWORD) 192000));
@@ -896,3 +896,15 @@ std::string CAESinkDirectSound::GetDefaultDevice()
return strDevName;
+bool CAESinkDirectSound::SoftSuspend()
+ Deinitialize();
+ return true;
+bool CAESinkDirectSound::SoftResume()
+ /* Return false to force re-init by engine */
@fritsch Team Kodi member
fritsch added a note

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 Team Kodi member
wsoltys added a note

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.

@fritsch Team Kodi member
fritsch added a note

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 Team Kodi member
wsoltys added a note

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.

This is correct.

@fritsch Team Kodi member
fritsch added a note

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?

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ return false;
2 xbmc/cores/AudioEngine/Sinks/AESinkDirectSound.h
@@ -43,6 +43,8 @@ class CAESinkDirectSound : public IAESink
virtual double GetCacheTime ();
virtual double GetCacheTotal ();
virtual unsigned int AddPackets (uint8_t *data, unsigned int frames, bool hasAudio);
+ virtual bool SoftSuspend ();
+ virtual bool SoftResume ();
static std::string GetDefaultDevice ();
static void EnumerateDevicesEx (AEDeviceInfoList &deviceInfoList, bool force = false);

0 comments on commit c468689

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