Runtime error when attempting to initialize player in "exclusive_mode"
See original GitHub issueHi,
I am attempting to generate real-time audio with low latency on a Windows 10 system with python 3.7. If I try to set the exclusive_mode
argument to speaker.player()
to True
, mediafoundation.py throws an error at line 92: RuntimeError: invalid argument
Here is a snippet of code that generates the error for me:
speaker = soundcard.default_speaker()
with speaker.player(samplerate=48000, blocksize=1200, exclusive_mode=True) as audioplayer:
pass
The values of samplerate
and blocksize
(and channels
, which I left as default) do not seem to matter here, the error always happens when I set exclusive_mode=True
.
Here is the full error when I run the above snippet in an interactive session:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python\Anaconda3\lib\site-packages\soundcard\mediafoundation.py", line 435, in player
return _Player(self._audio_client(), samplerate, channels, blocksize, False, exclusive_mode)
File "C:\Python\Anaconda3\lib\site-packages\soundcard\mediafoundation.py", line 542, in __init__
_com.check_error(hr)
File "C:\Python\Anaconda3\lib\site-packages\soundcard\mediafoundation.py", line 92, in check_error
raise RuntimeError("invalid argument")
RuntimeError: invalid argument
My PC has Realtek audio:
>>> print(speaker)
<Speaker Speakers (Realtek(R) Audio) (2 channels)>
Thanks! Overall this library seems very helpful and a bit easier to use than pyaudio.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
[FIXED] 'DirectX Failed to Initialize. Please Install the Correct ...
1. How to Fix the “DirectX Failed to Initialize” Error. 2. Update DirectX. 3. Upgrade the DirectX Suite.
Read more >C++ Runtime Error For Windows Media Player 12
Everytime I play a show or music using Windows Media Player, it works fine til the end of the show/song. Then when it...
Read more >[Bug] Cannot launch the game in 'exclusive' mode :: Brigand
But upon trying this I get either nothing and the game doesn't launch at all or I get this error : "Runtime Error...
Read more >Error (51) FMOD_ERR_OUTPUT_INIT, no default playback ...
FMOD_ERR_OUTPUT_INIT is more like a device failed to init. We are seeing this a bit more lately and is most likely USB headset...
Read more >Citrix Fixes and Known Issues – XenApp & XenDesktop ...
Windows Media Player throws an error "An error occured while playing the file" when attempting to play mp4 videos or "Windows Media Player...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can create the pull request at any time if you want to ask for help, just mark is as work-in-progress. I’m afraid I can’t help much at the moment, sorry.
Brilliant! Thank you for investigating this!
So we might be restricted to a pre-set sample rate if we open a device in exclusive mode. Or perhaps we have to change the device’s sample rate, as opposed to the AudioClient’s.