rb_cdio 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. data/ChangeLog.txt +17 -2
  2. data/VERSION +1 -1
  3. data/doc/classes/CdIo.html +19 -31
  4. data/doc/classes/CdIo.src/M000001.html +1 -1
  5. data/doc/classes/CdIo.src/M000002.html +1 -1
  6. data/doc/classes/CdIo.src/M000003.html +1 -1
  7. data/doc/classes/CdIo.src/M000004.html +1 -1
  8. data/doc/classes/CdIo.src/M000005.html +1 -1
  9. data/doc/classes/CdIo.src/M000006.html +1 -1
  10. data/doc/classes/CdIo.src/M000007.html +1 -1
  11. data/doc/classes/CdIo.src/M000008.html +1 -1
  12. data/doc/classes/CdIo/Cd.html +51 -51
  13. data/doc/classes/CdIo/Cd.src/{M000011.html → M000020.html} +1 -1
  14. data/doc/classes/CdIo/Cd.src/M000021.html +3 -3
  15. data/doc/classes/CdIo/Cd.src/M000022.html +3 -3
  16. data/doc/classes/CdIo/Cd.src/M000023.html +3 -3
  17. data/doc/classes/CdIo/Cd.src/M000024.html +3 -3
  18. data/doc/classes/CdIo/Cd.src/M000025.html +3 -3
  19. data/doc/classes/CdIo/Cd.src/M000026.html +3 -3
  20. data/doc/classes/CdIo/Cd.src/M000027.html +3 -3
  21. data/doc/classes/CdIo/Cd.src/M000028.html +3 -3
  22. data/doc/classes/CdIo/Cd.src/M000029.html +3 -3
  23. data/doc/classes/CdIo/Cd.src/M000030.html +3 -3
  24. data/doc/classes/CdIo/Cd.src/M000031.html +3 -3
  25. data/doc/classes/CdIo/Cd.src/M000032.html +3 -3
  26. data/doc/classes/CdIo/Cd.src/M000033.html +3 -3
  27. data/doc/classes/CdIo/Cd.src/M000034.html +3 -3
  28. data/doc/classes/CdIo/Cd.src/M000035.html +3 -3
  29. data/doc/classes/CdIo/Cdda.html +428 -0
  30. data/doc/classes/CdIo/{Cd.src/M000016.html → Cdda.src/M000009.html} +3 -3
  31. data/doc/classes/CdIo/{Cd.src/M000013.html → Cdda.src/M000010.html} +3 -3
  32. data/doc/classes/CdIo/{Cd.src/M000036.html → Cdda.src/M000011.html} +3 -3
  33. data/doc/classes/CdIo/{Cd.src/M000014.html → Cdda.src/M000012.html} +3 -3
  34. data/doc/classes/CdIo/Cdda.src/M000013.html +17 -0
  35. data/doc/classes/CdIo/{Cd.src/M000019.html → Cdda.src/M000014.html} +3 -3
  36. data/doc/classes/CdIo/Cdda.src/M000015.html +17 -0
  37. data/doc/classes/CdIo/Cdda.src/M000016.html +17 -0
  38. data/doc/classes/CdIo/Cdda.src/M000017.html +17 -0
  39. data/doc/classes/CdIo/Cdda.src/M000018.html +17 -0
  40. data/doc/classes/CdIo/Cdda.src/M000019.html +17 -0
  41. data/doc/classes/CdIo/{Cd.src/M000015.html → Cdda.src/M000020.html} +3 -3
  42. data/doc/classes/CdIo/{Cd.src/M000017.html → Cdda.src/M000021.html} +3 -3
  43. data/doc/classes/CdIo/{Cd.src/M000018.html → Cdda.src/M000022.html} +3 -3
  44. data/doc/classes/CdIo/Cdda.src/M000023.html +17 -0
  45. data/doc/classes/CdIo/Cdda.src/M000024.html +17 -0
  46. data/doc/classes/CdIo/Exception.html +118 -0
  47. data/doc/classes/CdIo/Exception/BadParameter.html +111 -0
  48. data/doc/classes/CdIo/Exception/BadPointer.html +111 -0
  49. data/doc/classes/CdIo/{Device.html → Exception/CddbConn.html} +5 -5
  50. data/doc/classes/CdIo/Exception/CddbError.html +111 -0
  51. data/doc/classes/CdIo/{CdText.html → Exception/Error.html} +5 -5
  52. data/doc/{files/test/testall_rb.html → classes/CdIo/Exception/NoDriver.html} +26 -25
  53. data/doc/classes/CdIo/Exception/NotPermitted.html +111 -0
  54. data/doc/classes/CdIo/Exception/Unsupported.html +111 -0
  55. data/doc/classes/CdIo/Track.html +16 -16
  56. data/doc/classes/CdIo/Track.src/M000017.html +3 -3
  57. data/doc/classes/CdIo/Track.src/M000018.html +3 -3
  58. data/doc/classes/CdIo/Track.src/M000019.html +3 -3
  59. data/doc/classes/CdIo/Track.src/{M000009.html → M000025.html} +1 -1
  60. data/doc/classes/CdIo/Track.src/{M000010.html → M000026.html} +1 -1
  61. data/doc/classes/CdIo/Track.src/{M000011.html → M000027.html} +1 -1
  62. data/doc/classes/CdIo/TrackCdda.html +169 -0
  63. data/doc/classes/CdIo/TrackCdda.src/M000031.html +17 -0
  64. data/doc/classes/CdIo/TrackCdda.src/M000039.html +17 -0
  65. data/doc/classes/CdIo/TrackCdda.src/M000040.html +17 -0
  66. data/doc/classes/CdIo/TrackCdda.src/M000041.html +17 -0
  67. data/doc/classes/CdIo/Tracks.html +15 -15
  68. data/doc/classes/CdIo/Tracks.src/{M000020.html → M000028.html} +1 -1
  69. data/doc/classes/CdIo/Tracks.src/{M000021.html → M000029.html} +1 -1
  70. data/doc/classes/CdIo/Tracks.src/{M000022.html → M000030.html} +1 -1
  71. data/doc/classes/CdIo/{Cd.src/M000012.html → Tracks.src/M000036.html} +3 -3
  72. data/doc/classes/CdIo/Tracks.src/M000037.html +17 -0
  73. data/doc/classes/CdIo/Tracks.src/M000038.html +17 -0
  74. data/doc/created.rid +1 -1
  75. data/doc/files/__/rb_cdio_def_rb.html +235 -0
  76. data/doc/files/rb_cdio_def_rb.html +80 -5
  77. data/doc/fr_class_index.html +11 -0
  78. data/doc/fr_method_index.html +33 -14
  79. data/ext/CdIo.c +58 -3
  80. data/ext/CdIo.h +74 -1
  81. data/ext/CdIo_Cd.c +33 -80
  82. data/ext/CdIo_Cdda.c +607 -0
  83. data/ext/CdIo_Common.c +53 -8
  84. data/ext/CdIo_Modulo.c +12 -4
  85. data/ext/CdIo_Track.c +23 -35
  86. data/ext/CdIo_TrackCdda.c +13 -0
  87. data/ext/CdIo_TrackIso9660.c +1 -9
  88. data/ext/CdIo_Tracks.c +12 -2
  89. data/ext/extconf.rb +3 -0
  90. data/ext/mkmf.log +23 -0
  91. data/lib/rb_cdio_read.rb +23 -14
  92. data/rb_cdio.def.rb +157 -16
  93. data/test/data/bad-file.toc +13 -0
  94. data/test/data/cdda-read.right +3 -0
  95. data/test/data/cdda.cue +1 -0
  96. data/test/data/cdda.right +5 -28
  97. data/test/data/cdda.toc +2 -1
  98. data/test/data/check_common_fn +9 -9
  99. data/test/data/check_common_fn.in +9 -9
  100. data/test/data/check_cue.sh.in +35 -20
  101. data/test/data/check_iso.sh.in +23 -3
  102. data/test/data/check_nrg.sh.in +18 -16
  103. data/test/data/check_opts0.right +2 -24
  104. data/test/data/check_opts1.right +2 -24
  105. data/test/data/check_opts2.right +5 -27
  106. data/test/data/check_opts3.right +5 -27
  107. data/test/data/check_opts4.right +5 -27
  108. data/test/data/check_opts5.right +5 -27
  109. data/test/data/check_opts6.right +5 -27
  110. data/test/data/check_opts7.right +5 -27
  111. data/test/data/check_paranoia.sh.in +78 -0
  112. data/test/data/check_sizeof.c +5 -5
  113. data/test/data/copying-rr.iso +0 -0
  114. data/test/data/copying-rr.right +25 -0
  115. data/test/data/copying.right +3 -3
  116. data/test/data/data5.toc +3 -3
  117. data/test/data/data6.toc +2 -2
  118. data/test/data/data7.toc +3 -3
  119. data/test/data/isofs-m1-no-rr.right +33 -0
  120. data/test/data/isofs-m1-read.right +3 -0
  121. data/test/data/isofs-m1.right +12 -36
  122. data/test/data/joliet-nojoliet.right +23 -0
  123. data/test/data/joliet.iso +0 -0
  124. data/test/data/joliet.right +23 -0
  125. data/test/data/testbincue.c +19 -3
  126. data/test/data/testdefault.c +8 -2
  127. data/test/data/testiso9660.c +10 -5
  128. data/test/data/testparanoia.c +185 -0
  129. data/test/data/testtoc.c +18 -5
  130. data/test/data/vcd2.toc +23 -0
  131. data/test/data/vcd_demo.right +55 -79
  132. data/test/data/vcd_demo_vcdinfo.right +97 -0
  133. data/test/data/videocd.right +37 -61
  134. data/test/test_cdda.rb +73 -0
  135. data/test/testall.rb +1 -0
  136. data/test/testbincue.rb +6 -1
  137. data/test/testclose.rb +6 -1
  138. data/test/testmethods.rb +29 -21
  139. data/test/testtoc.rb +9 -2
  140. metadata +137 -80
  141. data/doc/classes/CdIo.src/M000009.html +0 -17
  142. data/doc/classes/CdIo.src/M000010.html +0 -17
  143. data/doc/classes/CdIo.src/M000011.html +0 -17
  144. data/doc/classes/CdIo.src/M000012.html +0 -17
  145. data/doc/classes/CdIo.src/M000013.html +0 -17
  146. data/doc/classes/CdIo.src/M000014.html +0 -17
  147. data/doc/classes/CdIo.src/M000015.html +0 -17
  148. data/doc/classes/CdIo.src/M000016.html +0 -17
  149. data/doc/classes/CdIo/Track.src/M000020.html +0 -17
  150. data/test/data/check_cd_read.sh +0 -53
  151. data/test/data/check_cue.sh +0 -102
  152. data/test/data/check_iso.sh +0 -32
  153. data/test/data/check_nrg.sh +0 -68
  154. data/test/data/check_opts.sh +0 -33
