Revision 5052830f

View differences:

libavformat/mp3enc.c
79 79
/**
80 80
 * Write a text frame with one (normal frames) or two (TXXX frames) strings
81 81
 * according to encoding (only UTF-8 or UTF-16+BOM supported).
82
 * @return number of bytes written.
82
 * @return number of bytes written or a negative error code.
83 83
 */
84 84
static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2,
85
                           uint32_t tag, enum ID3v2Encoding enc)
85
                          uint32_t tag, enum ID3v2Encoding enc)
86 86
{
87 87
    int len;
88 88
    uint8_t *pb;
89
    void (*put)(ByteIOContext*, const char*) = avio_put_str;
89
    int (*put)(ByteIOContext*, const char*);
90 90
    ByteIOContext *dyn_buf;
91 91
    if (url_open_dyn_buf(&dyn_buf) < 0)
92
        return 0;
92
        return AVERROR(ENOMEM);
93 93

  
94 94
    put_byte(dyn_buf, enc);
95 95
    if (enc == ID3v2_ENCODING_UTF16BOM) {
96 96
        put_le16(dyn_buf, 0xFEFF);      /* BOM */
97 97
        put = avio_put_str16le;
98
    }
98
    } else
99
        put = avio_put_str;
100

  
99 101
    put(dyn_buf, str1);
100 102
    if (str2)
101 103
        put(dyn_buf, str2);
......
167 169
    ff_metadata_conv(&s->metadata, ff_id3v2_metadata_conv, NULL);
168 170
    while ((t = av_metadata_get(s->metadata, "", t, AV_METADATA_IGNORE_SUFFIX))) {
169 171
        uint32_t tag = 0;
172
        int ret;
170 173

  
171 174
        if (t->key[0] == 'T' && strlen(t->key) == 4) {
172 175
            int i;
173 176
            for (i = 0; *ff_id3v2_tags[i]; i++)
174 177
                if (AV_RB32(t->key) == AV_RB32(ff_id3v2_tags[i])) {
175 178
                    tag = AV_RB32(t->key);
176
                    totlen += id3v2_put_ttag(s, t->value, NULL, tag, ID3v2_ENCODING_UTF8);
179
                    if ((ret = id3v2_put_ttag(s, t->value, NULL, tag, ID3v2_ENCODING_UTF8)) < 0)
180
                        return ret;
181
                    totlen += ret;
177 182
                    break;
178 183
                }
179 184
        }
180 185

  
181 186
        if (!tag) { /* unknown tag, write as TXXX frame */
182 187
            tag = MKBETAG('T', 'X', 'X', 'X');
183
            totlen += id3v2_put_ttag(s, t->key, t->value, tag, ID3v2_ENCODING_UTF8);
188
            if ((ret = id3v2_put_ttag(s, t->key, t->value, tag, ID3v2_ENCODING_UTF8)) < 0)
189
                return ret;
190
            totlen += ret;
184 191
        }
185 192
    }
186 193

  

Also available in: Unified diff