18 #define Libburn_create_detached_threadS 1
27 #include "../config.h"
41 #include <sys/types.h>
55 #define Burnworker_type_scaN 0
56 #define Burnworker_type_erasE 1
57 #define Burnworker_type_formaT 2
58 #define Burnworker_type_writE 3
59 #define Burnworker_type_fifO 4
61 #define SCAN_GOING() (workers != NULL && \
62 workers->w_type == Burnworker_type_scaN)
64 typedef void *(*WorkerFunc) (
void *);
132 static pthread_mutex_t access_lock;
133 static int mutex_initialized = 0;
134 static int mutex_locked = 0;
137 if (mutex_initialized)
139 ret = pthread_mutex_init(&access_lock, NULL);
142 mutex_initialized = 1;
145 if (!mutex_initialized)
148 ret = pthread_mutex_lock(&access_lock);
155 ret = pthread_mutex_unlock(&access_lock);
179 pthread_attr_t *attr_pt = NULL;
181 #ifdef Libburn_create_detached_threadS
185 a = calloc(1,
sizeof(
struct w_list));
201 #ifdef Libburn_create_detached_threadS
207 pthread_attr_init(&attr);
208 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
217 if (pthread_create(&a->
thread, attr_pt, f, a)) {
227 struct w_list *a, *l = NULL;
236 #ifdef Libburn_detach_done_workeR
266 "remove_worker() cannot find given worker item", 0, 0);
282 int indices,
int sectors,
int flag)
306 "Library not running (on attempt to scan)", 0, 0);
320 "A drive operation is still going on (want to scan)",
334 goto drive_is_active;
353 "After scan a drive operation is still going on",
367 #define Libburn_protect_erase_threaD 1
369 #ifdef Libburn_protect_erase_threaD
370 sigset_t sigset, oldset;
374 sigdelset(&sigset, SIGSEGV);
375 sigdelset(&sigset, SIGILL);
376 pthread_sigmask(SIG_SETMASK, &sigset, &oldset);
382 #ifdef Libburn_protect_erase_threaD
384 pthread_sigmask(SIG_SETMASK, &oldset, NULL);
403 "NULL pointer caught in burn_disc_erase", 0, 0);
410 "A drive operation is still going on (want to erase)",
443 sprintf(msg,
"Drive and media state unsuitable for blanking. (role= %d , profile= 0x%x , status= %d)",
465 #define Libburn_protect_format_threaD 1
467 #ifdef Libburn_protect_format_threaD
468 sigset_t sigset, oldset;
472 sigdelset(&sigset, SIGSEGV);
473 sigdelset(&sigset, SIGILL);
474 pthread_sigmask(SIG_SETMASK, &sigset, &oldset);
481 #ifdef Libburn_protect_format_threaD
483 pthread_sigmask(SIG_SETMASK, &oldset, NULL);
503 "A drive operation is still going on (want to format)",
511 "Drive is a virtual placeholder", 0, 0);
543 "BD-R not unformatted blank any more. Cannot format.",
552 "Blank BD-R left unformatted for zero spare capacity.",
563 "Drive does not format BD-RE without spares.",
572 sprintf(msg,
"Will not format media type %4.4Xh",
594 #define Libburn_protect_write_threaD 1
596 #ifdef Libburn_protect_write_threaD
597 sigset_t sigset, oldset;
601 sigdelset(&sigset, SIGSEGV);
602 sigdelset(&sigset, SIGILL);
603 pthread_sigmask(SIG_SETMASK, &sigset, &oldset);
617 sprintf(msg,
"Write thread on drive %d ended", d->
global_index);
625 #ifdef Libburn_protect_write_threaD
627 pthread_sigmask(SIG_SETMASK, &oldset, NULL);
649 "A drive operation is still going on (want to write)",
665 "No valid write type selected", 0, 0);
673 "Drive is a virtual placeholder (null-drive)", 0, 0);
680 "Pseudo-drive is a read-only file. Cannot write.",
688 if (d->
mdata != NULL)
694 "Drive capabilities not inquired yet", 0, 0);
704 strcpy(reasons,
"Write job parameters are unsuitable:\n");
722 "Media not properly formatted. Cannot write.",
746 #define Libburn_protect_fifo_threaD 1
748 #ifdef Libburn_protect_fifo_threaD
749 sigset_t sigset, oldset;
753 sigdelset(&sigset, SIGSEGV);
754 sigdelset(&sigset, SIGILL);
755 pthread_sigmask(SIG_SETMASK, &sigset, &oldset);
761 #ifdef Libburn_protect_fifo_threaD
763 pthread_sigmask(SIG_SETMASK, &oldset, NULL);
780 if (fs->
buf == NULL) {
811 ret = pthread_join(pt, NULL);
817 #ifdef Libburn_has_burn_async_join_alL
int burn_fifo_abort(struct burn_source_fifo *fs, int flag)
void burn_disc_format(struct burn_drive *drive, off_t size, int flag)
void *(* WorkerFunc)(void *)
static void reset_progress(struct burn_drive *d, int sessions, int tracks, int indices, int sectors, int flag)
static void * scan_worker_func(struct w_list *w)
static void * format_worker_func(struct w_list *w)
struct libdax_msgs * libdax_messenger
#define Burnworker_type_formaT
static void * write_disc_worker_func(struct w_list *w)
void burn_disc_erase(struct burn_drive *drive, int fast)
#define Burnworker_type_scaN
int burn_drive_scan(struct burn_drive_info *drives[], unsigned int *n_drives)
#define Burnworker_type_erasE
static void remove_worker(pthread_t th)
static void * fifo_worker_func(struct w_list *w)
static struct w_list * find_worker(struct burn_drive *d)
int burn_fifo_start(struct burn_source *source, int flag)
#define Burnworker_type_writE
static void * erase_worker_func(struct w_list *w)
void burn_disc_write(struct burn_write_opts *opts, struct burn_disc *disc)
int burn_async_manage_lock(int mode)
static void add_worker(int w_type, struct burn_drive *d, WorkerFunc f, union w_list_data *data)
static struct w_list * workers
#define Burnworker_type_fifO
void burn_async_join_all(void)
#define BURN_ASYNC_LOCK_OBTAIN
#define BURN_ASYNC_LOCK_INIT
#define BURN_ASYNC_LOCK_RELEASE
void burn_disc_format_sync(struct burn_drive *d, off_t size, int flag)
int burn_drive_scan_sync(struct burn_drive_info *drives[], unsigned int *n_drives, int flag)
int burn_drives_are_clear(int flag)
void burn_disc_erase_sync(struct burn_drive *d, int fast)
int burn_fifo_source_shoveller(struct burn_source *source, int flag)
#define BURN_FREE_MEM(pt)
#define BURN_ALLOC_MEM_VOID(pt, typ, count)
void * burn_os_alloc_buffer(size_t amount, int flag)
void burn_write_opts_free(struct burn_write_opts *opts)
int burn_precheck_write(struct burn_write_opts *o, struct burn_disc *disc, char reasons[4096], int silent)
#define BURN_FORMAT_IS_FORMATTED
int libdax_msgs_submit(struct libdax_msgs *m, int origin, int error_code, int severity, int priority, char *msg_text, int os_errno, int flag)
#define LIBDAX_MSGS_SEV_DEBUG
#define LIBDAX_MSGS_SEV_FATAL
#define LIBDAX_MSGS_SEV_NOTE
#define LIBDAX_MSGS_PRIO_HIGH
#define LIBDAX_MSGS_SEV_SORRY
#define LIBDAX_MSGS_SEV_WARNING
#define LIBDAX_MSGS_SEV_FAILURE
struct burn_session ** session
enum burn_disc_status status
struct burn_progress progress
int(* read_format_capacities)(struct burn_drive *d, int top_wanted)
int current_feat23h_byte4
struct scsi_mode_data * mdata
enum burn_drive_status busy
struct burn_track ** track
struct burn_drive * drive
enum burn_write_types write_type
struct burn_drive * drive
struct burn_source * source
struct burn_drive_info ** drives
struct burn_drive * drive
struct burn_write_opts * opts
struct burn_drive * drive
struct format_opts format
void burn_disc_write_sync(struct burn_write_opts *o, struct burn_disc *disc)