Bonjour,
Je cherche a lire des tag dans un fichier flac mais ça ne fonctionne pas toujours.
Je n'arrive pas a voir d'où viens le problème, alors peut être qu'un regard neuf !
Voici le code que j'utilise
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "FLAC/all.h"
 
 
int get_tag_mem(const char* lefile, char* letag)
{
		FLAC__StreamMetadata *metadata_block;
		FLAC__StreamMetadata_VorbisComment *vorbisComment;
		FLAC__uint32  num_tag;
		FLAC__StreamMetadata_VorbisComment_Entry *vorbisComment_entry;
		int ret = -1;
		size_t lentag = strlen(letag);
        char* buftemp = NULL;
        printf("affichage get_tag_mem\n");
		if(FLAC__metadata_get_tags(lefile, &metadata_block))
			{
                printf("adress letag = %d\n", *letag);
				vorbisComment = &metadata_block->data.vorbis_comment;
				for(num_tag = 0; num_tag < vorbisComment->num_comments; num_tag++)	//parcours des tags
					{
						vorbisComment_entry = &vorbisComment->comments[num_tag];
						FLAC__byte *entry = vorbisComment_entry->entry;
						if(! strncmp((char*)entry, letag, lentag))
                        {
                            buftemp = (char*) realloc(letag, vorbisComment_entry->length + 1);
                            if(buftemp != NULL)
                            {
                                strcpy(buftemp, (char*) entry);
                                printf("adress buftemp = %d\n", *buftemp);
                                printf("adress letag = %d\n", *letag);
                                letag = buftemp;
                                printf("adress letag = %d\n", *letag);
                                printf("letag = %s\n", letag);
                                ret = strlen(buftemp);
                            }
                            break;
                        }
					}
				FLAC__metadata_object_delete(metadata_block);	//liberation de la memoire utilise par libflac
			}
		return(ret);
}
 
 
int main(int argc, char *argv[])
{
	if (argc == 2)
    {
        char *lefile = argv[argc - 1];
        int ret;
        char tag[] = "TITLE=", *buff;
        printf("%s\n", tag);
        buff = (char*) malloc(strlen(tag)+1);
        if(buff != NULL)
        {
            strcpy(buff, tag);
            printf("buff = %s\n", buff);
            ret = get_tag_mem(lefile, buff);
            printf("affichage dans main\n");
            printf("retour = %d\n", ret);
            printf("buff = %s\n", buff);
            printf("adress letag = %d\n", *buff);
            free(buff);
        }
    }
    return 0;
Et voici la sortie écran
alain@debian:~/Documents/Language_C/testrealloc/lib$ ./testrealloc 02\ Love\ Is\ Blind.flac
TITLE=
buff = TITLE=
affichage get_tag_mem
adress letag = 84
adress buftemp = 84
adress letag = 84
adress letag = 84
letag = TITLE=Love Is Blind
affichage dans main
retour = 19
buff = TITLE=Love Is Blind
adress letag = 84
alain@debian:~/Documents/Language_C/testrealloc/lib$ ./testrealloc 01\ Element\ Of\ Freedom\ \(Intro\).flac
TITLE=
buff = TITLE=
affichage get_tag_mem
adress letag = 84
adress buftemp = 84
adress letag = 48
adress letag = 84
letag = TITLE=Element Of Freedom (Intro)
affichage dans main
retour = 32
buff = 0��
adress letag = 48
alain@debian:~/Documents/Language_C/testrealloc/lib$
Si quelqu'un vois quelquechose qui m'échappe.
Merci.
ctac_