static void gst_nsfdec_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstNsfDec *nsfdec; nsfdec = GST_NSFDEC (object); switch (prop_id) { case PROP_TUNE: nsfdec->tune_number = g_value_get_int (value); break; case PROP_FILTER: nsfdec->filter = g_value_get_enum (value); if (nsfdec->nsf) nsf_setfilter (nsfdec->nsf, nsfdec->filter); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); return; } }
static int SetupSong(void) { nsf_t * nsf = app.nsf; int track; if (!nsf) { pdebug("nsf : setup song, no nsf\n"); return -1; } track = app.tracks[app.cur_track].map; pdebug("nsf : setup song #%d/%d map:[%d]\n", app.cur_track, app.n_tracks, track); if (nsf_playtrack(nsf, track, 44100, 16, 0) != track) { pdebug("nsf : play-track failed\n"); return -1; } pdebug("nsf : set filter\n"); nsf_setfilter(nsf, NSF_FILTER_NONE); app.bufcnt = 0; SetInfo(); return 0; }
static gboolean start_play_tune (GstNsfDec * nsfdec) { gboolean res; nsfdec->nsf = nsf_load (NULL, GST_BUFFER_DATA (nsfdec->tune_buffer), GST_BUFFER_SIZE (nsfdec->tune_buffer)); if (!nsfdec->nsf) goto could_not_load; if (!nsfdec_negotiate (nsfdec)) goto could_not_negotiate; nsfdec->taglist = gst_tag_list_new (); gst_tag_list_add (nsfdec->taglist, GST_TAG_MERGE_REPLACE, GST_TAG_AUDIO_CODEC, "NES Sound Format", NULL); if (nsfdec->nsf->artist_name) gst_tag_list_add (nsfdec->taglist, GST_TAG_MERGE_REPLACE, GST_TAG_ARTIST, nsfdec->nsf->artist_name, NULL); if (nsfdec->nsf->song_name) gst_tag_list_add (nsfdec->taglist, GST_TAG_MERGE_REPLACE, GST_TAG_TITLE, nsfdec->nsf->song_name, NULL); gst_element_post_message (GST_ELEMENT_CAST (nsfdec), gst_message_new_tag (GST_OBJECT (nsfdec), gst_tag_list_copy (nsfdec->taglist))); nsf_playtrack (nsfdec->nsf, nsfdec->tune_number, nsfdec->frequency, nsfdec->bits, nsfdec->stereo); nsf_setfilter (nsfdec->nsf, nsfdec->filter); nsfdec->bps = (nsfdec->bits >> 3) * nsfdec->channels; /* calculate the number of bytes we need to output after each call to * nsf_frame(). */ nsfdec->blocksize = nsfdec->bps * nsfdec->frequency / nsfdec->nsf->playback_rate; gst_pad_push_event (nsfdec->srcpad, gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME, 0, -1, 0)); res = gst_pad_start_task (nsfdec->srcpad, (GstTaskFunction) play_loop, nsfdec->srcpad, NULL); return res; /* ERRORS */ could_not_load: { GST_ELEMENT_ERROR (nsfdec, LIBRARY, INIT, ("Could not load tune"), ("Could not load tune")); return FALSE; } could_not_negotiate: { GST_ELEMENT_ERROR (nsfdec, CORE, NEGOTIATION, ("Could not negotiate format"), ("Could not negotiate format")); return FALSE; } }