Reload last used mixer on moc start / set default mixer

Hello all,
I depend a 100 % on software mixer because no other is able to change volume.
This is on a Soundblaster Live! Player , Alsa mixer channels fail to set any master volume
so i suspect the module to be the problem here , I can only alter the headphones input and auxilliary
or wave directly. ( PCM = headphones , Master = no effect )

This is the background story. Now when software mixing was patched into moc i could finally use it.

But what's a real drawback is that i have to switch to console, load moc tab and select software mixing everytime I start the system/moc .

If I don't manually select software mixer again i cannot alter volume with for instance "mocp -v -1" which I have on shortcuts.

Everytime master mixer is loaded as default which is useless on my setup and i guess a thousand others.

Now i have only little C knowledge but i tried to find any line where the order of the mixers is set up so i could write a patch that Software is just plain auto loaded. Well that was without success.

Could someone give me a hint here on how to either alter the config to load software mixer by default ( no success either ), or what to patch where to set software mixer as deafault.

Thanks very much !

Hi,

You have a very valid point here IMHO.
I think the most clean approach would be the following:

1. Add a new command line switch to change to a named mixer, e.g.
'mocp -b soft' to change to the mixer named 'soft'
This should be easy to implement; my suggestion:
1.1. Add the command line switch
1.2. Add a function that does the following (see the volume adjustment option for an example):
- get the current mixer name (CMD_GET_MIXER_NAME, see update_mixer_name in interface.c)
- if the mixer name matches the specified mixer you are done
- else send the CMD_TOGGLE_MIXER_CHANNEL and repeat the check
Important thing: there might be no matching channel, moc handles only three mixers
If possible, return with error code if no mixer is found.
Alternative:
Add command line switches to return the current mixer name and to toggle the mixer channel.
Then changing to a named mixer can be done with external scripts.

This should be codeable in half an hour I think. I would advice case-insensitive name matching.

If this is implemented, shortcuts should be updated to first set the mixer, then the value.

As an alternative and to actually reply to your question - :-) -,
setting a default mixer on the server side should also be easy:
1. Add a new option to save the last mixer name (options.c).
2. In audio_initialize (audio.c), check if that option is set
2.1 if yes, find the file containing the mixer name (see softmixer.c for example)
2.2 if not found, do nothing (probably first run with option on)
2.3 Else read the mixer name (audio_get_mixer_channel_name) and toggle the mixer channel (audio_toggle_mixer_channel) until the name matches. (again, check for not found).
2.4 on audio_exit write the current mixer name to the file you search for in 2.1 (again, see softmixer.c for example).

This should also be easy to code, but not as flexible as a command line toggle option.

If you need testers, I'll volunteer.

Good luck with coding!

Yikes i thought i'd get an email if there would be an answer ...
I shall try this i hope the volume adjustmend is helping me , will need some kinda example
Thx.

Find my patch here :

http://pastebin.com/f18b7c7c5

It's my first patch where the code is only from me so
expect "strange" C-style and ERRORS !

I hope the patch itself is functional it worked on the latest svn trunk ( 31082009) for me.

New Features:

mocp -X NAME
mocp --mixer NAME

Where NAME is the name of the mixer you would like to activate , in my case "Soft" ( "soft" works too ).
Usage : I start `mocp` and then run `mocp -X Soft`
Known Bugs : Thou shall be able to start mocp with only `mocp -X Soft` , in future days =)

Regards,
Steffen

Is your patch compatible with 2.5.1?

The bad news: No it isn't.

The good news: I have updated user tuxfusion's patch for both MOC 2.5.1 and 2.6-alpha2. They apply and build cleanly on their respective releases. They have not been fully tested, so if you find any bugs please report them.

Setting --mixer option works. Seems there is a bug when setting -X option.

~ $ mocp -S && mocp -X soft && mocp -x Running the server... Trying ALSA... ~ $ mocp -S && mocp --mixer soft && mocp -x Running the server... Trying ALSA... New mixer: Soft

The code path for both alternatives for the option is the same. I can see, however, that the patch does not handle the case where the softmixer is turned off. In that case the name is changed from 'soft' to 's.off'. That the user should have to know the state of the softmixer to choose the right name is obviously not ideal and I shall change that.

But does a change in the softmixer state account for what you see?

Softmixer is turned on

~ $ cat ~/.moc/softmixer Active: 1 Amplification: 100 Value: 60 Mono: 0 ~ $ mocp --mixer master New mixer: Master ~ $ mocp --mixer soft New mixer: Soft ~ $ mocp -X soft ~ $ mocp -X master ~ $ mocp --mixer master New mixer: Master ~ $ mocp --mixer soft New mixer: Soft

I notice that in the '-X' case there is no message at all. All code paths through the implementing function produce either success or failure messages. Therefore, I have to conclude that you are not actually getting into that function when the short option is used.

The only thing I can think of at this point is that you have overridden the '-X' option in your ~/.popt file to do something else.