@@ -19,9 +19,49 @@ def __init__(self, path):
1919 self .sources = []
2020 self .sounds = {}
2121
22- self .set_audio_device ('OpenAL Soft on Headphones (Oculus Virtual Audio Device)' )
22+ self .set_audio_device (self . find_vr_audio_device () )
2323
2424 self .head_pos = glm .vec3 (0 )
25+
26+ def find_vr_audio_device (self ):
27+ """Find VR headset audio device if available"""
28+ all_devices = []
29+
30+ # Try ALC_ALL_DEVICES_SPECIFIER first (OpenAL 1.1+) - this shows actual hardware
31+ try :
32+ ALC_ALL_DEVICES_SPECIFIER = 0x1013
33+ devices_string = alcGetString (None , ALC_ALL_DEVICES_SPECIFIER )
34+ if devices_string :
35+ devices = devices_string .decode ('utf-8' ).split ('\x00 ' )
36+ all_devices = [d for d in devices if d ]
37+ print (f"[AUDIO] Available devices via ALC_ALL_DEVICES_SPECIFIER ({ len (all_devices )} ): { all_devices } " )
38+ except Exception as e :
39+ print (f"[AUDIO] ALC_ALL_DEVICES_SPECIFIER not available: { e } " )
40+
41+ # Fall back to ALC_DEVICE_SPECIFIER if needed
42+ if not all_devices :
43+ devices_string = alcGetString (None , ALC_DEVICE_SPECIFIER )
44+ if devices_string :
45+ devices = devices_string .decode ('utf-8' ).split ('\x00 ' )
46+ all_devices = [d for d in devices if d ]
47+ print (f"[AUDIO] Available devices via ALC_DEVICE_SPECIFIER ({ len (all_devices )} ): { all_devices } " )
48+
49+ if all_devices :
50+ # Look for common VR audio device names
51+ vr_keywords = ['oculus' , 'virtual audio' , 'vr' , 'valve' , 'index' , 'vive' , 'rift' , 'quest' , 'meta' , 'steam link' ]
52+ for device in all_devices :
53+ if any (keyword in device .lower () for keyword in vr_keywords ):
54+ print (f"[AUDIO] Found VR audio device: { device } " )
55+ return device
56+
57+ # Fall back to default device
58+ default_device = alcGetString (None , ALC_DEFAULT_DEVICE_SPECIFIER )
59+ if default_device :
60+ default_device = default_device .decode ('utf-8' )
61+ print (f"[AUDIO] Using default audio device: { default_device } " )
62+ return default_device
63+
64+ return None
2565
2666 def load_sounds (self ):
2767 for sound in os .listdir (self .path ):
0 commit comments