Пример #1
0
//export go_operationFailed
func go_operationFailed(operationPtr unsafe.Pointer, message *C.char) {
	if operationPtr != nil {
		operation := (*Operation)(operationPtr)

		//  unref pa_operation
		if operation.paOper != nil {
			C.pa_operation_unref(operation.paOper)
		}

		if msg := C.GoString(message); msg == `` {
			operation.Done <- fmt.Errorf("Unknown error")
		} else {
			operation.Done <- errors.New(msg)
		}
	}
}
Пример #2
0
//export go_operationComplete
func go_operationComplete(operationPtr unsafe.Pointer) {
	if operationPtr != nil {
		operation := (*Operation)(operationPtr)

		//  truncate empty payloads
		for i, payload := range operation.Payloads {
			if len(payload.Properties) == 0 && len(payload.Data) == 0 {
				operation.Payloads = append(operation.Payloads[:i], operation.Payloads[i+1:]...)
			}
		}

		//  unref pa_operation
		if operation.paOper != nil {
			C.pa_operation_unref(operation.paOper)
		}

		operation.Done <- nil
	}
}
Пример #3
0
//export go_operationFailed
func go_operationFailed(operationId *C.char, message *C.char) {
	if obj, ok := cgoget(C.GoString(operationId)); ok {
		switch obj.(type) {
		case *Operation:
			operation := obj.(*Operation)

			//  unref pa_operation
			if operation.paOper != nil {
				C.pa_operation_unref(operation.paOper)
			}

			if msg := C.GoString(message); msg == `` {
				operation.SetError(fmt.Errorf("Unknown error"))
			} else {
				operation.SetError(errors.New(msg))
			}

			operation.Done()
		default:
			panic(fmt.Sprintf("go_operationFailed(): invalid object %s; expected *pulse.Operation, got %T", operationId, obj))
		}
	}
}
Пример #4
0
//export go_operationComplete
func go_operationComplete(operationId *C.char) {
	if obj, ok := cgoget(C.GoString(operationId)); ok {
		switch obj.(type) {
		case *Operation:
			operation := obj.(*Operation)

			//  truncate empty payloads
			for i, payload := range operation.Payloads {
				if len(payload.Properties) == 0 && len(payload.Data) == 0 {
					operation.Payloads = append(operation.Payloads[:i], operation.Payloads[i+1:]...)
				}
			}

			//  unref pa_operation
			if operation.paOper != nil {
				C.pa_operation_unref(operation.paOper)
			}

			operation.Done()
		default:
			panic(fmt.Sprintf("go_operationComplete(): invalid object %s; expected *pulse.Operation, got %T", operationId, obj))
		}
	}
}