Audio transcoding works correctly. Added a bunch of cleanup functions
This commit is contained in:
parent
064e3174c4
commit
6b44a0bdeb
@ -1,3 +1,4 @@
|
||||
CD Burner
|
||||
|
||||
INFO++;
|
||||
Needs to be installed for audio transcoding to work correctly
|
||||
|
@ -38,9 +38,9 @@ main(int argc, char **argv)
|
||||
ecdb_burn_init();
|
||||
|
||||
/* Start testing */
|
||||
Ecdb_Burn_Project *proj;
|
||||
Ecdb_Audio_Project *proj;
|
||||
Ecdb_Source *src;
|
||||
proj = ecdb_burn_project_new();
|
||||
proj = ecdb_audio_project_new();
|
||||
|
||||
i = 1;
|
||||
while ((i < argc) && (argv))
|
||||
@ -48,20 +48,22 @@ main(int argc, char **argv)
|
||||
/* No trailing slashes */
|
||||
if (ecore_file_exists(argv[i]))
|
||||
{
|
||||
if (ecore_file_is_dir(argv[i]))
|
||||
ret = 1;
|
||||
src = ecdb_source_new();
|
||||
ecdb_source_data_set(src, argv[i], ret);
|
||||
ecdb_source_child_append(proj->files, src);
|
||||
|
||||
ret = 0;
|
||||
if (!ecore_file_is_dir(argv[i]))
|
||||
{
|
||||
src = ecdb_source_new();
|
||||
ecdb_source_data_set(src, argv[i], 0);
|
||||
ecdb_source_child_append(proj->tracks, src);
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
ecdb_audio_project_start(proj);
|
||||
|
||||
/*
|
||||
proj->publisher_id = proj->data_preparer_id = proj->system_id =
|
||||
proj->application_id = proj->copywrite_id =
|
||||
proj->abstract_id = proj->biblio_id = "ecdb";
|
||||
proj->abstract_id = proj->biblio_id = strdup("ecdb");
|
||||
|
||||
if (!ecdb_aquire_drive(ECDB_PROJECT(proj), 0))
|
||||
{
|
||||
@ -77,6 +79,8 @@ main(int argc, char **argv)
|
||||
goto SHUTDOWN;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
ecore_main_loop_begin();
|
||||
|
||||
/* End testing */
|
||||
@ -98,6 +102,9 @@ ecdb_setup(void)
|
||||
em->drives = NULL;
|
||||
em->projects = ecore_list_new();
|
||||
|
||||
if (!ecore_file_mkdir("/tmp/ecdb"))
|
||||
printf("Creation of temporary directory failed!\n");
|
||||
|
||||
ECDB_DRIVE_ACTION_FINISHED = ecore_event_type_new();
|
||||
ECDB_DRIVE_ACTION_BEGUN = ecore_event_type_new();
|
||||
ECDB_DRIVE_ACTION_UPDATE = ecore_event_type_new();
|
||||
|
@ -33,22 +33,33 @@ ecdb_audio_project_init(Ecdb_Audio_Project *proj)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ecdb_audio_project_destroy(Ecdb_Audio_Project *proj)
|
||||
{
|
||||
ecdb_source_destroy(proj->tracks);
|
||||
ecdb_project_destroy(ECDB_PROJECT(proj));
|
||||
free(proj);
|
||||
}
|
||||
|
||||
void
|
||||
ecdb_audio_project_start(Ecdb_Audio_Project *proj)
|
||||
{
|
||||
char cmd[PATH_MAX]; //<-- + 20ish?
|
||||
int i;
|
||||
|
||||
/* Fork off the gstreamer program for every file to be added */
|
||||
/* Fork off the gstreamer program for every file to be added
|
||||
* Depending on the number of files, this can be pretty system intensive, so
|
||||
* is there a way to reduce/control this ?
|
||||
*/
|
||||
for (i = 0; proj->tracks->children[i]; i++)
|
||||
{
|
||||
snprintf(cmd, PATH_MAX, "ecdb_transcode_helper %s",
|
||||
proj->tracks->children[i]->dst);
|
||||
ecore_exe_pipe_run(cmd, ECORE_EXE_PIPE_READ |
|
||||
ECORE_EXE_PIPE_AUTO, NULL);
|
||||
ECORE_EXE_PIPE_READ_LINE_BUFFERED, NULL);
|
||||
}
|
||||
|
||||
proj->num_tracks = i - 1;
|
||||
proj->num_tracks = i;
|
||||
ecore_event_handler_add(ECORE_EXE_EVENT_DATA, transcode_data_cb, proj);
|
||||
}
|
||||
|
||||
@ -60,6 +71,7 @@ transcode_data_cb(void *data, int type, void *event)
|
||||
Ecdb_Audio_Project *proj = data;
|
||||
|
||||
rec = ev->data;
|
||||
proj->num_transcode_complete++;
|
||||
|
||||
printf("Message: %s\n", rec);
|
||||
|
||||
@ -74,8 +86,13 @@ transcode_data_cb(void *data, int type, void *event)
|
||||
printf("Error!\n");
|
||||
|
||||
if (proj->num_tracks == proj->num_transcode_complete)
|
||||
{
|
||||
printf("Hurrah, transcoding is done!\n");
|
||||
|
||||
/* Change to another event later */
|
||||
ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -3,5 +3,6 @@
|
||||
|
||||
Ecdb_Audio_Project *ecdb_audio_project_new(void);
|
||||
void ecdb_audio_project_start(Ecdb_Audio_Project *proj);
|
||||
void ecdb_audio_project_destroy(Ecdb_Audio_Project *proj);
|
||||
|
||||
#endif
|
||||
|
@ -81,6 +81,29 @@ ecdb_erase_project_init(Ecdb_Erase_Project *proj)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ecdb_burn_project_destroy(Ecdb_Burn_Project *proj)
|
||||
{
|
||||
ecdb_source_destroy(proj->files);
|
||||
FREE(proj->volume_id);
|
||||
FREE(proj->publisher_id);
|
||||
FREE(proj->data_preparer_id);
|
||||
FREE(proj->system_id);
|
||||
FREE(proj->application_id);
|
||||
FREE(proj->copywrite_id);
|
||||
FREE(proj->abstract_id);
|
||||
FREE(proj->biblio_id);
|
||||
ecdb_project_destroy(ECDB_PROJ(proj));
|
||||
free(proj);
|
||||
}
|
||||
|
||||
void
|
||||
ecdb_erase_project_destroy(Ecdb_Erase_Project *proj)
|
||||
{
|
||||
ecdb_project_destroy(ECDB_PROJ(proj));
|
||||
free(proj);
|
||||
}
|
||||
|
||||
/* Erase and Burn Function */
|
||||
int
|
||||
ecdb_burn_project(Ecdb_Burn_Project *proj)
|
||||
|
@ -5,5 +5,7 @@ int ecdb_burn_project(Ecdb_Burn_Project *proj);
|
||||
int ecdb_erase_disc(Ecdb_Erase_Project *proj);
|
||||
Ecdb_Burn_Project *ecdb_burn_project_new(void);
|
||||
Ecdb_Erase_Project *ecdb_erase_project_new(void);
|
||||
void ecdb_burn_project_destroy(Ecdb_Burn_Project *proj);
|
||||
void ecdb_erase_project_destroy(Ecdb_Erase_Project *proj);
|
||||
|
||||
#endif
|
||||
|
@ -31,6 +31,26 @@ ecdb_source_init(Ecdb_Source *src)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ecdb_source_destroy(Ecdb_Source *src)
|
||||
{
|
||||
int i;
|
||||
Ecdb_Source *child;
|
||||
|
||||
/* free the non-recursive stuff */
|
||||
FREE(src->dst);
|
||||
if (src->node)
|
||||
iso_node_unref(src->node);
|
||||
|
||||
for (i = 0; src->children[i]; i++)
|
||||
{
|
||||
child = src->children[i];
|
||||
ecdb_source_destroy(child);
|
||||
}
|
||||
|
||||
free(src);
|
||||
}
|
||||
|
||||
void
|
||||
ecdb_source_data_set(Ecdb_Source *src, const char *dst, unsigned char rec)
|
||||
{
|
||||
|
@ -2,6 +2,7 @@
|
||||
#define ECDB_IMAGE_H
|
||||
|
||||
Ecdb_Source *ecdb_source_new(void);
|
||||
void ecdb_source_destroy(Ecdb_Source *src);
|
||||
void ecdb_source_data_set(Ecdb_Source *src, const char *dst,
|
||||
unsigned char rec);
|
||||
void ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child);
|
||||
|
@ -24,6 +24,13 @@ ecdb_project_init(Ecdb_Project *proj)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
ecdb_project_destroy(Ecdb_Project *proj)
|
||||
{
|
||||
ecdb_lose_drive_info(proj);
|
||||
free(proj);
|
||||
}
|
||||
|
||||
int
|
||||
ecdb_shutdown(void *data, int type, void *event)
|
||||
{
|
||||
@ -32,6 +39,9 @@ ecdb_shutdown(void *data, int type, void *event)
|
||||
if (em->drives)
|
||||
ecore_list_destroy(em->drives);
|
||||
free(em);
|
||||
|
||||
if (!ecore_file_recursive_rm("/tmp/ecdb"))
|
||||
printf("Removal of temporary directory failed!\n");
|
||||
ecore_main_loop_quit();
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
Ecdb_Project *ecdb_project_new(void);
|
||||
int ecdb_project_init(Ecdb_Project *proj);
|
||||
void ecdb_project_destroy(void);
|
||||
int ecdb_shutdown(void *data, int type, void *event);
|
||||
void ecdb_burn_init(void);
|
||||
void ecdb_image_init(void);
|
||||
|
@ -71,6 +71,7 @@ main (int argc, char ** argv)
|
||||
GstCaps *filtercaps;
|
||||
GstPad *audiopad;
|
||||
GstBus *bus;
|
||||
gchar *path, *filename;
|
||||
|
||||
gst_init (&argc, &argv);
|
||||
loop = g_main_loop_new (NULL, FALSE);
|
||||
@ -113,7 +114,15 @@ main (int argc, char ** argv)
|
||||
|
||||
audiopad = gst_element_get_static_pad(conv, "sink");
|
||||
sink = gst_element_factory_make ("filesink", NULL);
|
||||
g_object_set(G_OBJECT(sink), "location", "/home/jaime/test.wav", NULL);
|
||||
|
||||
/* Generate filename */
|
||||
filename = g_path_get_basename(argv[1]);
|
||||
path = g_strconcat("/tmp/ecdb/", filename, ".wav", NULL);
|
||||
g_object_set(G_OBJECT(sink), "location", path, NULL);
|
||||
|
||||
free(filename);
|
||||
free(path);
|
||||
|
||||
gst_bin_add_many(GST_BIN (audio), conv, resample, filter, sink, NULL);
|
||||
gst_element_link_many(conv, resample, filter, sink, NULL);
|
||||
gst_element_add_pad (audio, gst_ghost_pad_new ("sink", audiopad));
|
||||
|
Loading…
Reference in New Issue
Block a user