ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
playcdda.c File Reference
#include <stdio.h>
#include <string.h>
#include <kernel.h>
#include <sifrpc.h>
#include <loadfile.h>
#include <tamtypes.h>
#include <audsrv.h>
+ Include dependency graph for playcdda.c:

Go to the source code of this file.

Functions

static void cdda_stopped (void *arg)
 
int main (int argc, char **argv)
 

Variables

static volatile int track_ended = 0
 

Function Documentation

◆ cdda_stopped()

static void cdda_stopped ( void *  arg)
static

Definition at line 25 of file playcdda.c.

26 {
27  track_ended = 1;
28 }
static volatile int track_ended
Definition: playcdda.c:23

References track_ended.

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 30 of file playcdda.c.

31 {
32  int ret;
33  int track;
34  int lastpos;
35 
36  SifInitRpc(0);
37 
38  printf("sample: kicking IRXs\n");
39  ret = SifLoadModule("rom0:LIBSD", 0, NULL);
40  printf("libsd loadmodule %d\n", ret);
41 
42  printf("sample: loading audsrv\n");
43  ret = SifLoadModule("host:audsrv.irx", 0, NULL);
44  printf("audsrv loadmodule %d\n", ret);
45 
46  ret = audsrv_init();
47  if (ret != 0)
48  {
49  printf("sample: failed to initialize audsrv\n");
50  printf("audsrv returned error string: %s\n", audsrv_get_error_string());
51  return 1;
52  }
53 
54  printf("setting callback\n");
56 
57  track = 4;
58  printf("playing track %d\n", track);
59  audsrv_play_cd(track);
60 
61  //printf("starting loop\n");
62 
63  lastpos = 0;
64  while (track_ended == 0)
65  {
66  int pos;
67 
68  if (audsrv_get_cdpos() == 0)
69  {
70  printf("-- track ended before semaphore --\n");
71  break;
72  }
73 
75  nopdelay();
76 
77  if (lastpos != pos)
78  {
79  printf("\rTrack %02d: %02d:%02d:%02d",
80  track, pos / (75*60), (pos / 75) % 60, pos % 75);
81  lastpos = pos;
82  }
83  }
84 
85  printf("\n");
86  printf("track ended\n");
87 
88  audsrv_quit();
89  printf("sample: ended\n");
90  return 0;
91 }
const char * audsrv_get_error_string()
Definition: audsrv_rpc.c:438
int audsrv_init()
Definition: audsrv_rpc.c:296
int audsrv_on_cdda_stop(audsrv_callback_t cb, void *arg)
Definition: audsrv_rpc.c:464
int audsrv_play_cd(int track)
Definition: audsrv_rpc.c:171
int audsrv_get_trackpos()
Definition: audsrv_rpc.c:193
int audsrv_get_cdpos()
Definition: audsrv_rpc.c:188
int audsrv_quit()
Definition: audsrv_rpc.c:117
int SifLoadModule(const char *path, int arg_len, const char *args)
static void nopdelay(void)
Definition: kernel.h:141
struct @29::@30 pos
static void cdda_stopped(void *arg)
Definition: playcdda.c:25
void SifInitRpc(int mode)
#define NULL
Definition: tamtypes.h:91

References audsrv_get_cdpos(), audsrv_get_error_string(), audsrv_get_trackpos(), audsrv_init(), audsrv_on_cdda_stop(), audsrv_play_cd(), audsrv_quit(), cdda_stopped(), nopdelay(), NULL, pos, SifInitRpc(), SifLoadModule(), and track_ended.

Variable Documentation

◆ track_ended

volatile int track_ended = 0
static

Definition at line 23 of file playcdda.c.

Referenced by cdda_stopped(), and main().