Beispiel #1
0
 def _allocate_buffer_id(self):
     if self.buffer_id is None:
         buffer_id = self.server.buffer_allocator.allocate(1)
         if buffer_id is None:
             ServerObject.free(self)
             raise ValueError
         self._buffer_id = buffer_id
 def _allocate_buffer_id(self):
     if self.buffer_id is None:
         buffer_id = self.server.buffer_allocator.allocate(1)
         if buffer_id is None:
             ServerObject.free(self)
             raise ValueError
         self._buffer_id = buffer_id
Beispiel #3
0
 def free(self):
     if not self.is_allocated:
         raise supriya.exceptions.BusNotAllocated
     if not self._bus_id_was_set_manually:
         allocator = self._get_allocator(
             calculation_rate=self.calculation_rate, server=self.server)
         allocator.free(self.bus_id)
     self._bus_id = None
     ServerObject.free(self)
     return self
 def _register_with_local_server(self, server):
     ServerObject.allocate(self, server=server)
     allocator = self.server.buffer_allocator
     buffer_id = allocator.allocate(len(self))
     if buffer_id is None:
         ServerObject.free(self)
         raise ValueError
     self._buffer_id = buffer_id
     for buffer_ in self:
         buffer_._register_with_local_server()
     return buffer_id
Beispiel #5
0
 def _register_with_local_server(self, server):
     ServerObject.allocate(self, server=server)
     allocator = self.server.buffer_allocator
     buffer_id = allocator.allocate(len(self))
     if buffer_id is None:
         ServerObject.free(self)
         raise ValueError
     self._buffer_id = buffer_id
     for buffer_ in self:
         buffer_._register_with_local_server()
     return buffer_id
 def _unregister_with_local_server(self):
     node_id = self.node_id
     if self.server is not None:
         if self._node_id in self._server._nodes:
             del self._server._nodes[self._node_id]
         if self.node_id_is_permanent:
             self.server.node_id_allocator.free_permanent_node_id(self.node_id)
     self._node_id = None
     self._node_id_is_permanent = None
     ServerObject.free(self)
     return node_id
Beispiel #7
0
 def free(self):
     if not self.is_allocated:
         raise supriya.exceptions.BusNotAllocated
     if not self._bus_id_was_set_manually:
         allocator = self._get_allocator(
             calculation_rate=self.calculation_rate, server=self.server
         )
         allocator.free(self.bus_id)
     self._bus_id = None
     ServerObject.free(self)
     return self
Beispiel #8
0
 def _unregister_with_local_server(self):
     node_id = self.node_id
     if self.server is not None:
         if self._node_id in self._server._nodes:
             del self._server._nodes[self._node_id]
         if self.node_id_is_permanent:
             self.server.node_id_allocator.free_permanent_node_id(self.node_id)
     self._node_id = None
     self._node_id_is_permanent = None
     ServerObject.free(self)
     return node_id
Beispiel #9
0
    def free(self):
        import supriya.realtime

        if not self.is_allocated:
            raise supriya.exceptions.BusNotAllocated
        allocator = supriya.realtime.Bus._get_allocator(
            calculation_rate=self.calculation_rate, server=self.server)
        allocator.free(self.bus_id)
        self._bus_id = None
        ServerObject.free(self)
        return self
    def free(self):
        import supriya.realtime

        if not self.is_allocated:
            raise supriya.exceptions.BusNotAllocated
        allocator = supriya.realtime.Bus._get_allocator(
            calculation_rate=self.calculation_rate, server=self.server
        )
        allocator.free(self.bus_id)
        self._bus_id = None
        ServerObject.free(self)
        return self
 def free(self) -> "BufferGroup":
     """
     Frees all buffers in buffer group.
     """
     if not self.is_allocated:
         raise supriya.exceptions.BufferNotAllocated
     for buffer_ in self:
         buffer_.free()
     buffer_id = self.buffer_id
     self._buffer_id = None
     self.server.buffer_allocator.free(buffer_id)
     ServerObject.free(self)
     return self
Beispiel #12
0
 def free(self) -> "BufferGroup":
     """
     Frees all buffers in buffer group.
     """
     if not self.is_allocated:
         raise supriya.exceptions.BufferNotAllocated
     for buffer_ in self:
         buffer_.free()
     buffer_id = self.buffer_id
     self._buffer_id = None
     self.server.buffer_allocator.free(buffer_id)
     ServerObject.free(self)
     return self
Beispiel #13
0
    def allocate(self, server=None):
        import supriya.realtime

        if self.is_allocated:
            raise supriya.exceptions.BusAlreadyAllocated
        ServerObject.allocate(self, server=server)
        allocator = supriya.realtime.Bus._get_allocator(
            calculation_rate=self.calculation_rate, server=self.server)
        bus_id = allocator.allocate(len(self))
        if bus_id is None:
            ServerObject.free(self)
            raise ValueError
        self._bus_id = bus_id
        return self
    def allocate(self, server=None):
        import supriya.realtime

        if self.is_allocated:
            raise supriya.exceptions.BusAlreadyAllocated
        ServerObject.allocate(self, server=server)
        allocator = supriya.realtime.Bus._get_allocator(
            calculation_rate=self.calculation_rate, server=self.server
        )
        bus_id = allocator.allocate(len(self))
        if bus_id is None:
            ServerObject.free(self)
            raise ValueError
        self._bus_id = bus_id
        return self
Beispiel #15
0
 def free(self) -> "Buffer":
     """
     Frees buffer.
     """
     if not self.is_allocated:
         raise supriya.exceptions.BufferNotAllocated
     buffer_id = self._unregister_with_local_server()
     request = self._unregister_with_remote_server(buffer_id)
     if self.server.is_running:
         request.communicate(server=self.server, sync=False)
     if not self._buffer_id_was_set_manually:
         self.server.buffer_allocator.free(self.buffer_id)
     self._buffer_id = None
     ServerObject.free(self)
     return self
 def free(self) -> "Buffer":
     """
     Frees buffer.
     """
     if not self.is_allocated:
         raise supriya.exceptions.BufferNotAllocated
     buffer_id = self._unregister_with_local_server()
     request = self._unregister_with_remote_server(buffer_id)
     if self.server.is_running:
         request.communicate(server=self.server, sync=False)
     if not self._buffer_id_was_set_manually:
         self.server.buffer_allocator.free(self.buffer_id)
     self._buffer_id = None
     ServerObject.free(self)
     return self
Beispiel #17
0
 def allocate(self, server=None, sync=False):
     if self.bus_group is not None:
         return
     if self.is_allocated:
         raise supriya.exceptions.BusAlreadyAllocated
     ServerObject.allocate(self, server=server)
     if self.bus_id is None:
         allocator = self._get_allocator(
             calculation_rate=self.calculation_rate, server=self.server)
         bus_id = allocator.allocate(1)
         if bus_id is None:
             ServerObject.free(self)
             raise ValueError
         self._bus_id = bus_id
     if sync:
         self.server.sync()
     return self
Beispiel #18
0
 def allocate(self, server=None, sync=False):
     if self.bus_group is not None:
         return
     if self.is_allocated:
         raise supriya.exceptions.BusAlreadyAllocated
     ServerObject.allocate(self, server=server)
     if self.bus_id is None:
         allocator = self._get_allocator(
             calculation_rate=self.calculation_rate, server=self.server
         )
         bus_id = allocator.allocate(1)
         if bus_id is None:
             ServerObject.free(self)
             raise ValueError
         self._bus_id = bus_id
     if sync:
         self.server.sync()
     return self