Skip to content

Windows player can reuse aliases #20

@GaMeNu

Description

@GaMeNu

I think I might've found an issue
I had this code:

def play_file(file: str, playback: bool):
    global playback_device

    path = os.path.join(os.getcwd(), file)

    if not (os.path.exists(path)):
        print(f'No file found at path \'{path}\'')
        print('Cannot play file.')
        return

    mixer.music.load(file)
    mixer.music.play()

    if playback:
        if playback_device is not None:
            playback_device.close()
        try:
            playback_device = AudioPlayer(file)
            playback_device.play()
        except audioplayer.abstractaudioplayer.AudioPlayerError as e:
            print('Failed to start playback')
            print(e)

When I called the function multiple times I got this error:
Failed to play "...\out.wav", code 289
(I modified the error message a bit to also show the error code)
I did some digging around and the error is apparently because there can be 2 aliases which are the same...?
I don't really know how that works but the problem seems to be with this code:

    def __init__(self, filename):
        super().__init__(filename)
        self._alias = "A{}".format(id(self))

and the fact id() can return the same values if the lifespans aren't overlapping or smth?

I haven't managed to reproduce the error, sorry
And also this is my first time reporting an issue on GitHub so sorry if I did something bad or wrong

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions