More work, but crashes

This commit is contained in:
Jaime Thomas 2008-04-07 01:04:15 +00:00
parent dca9139c46
commit 5005642900
6 changed files with 142 additions and 46 deletions

View File

@ -1,3 +1,19 @@
CD Burner CD Burner
INFO++; INFO++;
Crashes:
burn_disc_free, 184 --> no bt for now
libiso_msgs_submit, 333 (libisofs problem?)
Backtrace
------------
#0 libiso_msgs_submit (m=0x0, origin=1048576, error_code=2,
severity=268435456, priority=0,
msg_text=0xb74c3b8c "Starting image writing...", os_errno=0, flag=0)
at libisofs/libiso_msgs.c:329
#1 0xb7f08ba0 in iso_msg_debug (imgid=1048576,
fmt=0xb7f19697 "Starting image writing...") at libisofs/messages.c:96
#2 0xb7f0de93 in write_function (arg=0x8079b80) at libisofs/ecma119.c:766
#3 0xb7864125 in start_thread () from /lib/libpthread.so.0
#4 0xb774ca0e in clone () from /lib/libc.so.6

View File

@ -1,8 +1,12 @@
#include "ecdb.h" #include "ecdb.h"
/* Global Variables */
int ECDB_DRIVE_ACTION_FINISHED = 0;
int ECDB_DRIVE_ACTION_BEGUN = 0;
int ECDB_DRIVE_ACTION_UPDATE = 0;
Ecdb_Main *em; Ecdb_Main *em;
int ecdb_setup(); int ecdb_setup();
void ecdb_shutdown();
int int
main(int argc, char **argv) main(int argc, char **argv)
@ -10,6 +14,18 @@ main(int argc, char **argv)
Ecdb_Project *proj; Ecdb_Project *proj;
int i; int i;
if (!ecore_init())
{
printf("Cannot initialize Ecore!\n");
return 1;
}
if (!ecore_file_init())
{
printf("Cannot initialize Ecore_File!\n");
return 1;
}
if (!ecdb_setup()) if (!ecdb_setup())
{ {
printf("Setup failed\n"); printf("Setup failed\n");
@ -27,17 +43,27 @@ main(int argc, char **argv)
ecore_list_append(proj->files, strdup(argv[i])); ecore_list_append(proj->files, strdup(argv[i]));
i++; i++;
} }
proj->simulate = FALSE; proj->simulate = TRUE;
proj->publisher_id = proj->data_preparer_id = proj->system_id = proj->publisher_id = proj->data_preparer_id = proj->system_id =
proj->application_id = proj->copywrite_id = proj->abstract_id = proj->application_id = proj->copywrite_id = proj->abstract_id =
proj->biblio_id = "ecdb"; proj->biblio_id = "ecdb";
ecdb_aquire_drive(proj, 0); ecdb_aquire_drive(proj, 0);
ecdb_burn_project(proj);
sleep(7000); if (ecdb_burn_project(proj))
{
printf("Burn was unsuccessful\n");
burn_finish();
ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, NULL, NULL, NULL);
return 1;
}
ecore_main_loop_begin();
/* End testing */ /* End testing */
burn_finish(); burn_finish();
ecdb_shutdown(); ecore_shutdown();
ecore_file_shutdown();
printf("Program Done\n");
return 0; return 0;
}; };
@ -49,6 +75,13 @@ ecdb_setup(void)
em->drives = NULL; em->drives = NULL;
em->projects = ecore_list_new(); em->projects = ecore_list_new();
ECDB_DRIVE_ACTION_FINISHED = ecore_event_type_new();
ECDB_DRIVE_ACTION_BEGUN = ecore_event_type_new();
ECDB_DRIVE_ACTION_UPDATE = ecore_event_type_new();
ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, ecdb_shutdown,
NULL);
if (!ecdb_aquire_drive_info()) if (!ecdb_aquire_drive_info())
{ {
printf("Aquiring drives failed!\n"); printf("Aquiring drives failed!\n");

View File

@ -117,8 +117,14 @@ struct _Ecdb_Project_Info
/* The drive reference */ /* The drive reference */
Ecdb_Drive_Info *drive; Ecdb_Drive_Info *drive;
BurnProgress progress; BurnProgress progress;
BurnDriveStatus stat;
}; };
/* Callbacks */
extern int ECDB_DRIVE_ACTION_FINISHED;
extern int ECDB_DRIVE_ACTION_BEGUN;
extern int ECDB_DRIVE_ACTION_UPDATE;
#include "ecdb_drives.h" #include "ecdb_drives.h"
#include "ecdb_image.h" #include "ecdb_image.h"
#include "ecdb_burn.h" #include "ecdb_burn.h"

View File

