summaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorArwed v. Merkatz <v.merkatz@gmx.net>2005-05-18 10:26:00 +0000
committerArwed v. Merkatz <v.merkatz@gmx.net>2005-05-18 10:26:00 +0000
commit3926c8e2bb6082b5a571968d46891b68ab888673 (patch)
tree9035e90ad277262cc7c9c94a767846c478d7e191 /ext
parent6aa66ac48ddbec842fd2deffe3855239f49a05f7 (diff)
downloadgst-plugins-bad-3926c8e2bb6082b5a571968d46891b68ab888673.tar.gz
gst-plugins-bad-3926c8e2bb6082b5a571968d46891b68ab888673.tar.bz2
gst-plugins-bad-3926c8e2bb6082b5a571968d46891b68ab888673.zip
removed unnecessary GST_NASSINK_OPEN flag, don't open multiple connections to nas server, set element error and fail ...
Original commit message from CVS: removed unnecessary GST_NASSINK_OPEN flag, don't open multiple connections to nas server, set element error and fail the state change if connecting to server fails
Diffstat (limited to 'ext')
-rw-r--r--ext/nas/nassink.c56
-rw-r--r--ext/nas/nassink.h5
2 files changed, 31 insertions, 30 deletions
diff --git a/ext/nas/nassink.c b/ext/nas/nassink.c
index 722d17cc..f8e77809 100644
--- a/ext/nas/nassink.c
+++ b/ext/nas/nassink.c
@@ -203,17 +203,16 @@ gst_nassink_getcaps (GstPad * 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)
+ if (!nassink->audio)
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);
+ AuServerMinSampleRate (nassink->audio),
+ AuServerMaxSampleRate (nassink->audio), NULL);
}
caps = gst_caps_intersect (templatecaps, gst_pad_get_pad_template_caps (pad));
gst_caps_free (templatecaps);
@@ -372,13 +371,15 @@ gst_nassink_chain_handle_event (GstNassink * nassink, GstPad * pad,
return;
case GST_EVENT_DISCONTINUOUS:
/* evil hack */
- gst_nassink_close_audio (nassink);
- gst_nassink_open_audio (nassink);
- nassink->flow = AuGetScratchFlow (nassink->audio, NULL);
- if (nassink->flow == 0) {
- GST_CAT_DEBUG (NAS, "couldn't get flow");
- // return -1 (throw error?)
- }
+ /*
+ gst_nassink_close_audio (nassink);
+ gst_nassink_open_audio (nassink);
+ nassink->flow = AuGetScratchFlow (nassink->audio, NULL);
+ if (nassink->flow == 0) {
+ GST_CAT_DEBUG (NAS, "couldn't get flow");
+ // return -1 (throw error?)
+ }
+ */
gst_pad_event_default (pad, event);
return;
default:
@@ -527,11 +528,17 @@ gst_nassink_open_audio (GstNassink * sink)
/* Open Server */
sink->audio = AuOpenServer (sink->host, 0, NULL, 0, NULL, NULL);
- if (sink->audio == NULL)
+ if (sink->audio == NULL) {
+ GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL),
+ ("can't open connection to nas server"));
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);
+ AuCloseServer (sink->audio);
+ sink->audio = NULL;
+ GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_WRITE, (NULL),
+ ("can't get nas device with %i tracks", sink->tracks));
return FALSE;
}
@@ -540,10 +547,6 @@ gst_nassink_open_audio (GstNassink * sink)
sink->pos = 0;
sink->buf = NULL;
- /* Start a flow */
-
- GST_FLAG_SET (sink, GST_NASSINK_OPEN);
-
GST_CAT_DEBUG (NAS, "opened audio device");
return TRUE;
}
@@ -572,8 +575,6 @@ gst_nassink_close_audio (GstNassink * sink)
AuCloseServer (sink->audio);
sink->audio = NULL;
- GST_FLAG_UNSET (sink, GST_NASSINK_OPEN);
-
GST_CAT_DEBUG (NAS, "closed audio device");
}
@@ -588,21 +589,26 @@ gst_nassink_change_state (GstElement * element)
switch (GST_STATE_PENDING (element)) {
case GST_STATE_NULL:
- if (GST_FLAG_IS_SET (element, GST_NASSINK_OPEN))
- gst_nassink_close_audio (nassink);
+ gst_nassink_close_audio (nassink);
break;
case GST_STATE_READY:
- if (!GST_FLAG_IS_SET (element, GST_NASSINK_OPEN))
- gst_nassink_open_audio (nassink);
+ if (!gst_nassink_open_audio (nassink))
+ return GST_STATE_FAILURE;
break;
case GST_STATE_PAUSED:
- while (nassink->pos && nassink->buf)
- NAS_flush (nassink);
+ if (nassink->flow != AuNone)
+ AuPauseFlow (nassink->audio, nassink->flow, NULL);
+ /*
+ while (nassink->pos && nassink->buf)
+ NAS_flush (nassink);
+ */
break;
case GST_STATE_PLAYING:
+ if (nassink->flow != AuNone)
+ AuStartFlow (nassink->audio, nassink->flow, NULL);
break;
}
diff --git a/ext/nas/nassink.h b/ext/nas/nassink.h
index 3206541c..d9557e9c 100644
--- a/ext/nas/nassink.h
+++ b/ext/nas/nassink.h
@@ -39,11 +39,6 @@ extern "C" {
#define GST_IS_NASSINK_CLASS(obj) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_NASSINK))
-typedef enum {
- GST_NASSINK_OPEN = GST_ELEMENT_FLAG_LAST,
- GST_NASSINK_FLAG_LAST = GST_ELEMENT_FLAG_LAST+2
-} GstNasSinkFlags;
-
typedef struct _GstNassink GstNassink;
typedef struct _GstNassinkClass GstNassinkClass;