1074 |
return *Aerror ? FALSE : TRUE; |
return *Aerror ? FALSE : TRUE; |
1075 |
} |
} |
1076 |
|
|
1077 |
|
gboolean cdrecord_mediainfo_callback(GIOChannel *Astd, GIOCondition Acond, gpointer Adata) |
1078 |
|
{ |
1079 |
|
GIOStatus Lstatus; |
1080 |
|
Tgrave *Lg = (Tgrave *)Adata; |
1081 |
|
gint *Lcont = (gint *) sc_grave_get_data(Lg, "cont"); /* on traite encore des donnees ? */ |
1082 |
|
gchar *Ltrouve = (gchar *) sc_grave_get_data(Lg, "msinfo"); |
1083 |
|
gchar *Lbuffer = NULL; |
1084 |
|
gchar *s; |
1085 |
|
gint Lniveau = 0; |
1086 |
|
|
1087 |
|
/* fin du callback lorsque l'on recoi un signal comme quoi le pipe est ferme */ |
1088 |
|
if (Acond == G_IO_HUP || Acond == G_IO_ERR) { |
1089 |
|
*Lcont = 0; |
1090 |
|
return FALSE; |
1091 |
|
} |
1092 |
|
Lstatus = g_io_channel_read_line(Astd, &Lbuffer, NULL, NULL, NULL); |
1093 |
|
|
1094 |
|
for (s=Lbuffer; *s; s++) { |
1095 |
|
if (isdigit(*s)) { |
1096 |
|
if (Lniveau == 2) { |
1097 |
|
Lniveau = 3; |
1098 |
|
} else if (Lniveau == 0) { |
1099 |
|
Lniveau = 1; |
1100 |
|
} |
1101 |
|
} else if (*s==',') { |
1102 |
|
if (Lniveau == 1) { |
1103 |
|
Lniveau = 2; |
1104 |
|
} else { |
1105 |
|
Lniveau = 0; |
1106 |
|
break; |
1107 |
|
} |
1108 |
|
} else { |
1109 |
|
if (Lniveau != 3) Lniveau = 0; |
1110 |
|
break; |
1111 |
|
} |
1112 |
|
} |
1113 |
|
|
1114 |
|
if (Lniveau == 3) { |
1115 |
|
g_strlcpy(Ltrouve, Lbuffer, _BUF_SIZE-1); |
1116 |
|
} |
1117 |
|
|
1118 |
|
g_free(Lbuffer); |
1119 |
|
|
1120 |
|
return TRUE; |
1121 |
|
} |
1122 |
|
|
1123 |
|
gchar *cdrecord_get_mediainfo(Tgrave *Ag, gchar *Adevice, GError **Aerror) |
1124 |
|
{ |
1125 |
|
gchar **Lcmd; |
1126 |
|
gchar *Lcommandline, *Lout = NULL; |
1127 |
|
gint *Lpid = (gint *) sc_grave_get_data(Ag, "pid"); |
1128 |
|
gint *Lcont = (gint *)sc_grave_get_data(Ag, "cont"); |
1129 |
|
gboolean *Labort = (gboolean *) sc_grave_get_data(Ag, "gabort"); |
1130 |
|
gchar *Lreturn = NULL; |
1131 |
|
gboolean Lstatus = FALSE; |
1132 |
|
gchar Lmsinfo[_BUF_SIZE] = ""; |
1133 |
|
GIOChannel *Lcom; |
1134 |
|
guint Lcomevent; |
1135 |
|
gint Lexit, Lnbrarg, g_out; |
1136 |
|
guint Ltimeout; |
1137 |
|
|
1138 |
|
(*Lcont) = 2; |
1139 |
|
Ltimeout = g_timeout_add(500, encours_callback, Ag); |
1140 |
|
|
1141 |
|
sc_grave_set_data(Ag, &Lmsinfo, "msinfo"); |
1142 |
|
|
1143 |
|
Lcommandline = g_strdup_printf("%s dev=%s -msinfo", conf_get_string("cdrecord"), Adevice); |
1144 |
|
_DEB("execution [%s]", Lcommandline); |
1145 |
|
Lstatus = g_shell_parse_argv(Lcommandline, &Lnbrarg, &Lcmd, Aerror); |
1146 |
|
g_free(Lcommandline); |
1147 |
|
if (Lstatus != FALSE) { |
1148 |
|
*Lcont = 2; |
1149 |
|
|
1150 |
|
Lstatus = g_spawn_async_with_pipes(NULL, Lcmd, NULL, (GSpawnFlags) (G_SPAWN_DO_NOT_REAP_CHILD), |
1151 |
|
NULL, NULL, Lpid, NULL, &g_out, NULL, Aerror); |
1152 |
|
|
1153 |
|
Lcom = g_io_channel_unix_new( g_out ); |
1154 |
|
g_io_channel_set_encoding (Lcom, NULL, NULL); |
1155 |
|
g_io_channel_set_flags( Lcom, G_IO_FLAG_NONBLOCK, NULL ); |
1156 |
|
Lcomevent = g_io_add_watch (Lcom, (G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_PRI), |
1157 |
|
cdrecord_mediainfo_callback, Ag); |
1158 |
|
|
1159 |
|
while (*Lcont > 0 && *Labort == FALSE) { |
1160 |
|
gtk_main_iteration(); |
1161 |
|
} |
1162 |
|
} |
1163 |
|
g_strfreev(Lcmd); |
1164 |
|
|
1165 |
|
sc_grave_del_data(Ag, "msinfo"); |
1166 |
|
|
1167 |
|
/* attente de la fin du timeout */ |
1168 |
|
g_source_remove(Ltimeout); |
1169 |
|
|
1170 |
|
return *Lmsinfo ? g_strdup(Lmsinfo) : NULL; |
1171 |
|
} |
1172 |
|
|
1173 |
|
|
1174 |
/* |
/* |