示例#1
0
struct GrooveSink * groove_sink_create(void) {
    struct GrooveSinkPrivate *s = av_mallocz(sizeof(struct GrooveSinkPrivate));

    if (!s) {
        av_log(NULL, AV_LOG_ERROR, "could not create sink: out of memory\n");
        return NULL;
    }

    struct GrooveSink *sink = &s->externals;

    sink->buffer_size = 8192;

    s->audioq = groove_queue_create();

    if (!s->audioq) {
        groove_sink_destroy(sink);
        av_log(NULL, AV_LOG_ERROR, "could not create audio buffer: out of memory\n");
        return NULL;
    }

    s->audioq->context = sink;
    s->audioq->cleanup = audioq_cleanup;
    s->audioq->put = audioq_put;
    s->audioq->get = audioq_get;
    s->audioq->purge = audioq_purge;

    return sink;
}
示例#2
0
void groove_encoder_destroy(struct GrooveEncoder *encoder) {
    struct GrooveEncoderPrivate *e = (struct GrooveEncoderPrivate *) encoder;

    if (e->sink)
        groove_sink_destroy(e->sink);

    if (e->audioq)
        groove_queue_destroy(e->audioq);

    if (e->encode_head_mutex_inited)
        pthread_mutex_destroy(&e->encode_head_mutex);

    if (e->drain_cond_inited)
        pthread_cond_destroy(&e->drain_cond);

    if (e->avio)
        av_free(e->avio);

    if (e->avio_buf)
        av_free(e->avio_buf);

    if (e->metadata)
        av_dict_free(&e->metadata);

    av_free(e);
}
示例#3
0
void groove_fingerprinter_destroy(struct GrooveFingerprinter *printer) {
    if (!printer)
        return;

    struct GrooveFingerprinterPrivate *p = (struct GrooveFingerprinterPrivate *) printer;

    if (p->sink)
        groove_sink_destroy(p->sink);

    if (p->info_queue)
        groove_queue_destroy(p->info_queue);

    if (p->info_head_mutex_inited)
        pthread_mutex_destroy(&p->info_head_mutex);

    if (p->drain_cond_inited)
        pthread_cond_destroy(&p->drain_cond);

    deallocate(p);
}