Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.cdrom

Class EM_CDROM


Direct ancestors

EM_CONSTANTS, EM_SHARED_SUBSYSTEMS, EM_SHARED_ERROR_HANDLER, SDL_CD_STRUCT_EXTERNAL, SDL_CDROM_FUNCTIONS_EXTERNAL, EWG_STRUCT

Creation

Features

Invariants

indexing

description

Class for wrapping C SDL_CD struct. This class represents a cdrom drive.

date

$Date: 2005/10/23 16:36:28 $

revision

$Revision: 1.9 $

class

EM_CDROM

inherit

EWG_STRUCT

create

make_default

-- Initialize default CD-Rom device 0

make_for_device (a_device: INTEGER)

-- Initialize CD-Rom device a_device

require
cdrom_subsystem_enbaled: cdrom_subsystem.is_enabled
valid_device: a_device >= 0 and a_device < cdrom_subsystem.count
ensure
device_set: device = a_device
device_registered: cdrom_subsystem.devices.has (current)

feature {ANY} -- Access

exists: BOOLEAN

-- Does item point to a valid C struct ?

-- (From EWG_STRUCT)

is_shared: BOOLEAN

-- Is the contents of item referenced by other C or Eiffel code?
-- If is_shared is True then when the current object will be
-- collected by the garbage collector, the wrapped struct will
-- also be freed.
-- This is a good idea, only if you can be sure that when the
-- Eiffel object gets collected, the C side does not have a reference
-- to the wrapped struct anymore.

-- (From EWG_STRUCT)

require
exists: exists
item: POINTER

-- Pointer to the wrapped struct

-- (From EWG_STRUCT)

require
exists: exists
ensure
item_not_default_pointer: Result /= Default_pointer

feature -- Device handler handling

close

-- Here free the device handler
-- Automatically called by the cdrom_subsystem if called disable

require
valid_cdrom_handler: exists implies valid_handler
ensure
device_unregistered: not cdrom_subsystem.devices.has (current)

feature -- CDRom Access

eject

-- eject the given cdrom even if it has no cd in drive
-- Be warned: this procedure does not work on every hardware

require
valid_cdrom_handler: exists implies valid_handler
name: STRING

-- return the cdrom device identifier
-- this argument is system dependent

-- go to next track an play it
-- if last track reached, replay

require
valid_cdrom_handler: exists implies valid_handler
cd_in_drive: has_cd_in_drive
is_playing: is_playing
ensure
correct_track: (current_track = old current_track +1) or current_track = count
pause

-- pause playback

require
valid_cdrom_handler: exists implies valid_handler
cd_in_drive: has_cd_in_drive
not_paused: not is_paused
ensure
cd_status_set: is_paused
play_cd

-- play the entire cd

require
valid_cdrom_handler: exists implies valid_handler
cd_in_drive: has_cd_in_drive
play_cd_from_track (a_track: INTEGER)

-- play the entire cd beginning from track a_track

require
valid_cdrom_handler: exists implies valid_handler
cd_in_drive: has_cd_in_drive
valid_track: 0 < a_track and a_track < count
play_track (a_track: INTEGER)

-- play only track a_track

require
valid_cdrom_handler: exists implies valid_handler
cd_in_drive: has_cd_in_drive
valid_track: 0 < a_track and a_track < count

-- go to previous track and play it
-- if first track reached, replay

require
valid_cdrom_handler: exists implies valid_handler
cd_in_drive: has_cd_in_drive
is_playing: is_playing
ensure
correct_track: (current_track = old current_track -1) or current_track = 1
resume

-- resume playback

require
valid_cdrom_handler: exists implies valid_handler
cd_in_drive: has_cd_in_drive
is_paused: is_paused
ensure
cd_status_set: not is_paused
stop

-- stop playback

require
valid_cdrom_handler: exists implies valid_handler
cd_in_drive: has_cd_in_drive
ensure
cd_status_set: is_stopped

feature -- Properties

count: INTEGER

-- how many tracks are on the cd

require
valid_cdrom_handler: exists implies valid_handler
ensure
count_correct: result = get_numtracks_external (item)
current_time: INTEGER

-- gives the current playback time, from the beginning

require
valid_cdrom_handler: exists implies valid_handler
ensure
current_time_correct: result = get_cur_frame_external (item) // Em_cdrom_fps
current_time_string: STRING

-- return an human readable time string (hh:mm:ss)

require
valid_cdrom_handler: exists implies valid_handler
current_track: INTEGER

-- give the current played track, if any

require
valid_cdrom_handler: exists implies valid_handler
ensure
current_track_correct: result = get_cur_track_external (item)
current_track_length: INTEGER

-- gives the length of the current track

current_track_length_string: STRING

-- return an human readable length string (hh:mm:ss)

device: INTEGER

-- Device indentifier
-- 0 is the default device

device_id: INTEGER

-- returns the private drive identifier

require
valid_cdrom_handler: exists implies valid_handler
ensure
device_id_correct: result = get_id_external (item)
length: INTEGER

-- length of all audio tracks

require
valid_cdrom_handler: exists implies valid_handler
length_string: STRING

-- return an human readable length string (hh:mm:ss)

require
valid_cdrom_handler: exists implies valid_handler
tracks: DS_LINKED_LIST [EM_CDROM_TRACK]

-- result is a linked list containing all tracks
-- sorted from 1 .. count_track

require
valid_cdrom_handler: exists implies valid_handler
ensure
result_not_void: result /= void

feature -- Cdrom status information

has_cd_in_drive: BOOLEAN

-- indicates if the drive has an cd in it and has no errors

require
valid_cdrom_handler: exists implies valid_handler
is_empty: BOOLEAN

-- indicates if the drive is empty

require
valid_cdrom_handler: exists implies valid_handler
is_erroneous: BOOLEAN

-- indicates if the drive has an error

require
valid_cdrom_handler: exists implies valid_handler
is_paused: BOOLEAN

-- indicates if the drive is paused

require
valid_cdrom_handler: exists implies valid_handler
is_playing: BOOLEAN

-- indicates if the drive is currently playing a cd

require
valid_cdrom_handler: exists implies valid_handler
is_stopped: BOOLEAN

-- indicates if the drive is stopped

require
valid_cdrom_handler: exists implies valid_handler

feature -- Additional cdrom structure information

has_audio_track: BOOLEAN

-- check if this cd drive has an audio track

require
cd_in_drive: has_cd_in_drive
has_data_track: BOOLEAN

-- check if this cd drive has a data track

require
cd_in_drive: has_cd_in_drive

feature -- Cdrom subsystem flags

valid_handler: BOOLEAN

-- Indicates if this CDRom handler (current) is valid
-- An invalid handler can be the result of following code
-- create instance of EM_CDROM
-- cdrom_subsystem.disable <-- from here the handler is invalid and can cause an segmentation fault
--
-- cdrom_subsystem.enable

invariant

cdrom_subsystem_enabled: cdrom_subsystem.is_enabled

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

-- From EWG_STRUCT
managed_data_not_void: managed_data /= Void
managed_capacity_equals_sizeof: exists implies managed_data.capacity = sizeof

end