Shareable Flag

By setting the shareable flag for an open request, an application can share an OS/2 multimedia device with other applications. To enable device sharing, the multimedia system posts the MM_MCIPASSDEVICE message with WinPostMsg to the application. The message informs the application the device context is becoming active (MCI_GAINING_USE) or inactive (MCI_LOSING_USE).

After the application processes the MCI_GAINING_USE event notification, it can issue device commands. The device context becomes inactive when the MCI_LOSING_USE event notification is received.

If the application has specified a notify flag on the open, the receipt of an MM_MCINOTIFY message does not mean the device context is active. When MCI_NOTIFY_SUCCESSFUL is received, the commands status, capability, and info can be issued, because the multimedia system allows these commands to be made to inactive instances. If the application issues a command to an inactive instance and the instance must be active to process the command, the multimedia system returns MCIERR_INSTANCE_INACTIVE.

When an application opens a device without setting the shareable flag, the Media Device Manager attempts to acquire the device for the exclusive use of the application. If a device context already exists that was either opened as nonshareable by another application or opened as shareable but then acquired exclusively by another application, the open fails and the application receives the MCIERR_DEVICE_LOCKED error code. The application can subsequently make the device context shareable by issuing an MCI_RELEASEDEVICE message.

See Device Sharing By Applications for more detailed information on device sharing.


[Back: Default and Specific Devices]
[Next: Device Alias]