The Ultimedia Services for AIX object library supports the sharing of the audio device using the UMS programming interface and a program called the Shared Server. The sharing is performed in such a way as to not affect the application interface or even cause the application to re-compile. Ultimedia Services audio applications read the UMS configuration file, .UMS_config, to see if the Shared Server should be used.
To use the Shared Server, you must program the audio application to use the UMS AudioDevice meta class. The standard UMS applets all use this meta class by default, so if you only use UMS applications you do not have to modify the UMS configuration file. The Shared Server, when started, controls the audio device. All applications that participate in sharing attach through the Shared Server to gain control of the audio resources. All other applications receive an error that the audio device is busy.
The Shared Server serves a couple of useful purposes. First, it arbitrates between applications for control of the audio device. The Shared Server manages this by having you assign priorities to audio aliases (and applications) through the configuration file. The current mode supported is preemption. If an audio application, such as speech, starts and uses the record device for a long time, you can start another application at a higher priority that takes control of the record device (this is preemption). The new application uses the device until it gives up control. At this point, the device is returned to the first application and its state is restored. The old application can now use the audio device again.
Secondly, the Shared Server has automatic rate control. One of the limitations of the audio device is that record and play have to be performed at the same rate. The Shared Server automatically synchronizes the play rate to the existing record rate using digital filters. You cannot change the rate yourself--the application controls it.
To learn more about the Shared Server, see:
To start the Shared Server, you need to add some new entries in the UMS configuration file (.UMS_config). The entries can be added either to the default Audio alias stanza or to a new alias stanza. Each application may have its own alias. The alias is later used as input to the make_by_alias method when the audio object is constructed.
The key entry is Shareable_Device. If this entry is set to true, the Shared Server starts. If the entry is missing or set to false, the server does not start. Another important entry is Record_Share_Priority, which is an integer between 0 and 100 inclusive, where 100 is the highest priority.
Here is a sample configuration entry to start the Shared Server using the Audio alias:
Audio: device_path "/dev/paud0" CLASS_UMSAudioDevice "UMSBAUDDevice" Shareable_Device "true" Record_Share_Priority "50"
The Shared Server starts automatically when you use the UMS applets and exits after the last UMS audio application exits. The Shared Server can also be started from the command line.
To start the Shared Server from the command line, type:
shserver audio_dev_name audio_object_class_name startup_flag [1]
You do not need to explicitly exit from the Shared Server if you are using UMS applets. However, you might need to stop the Shared Server from running if you start the server from the command line or if an error occurs.
To stop the Shared Server, type:
ps -ef | grep shsherver
Take note of the process identification (PID) number. Then type:
kill -9 process_id
where process_id is the PID number.
If you have a problem starting the Shared Server, a file named s.UMSshserv_* might have been left in the /tmp directory by another user (i.e., root). If the new Shared Server was not able to remove this file, you need to remove it and restart the server again.