Platform SDK: Broadcast Architecture

Suspending the Video Access Server

You can use the BPCSuspend class to suspend background data capture and cause the Video Access server to release its devices for use by other applications. For example, if the user's computer contains a television tuner card, the Video Access server can continuously monitor the tuner input as a background process, gathering television programming data from the vertical blanking interval (VBI). While the Video Access server is using the tuner in this manner, however, other applications cannot access the tuner.

To enable other applications to access devices in use by the Video Access server, you create an instance of BPCSuspend and call its DeviceRelease method. If the Video Access server successfully releases all devices, the method returns a valid BPCSuspended object. Otherwise, it returns Nothing. If Nothing is returned, it means that the Video Access server cannot release some devices because they are currently being used by applications that display video on the broadcast client.

Your application should handle the case where DeviceRelease returns Nothing as it does a failure indicating a busy or open device. Your application can wait and try again, or it can signal the user to shut down the video applications using the devices.

When your application is done using devices, it should destroy the BPCSuspended object. Doing this notifies the Video Access server that the server can resume using devices and return to background data capture.

The following code illustrates this process.

Note  For the following code to work, the Video Access server (Vidsvr.exe) must be running and you must add the following keys to the registry:

HKEY_CLASSES_ROOT\MS BPC Video Server Suspend

HKEY_CLASSES_ROOT\MS BPC Video Server Suspend\CLSID
  "{887072E7-45D6-11D1-B6B0-00C04FBBDE6E}"

Private Sub BPCSuspend()
    Dim susp As BPCSuspend
    Dim suspended As BPCSuspended
    
    On Error GoTo ErrorHandler
    Set susp = GetObject(, "MS BPC Video Server Suspend")
    On Error Goto 0
    If (susp Is Nothing) Then
        MsgBox "Video Access server is not running."
    Else
        On Error Goto ErrorHandler2
        susp.DeviceRelease 0, suspended
        On Error Goto 0
        If (suspended Is Nothing) Then
            MsgBox "Video Access server is active, won't suspend."
        Else
            MsgBox "DeviceRelease() succeeded. Video Access server suspended."
            Set suspended = Nothing
        End If
        Set susp = Nothing
    End If
    Exit Sub
    
ErrorHandler:
    If (Err.Number = 429) Then
        MsgBox "Video Access server is not running."
    Else
        MsgBox "Error " + Str(Err.Number)
    End If
    Goto Exit_BPCSuspend
 
ErrorHandler2:
    If (Err.Number = -2147467259) Then
        MsgBox "Video Access server is active, won't suspend."
    Else
        MsgBox "Error " + Str(Err.Number)
    End If
 
Exit_BPCSuspend:    
    
End Sub

Note  Your application should not use the BPCSuspend or BPCSuspended class while it is in a state in which cross-process Component Object Model (COM) calls are disallowed. For example, if your application is currently processing a call to the Microsoft® Win32® SendMessage function or a broadcast system message, any cross-process COM calls fail with an RPC_E_CANTCALLOUT_ININPUTSYNCCALL error code. If your application is in such a state when it attempts to suspend the Video Access server, the running object table can become corrupt and lock up the server.

If you are developing applications using C++, you can use the CBPCSuspend wrapper class implemented in the Bpcsusp.h header file to provide suspension functionality. For more information, see Suspending the Video Access Server Using Bpcsusp.h.