コード例 #1
0
ファイル: plugin.c プロジェクト: rumly111/deadbeef
static void
aoplug_free (DB_fileinfo_t *_info) {
    aoplug_info_t *info = (aoplug_info_t *)_info;
    if (info) {
        if (info->filebuffer) {
            ao_stop (info->type, info->decoder);
            free (info->filebuffer);
            info->filebuffer = NULL;
        }
        free (info);
    }
}
コード例 #2
0
ファイル: sal_audio.c プロジェクト: thatking/util
static int audio_adec_stop()
{
    HI_S32 s32Ret= HI_SUCCESS;
    ADEC_CHN    AdChn = 0;
    AUDIO_DEV   AoDev = 0;
    AO_CHN      AoChn = 0;

    s32Ret = ao_unbind_adec(AoDev, AoChn, AdChn);
    CHECK(s32Ret == HI_SUCCESS, HI_FAILURE, "Error with %#x.\n", s32Ret);

    s32Ret = ao_stop(AoDev, AoChn);
    CHECK(s32Ret == HI_SUCCESS, HI_FAILURE, "Error with %#x.\n", s32Ret);

    s32Ret = adec_stop(AoDev);
    CHECK(s32Ret == HI_SUCCESS, HI_FAILURE, "Error with %#x.\n", s32Ret);

    return HI_SUCCESS;
}
コード例 #3
0
ファイル: plugin.c プロジェクト: rumly111/deadbeef
static DB_playItem_t *
aoplug_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
    DB_FILE *fp = deadbeef->fopen (fname);
    if (!fp) {
        trace ("psf: failed to fopen %s\n", fname);
        return NULL;
    }

    size_t size = deadbeef->fgetlength (fp);
    char *buffer = malloc (size);
    if (!buffer) {
        deadbeef->fclose (fp);
		fprintf(stderr, "psf: could not allocate %d bytes of memory\n", (int)size);
        return NULL;
    }

	if (deadbeef->fread(buffer, 1, size, fp) != size) {
        deadbeef->fclose (fp);
        free (buffer);
		fprintf(stderr, "psf: file read error: %s\n", fname);
        return NULL;
    }

    deadbeef->fclose (fp);

    int type = ao_identify (buffer);
    if (type < 0) {
        free (buffer);
        return NULL;
    }

    void *dec = ao_start (type, fname, (uint8*)buffer, size);
    if (!dec) {
        free (buffer);
        return NULL;
    }
    ao_display_info info;
    memset (&info, 0, sizeof (info));
    int have_info = 0;
    if (ao_get_info (type, dec, &info) == AO_SUCCESS) {
        have_info = 1;
    }

    ao_stop (type, dec);
    dec = NULL;

	free (buffer);
	
    DB_playItem_t *it = deadbeef->pl_item_alloc_init (fname, plugin.plugin.id);
    const char *ext = fname + strlen (fname);
    while (*ext != '.' && ext > fname) {
        ext--;
    }
    if (*ext == '.') {
        ext++;
        if (!strcasecmp (ext, "psf") || !strcasecmp (ext, "minipsf")) {
            deadbeef->pl_add_meta (it, ":FILETYPE", "PSF");
        }
        else if (!strcasecmp (ext, "psf2") || !strcasecmp (ext, "minipsf2")) {
            deadbeef->pl_add_meta (it, ":FILETYPE", "PSF2");
        }
        else if (!strcasecmp (ext, "spu")) {
            deadbeef->pl_add_meta (it, ":FILETYPE", "SPU");
        }
        else if (!strcasecmp (ext, "ssf") || !strcasecmp (ext, "minissf")) {
            deadbeef->pl_add_meta (it, ":FILETYPE", "SSF");
        }
        else if (!strcasecmp (ext, "qsf") || !strcasecmp (ext, "miniqsf")) {
            deadbeef->pl_add_meta (it, ":FILETYPE", "QSF");
        }
        else if (!strcasecmp (ext, "dsf") || !strcasecmp (ext, "minidsf")) {
            deadbeef->pl_add_meta (it, ":FILETYPE", "DSF");
        }
    }
    else {
        deadbeef->pl_add_meta (it, ":FILETYPE", "PSF");
    }

    float duration = 120;
    float fade = 0;

    if (have_info) {
        int i;
        for (i = 1; i < 9; i++) {
            if (!strncasecmp (info.title[i], "Length: ", 8)) {
                int min;
                float sec;
                if (sscanf (info.info[i], "%d:%f", &min, &sec) == 2) {
                    duration = min * 60 + sec;
                }
                else if (sscanf (info.info[i], "%f", &sec) == 1) {
                    duration = sec;
                }
                aoplug_add_meta (it, NULL, info.info[i], info.title[i]);
            }
            else if (!strncasecmp (info.title[i], "Name: ", 6) || !strncasecmp (info.title[i], "Song: ", 6)) {
                aoplug_add_meta (it, "title", info.info[i], info.title[i]);
            }
            else if (!strncasecmp (info.title[i], "Game: ", 6)) {
                aoplug_add_meta (it, "album", info.info[i], info.title[i]);
            }
            else if (!strncasecmp (info.title[i], "Artist: ", 8)) {
                aoplug_add_meta (it, "artist", info.info[i], info.title[i]);
            }
            else if (!strncasecmp (info.title[i], "Copyright: ", 11)) {
                aoplug_add_meta (it, "copyright", info.info[i], info.title[i]);
            }
            else if (!strncasecmp (info.title[i], "Year: ", 6)) {
                aoplug_add_meta (it, "year", info.info[i], info.title[i]);
            }
            else if (!strncasecmp (info.title[i], "Fade: ", 6)) {
                fade = atof (info.info[i]);
                aoplug_add_meta (it, "fade", info.info[i], info.title[i]);
            }
            else {
                char *colon = strchr (info.title[i], ':');
                char name[colon-info.title[i]+1];
                memcpy (name, info.title[i], colon-info.title[i]);
                name[colon-info.title[i]] = 0;
                aoplug_add_meta (it, name, info.info[i], info.title[i]);
            }
        }
    }
    deadbeef->plt_set_item_duration (plt, it, duration+fade);
    deadbeef->pl_add_meta (it, "title", NULL);
    after = deadbeef->plt_insert_item (plt, after, it);
    deadbeef->pl_item_unref (it);
    return after;
}