-
- ndata.self = self;
- ndata.data_halt_reason= data_halt_reason;
- ndata.mover_halt_reason= mover_halt_reason;
- ndata.mover_pause_reason= mover_pause_reason;
- ndata.mover_pause_seek_position = mover_pause_seek_position;
- ndata.abort_mutex = abort_mutex;
- ndata.abort_cond = abort_cond;
- ndata.status = 2;
+ int status;
+ int i;
+
+ g_static_mutex_lock(¬ify_mutex);
+ if (notify_data == NULL) {
+ glib_init();
+ nb_notify_data = 10;
+ notify_data = g_new0(notify_data_t *, nb_notify_data);
+ for (i=0;i<nb_notify_data;i++) {
+ notify_data[i] = g_new0(notify_data_t, 1);
+ }
+ }
+ /* find a not used notify_data */
+ ndata = *notify_data;
+ i = 0;
+ while (i< nb_notify_data && notify_data[i]->in_use > 0) {
+ i++;
+ }
+ if (i == nb_notify_data) {
+ int new_nb_notify_data = nb_notify_data * 2;
+ int j;
+ notify_data = g_realloc(notify_data,
+ sizeof(notify_data_t *) * new_nb_notify_data);
+ for (j=nb_notify_data; j<new_nb_notify_data; j++) {
+ notify_data[j] = g_new0(notify_data_t, 1);
+ }
+ nb_notify_data = new_nb_notify_data;
+ ndata = notify_data[i];
+ }
+ ndata = notify_data[i];
+ ndata->self = self;
+ ndata->data_halt_reason= data_halt_reason;
+ ndata->mover_halt_reason= mover_halt_reason;
+ ndata->mover_pause_reason= mover_pause_reason;
+ ndata->mover_pause_seek_position = mover_pause_seek_position;
+ ndata->abort_mutex = abort_mutex;
+ ndata->abort_cond = abort_cond;
+ ndata->status = 2;
+ ndata->in_use = 1;
+ g_static_mutex_unlock(¬ify_mutex);