@@ -24,6 +24,7 @@ get_cap(cdio_drive_read_cap_t * read_cap,
24
24
  rb_hash_aset(ret, rb_str_new2("read"), read);
25
25
  rb_hash_aset(ret, rb_str_new2("write"), write);
26
26
  rb_hash_aset(ret, rb_str_new2("misc"), misc);
27
+ // read
27
28
  CAP(read, "audio", read_cap, CDIO_DRIVE_CAP_READ_AUDIO);
28
29
  CAP(read, "cd-da", read_cap, CDIO_DRIVE_CAP_READ_CD_DA);
29
30
  CAP(read, "cd+g", read_cap, CDIO_DRIVE_CAP_READ_CD_G);
@@ -36,6 +37,12 @@ get_cap(cdio_drive_read_cap_t * read_cap,
36
37
  CAP(read, "dvd-rw", read_cap, CDIO_DRIVE_CAP_READ_DVD_RW);
37
38
  CAP(read, "dvd+rw", read_cap, CDIO_DRIVE_CAP_READ_DVD_RPW);
38
39
  CAP(read, "c2_errs", read_cap, CDIO_DRIVE_CAP_READ_C2_ERRS);
40
+ CAP(read, "mode2_form1", read_cap, CDIO_DRIVE_CAP_READ_MODE2_FORM1);
41
+ CAP(read, "mode2_form2", read_cap, CDIO_DRIVE_CAP_READ_MODE2_FORM2);
42
+ CAP(read, "mcn", read_cap, CDIO_DRIVE_CAP_READ_MCN);
43
+ CAP(read, "isrc", read_cap, CDIO_DRIVE_CAP_READ_ISRC);
44
+
45
+ // write
39
46
  CAP(write, "cd-r", write_cap, CDIO_DRIVE_CAP_WRITE_CD_R);
40
47
  CAP(write, "cd-rw", write_cap, CDIO_DRIVE_CAP_WRITE_CD_RW);
41
48
  CAP(write, "dvd-r", write_cap, CDIO_DRIVE_CAP_WRITE_DVD_R);
@@ -48,6 +55,7 @@ get_cap(cdio_drive_read_cap_t * read_cap,
48
55
  CAP(write, "burn_proof", write_cap, CDIO_DRIVE_CAP_WRITE_BURN_PROOF);
49
56
  CAP(write, "cd", write_cap, CDIO_DRIVE_CAP_WRITE_CD);
50
57
  CAP(write, "dvd", write_cap, CDIO_DRIVE_CAP_WRITE_DVD);
58
+ // misc
51
59
  CAP(misc, "close_tray", misc_cap, CDIO_DRIVE_CAP_MISC_CLOSE_TRAY);
52
60
  CAP(misc, "eject", misc_cap, CDIO_DRIVE_CAP_MISC_EJECT);
53
61
  CAP(misc, "lock", misc_cap, CDIO_DRIVE_CAP_MISC_LOCK);
@@ -57,9 +65,7 @@ get_cap(cdio_drive_read_cap_t * read_cap,
57
65
  CDIO_DRIVE_CAP_MISC_MULTI_SESSION);
58
66
  CAP(misc, "media_changed", misc_cap,
59
67
  CDIO_DRIVE_CAP_MISC_MEDIA_CHANGED);
60
- CAP(misc, "misc_reset", misc_cap, CDIO_DRIVE_CAP_MISC_RESET);
61
- CAP(misc, "mcn", misc_cap, CDIO_DRIVE_CAP_MCN);
62
- CAP(misc, "isrc", misc_cap, CDIO_DRIVE_CAP_ISRC);
68
+ CAP(misc, "reset", misc_cap, CDIO_DRIVE_CAP_MISC_RESET);
63
69
  CAP(misc, "file", misc_cap, CDIO_DRIVE_CAP_MISC_FILE);
64
70
  return ret;
65
71
  }
@@ -115,14 +121,53 @@ _cdio_cd_is_iso(CdIo * p_cdio, track_t track)
115
121
  */
116
122
 
117
123
  VALUE
118
- get_track(VALUE obj, track_t i)
124
+ get_track(VALUE cd, track_t i)
119
125
  {
120
- GET_CDIO(obj, p_cdio);
126
+ GET_CDIO(cd, p_cdio);
127
+ // printf("get_track 1:%d\n",i);
121
128
  VALUE track;
129
+ track_format_t format = cdio_get_track_format(p_cdio, i);
130
+ VALUE argv[2];
131
+ argv[0] = cd;
132
+ argv[1] = INT2FIX(i);
133
+ // printf("get_track 2:%d\n",FIX2INT(argv[1]));
134
+
122
135
  if (_cdio_cd_is_iso(p_cdio, i)) {
123
- track = rb_cdio_trackiso9660_new(obj, i);
136
+ return rb_class_new_instance(2, argv, cCdIoTrackIso9660);
137
+ } else if (TRACK_FORMAT_AUDIO == format) {
138
+ return rb_class_new_instance(2, argv, cCdIoTrackCdda);
124
139
  } else {
125
- track = rb_cdio_track_new(obj, i);
140
+ return rb_class_new_instance(2, argv, cCdIoTrack);
141
+ }
142
+ }
143
+ void
144
+ verify_return_code(driver_return_code_t rc)
145
+ {
146
+ switch (rc) {
147
+ case DRIVER_OP_SUCCESS:
148
+ break;
149
+ case DRIVER_OP_ERROR:
150
+ rb_raise(eCdIoError, "Operation returned an error");
151
+ break;
152
+ case DRIVER_OP_UNSUPPORTED:
153
+ rb_raise(eCdIoUnsupported, "Driver doesn't support feature");
154
+ break;
155
+ case DRIVER_OP_UNINIT:
156
+ rb_raise(eCdIoUnitit, "driver hasn't been initialized");
157
+ break;
158
+ case DRIVER_OP_NOT_PERMITTED:
159
+ rb_raise(eCdIoNotPermitted, "Operation not permitted.");
160
+ break;
161
+ case DRIVER_OP_BAD_PARAMETER:
162
+ rb_raise(eCdIoBadParameter,
163
+ "Bad parameter (library bug, probably)");
164
+ break;
165
+ case DRIVER_OP_BAD_POINTER:
166
+ rb_raise(eCdIoBadPointer, "Bad pointer (library bug, probably)");
167
+ break;
168
+ case DRIVER_OP_NO_DRIVER:
169
+ rb_raise(eCdIoNoDriver,
170
+ "Operaton called on a driver not available on this OS");
171
+ break;
126
172
  }
127
- return track;
128
173
  }
@@ -31,8 +31,6 @@ rb_cdio_get_devices(int argc, VALUE * argv, VALUE module)
31
31
  rb_ary_push(aDevices, rb_str_new2(*i));
32
32
  }
33
33
  cdio_free_device_list(devices);
34
- free(devices);
35
- devices = NULL;
36
34
  return aDevices;
37
35
  } else {
38
36
  return Qnil;
@@ -193,7 +191,7 @@ rb_cdio_track_type_describe(VALUE module, VALUE track)
193
191
  return rb_str_new2(desc);
194
192
  }
