ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
testcd.c
Go to the documentation of this file.
1 /*
2 # _____ ___ ____ ___ ____
3 # ____| | ____| | | |____|
4 # | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5 #-----------------------------------------------------------------------
6 # Copyright 2005, ps2dev - http://www.ps2dev.org
7 # Licenced under GNU Library General Public License version 2
8 # Review ps2sdk README & LICENSE files for further details.
9 #
10 # audsrv cdda toc sample
11 */
12 
13 #include <stdio.h>
14 #include <string.h>
15 
16 #include <kernel.h>
17 #include <sifrpc.h>
18 #include <loadfile.h>
19 #include <tamtypes.h>
20 
21 #include <audsrv.h>
22 
23 int main(int argc, char **argv)
24 {
25  int ret;
26  int n, track;
27  int lastpos;
28 
29  SifInitRpc(0);
30 
31  printf("sample: kicking IRXs\n");
32  ret = SifLoadModule("rom0:LIBSD", 0, NULL);
33  printf("libsd loadmodule %d\n", ret);
34 
35  printf("sample: loading audsrv\n");
36  ret = SifLoadModule("host:audsrv.irx", 0, NULL);
37  printf("audsrv loadmodule %d\n", ret);
38 
39  ret = audsrv_init();
40  if (ret != 0)
41  {
42  printf("sample: failed to initialize audsrv\n");
43  printf("audsrv returned error string: %s\n", audsrv_get_error_string());
44  return 1;
45  }
46 
48  printf("There are %d tracks on this disc\n", n);
49 
50  lastpos = 0;
51  for (track=0; track<=n; track++)
52  {
53  int pos = audsrv_get_track_offset(track);
54 
55  if (track > 0)
56  {
57  int length = pos - lastpos;
58 
59  printf("Track %02d: sector 0x%x, length: %02d:%02d:%02d\n",
60  track, pos, length / (75*60), (length / 75) % 60, length % 75);
61  }
62 
63  lastpos = pos;
64  }
65 
66  audsrv_quit();
67  printf("sample: ended\n");
68  return 0;
69 }
int audsrv_get_numtracks()
Definition: audsrv_rpc.c:198
const char * audsrv_get_error_string()
Definition: audsrv_rpc.c:438
int audsrv_init()
Definition: audsrv_rpc.c:296
int audsrv_get_track_offset(int track)
Definition: audsrv_rpc.c:203
int audsrv_quit()
Definition: audsrv_rpc.c:117
int SifLoadModule(const char *path, int arg_len, const char *args)
struct @29::@30 pos
void SifInitRpc(int mode)
#define NULL
Definition: tamtypes.h:91
int main(int argc, char **argv)
Definition: testcd.c:23