~ubuntu-branches/ubuntu/raring/ecasound2.2/raring

« back to all changes in this revision

Viewing changes to Documentation/archived/edi-28.txt

  • Committer: Bazaar Package Importer
  • Author(s): Junichi Uekawa
  • Date: 2009-05-06 15:18:46 UTC
  • mfrom: (5.1.1 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090506151846-dvp8mirqmxwhve66
Tags: 2.6.0-1
* New upstream release
- 08_fix_header_install: remove
- 07_configure_in_maintainer_mode: update
- do not install manpage copies, and just install symlinks for
  ecatools.1
* Build-Depend on texlive-latex-recommended too for ecrm1000 font.
  (closes: #526535)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
------------------------------------------------------------------------
 
2
Status: CLOSED
 
3
 
 
4
(edi-28): Extending the EIAM command set to allow writing standalone ECI 
 
5
          implementations.
 
6
         - submitted: kaiv, 29.09.2002
 
7
         - initial implmementation: kaiv, 05.10.2002
 
8
         - done: kaiv, 29.10.2002
 
9
 
 
10
------------------------------------------------------------------------
 
11
Details:
 
12
 
 
13
- rationale
 
14
    - currently all ECI implementations depend on libecasound (either
 
15
      or directly or indirectly) and are thus susceptible to 
 
16
      library versioning conflicts
 
17
    - a standalone implementation would not depend on ecasound 
 
18
      libraries in any way, which again would greatly improve 
 
19
      user-friendliness of ECI apps (easier installation, fewer 
 
20
      problems with libraries, etc, etc)
 
21
- list of goals/requirements that should be reached
 
22
    - a reference standalone ECI implementation in some language
 
23
- ideas
 
24
    - EIAM commands for selecting the ecasound return value
 
25
      syntax -> either normal (current) or one matching the
 
26
      the NetECI wire-syntax
 
27
- arlready-done-list
 
28
    - new EIAM commands are needed to make it possible to 
 
29
      parse return values
 
30
    - redirecting all iactive mode prompt to stderr (solved
 
31
      by using '-D)
 
32
    - adding 'e' and '-' return types to eca-control and 
 
33
      eca-control-base
 
34
    - making eca-control create the output differently in
 
35
      wellformed and normal modes (1. whether to add 
 
36
      a type prefix, 2. whether to print empty replies 
 
37
      and 3. how to print errors)
 
38
    - reference C implementation (libecasoundc)
 
39
    - document the use of ECASOUND environment variable
 
40
 
 
41
------------------------------------------------------------------------
 
42
[kaiv on ecasound-list, 28.09.2002]
 
43
 
 
44
Tkeca-0.2.1, which btw is a really usable app, uses ecasound by forking
 
45
the console interface on the background and then piping commands and
 
46
replies via stdin and stdout.
 
47
 
 
48
Compared to using ECI or directly linking against libecasound, this
 
49
approach has the huge benefit of complete independence from ecasound 
 
50
libraries. In practice, just by renaming the ecasound executable (or 
 
51
changing PATH), I can select between ecasound 2.0.4 and 2.1dev12 (CVS). 
 
52
Tkeca-0.2.1 works nicely with both versions! 
 
53
 
 
54
Now what if all ECI apps would use the same mechanism? This could be 
 
55
achieved by making a new C-implementation of the ECI API, which would do:
 
56
 
 
57
- fork "ecasound -c" to the background 
 
58
- pass ECI commands to the ecasound instance via its stdin
 
59
- read the return codes from ecasound's stdout, parse them and
 
60
  pass them to the ECI app
 
61
 
 
62
... that's about it. The C++, Python, Perl and PHP ECI implementations
 
63
could either use the C implementation or alternatively provide their own
 
64
implementation. For instance, a Python ECI implementation could be
 
65
written totally in Python.  This means that no extension modules would
 
66
need to installed. Just a Python interpreter and the ecasound executable
 
67
and that's it!
 
68
 
 
69
------------------------------------------------------------------------
 
70
[kaiv on ecasound-list, 01.10.2002]
 
71
 
 
72
One of the best alternatives I've come up with so far is reusing the
 
73
NetECI protocol wire format:
 
74
 
 
75
---
 
76
[1. int-output-eci]
 
77
 
 
78
There would be a new ecasound command for enabling 
 
79
a parser-friendly output mode (for instance 'int-output-eci').
 
80
 
 
81
---
 
82
[2. well-formed stdout messages]
 
83
 
 
84
Once 'int-output-eci' is issued, all output from libecasound 
 
85
to stdout will adhere to the following format:
 
86
 
 
87
"<loglevel> <msg-size><crlf><msg><crlf><crlf>"
 
88
 
 
89
Different types of messages already all have a different loglevel
 
90
associacated with them. For instance when setting ecasound's debug level
 
91
(with -d:x), you're actually setting a mask specifying which loglevels to
 
92
pass through.
 
93
 
 
94
Example: "16 10\r\nMy message". Ie. "My message" (length=10) was sent with
 
95
loglevel 16.
 
96
 
 
97
---
 
98
[3. the ECI loglevel]
 
99
 
 
100
One loglevel would be allocated to command return values. These messages 
 
101
would adhere to the following format, which is an extension of the 
 
102
message format in the NetECI protocol:
 
103
 
 
104
"<ECI-loglevel> <status-code> <return-type> <msg-size><crlf><msg><crlf><crlf>"
 
105
 
 
106
Example (response to 'c-selected'): "64 100 s 7\r\ndefault\r\n\r\n". Ie.  
 
107
the response was "default" (length=7), response type s=string, status
 
108
100=ok and it was sent with loglevel 64.
 
109
 
 
110
...
 
111
 
 
112
With this new output mode, it should be quite easy to reliably parse
 
113
ecasound's output. Just issue a command and then read log messages until
 
114
you encounter the next message with eci-loglevel. The msg 'status-code'
 
115
will indicate whether the command succeeded or not. 'return-type' and
 
116
'msg-size' will help in parsing the actual message contents (and to find
 
117
the next well-formed message).
 
118
 
 
119
In addition to making parsing easier, the line-feeds (crlf) also serve as
 
120
a mechanism to recover from errors (parser receives an invalid message and
 
121
does not know where the next message starts ==> search for an empty line
 
122
to find a possible new well-formed message).
 
123
 
 
124
------------------------------------------------------------------------
 
125
[kaiv on ecasound-list, 02.10.2002]
 
126
 
 
127
1. Enabling the well-formed mode
 
128
 
 
129
The new log message mode can be enabled with the new 
 
130
"int-output-mode-wellformed" EIAM command.
 
131
 
 
132
2. Syntax of well-format log messages
 
133
 
 
134
I've added the below documentation to Ecasound Programmer's Guide:
 
135
 
 
136
--cut--
 
137
By issuing the EIAM command ``int-output-mode-wellformed'', 
 
138
ecasound will start printing all messages using the following
 
139
format:
 
140
 
 
141
<message> = <loglevel><sp><msgsize>(<genmsg> | <returnmsg>)
 
142
 
 
143
<loglevel> = <integer>      ; loglevel number
 
144
<msgsize = <integer>        ; size of content in octets
 
145
<genmsg> = <contentblock>   ; generic log message
 
146
<returnmsg> = <sp><returntype><contentblock>
 
147
                            ; EIAM return value message
 
148
<contentblock> = <crlf><content><crlf><crlf>
 
149
                            ; actual content of the message
 
150
<returntype> = ``i'' | ``li'' | ``f'' | ``s''�| ``S'' | ``e''
 
151
                            ; type of the return value (see ECI/EIAM docs)
 
152
<content> = *<octet>        ; zero or more octets of message content
 
153
 
 
154
<sp> = 0x20                 ; space
 
155
<octet> = 0x00-0xff         ; 8bits of data
 
156
<crlf> = <cr><lf>           ; new line 
 
157
<cr> = 0x0d                 ; carriage return
 
158
<lf> = 0x0a                 ; line feed
 
159
<integer> = +<digit>        ; one or more digits
 
160
<digit> = 0x30-0x39         ; digits 0-9
 
161
--cut--
 
162
 
 
163
3. Loglevel for ECI/EIAM return values 
 
164
 
 
165
I've assigned value 256 (0x100) for the return value messages. As an
 
166
example:
 
167
 
 
168
--cut--
 
169
ecasound ('h' for help)> int-output-mode-wellformed 
 
170
ecasound ('h' for help)> cs-is-valid 
 
171
256 1 i
 
172
1
 
173
 
 
174
ecasound ('h' for help)> cs-selected
 
175
256 18 s
 
176
command-line-setup
 
177
 
 
178
--cut--
 
179
 
 
180
256 = loglevel for the return-type messages
 
181
1 = length of content is 1 octet
 
182
i = return value is an integer
 
183
1 = the content (boolean one, ie. cs-is-valid returned true)
 
184
<crlf> = an empty line ends the message
 
185
... and so on.
 
186
 
 
187
That's about it I think. Now it should be possible to write a native,
 
188
standalone ECI implementation in any language that supports launching
 
189
external apps (ie. forking) and using pipes to communicate with the
 
190
executed process.
 
191
 
 
192
PS If this turns out to work ok, I might also add this functionality
 
193
   to the 2.x tree (-> 2.0.5 release).
 
194
 
 
195
------------------------------------------------------------------------
 
 
b'\\ No newline at end of file'