195
193
 
196
- static VALUE
194
+ static VALUE
197
195
  _is_file_bool(bool(*pf) (const char *n), VALUE name)
198
196
  {
199
197
  Check_Type(name, T_STRING);
@@ -202,7 +200,7 @@ _is_file_bool(bool(*pf) (const char *n), VALUE name)
202
200
  return res ? Qtrue : Qfalse;
203
201
  }
204
202
 
205
- static VALUE
203
+ static VALUE
206
204
  _is_file_char(char *(*pf) (const char *n), VALUE name)
207
205
  {
208
206
  Check_Type(name, T_STRING);
@@ -244,3 +242,13 @@ rb_cdio_is_device(int argc, VALUE * argv, VALUE module)
244
242
  {
245
243
  return Qnil;
246
244
  }
245
+
246
+ VALUE
247
+ rb_cdio_close_tray(VALUE module, VALUE name)
248
+ {
249
+ Check_Type(name, T_STRING);
250
+ SafeStringValue(name);
251
+ driver_return_code_t rc = cdio_close_tray(StringValuePtr(name), NULL);
252
+ verify_return_code(rc);
253
+ return Qtrue;
254
+ }
@@ -8,49 +8,20 @@
8
8
  */
9
9
 
10
10
  #include "CdIo.h"
11
- /**
12
- * Funci?n extraida de cd-info.c
13
- */
14
-
15
-
16
- VALUE
17
- rb_cdio_track_new(VALUE cd, int track)
18
- {
19
- VALUE argv[2];
20
- argv[0] = cd;
21
- argv[1] = INT2FIX(track);
22
- return rb_class_new_instance(2, argv, cCdIoTrack);
23
- }
24
-
25
- int
26
- rb_cdio_track_number(VALUE obj)
27
- {
28
- return FIX2INT(rb_iv_get(obj, "@number"));
29
- }
30
-
31
- VALUE
32
- rb_cdio_track_green(VALUE obj)
33
- {
34
- GET_CDIO(rb_iv_get(obj, "@cd"), p_cdio);
35
- if (cdio_get_track_green(p_cdio, rb_cdio_track_number(obj))) {
36
- return Qtrue;
37
- } else {
38
- return Qfalse;
39
- }
40
- }
41
-
42
11
  VALUE
43
12
  rb_cdio_track_init(VALUE obj, VALUE cd, VALUE track)
44
13
  {
45
- // Verificaci?n de tipos.
14
+ // Verificacion de tipos.
46
15
  lsn_t lsn;
47
16
  int i_track;
48
17
  FIXNUM_P(track);
49
18
  if (Qtrue != rb_obj_is_instance_of(cd, cCdIoCd)) {
50
19
  rb_raise(rb_eArgError, "Arg 1 must be a CdIo::Cd");
51
20
  }
21
+
52
22
  GET_CDIO(cd, p_cdio);
53
23
  i_track = FIX2INT(track);
24
+ // printf("En init:%d\n",i_track);
54
25
  // Verify track number
55
26
  track_t min,
56
27
  max;
@@ -79,9 +50,9 @@ rb_cdio_track_init(VALUE obj, VALUE cd, VALUE track)
79
50
  if (cdio_get_track_msf(p_cdio, i_track, &msf)) {
80
51
  msf_s = cdio_msf_to_str(&msf);
81
52
  // printf("C->%d:%d:%d\n",(int)msf.m,(int)msf.s,(int)msf.f);
82
- rb_iv_set(obj, "@min", INT2FIX(from_bcd8(msf.m)));
83
- rb_iv_set(obj, "@sec", INT2FIX(from_bcd8(msf.s)));
84
- rb_iv_set(obj, "@frames", INT2FIX(from_bcd8(msf.f)));
53
+ rb_iv_set(obj, "@min", INT2FIX(cdio_from_bcd8(msf.m)));
54
+ rb_iv_set(obj, "@sec", INT2FIX(cdio_from_bcd8(msf.s)));
55
+ rb_iv_set(obj, "@frames", INT2FIX(cdio_from_bcd8(msf.f)));
85
56
  rb_iv_set(obj, "@msf", rb_str_new2(msf_s));
86
57
  free(msf_s);
87
58
  }
@@ -98,6 +69,23 @@ rb_cdio_track_init(VALUE obj, VALUE cd, VALUE track)
98
69
  return obj;
99
70
  }
100
71
 
72
+ int
73
+ rb_cdio_track_number(VALUE obj)
74
+ {
75
+ return FIX2INT(rb_iv_get(obj, "@number"));
76
+ }
77
+
78
+ VALUE
79
+ rb_cdio_track_green(VALUE obj)
80
+ {
81
+ GET_CDIO(rb_iv_get(obj, "@cd"), p_cdio);
82
+ if (cdio_get_track_green(p_cdio, rb_cdio_track_number(obj))) {
83
+ return Qtrue;
84
+ } else {
85
+ return Qfalse;
86
+ }
87
+ }
88
+
101
89
  VALUE
102
90
  rb_cdio_track_get_cdtext(VALUE obj)
103
91
  {
@@ -0,0 +1,13 @@
1
+ #include "CdIo.h"
2
+
3
+ VALUE
4
+ rb_cdio_trackcdda_play(VALUE obj)
5
+ {
6
+ GET_TRACK(obj, p_cdio, track_i);
7
+ msf_t msf_start,
8
+ msf_end;
9
+ cdio_get_track_msf(p_cdio, track_i, &msf_start);
10
+ cdio_get_track_msf(p_cdio, track_i + 1, &msf_end);
11
+ verify_return_code(cdio_audio_play_msf(p_cdio, &msf_start, &msf_end));
12
+ return Qtrue;
13
+ }
@@ -9,7 +9,7 @@
9
9
 
10
10
 
11
11
  #include "CdIo.h"
12
- static bool
12
+ static bool
13
13
  read_iso9660_pvd(const CdIo * p_cdio, track_format_t track_format, /* out
14
14
  */
15
15
  iso9660_pvd_t * p_pvd)
@@ -36,14 +36,6 @@ read_iso9660_pvd(const CdIo * p_cdio, track_format_t track_format, /* out
36
36
  return true;
37
37
  }
38
38
 
39
- VALUE
40
- rb_cdio_trackiso9660_new(VALUE cd, int track)
41
- {
42
- VALUE argv[2];
43
- argv[0] = cd;
44
- argv[1] = INT2FIX(track);
45
- return rb_class_new_instance(2, argv, cCdIoTrackIso9660);
46
- }
47
39
 
48
40
  VALUE
49
41
  rb_cdio_trackiso9660_init(VALUE obj, VALUE cd, VALUE track)
@@ -18,6 +18,7 @@ rb_cdio_tracks_init(VALUE obj, VALUE cd)
18
18
  int j,
19
19
  i = first_track_num;
20
20
  for (j = 0; j < num_tracks; i++, j++) {
21
+ // printf("rb_cdio_tracks_init->%d\n",i);
21
22
  rb_ary_push(aTracks, get_track(cd, i));
22
23
  }
23
24
  rb_iv_set(obj, "@tracks", aTracks);
@@ -60,7 +61,16 @@ rb_cdio_tracks_diff(VALUE obj, VALUE a, VALUE b)
60
61
  VALUE
61
62
  rb_cdio_tracks_index(VALUE obj, VALUE index)
62
63
  {
63
-
64
+ // ok, this is a very stupid method, but...
64
65
  FIXNUM_P(index);
65
- return get_track(rb_iv_get(obj, "@cd"), FIX2INT(index));
66
+ VALUE aTracks = rb_iv_get(obj, "@tracks");
67
+ long len = RARRAY(aTracks)->len;
68
+ long i;
69
+ for (i = 0; i < len; i++) {
70
+ if (rb_iv_get(rb_ary_entry(aTracks, i), "@number") == index) {
71
+ return rb_ary_entry(aTracks, i);
72
+ }
73
+ }
74
+ return Qnil;
75
+ // return get_track(rb_iv_get(obj, "@cd"), FIX2INT(index));
66
76
  }
@@ -1,4 +1,7 @@
1
1
  require 'mkmf'
2
2
  have_library("cdio","cdio_open");
3
3
  have_library("iso9660","iso9660_get_system_id");
4
+ if have_library("cddb","cddb_new")
5
+ have_header("cddb/cddb.h")
6
+ end
4
7
  create_makefile("rb_cdio");
@@ -24,3 +24,26 @@ int t() { iso9660_get_system_id(); return 0; }
24
24
 
25
25
  --------------------
26
26
 
27
+ have_library: checking for cddb_new() in -lcddb... -------------------- yes
28
+
29
+ "i686-pc-linux-gnu-gcc -o conftest -I/home/cdx/ruby/rb_cdio/ext -I/usr/lib/ruby/1.8/i686-linux -O2 -march=athlon-xp -m3dnow -msse -mfpmath=sse -mmmx -pipe -ffast-math -fPIC conftest.c -L'/usr/lib' -Wl,-R'/usr/lib' -liso9660 -lcdio -lruby18-static -lcddb -liso9660 -lcdio -ldl -lcrypt -lm -lc"
30
+ checked program was:
31
+ /* begin */
32
+
33
+ /*top*/
34
+ int main() { return 0; }
35
+ int t() { cddb_new(); return 0; }
36
+ /* end */
37
+
38
+ --------------------
39
+
40
+ have_header: checking for cddb/cddb.h... -------------------- yes
41
+
42
+ "i686-pc-linux-gnu-gcc -E -I/home/cdx/ruby/rb_cdio/ext -I/usr/lib/ruby/1.8/i686-linux -O2 -march=athlon-xp -m3dnow -msse -mfpmath=sse -mmmx -pipe -ffast-math -fPIC conftest.c -o conftest.i"
43
+ checked program was:
44
+ /* begin */
45
+ #include <cddb/cddb.h>
46
+ /* end */
47
+
48
+ --------------------
49
+
@@ -1,6 +1,9 @@
1
- #require 'rubygems'
2
- #require_gem "rb_cdio",">=0.0.3"
3
- require "../ext/rb_cdio"
1
+ if(File::exists?("../ext/rb_cdio.so"))
2
+ require "../ext/rb_cdio"
3
+ else
4
+ require 'rubygems'
5
+ require_gem "rb_cdio",">=0.2"
6
+ end
4
7
  dev=( ARGV[0].nil? ) ? nil:ARGV[0];
5
8
  CdIo.open(ARGV[0]) {|cd|
6
9
  puts "Device:"+cd.device
@@ -12,26 +15,32 @@ CdIo.open(ARGV[0]) {|cd|
12
15
  puts "Discmode: "+CdIo.discmode_describe(cd.discmode);
13
16
  puts "Is Cd?: "+((cd.is_cd? ) ? "Yes" : "No");
14
17
  puts "Is Dvd?: "+((cd.is_dvd? ) ? "Yes" : "No");
18
+ cdda=false
15
19
  if (cd.discmode==CdIo::CDIO_DISC_MODE_CD_DA)
16
- puts "CDTEXT"
17
- p cd.get_cdtext
18
- #puts "Cddb: "+cd.cddb_id
19
- #freedb=cd.get_freedb
20
- #freedb.fetch
21
- #freedb.results.each { |r| puts r }
22
- #puts "Pistas = \n"
20
+ puts "CDTEXT: "+cd.cdtext.to_s
21
+ puts "Cddb: "+cd.cddb_id
22
+ begin
23
+ cd.cddb_fetch(1)
24
+ puts "Artist:"+cd.artist
25
+ puts "Title:"+cd.title
26
+ cdda=true
27
+ rescue =>e
28
+ puts "ERROR - Can't get cddb info : "+e.to_s
29
+ end
23
30
  end
24
- cd.get_tracks.each {|track|
31
+ cd.tracks.each {|track|
25
32
  puts "=========\nTrack number "+track.number.to_s
26
33
  puts CdIo.track_format_describe(track.format);
27
34
 
28
35
  if(cd.discmode==CdIo::CDIO_DISC_MODE_CD_DA)
29
- puts "CDTEXT"
30
- p track.get_cdtext
36
+ puts "CDTEXT:"+track.cdtext.to_s
31
37
  end
32
38
  puts "Format: "+CdIo.track_format_describe(track.format);
33
39
  puts "Type: "+CdIo.track_type_describe(track);
34
- puts track.msf
40
+ puts "Mfs: "+track.msf
41
+ if(cdda)
42
+ puts "Title:"+track.title
43
+ end
35
44
  }
36
45
  }
37
46
 
@@ -1,6 +1,9 @@
1
1
  #!/bin/env ruby
2
2
  # = rb_cdio
3
- # This package create bindings to the library libcdio
3
+ # Create bindings to the library libcdio and libcddb(optional).
4
+ # You can retrieve information about Cd and images. If you have
5
+ # library libcddb installed, you can retrieve information like artist and titles
6
+ # for CD-DA.
4
7
  #
5
8
  # == Version
6
9
  # :include:VERSION
@@ -8,6 +11,43 @@
8
11
  # == Changelog
9
12
  # :include:ChangeLog.txt
10
13
  #
14
+ # == Download
15
+ #
16
+ # http://rb-cdio.rubyforge.org
17
+ #
18
+ # == Example of use
19
+ # CdIo.devices
20
+ # ==>["/dev/cdrom", "/dev/dvd"]
21
+ # cd=CdIo.default_device
22
+ # ==>"/dev/cdrom"
23
+ # CdIo.drive_cap_dev(cd)
24
+ # ==>{"misc"=>{"close_tray"=>true, "media_changed"=>false, "select_disk"=>false, "lock"=>true, "multi_session"=>true, "eject"=>true, "reset"=>false, "select_speed"=>false, "file"=>false}, "read"=>{"mode2_form1"=>true, "dvd-rw"=>false, "audio"=>true, "mode2_form2"=>true, "c2_errs"=>false, "dvd-r"=>false, "mcn"=>true, "cd-da"=>true, "dvd-rom"=>false, "isrc"=>true, "cd-r"=>true, "dvd-ram"=>false, "dvr+r"=>false, "cd+g"=>false, "dvd+rw"=>false, "cd-rw"=>true}, "write"=>{"dvd-rw"=>false, "cd"=>false, "dvd-r"=>false, "burn_proof"=>false, "dvd+r"=>false, "cd-r"=>false, "dvd"=>false, "dvd-ram"=>false, "dvd+rw"=>false, "mount_rainier"=>false, "cd-rw"=>false}}
25
+ # CdIo.driver_describe(CdIo::DRIVER_LINUX)
26
+ # ==>"GNU/Linux ioctl and MMC driver"
27
+ # CdIo.discmode_describe(CdIo::CDIO_DISC_MODE_CD_DA)
28
+ # ==>"CD-DA"
29
+ # CdIo.track_format_describe(CdIo::TRACK_FORMAT_XA)
30
+ # ==>"XA"
31
+ # cdo=CdIo.open(cd)
32
+ # ==>#<CdIo::Cd:0xb7d2a91c>
33
+ # cdo.cdtext
34
+ # ==>nil
35
+ # cdo.tracks.each do |track|
36
+ # track.number
37
+ # track
38
+ # end
39
+ # ==>[#<CdIo::TrackIso9660:0xb7cde440 @leadout=false, @min=0, @cd=#<CdIo::Cd:0xb7d2a91c>, @sec_count=311872, @frames=0, @lsn=0, @format=3, @track_type=3, @msf="00:02:00", @number=1, @sec=2, @lba=150>]
40
+ # cdo.tracks[CdIo::CDIO_CDROM_LEADOUT_TRACK];
41
+ # cdo.is_cd?
42
+ # ==>true
43
+ # cdo.is_dvd?
44
+ # ==>false
45
+ # cdo.drive_cap
46
+ # ==>{"misc"=>{"close_tray"=>true, "media_changed"=>false, "select_disk"=>false, "lock"=>true, "multi_session"=>true, "eject"=>true, "reset"=>false, "select_speed"=>false, "file"=>false}, "read"=>{"mode2_form1"=>true, "dvd-rw"=>false, "audio"=>true, "mode2_form2"=>true, "c2_errs"=>false, "dvd-r"=>false, "mcn"=>true, "cd-da"=>true, "dvd-rom"=>false, "isrc"=>true, "cd-r"=>true, "dvd-ram"=>false, "dvr+r"=>false, "cd+g"=>false, "dvd+rw"=>false, "cd-rw"=>true}, "write"=>{"dvd-rw"=>false, "cd"=>false, "dvd-r"=>false, "burn_proof"=>false, "dvd+r"=>false, "cd-r"=>false, "dvd"=>false, "dvd-ram"=>false, "dvd+rw"=>false, "mount_rainier"=>false, "cd-rw"=>false}}
47
+ # cdo.hwinfo
48
+ # ==>{"revision"=>"1.00", "vendor"=>"HL-DT-ST", "model"=>"CD-ROM GCR-8520B"}
49
+ # cdo.joliet_level
50
+ # ==>0
11
51
 
12
52
  # = Module CdIo
13
53
  # The module CdIo defines constants, classes and methods
@@ -16,9 +56,10 @@
16
56
  #
17
57
  #
18
58
  # The name of the constants are the same of libcdio, so theirs values
19
- # can change on different OS and versions of the library
59
+ # can change on different OS and versions of the libcdio library
20
60
 
21
61
  module CdIo
62
+ CDIO_CDROM_LEADOUT_TRACK=170
22
63
  CDIO_DISC_MODE_CD_DA=0
23
64
  CDIO_DISC_MODE_CD_DATA=1
24
65
  CDIO_DISC_MODE_CD_MIXED=3
@@ -32,26 +73,22 @@ module CdIo
32
73
  CDIO_DISC_MODE_DVD_RW=7
33
74
  CDIO_DISC_MODE_ERROR=12
34
75
  CDIO_DISC_MODE_NO_INFO=11
35
- # Driver for a .bin or .cue file
36
- DRIVER_BINCUE=8
37
- DRIVER_CDRDAO=7
38
- # Driver for a device (cd or dvd)
39
- DRIVER_DEVICE=10
40
- DRIVER_FREEBSD=2
41
- DRIVER_LINUX=3
42
- DRIVER_NRG=9
43
- DRIVER_OSX=5
44
- DRIVER_SOLARIS=4
76
+ DRIVER_BINCUE=9
77
+ DRIVER_CDRDAO=8
78
+ DRIVER_DEVICE=11
79
+ DRIVER_FREEBSD=3
80
+ DRIVER_LINUX=4
81
+ DRIVER_NRG=10
82
+ DRIVER_OSX=6
83
+ DRIVER_SOLARIS=5
45
84
  DRIVER_UNKNOWN=0
46
- DRIVER_WIN32=6
85
+ DRIVER_WIN32=7
47
86
  TRACK_FORMAT_AUDIO=0
48
87
  TRACK_FORMAT_CDI=1
49
88
  TRACK_FORMAT_DATA=3
50
89
  TRACK_FORMAT_ERROR=5
51
90
  TRACK_FORMAT_PSX=4
52
91
  TRACK_FORMAT_XA=2
53
- # The number for the leadout track of a cd
54
- CDIO_CDROM_LEADOUT_TRACK=170
55
92
  # Returns all active devices (with a cd or dvd inside)
56
93
  #
57
94
  # CdIo.get_devices #=> ["/dev/cdrom"]
@@ -101,8 +138,26 @@ module CdIo
101
138
  #
102
139
  def CdIo.open(device=nil,driver=nil,&block)
103
140
  end
141
+ module Exception
142
+ class Error < IoError
143
+ end
144
+ class Unsupported < IoError
145
+ end
146
+ class NotPermitted < IoError
147
+ end
148
+ class BadParameter < IoError
149
+ end
150
+ class BadPointer < IoError
151
+ end
152
+ class NoDriver < IoError
153
+ end
154
+ class CddbError < Exception
155
+ end
156
+ class CddbConn < IoError
157
+ end
158
+ end
104
159
  class Cd
105
- attr_reader :device, :mcn, :driver_name, :driver_id, :first_track_num, :disc_mode, :num_tracks, :stat_size, :cddb_id
160
+ attr_reader :device, :mcn, :driver_name, :driver_id, :first_track_num, :disc_mode, :num_tracks, :last_lsn, :joliet_level
106
161
  #
107
162
  # Create a new Cd::CdIo object.
108
163
  # The first argument is an String for a device or a cue/bin/toc/nrg file
@@ -144,6 +199,84 @@ module CdIo
144
199
  def close
145
200
  end
146
201
  end
202
+ # module with extra methods to extends a normal Cd
203
+ module Cdda
204
+ # get the volume in an array.
205
+ #
206
+ # cd.volume
207
+ # ==> [255, 255, 0, 0]
208
+ def volume
209
+ end
210
+ # set the volume. You have to put an array
211
+ #
212
+ # cd.volume=[255,255,0,0]
213
+ def volume=(vol_set)
214
+ end
215
+ # play cd tracks. Returns an array with the first and the last track to play
216
+ # Ex.: cd with 11 tracks:
217
+ #
218
+ # cd.play
219
+ # ==> [1,11]
220
+ # cd.play(1)
221
+ # ==> [1,1]
222
+ # cd.play(2,20)
223
+ # ==> [2,11]
224
+ def play
225
+ end
226
+ # pause the reproduction of cd
227
+ def pause
228
+ end
229
+ # resume the reproduction of cd after a pause
230
+ def resume
231
+ end
232
+ # stop the reproduction of the cd
233
+ def stop
234
+ end
235
+ # get subchannel information of reproduction of the cd
236
+ #
237
+ # cd.subchannel
238
+ # ==> {"control"=>0, "rel_addr"=>"00:00:02", "abs_addr"=>"00:02:02", "format"=>212, "audio_status_desc"=>"no_status", "track"=>1, "audio_status"=>21, "index"=>1, "address"=>6}
239
+ def subchannel
240
+ end
241
+ # get the cddb key for the cd, in hex format
242
+ #
243
+ # cd.cddb_id
244
+ # ==> "9609630b"
245
+ def cddb_id
246
+ end
247
+ # get matches for cddb in an array.
248
+ # Requires <b>libcddb</b>
249
+ #
250
+ # cd.cddb_matches
251
+ # ==> [{"artist"=>"Seru Giran", "category"=>"rock", "title"=>"Peperina", "id"=>"2466865419", "length"=>"2403", "year"=>"0", "genre"=>"rock"}, {"artist"=>"Seru Giran", "category"=>"rock", "title"=>"Peperina", "id"=>"2517197579", "length"=>"2403", "year"=>"0", "genre"=>"rock"}]
252
+ def cddb_matches
253
+ end
254
+ # Get the match number x on cddb. Add information for the cd
255
+ # and the tracks
256
+ # Requires <b>libcddb</b>
257
+ #
258
+ # cd.cddb_fetch(1)
259
+ # ==> true
260
+ # t=cd.tracks[1]
261
+ # puts t.number.to_s+"-"+t.artist+"-"+t.title
262
+ # ==> 1-Seru Giran-Peperina
263
+ #
264
+ #
265
+ def cddb_fetch(match)
266
+ end
267
+ def artist
268
+ end
269
+ def title
270
+ end
271
+ def category
272
+ end
273
+ def genre
274
+ end
275
+ def length
276
+ end
277
+ def extra_data
278
+ end
279
+ end
147
280
  # Provides access to the tracks of a CdIo::Cd object
148
281
  class Tracks
149
282
  # Returns a CdIo::Tracks object por a given CdIo::Cd
@@ -184,4 +317,12 @@ module CdIo
184
317
  class TrackIso9660 < Track
185
318
  attr_reader :system_id, :volume_id, :volumeset_id, :preparer_id, :publisher_id, :application_id
186
319
  end
320
+ class TrackCdda < Track
321
+ def play
322
+ end
323
+ def artist
324
+ end
325
+ def title
326
+ end
327
+ end
187
328
  end