More work, but crashes
This commit is contained in:
@@ -11,6 +11,8 @@ struct Burn_Data
|
||||
};
|
||||
|
||||
void *_progress_update(void *d);
|
||||
int _progress_gui_update(void *d);
|
||||
int ecdb_burn_finished(void *data, int type, void *event);
|
||||
|
||||
/* Event handlers */
|
||||
int
|
||||
@@ -65,11 +67,12 @@ ecdb_burn_project(Ecdb_Project *proj)
|
||||
burn_write_opts_set_perform_opc(opts, proj->opc);
|
||||
burn_write_opts_set_multi(opts, proj->multi);
|
||||
if (proj->simulate)
|
||||
printf("simulating!\n");
|
||||
printf("Simulating Burn!\n");
|
||||
burn_write_opts_set_simulate(opts, proj->simulate);
|
||||
burn_drive_set_speed(proj->drive->tangible->drive, 0, proj->speed);
|
||||
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)
|
||||
== BURN_WRITE_NONE)
|
||||
{
|
||||
@@ -78,22 +81,29 @@ ecdb_burn_project(Ecdb_Project *proj)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Not sure where to put this for now */
|
||||
burn_disc_write(opts, data->disc);
|
||||
burn_write_opts_free(opts);
|
||||
|
||||
printf("Disc now burning\n");
|
||||
pthread_create(&progress_update, NULL, _progress_update, data);
|
||||
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;
|
||||
}
|
||||
|
||||
/* 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 *
|
||||
_progress_update(void *d)
|
||||
{
|
||||
Burn_Data *data;
|
||||
BurnProgress p;
|
||||
BurnDriveStatus stat;
|
||||
struct burn_drive *drive;
|
||||
|
||||
data = d;
|
||||
@@ -105,54 +115,83 @@ _progress_update(void *d)
|
||||
}
|
||||
drive = data->proj->drive->tangible[0].drive;
|
||||
|
||||
|
||||
printf("Progress update active\n");
|
||||
while (TRUE)
|
||||
{
|
||||
stat = burn_drive_get_status(drive, &p);
|
||||
if (stat == BURN_DRIVE_SPAWNING)
|
||||
data->proj->stat = burn_drive_get_status(drive, &p);
|
||||
if (data->proj->stat == BURN_DRIVE_SPAWNING)
|
||||
{
|
||||
sleep(3);
|
||||
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);
|
||||
break;
|
||||
}
|
||||
|
||||
//printf("Total sectors: %d, on sector: %d\n", p.sectors,
|
||||
// p.sector);
|
||||
data->proj->progress = p;
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user