openbsd-ports/x11/ogle/patches/patch-ctrl_ctrl_c
espie 2182891413 avoid dumping core on exit.
be a lot less verbose on the console.
don't rebuild binutils if there is a /usr/bin/as-static
2001-10-24 12:54:33 +00:00

336 lines
8.5 KiB
Plaintext

$OpenBSD: patch-ctrl_ctrl_c,v 1.1 2001/10/24 12:54:33 espie Exp $
--- ctrl/ctrl.c.orig Mon Oct 22 15:16:00 2001
+++ ctrl/ctrl.c Mon Oct 22 15:26:03 2001
@@ -175,21 +175,29 @@ int search_capabilities(int caps, MsgEve
if(client != NULL) {
*client = CLIENT_NONE;
}
+#if DEBUG
fprintf(stderr, "searching cap: %d\n", caps);
+#endif
for(n = 0; n < nr_caps; n++) {
if((caps_array[n].caps & caps) == caps) {
nr++;
if(client != NULL) {
*client = caps_array[n].client;
+#if DEBUG
fprintf(stderr, "found capclient: %ld\n", *client);
+#endif
}
if(ret_caps != NULL) {
*ret_caps = caps_array[n].caps;
+#if DEBUG
fprintf(stderr, "found cap: %x\n", *ret_caps);
+#endif
}
+#if DEBUG
fprintf(stderr, "state cap: %d\n", caps_array[n].state);
+#endif
if(ret_state != NULL) {
*ret_state = caps_array[n].state;
@@ -308,7 +316,9 @@ static char *capability_to_decoderstr(in
static void cleanup(void)
{
+#if DEBUG
fprintf(stderr, "ctrl: waiting for children to really die\n");
+#endif
while(sleep(2)); // Continue sleeping if interupted
@@ -324,7 +334,9 @@ int request_capability(MsgEventQ_t *q, i
MsgEvent_t r_ev;
char *decodername;
cap_state_t state = 0;
+#if DEBUG
fprintf(stderr, "ctrl: _MsgEventQReqCapability\n");
+#endif
if(!search_capabilities(cap, capclient, retcaps, &state)) {
@@ -337,9 +349,11 @@ int request_capability(MsgEventQ_t *q, i
fullcap,
CAP_started);
+#if DEBUG
fprintf(stderr, "ctrl: starting decoder %d %s\n",
fullcap,
decodername);
+#endif
init_decoder(msgqid_str, decodername);
}
@@ -361,7 +375,9 @@ int request_capability(MsgEventQ_t *q, i
}
if(state == CAP_running) {
+#if DEBUG
fprintf(stderr, "ctrl: sending ctrldata\n");
+#endif
r_ev.type = MsgEventQCtrlData;
r_ev.ctrldata.shmid = ctrl_data_shmid;
@@ -369,7 +385,7 @@ int request_capability(MsgEventQ_t *q, i
return 1;
} else {
- fprintf(stderr, "ctrl: didn't find capability\n");
+ fprintf(stderr, "ctrl: didn't find capability %d\n", cap);
return 0;
}
}
@@ -385,13 +401,17 @@ static void handle_events(MsgEventQ_t *q
switch(ev->type) {
case MsgEventQInitReq:
+#if DEBUG
fprintf(stderr, "ctrl: _MsgEventQInitReq, new_id: %d\n", next_client_id);
+#endif
ev->type = MsgEventQInitGnt;
ev->initgnt.newclientid = next_client_id++;
MsgSendEvent(q, CLIENT_UNINITIALIZED, ev, 0);
break;
case MsgEventQRegister:
+#if DEBUG
fprintf(stderr, "ctrl: _MsgEventQRegister\n");
+#endif
register_capabilities(ev->registercaps.client,
ev->registercaps.capabilities,
CAP_running);
@@ -416,8 +436,10 @@ static void handle_events(MsgEventQ_t *q
{
shm_bufinfo_t bufinfo;
+#if DEBUG
fprintf(stderr, "ctrl: _got request for buffer size %d\n",
ev->reqbuf.size);
+#endif
if(get_buffer(ev->reqbuf.size, &bufinfo) == -1) {
bufinfo.shmid = -1;
}
@@ -432,9 +454,11 @@ static void handle_events(MsgEventQ_t *q
{
int shmid;
cap_state_t state = 0;
+#if DEBUG
fprintf(stderr, "ctrl: _new stream %x, %x\n",
ev->reqstreambuf.stream_id,
ev->reqstreambuf.subtype);
+#endif
if(register_stream(ev->reqstreambuf.stream_id,
ev->reqstreambuf.subtype)) {
@@ -456,9 +480,11 @@ static void handle_events(MsgEventQ_t *q
decodername = streamid_to_decoderstr(ev->reqstreambuf.stream_id,
ev->reqstreambuf.subtype);
+#if DEBUG
if((capability & VIDEO_OUTPUT) || (capability & DECODE_DVD_SPU)) {
fprintf(stderr, "****ctrl: registered VO or SPU started\n");
}
+#endif
if(capability == DECODE_DVD_SPU) {
register_capabilities(0,
DECODE_DVD_SPU | VIDEO_OUTPUT,
@@ -468,11 +494,14 @@ static void handle_events(MsgEventQ_t *q
capability,
CAP_started);
}
+#if DEBUG
fprintf(stderr, "ctrl: starting decoder %d %s\n", capability,
decodername);
+#endif
init_decoder(msgqid_str, decodername);
+#if DEBUG
fprintf(stderr, "ctrl: started decoder %d\n", capability);
-
+#endif
}
while(!search_capabilities(capability, &rcpt, NULL, &state) ||
@@ -494,7 +523,9 @@ static void handle_events(MsgEventQ_t *q
// send ctrl_data shm: let client know where the timebase
// data is
+#if DEBUG
fprintf(stderr, "ctrl: sending ctrldata\n");
+#endif
s_ev.type = MsgEventQCtrlData;
s_ev.ctrldata.shmid = ctrl_data_shmid;
@@ -551,7 +582,9 @@ static void handle_events(MsgEventQ_t *q
{
int shmid;
cap_state_t state;
+#if DEBUG
fprintf(stderr, "ctrl: _new pic q\n");
+#endif
// check if we have a decoder
@@ -563,13 +596,17 @@ static void handle_events(MsgEventQ_t *q
//
if(!search_capabilities(VIDEO_OUTPUT, &rcpt, NULL, NULL)) {
+#if DEBUG
fprintf(stderr, "****ctrl: registered VO|SPU started\n");
+#endif
register_capabilities(0,
VIDEO_OUTPUT | DECODE_DVD_SPU,
CAP_started);
init_decoder(msgqid_str, getenv("DVDP_VIDEO_OUT"));
+#if DEBUG
fprintf(stderr, "ctrl: started video_out\n");
+#endif
}
while(!search_capabilities(VIDEO_OUTPUT, &rcpt, NULL, &state) ||
(state != CAP_running)) {
@@ -585,13 +622,17 @@ static void handle_events(MsgEventQ_t *q
}
handle_events(q, &r_ev);
}
+#if DEBUG
fprintf(stderr, "ctrl: got capability video_out\n");
+#endif
// we now have a decoder running ready to decode the stream
// send ctrl_data shm: let client know where the timebase
// data is
+#if DEBUG
fprintf(stderr, "ctrl: sending ctrldata\n");
+#endif
s_ev.type = MsgEventQCtrlData;
s_ev.ctrldata.shmid = ctrl_data_shmid;
@@ -612,8 +653,10 @@ static void handle_events(MsgEventQ_t *q
s_ev.type = MsgEventQGntPicBuf;
s_ev.gntpicbuf.q_shmid = shmid;
+#if DEBUG
fprintf(stderr, "ctrl: create_q, q_shmid: %d picture_buf_shmid: %d\n",
shmid, ev->reqpicbuf.data_buf_shmid);
+#endif
MsgSendEvent(q, ev->reqpicbuf.client, &s_ev, 0);
@@ -631,8 +674,10 @@ static void handle_events(MsgEventQ_t *q
clocktime_t rt;
clocktime_get(&rt);
+#if DEBUG
fprintf(stderr, "ctrl: _MsgEventQSpeed\n");
fprintf(stderr, "ctrl: speed: %.2f\n", ev->speed.speed);
+#endif
ctrl_data->speed = ev->speed.speed;
@@ -641,7 +686,9 @@ static void handle_events(MsgEventQ_t *q
// send speed event to syncmasters
{
+#if DEBUG
fprintf(stderr, "ctrl: new speed\n");
+#endif
// TODO get decoders that do sync...
@@ -767,14 +814,18 @@ int main(int argc, char *argv[])
sprintf(msgqid_str, "%d", msgqid);
+#if DEBUG
fprintf(stderr, "msgid: %d\n", msgqid);
+#endif
{
struct msqid_ds msgqinfo;
msgctl(msgqid, IPC_STAT, &msgqinfo);
+#if DEBUG
fprintf(stderr, "max_bytes: %ld\n", (long)msgqinfo.msg_qbytes);
+#endif
}
@@ -845,7 +896,9 @@ int init_decoder(char *msgqid_str, char
return -1;
}
+#if DEBUG
fprintf(stderr, "ctrl: init_decoder(): %s\n", decode_name);
+#endif
//starting_decoder = 1;
@@ -900,7 +953,9 @@ int init_decoder(char *msgqid_str, char
}
+#if DEBUG
fprintf(stderr, "Started %s with pid %ld\n", decoderstr, (long)pid);
+#endif
// starting_decoder = 0;
return pid;
@@ -1078,7 +1133,7 @@ int create_msgq()
if((msgqid = msgget(IPC_PRIVATE, IPC_CREAT | 0600)) == -1) {
perror("msgget msgqid");
- exit(-1);
+ exit(1);
}
return 0;
@@ -1126,8 +1181,10 @@ int create_q(int nr_of_elems, int buf_sh
q_elem_t *q_elems;
int n;
+#if DEBUG
fprintf(stderr, "create_q\n");
fprintf(stderr, "shmget\n");
+#endif
if((shmid = shmget(IPC_PRIVATE,
sizeof(q_head_t) + nr_of_elems*sizeof(q_elem_t),
IPC_CREAT | 0600)) == -1) {
@@ -1136,7 +1193,9 @@ int create_q(int nr_of_elems, int buf_sh
}
+#if DEBUG
fprintf(stderr, "shmat\n");
+#endif
if((shmaddr = shmat(shmid, NULL, SHM_SHARE_MMU)) == (void *)-1) {
perror("create_q(), shmat()");
@@ -1241,7 +1300,9 @@ void remove_q_shm()
int n;
for(n = 0; n < nr_shmids; n++) {
+#if DEBUG
fprintf(stderr, "removing shmid: %d\n", shm_ids[n]);
+#endif
if(shmctl(shm_ids[n], IPC_RMID, NULL) == -1) {
perror("ipc_rmid");
}
@@ -1254,10 +1315,14 @@ void remove_q_shm()
void cleanup_and_exit(void)
{
+#if DEBUG
fprintf(stderr, "ctrl: cleaning up\n");
+#endif
remove_q_shm();
destroy_msgq();
+#if DEBUG
fprintf(stderr, "ctrl: exiting\n");
+#endif
exit(0);
}