Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Featurerequest for a Method AudioOutput.release() #51

Open
litolff opened this issue Jul 27, 2015 · 0 comments
Open

Featurerequest for a Method AudioOutput.release() #51

litolff opened this issue Jul 27, 2015 · 0 comments

Comments

@litolff
Copy link

litolff commented Jul 27, 2015

please provide a Method AudioOutput.release()

short story: i want to play 16bit/2.0 24bit/5.0 and 24bit/5.1 flac-files all in the same playlist, without restarting my application whenever channelcount is changing.

use-case:
there are situations alsa has to be reconfigured by altering .asoundrc.
Those changes only take effect when alsa-lib has been released and reloaded.
For now it's necessary to stop the whole application(and python-interpreter) which is using audiotools to force ALSAAudio_dealloc in alsa.c being called.
I tried to implement this by myself but unfortunately without success.

my special use-case for reconfiguring alsa:
instead of writing prosa, here my different .asoundrc
Switching between them with python-code works reliable but changes only take effect after restarting my whole app.

for stereo:
pcm.!default {
type hw
card 0
device 8
}

for 5.0
pcm.!default = {
type= route
slave {
pcm = "hw:0,8"
channels 6
}
ttable {
0.0=1
1.1=1
2.4=1
3.2=1
4.3=1
}
}

for 5.1
pcm.!default = {
type= route
slave {
pcm = "hw:0,8"
channels 6
}
ttable {
0.0=1
1.1=1
2.4=1
3.5=1
4.2=1
5.3=1
}
}

PS: besides using audiotools.player.Player i also tried your more low-level api, to play 16bit/2.0 24bit/5.0 and 24bit/5.1 flac-files all in the same playlist
The code below did the trick, but for audiotools.player.Player i did not find any other solution than the one in the requested feature above (switching .asoundrc).

MASK_20 = ChannelMask.from_fields(front_left=True,front_right=True)
MASK_50 = ChannelMask.from_fields(front_left=True,front_right=True,front_center=True,side_left=True,side_right=True)
MASK_51 = ChannelMask.from_fields(front_left=True,front_right=True,front_center=True,side_left=True,side_right=True,low_frequency=True)

ORDER = {2:[0,1], 5:[1,3,4,2,0,0], 6:[1,4,5,2,3,0]}
MASK = {2:MASK_20, 5:MASK_51, 6:MASK_51}

nChannels = gotFromDatabase(file)
mask = MASK[nChannels]
order = ORDER[nChannels]
flacReader = FlacAudio(uri).to_pcm()
reorderedReader = at.ReorderedPCMReader(flacReader, order, mask)
pcmReader = at.BufferedPCMReader(reorderedReader)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant