Far-Se / win32audio

Flutter package to handle windows audio devices. Also extracts native icon to bytes in dart
MIT License
16 stars 5 forks source link

RangeError (index): Invalid value: Only valid value is 0: 1 when using "VB-Audio Virtual Cable" #3

Closed MindStudioOfficial closed 2 years ago

MindStudioOfficial commented 2 years ago

I am getting an errror RangeError (index): Invalid value: Only valid value is 0: 1

on line 101 of win32audio.dart https://github.com/Far-Se/win32audio/blob/6e0b532cae1e6d54bc40ffb3089b1caefe6eb95a/lib/win32audio.dart#L101

When the audio device "CABLE Input (VB-Audio Virtual Cable)" is present on a system. This virtual audio driver can be downloaded here https://vb-audio.com/Cable/.

It seem like this audio device uses a custom icon that maybe fails to load or something similar.

grafik

anyway, this audio device causes the List<String> iconData in the enumDevices() method to be of length 1 instead of 2 and thus causes this RangeError, which currently causes my application to not start up correctly.

When uninstalling this specific driver the error disappears.

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: RangeError (index): Invalid value: Only valid value is 0: 1
#0      List.[] (dart:core-patch/growable_array.dart:264:36)
#1      Audio.enumDevices (package:win32audio/win32audio.dart:101:46)
<asynchronous suspension>

So far I've encountered this error only when this specific audio driver is present. And users who also reported this exception also had this audio driver installed. For me it is sadly not a workaround to simply uninstall this driver since many of my users depend on it because it is a big part of their workflow.

Far-Se commented 2 years ago

I've changed the code and updated git & pub.dev package

      if (iconData.length == 2) {
        audioDevice.iconPath = iconData[0];
        audioDevice.iconID = int.tryParse(iconData[1]) ?? -1;
      } else {
        audioDevice.iconPath = map[key]["iconInfo"];
        audioDevice.iconID = -1;
      }
MindStudioOfficial commented 2 years ago

Thanks a lot, i will take a look at it :D

MindStudioOfficial commented 2 years ago

works, thanks!