diff options
author | Christian Schaller <uraeus@gnome.org> | 2004-03-08 22:24:47 +0000 |
---|---|---|
committer | Christian Schaller <uraeus@gnome.org> | 2004-03-08 22:24:47 +0000 |
commit | e6fa7133c8414771e745c868ed8b081194e6689a (patch) | |
tree | fadde97a71c0892604543889fbc7ccfc80e05112 /ext/nas | |
parent | 956ab077d53eb91d45234ccd2dbf2460ebc822c9 (diff) | |
download | gstreamer-plugins-bad-e6fa7133c8414771e745c868ed8b081194e6689a.tar.gz |
Can you feel the nas tonight? Can you feel the NAS? hey, I am even better than Elton John at these songs
Original commit message from CVS:
Can you feel the nas tonight? Can you feel the NAS? hey, I am even better than Elton John at these songs
Diffstat (limited to 'ext/nas')
-rw-r--r-- | ext/nas/nassink.c | 67 | ||||
-rw-r--r-- | ext/nas/nassink.h | 1 |
2 files changed, 57 insertions, 11 deletions
diff --git a/ext/nas/nassink.c b/ext/nas/nassink.c index 6ad2767f8..a61ef72d5 100644 --- a/ext/nas/nassink.c +++ b/ext/nas/nassink.c @@ -56,13 +56,13 @@ GST_STATIC_PAD_TEMPLATE ( "signed = (boolean) TRUE, " "width = (int) 16, " "depth = (int) 16, " - "rate = (int) [ 8000, 96000 ], " + "rate = (int) [ 1000, 96000 ], " "channels = (int) [ 1, 2 ]; " "audio/x-raw-int, " "signed = (boolean) FALSE, " "width = (int) 8, " "depth = (int) 8, " - "rate = (int) [ 8000, 96000 ], " + "rate = (int) [ 1000, 96000 ], " "channels = (int) [ 1, 2 ]" ) ); @@ -74,6 +74,7 @@ static void gst_nassink_init (GstNassink *nassink); static gboolean gst_nassink_open_audio (GstNassink *sink); static void gst_nassink_close_audio (GstNassink *sink); static GstElementStateReturn gst_nassink_change_state (GstElement *element); +static GstCaps* gst_nassink_getcaps (GstPad *pad); static gboolean gst_nassink_sync_parms (GstNassink *nassink); static GstPadLinkReturn gst_nassink_sinkconnect (GstPad *pad, const GstCaps *caps); @@ -168,6 +169,7 @@ gst_nassink_init(GstNassink *nassink) gst_element_add_pad(GST_ELEMENT(nassink), nassink->sinkpad); gst_pad_set_chain_function(nassink->sinkpad, GST_DEBUG_FUNCPTR(gst_nassink_chain)); gst_pad_set_link_function(nassink->sinkpad, gst_nassink_sinkconnect); + gst_pad_set_getcaps_function(nassink->sinkpad, gst_nassink_getcaps); nassink->mute = FALSE; nassink->depth = 16; @@ -184,6 +186,31 @@ gst_nassink_init(GstNassink *nassink) nassink->buf = NULL; } +static GstCaps* +gst_nassink_getcaps (GstPad *pad) +{ + GstNassink *nassink = GST_NASSINK(gst_pad_get_parent(pad)); + GstCaps *templatecaps = gst_caps_copy(gst_pad_get_pad_template_caps(pad)); + GstCaps *caps; + int i; + AuServer *server; + + server = AuOpenServer(nassink->host, 0, NULL, 0, NULL, NULL); + if (!server) + return templatecaps; + + for (i = 0; i < gst_caps_get_size (templatecaps); i++) { + GstStructure *structure = gst_caps_get_structure (templatecaps, i); + + gst_structure_set (structure, "rate", GST_TYPE_INT_RANGE, AuServerMinSampleRate(server), AuServerMaxSampleRate(server), NULL); + } + caps = gst_caps_intersect(templatecaps, gst_pad_get_pad_template_caps(pad)); + gst_caps_free(templatecaps); + + return caps; + +} + static gboolean gst_nassink_sync_parms (GstNassink *nassink) { @@ -373,6 +400,11 @@ gst_nassink_open_audio (GstNassink *sink) sink->audio = AuOpenServer(sink->host, 0, NULL, 0, NULL, NULL); if (sink->audio == NULL) return FALSE; + sink->device = NAS_getDevice(sink->audio, sink->tracks); + if (sink->device == AuNone) { + GST_CAT_DEBUG(NAS,"no device with %i tracks found", sink->tracks); + return FALSE; + } sink->flow = AuNone; sink->size = 0; @@ -583,17 +615,9 @@ NAS_allocBuffer(GstNassink *sink) static int NAS_createFlow(GstNassink *sink, unsigned char format, unsigned short rate, int numTracks) { - AuDeviceID device; AuElement elements[2]; AuUint32 buf_samples; - GST_CAT_DEBUG(NAS,"getting device"); - device = NAS_getDevice(sink->audio, numTracks); - if (device == AuNone) { - GST_CAT_DEBUG(NAS,"no device found"); - return -1; - } - sink->flow = AuGetScratchFlow(sink->audio, NULL); if (sink->flow == 0) { GST_CAT_DEBUG(NAS,"couldn't get flow"); @@ -621,6 +645,27 @@ NAS_createFlow(GstNassink *sink, unsigned char format, unsigned short rate, int } } + /* free old Elements and reconnet to server, needed to change samplerate */ + { + AuBool clocked; + int num_elements; + AuStatus status; + AuElement *oldelems; + oldelems = AuGetElements(sink->audio, sink->flow, &clocked, &num_elements, &status); + if (num_elements > 0) { + GST_CAT_DEBUG(NAS,"GetElements status: %i", status); + if (oldelems) + AuFreeElements(sink->audio, num_elements, oldelems); + gst_nassink_close_audio(sink); + gst_nassink_open_audio(sink); + sink->flow = AuGetScratchFlow(sink->audio, NULL); + if (sink->flow == 0) { + GST_CAT_DEBUG(NAS,"couldn't get flow"); + return -1; + } + } + } + buf_samples = rate * NAS_SOUND_PORT_DURATION; @@ -638,7 +683,7 @@ NAS_createFlow(GstNassink *sink, unsigned char format, unsigned short rate, int AuMakeElementExportDevice( &elements[1], /* element */ 0, /* input */ - device, /* device */ + sink->device, /* device */ rate, /* rate */ AuUnlimitedSamples, /* num samples */ 0, /* num actions */ diff --git a/ext/nas/nassink.h b/ext/nas/nassink.h index abc4c9f92..3206541c3 100644 --- a/ext/nas/nassink.h +++ b/ext/nas/nassink.h @@ -64,6 +64,7 @@ struct _GstNassink { AuServer *audio; AuFlowID flow; + AuDeviceID device; /* buffer */ |