![]() |
![]() |
![]() |
![]() |
Media changer devices — essentially CD and DVD changers — differ from other media devices because they contain and change removable mediastores.
A removable mediastore is a physical storage medium, such as a CD or DVD, with one of more media files that can be synchronized and played. Media changer devices can load and unload these mediastores as required, changing their states from “unavailable” to “available” to “active”.
This chapter describes how these devices and their mediastores can be represented to MediaFS, and how state changes on these devices should be communicated to MediaFS:
MediaFS uses extensions to offer a common representation of devices with multiple mediastores — devices such as CD and DVD changers. It represents a media changer device as a single changer container. This changer container includes multiple slot items. Each slot represents one mediastore (such as a CD or a DVD), and is described by a separate MediaFS instance.
For example, the following illustration represents the hierarchy of one media changer device with three slots, each slot described by a MediaFS instance:
MediaFS changer device and mediastore hierarchy representation
A slot represents a single mediastore. Each slot has a MediaFS instance, which adheres to the MediaFS specifications for media device representation. That is, each slot has a MediaFS instance with its own info.xml file, control file, optional playback directory, dev symbolic link, and optional current symbolic link.
MediaFS info.xml files for changer devices and slots differ from info.xml files for other media devices in order to accurately represent the devices as containers for the mediastores, and the mediastores as dependent on a device. That is, the info.xml files for changer devices and slots must indicate that the changer device can hold one, many or no mediastores, and that these mediastores can only be accessed inside a changer.
The table below lists the elements required in an info.xml file use to describe media changer devices and slots:
XML Key | Required? | Description |
---|---|---|
<media> | Yes | Root XML key for the media |
<media>/<driver> | Yes | Description of the device as a MediaFS changer device |
<media>/<name> | Yes | Name of the mediastore |
<media>/<serial> | Yes | Device serial number |
<media>/<slot> | Yes | Slot number for the mediastore |
<media>/<type> | Yes | Description of the mediastore type |
The keys listed below are required in the info.xml file for a media changer device slot:
The example below shows an info.xml file for a MediaFS slot representing a mediastore changer device:
<?xml version="1.0" standalone="yes"?> <info> <media> <device>mediafs-changer</device> <slot>1</slot> <serial>280a1752</serial> <name>MIXED</name> <type>FS</type> </media> <device> <driver>mediafs-changer</driver> <catagory>media</catagory> </device> </info>
For more information about the info.xml file, see “The info.xml file” in the chapter MediaFS Entities.
MediaFS expects a slot to have one of the following states:
For example, if a CD changer has six possible mediastore locations, it can be represented by a changer with any one of slots 0 to 5. If a mediastore is loaded into slot 0, MediaFS represents it as shown in the figure below:
MediaFS changer representation of a mediastore in slot 0
If the mediastore is ejected from the changer, MediaFS removes its slot representation:
MediaFS changer representation of device with no available mediastores
For files on a mediastore to be synchronized or played, the slot representing the mediastore in MediaFS must by marked active as well as available. That is, the device controller must use the slot's control file to inform MediaFS not only that the slot is present, but that a readable disc is physically loaded in the changer and is ready to be read. Thus, only one changer slot can be active at any one time.
To get the current changer state from MediaFs, the client application or the device controller must issue the DCMD_CAM_CDROM_MECHANISM_STATUS device control message to each changer slot's control file, as appropriate.
DCMD_CAM_CDROM_MECHANISM_STATUS is a standard control defined in the sys/cdrom.h header file. The example below shows one way to implement the DCMD_CAM_CDROM_MECHANISM_STATUS device control command:
#define CDROM_MSH_CHANGER_SET_CURRENT_SLOT( cdrom_status, slot )\ cdrom_status.mech_state &= ~0x07 ; \ cdrom_status.changer_state_slot &= ~0x1F ; \ cdrom_status.mech_state |= (slot >> 5) ; \ cdrom_status.changer_state_slot |= (slot & 0x1F) ; struct _cdrom_mechanism_status cdrom_status ; struct _cdrom_exchange cdrom_exchange ; switch(changer.status) { case STATUS_EMPTY: cdrom_status.hdr.mech_state = CDROM_MSH_MECHANISM_IDLE ; break; case STATUS_RETRACT: case STATUS_LOAD: cdrom_status.hdr.changer_state_slot = CDROM_MSH_CHANGER_LOADING ; break; case STATUS_UNLOAD: cdrom_status.hdr.changer_state_slot = CDROM_MSH_CHANGER_UNLOADING ; break; default: cdrom_status.hdr.changer_state_slot = CDROM_MSH_CHANGER_READY ; break; } cdrom_status.hdr.num_slots_avail = changer.num_slots ; cdrom_status.hdr.slot_table_len = changer.num_slots ; for( index=0; index < changer.num_slots; index++ ) { if(changer.slotInfo[index].status == DISCIN) { cdrom_status.str[index].flags |= CDROM_STR_DISC_PRESENT; } } CDROM_MSH_CHANGER_SET_CURRENT_SLOT( cdrom_status.hdr, changer.active_slot);
![]() |
![]() |
![]() |
![]() |