audio_output_enumerate_devices() throws exception

This forum is about all development around libVLC.
User avatar
joba1
New Cone
New Cone
Posts: 6
Joined: 09 Mar 2016 00:42

audio_output_enumerate_devices() throws exception

Postby joba1 » 30 Apr 2016 15:54

This method does not work for me:

Code: Select all

instance.audio_output_enumerate_devices()
Traceback (most recent call last):
File "C:\Users\joba1\workspace\chordsplay\chordsplay.py", line 165, in main
player = ChordsPlay.play.Play(gui, db)
File "C:\Users\joba1\workspace\chordsplay\ChordsPlay\play.py", line 23, in __init__
devs = self.instance.audio_output_enumerate_devices()
File "C:\Program Files (x86)\Python35-32\lib\site-packages\vlc.py", line 1627, in audio_output_enumerate_devices
for d in range(libvlc_audio_output_device_count (self, i.name))]
NameError: name 'libvlc_audio_output_device_count' is not defined
I wrote my own method for this, but I am not sure it is fully equivalent (obviously cant't compare :) )

Code: Select all

def getAudioOut(self): """Enumerate the defined audio output devices. @return: list of dicts {name:, description:, devices:} with devices as list of dicts {device:, description:} """ result = [] mods = self.instance.audio_output_list_get() if mods: mod = mods while mod: mod = mod.contents # log.info("init: aolg: contents {}".format(dir(mod))) devices = [] devs = self.instance.audio_output_device_list_get(mod.name) if devs: dev = devs while dev: dev = dev.contents # log.info("init: aodlg: contents {}".format(dir(dev))) devices.append({'device': dev.device, 'description': vlc.bytes_to_str(dev.description)}) dev = dev.next vlc.libvlc_audio_output_device_list_release(devs) result.append({'name': mod.name, 'description': vlc.bytes_to_str(mod.description), 'devices': devices}) mod = mod.next vlc.libvlc_audio_output_list_release(mods) return result
Should I be able to use result like this to change audio output device?

Code: Select all

mindex = some valid index in the modules list dindex = some valid index in the devices list module = result[mindex]["name"] device = result[mindex]["devices"][dindex]["device"] player.audio_output_set(module) player.audio_output_device_set(module, device)
I ask, because I get very different results. Sometimes it works, sometimes it doesn't.
E.g. If the module is alsa, it always ends playing on the internal notebook speakers, no matter which device I choose (including HDMI). But if I select pulseaudio module, it always plays on the HDMI device. Cant' figure out a pattern and would like to rule out it is the way I enumerate the devices.

Full code is here: http://banzhaf.chickenkiller.com/hg/cho ... ay/play.py

Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 28 guests