Herramientas de usuario

Herramientas del sitio


notas:programacion:the_linux_cdrom_interface

Diferencias

Muestra las diferencias entre dos versiones de la página.

Enlace a la vista de comparación

notas:programacion:the_linux_cdrom_interface [2011/06/10 12:41] – creado cayunotas:programacion:the_linux_cdrom_interface [2011/06/10 12:41] (actual) cayu
Línea 19: Línea 19:
 Almost all commands involved with controlling a CDROM device are used in conjunction with ioctl. The commands and definitions for accessing the CD drive can be found in ///usr/include/linux/cdrom.h//. For example, the program eject.c below will eject the drive platter. It firstly opens up the controlling device (in this case ///dev/cdrom//, which will usually be a symbolic link to a real device, such as ///dev/hdc//, for IDE devices) and then uses ioctl to send the **CDROMEJECT** command. Almost all commands involved with controlling a CDROM device are used in conjunction with ioctl. The commands and definitions for accessing the CD drive can be found in ///usr/include/linux/cdrom.h//. For example, the program eject.c below will eject the drive platter. It firstly opens up the controlling device (in this case ///dev/cdrom//, which will usually be a symbolic link to a real device, such as ///dev/hdc//, for IDE devices) and then uses ioctl to send the **CDROMEJECT** command.
  
-> <code> +> <code c>
- +
 /* eject.c /* eject.c
 ** Copyright Paul Dwerryhouse, 1997-2004 ** Copyright Paul Dwerryhouse, 1997-2004
Línea 59: Línea 58:
 The volume control commands revolve around the struct cdrom_volctrl structure, listed below. This structure is used when setting the output volume, when playing audio CDs and also when reading what the values are currently set to. For a stereo CD player, only channels 0 and 1 are used. The values range from zero (no sound) to 255 (loudest possible setting) and the relevent ioctl commands are CDROMVOLCTRL and CDROMVOLREAD for setting and reading the volume, respectively. The volume control commands revolve around the struct cdrom_volctrl structure, listed below. This structure is used when setting the output volume, when playing audio CDs and also when reading what the values are currently set to. For a stereo CD player, only channels 0 and 1 are used. The values range from zero (no sound) to 255 (loudest possible setting) and the relevent ioctl commands are CDROMVOLCTRL and CDROMVOLREAD for setting and reading the volume, respectively.
  
-> <code> +> <code c>
- +
 struct cdrom_volctrl struct cdrom_volctrl
 { {
Línea 72: Línea 70:
 For example, in order to read the values that are currently set: For example, in order to read the values that are currently set:
  
-> <code> +> <code c>
- +
 #define CDDEVICE "/dev/cdrom" #define CDDEVICE "/dev/cdrom"
    
Línea 91: Línea 88:
 Conversely, if you wish to set the volume of each channel of the CD player: Conversely, if you wish to set the volume of each channel of the CD player:
  
-> <code> +> <code c>
- +
 #define CDDEVICE "/dev/cdrom" #define CDDEVICE "/dev/cdrom"
    
Línea 113: Línea 109:
 There are three structures directly associated with CD track positioning: struct cdrom_tochdr, struct cdrom_ti and struct cdrom_msf. The first, when used with the CDROMREADTOCHDR function, returns the track numbers of the initial and the final tracks on the CD in the drive. The second, allows a particular range of tracks to be played, including the ability to start and stop playing a track from a particular point within a track, when used with CDROMPLAYTRKIND. The third structure is similar, but allows the programmer to specify the position of the CD in minutes, seconds and frames and is used with the CDROMPLAYMSF function (there are CD_FRAMES frames to a second, and CD_FRAMES is defined as 75 at the top of /usr/include/linux/cdrom.h). There are three structures directly associated with CD track positioning: struct cdrom_tochdr, struct cdrom_ti and struct cdrom_msf. The first, when used with the CDROMREADTOCHDR function, returns the track numbers of the initial and the final tracks on the CD in the drive. The second, allows a particular range of tracks to be played, including the ability to start and stop playing a track from a particular point within a track, when used with CDROMPLAYTRKIND. The third structure is similar, but allows the programmer to specify the position of the CD in minutes, seconds and frames and is used with the CDROMPLAYMSF function (there are CD_FRAMES frames to a second, and CD_FRAMES is defined as 75 at the top of /usr/include/linux/cdrom.h).
  
-> <code> +> <code c>
- +
 struct cdrom_tochdr struct cdrom_tochdr
 { {
Línea 142: Línea 137:
 For example, should you wish to play any CD from start to finish, you could use the following: For example, should you wish to play any CD from start to finish, you could use the following:
  
-> <code> +> <code c>
- +
 #define CDDEVICE "/dev/cdrom" #define CDDEVICE "/dev/cdrom"
    
Línea 168: Línea 162:
 Pausing, resuming, stopping and ejecting are done with ioctl calls using CDROMPAUSE, CDROMRESUME, CDROMSTOP and CDROMEJECT respectively: Pausing, resuming, stopping and ejecting are done with ioctl calls using CDROMPAUSE, CDROMRESUME, CDROMSTOP and CDROMEJECT respectively:
  
-> <code> +> <code c>
- +
 ioctl(cdrom,CDROMPAUSE,0);    // Pause CD play. ioctl(cdrom,CDROMPAUSE,0);    // Pause CD play.
 ioctl(cdrom,CDROMRESUME,0);   // Resume CD play from where it was paused. ioctl(cdrom,CDROMRESUME,0);   // Resume CD play from where it was paused.
notas/programacion/the_linux_cdrom_interface.1307709665.txt.gz · Última modificación: 2011/06/10 12:41 por cayu