add raw1394_new_handle_on_port() convenience function
git-svn-id: svn://svn.linux1394.org/libraw1394/trunk@104 53a565d1-3bb7-0310-b661-cf11e63c67ab
This commit is contained in:
parent
e753a09b38
commit
081780c175
32
src/main.c
32
src/main.c
|
@ -394,6 +394,38 @@ int raw1394_set_port(struct raw1394_handle *handle, int port)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* raw1394_new_handle_on_port - create a new handle and bind it to a port
|
||||
* @port: port to connect to (same as argument to raw1394_set_port())
|
||||
*
|
||||
* Same as raw1394_new_handle(), but also binds the handle to the
|
||||
* specified 1394 port. Equivalent to raw1394_new_handle() followed by
|
||||
* raw1394_get_port_info() and raw1394_set_port(). Useful for
|
||||
* command-line programs that already know what port they want. If
|
||||
* raw1394_set_port() returns ESTALE, retries automatically.
|
||||
**/
|
||||
raw1394handle_t raw1394_new_handle_on_port(int port)
|
||||
{
|
||||
raw1394handle_t handle = raw1394_new_handle();
|
||||
if (!handle)
|
||||
return NULL;
|
||||
|
||||
tryagain:
|
||||
if (raw1394_get_port_info(handle, NULL, 0) < 0)
|
||||
return NULL;
|
||||
|
||||
if (raw1394_set_port(handle, port)) {
|
||||
if (errno == ESTALE || errno == EINTR) {
|
||||
goto tryagain;
|
||||
} else {
|
||||
raw1394_destroy_handle(handle);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return handle;
|
||||
}
|
||||
|
||||
int raw1394_reset_bus_new(struct raw1394_handle *handle, int type)
|
||||
{
|
||||
struct raw1394_request *req = &handle->req;
|
||||
|
|
|
@ -156,12 +156,20 @@ int raw1394_errcode_to_errno(raw1394_errcode_t);
|
|||
raw1394handle_t raw1394_new_handle(void);
|
||||
void raw1394_destroy_handle(raw1394handle_t handle);
|
||||
|
||||
/*
|
||||
* Same as raw1394_new_handle(), but also binds the handle to the
|
||||
* specified 1394 port. Equivalent to raw1394_new_handle() followed by
|
||||
* raw1394_get_port_info() and raw1394_set_port(). Useful for
|
||||
* command-line programs that already know what port they want.
|
||||
*/
|
||||
raw1394handle_t raw1394_new_handle_on_port(int port);
|
||||
|
||||
/*
|
||||
* Switch off/on busreset-notification for handle
|
||||
* return-value:
|
||||
* ==0 success
|
||||
* !=0 failure
|
||||
* off_on_switch .... RAW1394_NOTIFY_OFF or RAW1394_NOTIFY_ON
|
||||
* off_on_switch .... RAW1394_NOTIFY_OFF or RAW1394_NOTIFY_ON
|
||||
*/
|
||||
int raw1394_busreset_notify (raw1394handle_t handle, int off_on_switch);
|
||||
|
||||
|
|
Reference in New Issue