Changeset 4c6fd56 in mainline for uspace/lib/hound/src/protocol.c


Ignore:
Timestamp:
2023-09-16T19:58:18Z (16 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7d7f5e3
Parents:
6a0b2cc
git-author:
Jiri Svoboda <jiri@…> (2023-09-16 19:48:07)
git-committer:
Jiri Svoboda <jiri@…> (2023-09-16 19:58:18)
Message:

loc_server_register() should be callable more than once (API only)

Now loc_server_register() returns a pointer to a loc_srv_t object,
that is then passed to loc_service_register() and
loc_service_add_to_cat().

Added loc_server_unregister() that unregisters the server
and frees the loc_srv_t object.

Updated all callers. The implementation, however, is a stub.
It is not actually possible to call loc_server_register() more
than once, yet.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/hound/src/protocol.c

    r6a0b2cc r4c6fd56  
    11/*
     2 * Copyright (c) 2023 Jiri Svoboda
    23 * Copyright (c) 2012 Jan Vesely
    34 * All rights reserved.
     
    8485const char *HOUND_SERVICE = "audio/hound";
    8586
     87/** Server object */
     88static loc_srv_t *hound_srv;
     89
    8690/**
    8791 * Start a new audio session.
     
    730734errno_t hound_server_register(const char *name, service_id_t *id)
    731735{
     736        errno_t rc;
     737
    732738        if (!name || !id)
    733739                return EINVAL;
    734740
    735         errno_t ret = loc_server_register(name);
    736         if (ret != EOK)
    737                 return ret;
    738 
    739         return loc_service_register(HOUND_SERVICE, id);
     741        if (hound_srv != NULL)
     742                return EBUSY;
     743
     744        rc = loc_server_register(name, &hound_srv);
     745        if (rc != EOK)
     746                return rc;
     747
     748        rc = loc_service_register(hound_srv, HOUND_SERVICE, id);
     749        if (rc != EOK) {
     750                loc_server_unregister(hound_srv);
     751                return rc;
     752        }
     753
     754        return EOK;
    740755}
    741756
     
    746761void hound_server_unregister(service_id_t id)
    747762{
    748         loc_service_unregister(id);
     763        loc_service_unregister(hound_srv, id);
     764        loc_server_unregister(hound_srv);
    749765}
    750766
Note: See TracChangeset for help on using the changeset viewer.