@ -11,6 +11,8 @@ struct Burn_Data
}; };
void *_progress_update(void *d); void *_progress_update(void *d);
int _progress_gui_update(void *d);
int ecdb_burn_finished(void *data, int type, void *event);
/* Event handlers */ /* Event handlers */
int int
@ -65,11 +67,12 @@ ecdb_burn_project(Ecdb_Project *proj)
burn_write_opts_set_perform_opc(opts, proj->opc); burn_write_opts_set_perform_opc(opts, proj->opc);
burn_write_opts_set_multi(opts, proj->multi); burn_write_opts_set_multi(opts, proj->multi);
if (proj->simulate) if (proj->simulate)
printf("simulating!\n"); printf("Simulating Burn!\n");
burn_write_opts_set_simulate(opts, proj->simulate); burn_write_opts_set_simulate(opts, proj->simulate);
burn_drive_set_speed(proj->drive->tangible->drive, 0, proj->speed); burn_drive_set_speed(proj->drive->tangible->drive, 0, proj->speed);
burn_write_opts_set_underrun_proof(opts, proj->underrun_proof); burn_write_opts_set_underrun_proof(opts, proj->underrun_proof);
printf("Searching for burn mode\n");
if (burn_write_opts_auto_write_type(opts, data->disc, reasons, 0) if (burn_write_opts_auto_write_type(opts, data->disc, reasons, 0)
== BURN_WRITE_NONE) == BURN_WRITE_NONE)
{ {
@ -78,22 +81,29 @@ ecdb_burn_project(Ecdb_Project *proj)
return 1; return 1;
} }
/* Not sure where to put this for now */
burn_disc_write(opts, data->disc); burn_disc_write(opts, data->disc);
burn_write_opts_free(opts); burn_write_opts_free(opts);
printf("Disc now burning\n");
pthread_create(&progress_update, NULL, _progress_update, data); pthread_create(&progress_update, NULL, _progress_update, data);
pthread_detach(progress_update); pthread_detach(progress_update);
ecore_timer_add(0.5, _progress_gui_update, data);
ecore_event_handler_add(ECDB_DRIVE_ACTION_FINISHED, ecdb_burn_finished,
data);
return 0; return 0;
} }
/* Hopefully at some point EFL will become thread-safe, or ecore_timer will
* work with burn_drive_get_status without segfaulting. At that point we can
* do away with this.
*/
void * void *
_progress_update(void *d) _progress_update(void *d)
{ {
Burn_Data *data; Burn_Data *data;
BurnProgress p; BurnProgress p;
BurnDriveStatus stat;
struct burn_drive *drive; struct burn_drive *drive;
data = d; data = d;
@ -105,54 +115,83 @@ _progress_update(void *d)
} }
drive = data->proj->drive->tangible[0].drive; drive = data->proj->drive->tangible[0].drive;
printf("Progress update active\n");
while (TRUE) while (TRUE)
{ {
stat = burn_drive_get_status(drive, &p); data->proj->stat = burn_drive_get_status(drive, &p);
if (stat == BURN_DRIVE_SPAWNING) if (data->proj->stat == BURN_DRIVE_SPAWNING)
{ {
sleep(3); sleep(3);
continue; continue;
} }
else if (stat == BURN_DRIVE_IDLE) else if (data->proj->stat == BURN_DRIVE_IDLE)
{ {
BurnTrack *track;
BurnSource *source;
ecore_list_first_goto(data->sources);
ecore_list_first_goto(data->tracks);
while ((source = ecore_list_remove(data->sources)))
{
burn_source_free(source);
track = ecore_list_remove(data->tracks);
burn_track_free(track);
}
ecore_list_destroy(data->sources);
ecore_list_destroy(data->tracks);
burn_session_free(data->session);
burn_disc_free(data->disc);
burn_drive_release(drive, 0);
burn_drive_info_free(data->proj->drive->tangible);
/* Don't keep in here */
printf("fail\n");
ecore_list_destroy(data->proj->files);
FREE(data->proj);
/* End testing */
printf("here\n");
FREE(data);
pthread_exit(NULL); pthread_exit(NULL);
break; break;
} }
//printf("Total sectors: %d, on sector: %d\n", p.sectors,
// p.sector);
data->proj->progress = p; data->proj->progress = p;
sleep(5); sleep(5);
} }
} }
int
_progress_gui_update(void *data)
{
Burn_Data *d;
d = data;
if (d->proj->stat == BURN_DRIVE_IDLE)
{
ecore_event_add(ECDB_DRIVE_ACTION_FINISHED, NULL, NULL, data);
printf("Burn finished\n");
return ECORE_CALLBACK_CANCEL;
}
else
ecore_event_add(ECDB_DRIVE_ACTION_UPDATE, NULL, NULL, data);
return ECORE_CALLBACK_RENEW;
}
int
ecdb_burn_finished(void *data, int type, void *event)
{
Burn_Data *proj;
BurnTrack *track;
BurnSource *source;
proj = data;
ecore_list_first_goto(proj->sources);
ecore_list_first_goto(proj->tracks);
printf("Freeing source and tracks\n");
while ((source = ecore_list_remove(proj->sources)))
{
burn_source_free(source);
track = ecore_list_remove(proj->tracks);
burn_track_free(track);
}
ecore_list_destroy(proj->sources);
ecore_list_destroy(proj->tracks);
printf("Freeing session and disc\n");
burn_session_free(proj->session);
/* Crashes on this line... */
burn_disc_free(proj->disc);
printf("Releasing drive\n");
burn_drive_release(proj->proj->drive->tangible[0].drive, 1);
burn_drive_info_free(proj->proj->drive->tangible);
printf("Ze brun hath finish\n");
/* To be removed from here at some point */
ecore_list_destroy(proj->proj->files);
FREE(proj->proj);
FREE(proj);
ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, NULL, NULL, NULL);
return 0;
}

View File

@ -17,14 +17,16 @@ ecdb_project_new(void)
return proj; return proj;
} }
void int
ecdb_shutdown(void) ecdb_shutdown(void *data, int type, void *event)
{ {
if (em->projects) if (em->projects)
ecore_list_destroy(em->projects); ecore_list_destroy(em->projects);
if (em->drives) if (em->drives)
ecore_list_destroy(em->drives); ecore_list_destroy(em->drives);
free(em); free(em);
ecore_main_loop_quit();
return 0;
} }
void void

View File

@ -2,7 +2,7 @@
#define ECDB_MISC_H #define ECDB_MISC_H
Ecdb_Project *ecdb_project_new(void); Ecdb_Project *ecdb_project_new(void);
void ecdb_shutdown(void); int ecdb_shutdown(void *data, int type, void *event);
void ecdb_burn_init(void); void ecdb_burn_init(void);
void ecdb_image_init(void); void ecdb_image_init(void);