[Spice-devel] [PATCH spice-common] protocol: Use a typedef to specify stream_id type

Frediano Ziglio fziglio at redhat.com
Sat May 5 15:43:55 UTC 2018


This change does not affect generated code but make source more
readable. Also document in a single location the range of this
type.

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
There are no other typedef beside fixed28_4, so the "_t" suffix is
used only here. Maybe would be better to use the name "StreamId"?
Or the "_type" suffix used by some enumeration type?
---
 spice.proto | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/spice.proto b/spice.proto
index 6f873a2..4d916bb 100644
--- a/spice.proto
+++ b/spice.proto
@@ -4,6 +4,11 @@
 
 typedef fixed28_4 int32 @ctype(SPICE_FIXED28_4);
 
+/* IDs of the video stream messages.
+ * These IDs are in the interval [0, SPICE_MAX_NUM_STREAMS)
+ */
+typedef stream_id_t uint32;
+
 struct Point {
     int32 x;
     int32 y;
@@ -698,7 +703,7 @@ struct String {
 };
 
 struct StreamDataHeader {
-	uint32 id;
+	stream_id_t id;
 	uint32 multi_media_time;
 };
 
@@ -756,7 +761,7 @@ channel DisplayChannel : BaseChannel {
 
     message {
 	uint32 surface_id;
-	uint32 id;
+	stream_id_t id;
 	stream_flags flags;
 	video_codec_type codec_type;
 	uint64 stamp;
@@ -775,12 +780,12 @@ channel DisplayChannel : BaseChannel {
     } stream_data;
 
     message {
-	uint32 id;
+	stream_id_t id;
 	Clip clip;
     } stream_clip;
 
     message {
-	uint32 id;
+	stream_id_t id;
     } stream_destroy;
 
     Empty stream_destroy_all;
@@ -954,7 +959,7 @@ channel DisplayChannel : BaseChannel {
     } draw_composite;
 
     message {
-        uint32 stream_id;
+        stream_id_t stream_id;
         uint32 unique_id;
         uint32 max_window_size;
         uint32 timeout_ms;
@@ -986,7 +991,7 @@ channel DisplayChannel : BaseChannel {
     } init = 101;
 
     message {
-        uint32 stream_id;
+        stream_id_t stream_id;
         uint32 unique_id;
         // the mm_time of the first frame included in the report
         uint32 start_frame_mm_time;
-- 
2.17.0



More information about the Spice-devel mailing list